re PR bootstrap/80887 (gnat bootstrap fails at s-regpat.o: raised STORAGE_ERROR : stack overflow or erroneous memory access)
2017-06-19 Richard Biener <rguenther@suse.de> PR tree-optimization/80887 c/ * gimple-parser.c (c_parser_gimple_postfix_expression): Handle negated _Literals to parse _Literal (int) -1. * tree-ssa-sccvn.c (mprts_hook_cnt): New global. (vn_lookup_simplify_result): Allow only mprts_hook_cnt succesful simplified lookups, then reset mprts_hook. (vn_nary_build_or_lookup_1): Set mprts_hook_cnt to 9 before simplifying. (try_to_simplify): Likewise. * gcc.dg/tree-ssa/pr80887.c: New testcase. From-SVN: r249373
This commit is contained in:
parent
9787269815
commit
343ae898b1
@ -1,3 +1,13 @@
|
||||
2017-06-19 Richard Biener <rguenther@suse.de>
|
||||
|
||||
PR tree-optimization/80887
|
||||
* tree-ssa-sccvn.c (mprts_hook_cnt): New global.
|
||||
(vn_lookup_simplify_result): Allow only mprts_hook_cnt succesful
|
||||
simplified lookups, then reset mprts_hook.
|
||||
(vn_nary_build_or_lookup_1): Set mprts_hook_cnt to 9 before
|
||||
simplifying.
|
||||
(try_to_simplify): Likewise.
|
||||
|
||||
2017-06-19 Martin Liska <mliska@suse.cz>
|
||||
|
||||
PR sanitizer/80879
|
||||
|
@ -1,3 +1,8 @@
|
||||
2017-06-19 Richard Biener <rguenther@suse.de>
|
||||
|
||||
* gimple-parser.c (c_parser_gimple_postfix_expression): Handle
|
||||
negated _Literals to parse _Literal (int) -1.
|
||||
|
||||
2017-06-13 Martin Liska <mliska@suse.cz>
|
||||
|
||||
PR sanitize/78204
|
||||
|
@ -850,7 +850,7 @@ c_parser_gimple_postfix_expression (c_parser *parser)
|
||||
}
|
||||
else if (strcmp (IDENTIFIER_POINTER (id), "_Literal") == 0)
|
||||
{
|
||||
/* _Literal '(' type-name ')' number */
|
||||
/* _Literal '(' type-name ')' [ '-' ] constant */
|
||||
c_parser_consume_token (parser);
|
||||
tree type = NULL_TREE;
|
||||
if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
|
||||
@ -862,15 +862,27 @@ c_parser_gimple_postfix_expression (c_parser *parser)
|
||||
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
|
||||
"expected %<)%>");
|
||||
}
|
||||
bool neg_p;
|
||||
if ((neg_p = c_parser_next_token_is (parser, CPP_MINUS)))
|
||||
c_parser_consume_token (parser);
|
||||
tree val = c_parser_gimple_postfix_expression (parser).value;
|
||||
if (! type
|
||||
|| ! val
|
||||
|| val == error_mark_node
|
||||
|| TREE_CODE (val) != INTEGER_CST)
|
||||
|| ! CONSTANT_CLASS_P (val))
|
||||
{
|
||||
c_parser_error (parser, "invalid _Literal");
|
||||
return expr;
|
||||
}
|
||||
if (neg_p)
|
||||
{
|
||||
val = const_unop (NEGATE_EXPR, TREE_TYPE (val), val);
|
||||
if (! val)
|
||||
{
|
||||
c_parser_error (parser, "invalid _Literal");
|
||||
return expr;
|
||||
}
|
||||
}
|
||||
expr.value = fold_convert (type, val);
|
||||
return expr;
|
||||
}
|
||||
|
@ -1,3 +1,8 @@
|
||||
2017-06-19 Richard Biener <rguenther@suse.de>
|
||||
|
||||
PR tree-optimization/80887
|
||||
* gcc.dg/tree-ssa/pr80887.c: New testcase.
|
||||
|
||||
2017-06-19 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR ipa/81112
|
||||
|
32
gcc/testsuite/gcc.dg/tree-ssa/pr80887.c
Normal file
32
gcc/testsuite/gcc.dg/tree-ssa/pr80887.c
Normal file
@ -0,0 +1,32 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-fgimple -O" } */
|
||||
|
||||
int pos;
|
||||
void __GIMPLE (startwith("fre"))
|
||||
f()
|
||||
{
|
||||
unsigned int t2;
|
||||
unsigned int t1;
|
||||
int a;
|
||||
unsigned int u;
|
||||
int _1;
|
||||
int _2;
|
||||
int _3;
|
||||
unsigned int _4;
|
||||
int _5;
|
||||
unsigned int _6;
|
||||
|
||||
bb_2:
|
||||
_1 = pos;
|
||||
_2 = _1 + 1;
|
||||
pos = _2;
|
||||
_3 = pos;
|
||||
_4 = (unsigned int) _3;
|
||||
u_9 = _4 + 4294967295u;
|
||||
a_10 = pos;
|
||||
_5 = a_10 + _Literal (int) -1;
|
||||
t1_11 = (unsigned int) _5;
|
||||
_6 = (unsigned int) a_10;
|
||||
t2_12 = _6 + 4294967294u;
|
||||
return;
|
||||
}
|
@ -1639,6 +1639,7 @@ vn_reference_lookup_or_insert_for_pieces (tree vuse,
|
||||
}
|
||||
|
||||
static vn_nary_op_t vn_nary_op_insert_stmt (gimple *stmt, tree result);
|
||||
static unsigned mprts_hook_cnt;
|
||||
|
||||
/* Hook for maybe_push_res_to_seq, lookup the expression in the VN tables. */
|
||||
|
||||
@ -1648,8 +1649,22 @@ vn_lookup_simplify_result (code_helper rcode, tree type, tree *ops)
|
||||
if (!rcode.is_tree_code ())
|
||||
return NULL_TREE;
|
||||
vn_nary_op_t vnresult = NULL;
|
||||
return vn_nary_op_lookup_pieces (TREE_CODE_LENGTH ((tree_code) rcode),
|
||||
(tree_code) rcode, type, ops, &vnresult);
|
||||
tree res = vn_nary_op_lookup_pieces (TREE_CODE_LENGTH ((tree_code) rcode),
|
||||
(tree_code) rcode, type, ops, &vnresult);
|
||||
/* We can end up endlessly recursing simplifications if the lookup above
|
||||
presents us with a def-use chain that mirrors the original simplification.
|
||||
See PR80887 for an example. Limit successful lookup artificially
|
||||
to 10 times if we are called as mprts_hook. */
|
||||
if (res
|
||||
&& mprts_hook
|
||||
&& --mprts_hook_cnt == 0)
|
||||
{
|
||||
if (dump_file && (dump_flags & TDF_DETAILS))
|
||||
fprintf (dump_file, "Resetting mprts_hook after too many "
|
||||
"invocations.\n");
|
||||
mprts_hook = NULL;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Return a value-number for RCODE OPS... either by looking up an existing
|
||||
@ -1666,6 +1681,7 @@ vn_nary_build_or_lookup_1 (code_helper rcode, tree type, tree *ops,
|
||||
So first simplify and lookup this expression to see if it
|
||||
is already available. */
|
||||
mprts_hook = vn_lookup_simplify_result;
|
||||
mprts_hook_cnt = 9;
|
||||
bool res = false;
|
||||
switch (TREE_CODE_LENGTH ((tree_code) rcode))
|
||||
{
|
||||
@ -3896,6 +3912,7 @@ try_to_simplify (gassign *stmt)
|
||||
|
||||
/* First try constant folding based on our current lattice. */
|
||||
mprts_hook = vn_lookup_simplify_result;
|
||||
mprts_hook_cnt = 9;
|
||||
tem = gimple_fold_stmt_to_constant_1 (stmt, vn_valueize, vn_valueize);
|
||||
mprts_hook = NULL;
|
||||
if (tem
|
||||
|
Loading…
Reference in New Issue
Block a user