This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/80109] ICE in get_range_info, at tree-ssanames.c:375
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 20 Mar 2017 15:35:20 +0000
- Subject: [Bug tree-optimization/80109] ICE in get_range_info, at tree-ssanames.c:375
- Auto-submitted: auto-generated
- References: <bug-80109-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80109
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|ice-on-valid-code |ice-on-invalid-code
CC| |aldyh at gcc dot gnu.org
--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
It also ICEs with a native compiler. The test case is invalid: it calls
alloca() with a pointer argument. A smaller test case is:
$ cat z.c && gcc -S -Wall -Wextra -O2 -Walloca-larger-than=126812070 z.c
void g (int *p)
{
extern void f (void*);
void *q = __builtin_alloca (p);
f (q);
}
z.c: In function ‘g’:
z.c:5:31: warning: passing argument 1 of ‘__builtin_alloca’ makes integer from
pointer without a cast [-Wint-conversion]
void *q = __builtin_alloca (p);
^
z.c:5:31: note: expected ‘long unsigned int’ but argument is of type ‘int *’
z.c:1:6: internal compiler error: in get_range_info, at tree-ssanames.c:375
void g (int *p)
^
0x11ac2f9 get_range_info(tree_node const*, generic_wide_int<wide_int_storage>*,
generic_wide_int<wide_int_storage>*)
/src/gcc/svn/gcc/tree-ssanames.c:375
0x190908e alloca_call_type
/src/gcc/svn/gcc/gimple-ssa-warn-alloca.c:334
0x1909637 pass_walloca::execute(function*)
/src/gcc/svn/gcc/gimple-ssa-warn-alloca.c:466
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
The bug seems to be in the following block in the alloca_call_type function
that passes the pointer (len_casted) to get_range_info:
gimple *def = SSA_NAME_DEF_STMT (len);
if (gimple_assign_cast_p (def)
&& TYPE_UNSIGNED (TREE_TYPE (gimple_assign_rhs1 (def))))
{
len_casted = gimple_assign_rhs1 (def);
range_type = get_range_info (len_casted, &min, &max);
}
The following otherwise untested patch avoids the ICE. I CC'd Aldy for hits
thoughts.
diff --git a/gcc/gimple-ssa-warn-alloca.c b/gcc/gimple-ssa-warn-alloca.c
index b940efa..50b35f6 100644
--- a/gcc/gimple-ssa-warn-alloca.c
+++ b/gcc/gimple-ssa-warn-alloca.c
@@ -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 rhs = gimple_assign_rhs1 (def);
+ tree rhstype = TREE_TYPE (rhs);
+
+ // Bail if the argument type is not valid.
+ if (!INTEGRAL_TYPE_P (rhstype))
+ return alloca_type_and_limit (ALLOCA_OK);
+
+ if (TYPE_UNSIGNED (rhstype))
+ {
+ len_casted = rhs;
+ 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.