aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2017-06-19 15:01:13 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2017-06-19 15:01:13 +0000
commit343ae898b17490d15c98f711ffcb04c88cca9235 (patch)
treeef6963983505b5fc27f730d9f530a778279acca3 /gcc
parent9787269815559a63fbbda58b35137f832a612984 (diff)
downloadgcc-343ae898b17490d15c98f711ffcb04c88cca9235.zip
gcc-343ae898b17490d15c98f711ffcb04c88cca9235.tar.gz
gcc-343ae898b17490d15c98f711ffcb04c88cca9235.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/c/ChangeLog5
-rw-r--r--gcc/c/gimple-parser.c16
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr80887.c32
-rw-r--r--gcc/tree-ssa-sccvn.c21
6 files changed, 85 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index aab38b1..99a7242 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 173fa92..58d59a6 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -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
diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c
index 4a55904..22f58f4 100644
--- a/gcc/c/gimple-parser.c
+++ b/gcc/c/gimple-parser.c
@@ -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;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f382a38..47e2a98 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr80887.c b/gcc/testsuite/gcc.dg/tree-ssa/pr80887.c
new file mode 100644
index 0000000..df7a9d9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr80887.c
@@ -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;
+}
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 419da47..324cd73 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -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