]> gcc.gnu.org Git - gcc.git/commitdiff
Remove static marker for range in alloca pass.
authorAldy Hernandez <aldyh@redhat.com>
Sun, 3 Oct 2021 17:42:10 +0000 (19:42 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Mon, 4 Oct 2021 11:20:25 +0000 (13:20 +0200)
The m_ranges[] field in int_range<N> are trees, so they live in GC
space.  Since invalid_range is static, it must be marked with GTY
magic.  However, calculating invalid_range is not particularly slow,
or on a critical path, so we can just put it in local scope and
recalculate every time.

Tested on x86-64 Linux.

gcc/ChangeLog:

PR tree-optimization/102560
* gimple-ssa-warn-alloca.c (alloca_call_type): Remove static
marker for invalid_range.

gcc/testsuite/ChangeLog:

* g++.dg/Walloca2.C: New test.

gcc/gimple-ssa-warn-alloca.c
gcc/testsuite/g++.dg/Walloca2.C [new file with mode: 0644]

index 4fc7125d378e0d26b4e42f42e656d38628cf5011..d59cea8d4ecf20c1e6f04dc9631a42cfd9d52868 100644 (file)
@@ -221,10 +221,9 @@ alloca_call_type (gimple *stmt, bool is_vla)
       && !r.varying_p ())
     {
       // The invalid bits are anything outside of [0, MAX_SIZE].
-      static int_range<2> invalid_range (build_int_cst (size_type_node, 0),
-                                        build_int_cst (size_type_node,
-                                                       max_size),
-                                        VR_ANTI_RANGE);
+      int_range<2> invalid_range (build_int_cst (size_type_node, 0),
+                                 build_int_cst (size_type_node, max_size),
+                                 VR_ANTI_RANGE);
 
       r.intersect (invalid_range);
       if (r.undefined_p ())
diff --git a/gcc/testsuite/g++.dg/Walloca2.C b/gcc/testsuite/g++.dg/Walloca2.C
new file mode 100644 (file)
index 0000000..b6992d0
--- /dev/null
@@ -0,0 +1,6 @@
+// { dg-do compile }
+// { dg-options "-Walloca-larger-than=4207115063 -Wvla-larger-than=1233877270 -O2 --param ggc-min-heapsize=0 --param ggc-min-expand=0 -w" }
+// { dg-require-effective-target alloca }
+
+int a;
+char *b = static_cast<char *>(__builtin_alloca (a));
This page took 0.066774 seconds and 5 git commands to generate.