re PR tree-optimization/80109 (ICE in get_range_info, at tree-ssanames.c:375)
authorMarek Polacek <polacek@redhat.com>
Tue, 21 Mar 2017 16:21:14 +0000 (16:21 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Tue, 21 Mar 2017 16:21:14 +0000 (16:21 +0000)
PR tree-optimization/80109
* gimple-ssa-warn-alloca.c (alloca_call_type): Only call get_range_info
on INTEGRAL_TYPE_P.

* gcc.dg/Walloca-14.c: New test.

Co-Authored-By: Martin Sebor <msebor@redhat.com>
From-SVN: r246325

gcc/ChangeLog
gcc/gimple-ssa-warn-alloca.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Walloca-14.c [new file with mode: 0644]

index 03b2a419331e261ffd608ca3b5941d07046b9c3d..2998017abd7b3559d22a713a7c4b707fc0d39798 100644 (file)
@@ -1,3 +1,10 @@
+2017-03-21  Marek Polacek  <polacek@redhat.com>
+           Martin Sebor  <msebor@redhat.com>
+
+       PR tree-optimization/80109
+       * gimple-ssa-warn-alloca.c (alloca_call_type): Only call get_range_info
+       on INTEGRAL_TYPE_P.
+
 2017-03-21  Jakub Jelinek  <jakub@redhat.com>
            Segher Boessenkool  <segher@kernel.crashing.org>
 
index b940efa910cdda41ee6806b9d7d4701e8f01ffdc..ec95cc6ddd87c0858f40032ec30a9be68a3b1e10 100644 (file)
@@ -327,11 +327,20 @@ alloca_call_type (gimple *stmt, bool is_vla, tree *invalid_casted_type)
              // away with better range information.  But it gets
              // most of the cases.
              gimple *def = SSA_NAME_DEF_STMT (len);
-             if (gimple_assign_cast_p (def)
-                 && TYPE_UNSIGNED (TREE_TYPE (gimple_assign_rhs1 (def))))
+             if (gimple_assign_cast_p (def))
                {
-                 len_casted = gimple_assign_rhs1 (def);
-                 range_type = get_range_info (len_casted, &min, &max);
+                 tree rhs1 = gimple_assign_rhs1 (def);
+                 tree rhs1type = TREE_TYPE (rhs1);
+
+                 // Bail if the argument type is not valid.
+                 if (!INTEGRAL_TYPE_P (rhs1type))
+                   return alloca_type_and_limit (ALLOCA_OK);
+
+                 if (TYPE_UNSIGNED (rhs1type))
+                   {
+                     len_casted = rhs1;
+                     range_type = get_range_info (len_casted, &min, &max);
+                   }
                }
              // An unknown range or a range of the entire domain is
              // really no range at all.
index 6a87efc180d53405184cdff7a45af7c85ba10d42..854726236e0284706e9dc0586dbc5db2b1803d3b 100644 (file)
@@ -1,3 +1,9 @@
+2017-03-21  Marek Polacek  <polacek@redhat.com>
+           Martin Sebor  <msebor@redhat.com>
+
+       PR tree-optimization/80109
+       * gcc.dg/Walloca-14.c: New test.
+
 2017-03-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/80125
diff --git a/gcc/testsuite/gcc.dg/Walloca-14.c b/gcc/testsuite/gcc.dg/Walloca-14.c
new file mode 100644 (file)
index 0000000..6ff2e7f
--- /dev/null
@@ -0,0 +1,12 @@
+/* PR tree-optimization/80109 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Walloca-larger-than=126812070" } */
+
+void
+g (int *p)
+{
+  extern void f (void *);
+
+  void *q = __builtin_alloca (p); /* { dg-warning "passing argument 1" } */
+  f (q);
+}