aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-01-12 11:22:04 +0100
committerJakub Jelinek <jakub@redhat.com>2024-01-12 11:22:04 +0100
commit4c08f0dde4c2a48931a61b84a00d5c16f4b0e291 (patch)
treefe9c77935deb9b48b8fa237d9ed5dc82853bd044
parenta2d66158541c0923620b044098bf66a73b51c463 (diff)
downloadgcc-4c08f0dde4c2a48931a61b84a00d5c16f4b0e291.zip
gcc-4c08f0dde4c2a48931a61b84a00d5c16f4b0e291.tar.gz
gcc-4c08f0dde4c2a48931a61b84a00d5c16f4b0e291.tar.bz2
sra: Punt for too large _BitInt accesses [PR113330]
This is the case I was talking about in https://gcc.gnu.org/pipermail/gcc-patches/2024-January/642423.html and Zdenek kindly found a testcase for it. We can only create BITINT_TYPE with precision at most 65535, not 65536, so need to punt if we'd want to create it. 2024-01-12 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/113330 * tree-sra.cc (create_access): Punt for BITINT_TYPE accesses with too large size. * gcc.dg/bitint-69.c: New test.
-rw-r--r--gcc/testsuite/gcc.dg/bitint-69.c25
-rw-r--r--gcc/tree-sra.cc6
2 files changed, 31 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/bitint-69.c b/gcc/testsuite/gcc.dg/bitint-69.c
new file mode 100644
index 0000000..c225cbd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/bitint-69.c
@@ -0,0 +1,25 @@
+/* PR tree-optimization/113330 */
+/* { dg-do compile { target bitint } } */
+/* { dg-require-stack-check "generic" } */
+/* { dg-options "-std=c23 -O --param=large-stack-frame=131072 -fstack-check=generic --param=sccvn-max-alias-queries-per-access=0" } */
+
+_BitInt(8) a;
+
+static inline __attribute__((__always_inline__)) void
+bar (int, int, int, int, int, int, int, int)
+{
+#if __BITINT_MAXWIDTH__ >= 65535
+ _BitInt(65535) b = 0;
+ _BitInt(383) c = 0;
+#else
+ _BitInt(63) b = 0;
+ _BitInt(39) c = 0;
+#endif
+ a = b;
+}
+
+void
+foo (void)
+{
+ bar (0, 0, 0, 0, 0, 0, 0, 0);
+}
diff --git a/gcc/tree-sra.cc b/gcc/tree-sra.cc
index e786232..6a1141b 100644
--- a/gcc/tree-sra.cc
+++ b/gcc/tree-sra.cc
@@ -967,6 +967,12 @@ create_access (tree expr, gimple *stmt, bool write)
disqualify_candidate (base, "Encountered an access beyond the base.");
return NULL;
}
+ if (TREE_CODE (TREE_TYPE (expr)) == BITINT_TYPE
+ && size > WIDE_INT_MAX_PRECISION - 1)
+ {
+ disqualify_candidate (base, "Encountered too large _BitInt access.");
+ return NULL;
+ }
access = create_access_1 (base, offset, size);
access->expr = expr;