From 7f15b177ba2b5907242dec45da10da635df3e16e Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 13 Jul 2016 08:03:04 +0000 Subject: [PATCH] re PR tree-optimization/71104 (ICE: verify_ssa failed (with vfork / error: definition in block 3 does not dominate use in block 7 )) 2016-07-13 Richard Biener PR middle-end/71104 * gimplify.c (gimplify_modify_expr): Gimplify the RHS before gimplifying the LHS. Make sure to gimplify a returning twice call LHS without using SSA names. * gcc.dg/pr71104-1.c: New testcase. * gcc.dg/pr71104-2.c: Likewise. From-SVN: r238287 --- gcc/ChangeLog | 7 +++++++ gcc/gimplify.c | 12 ++++++++++++ gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gcc.dg/pr71104-1.c | 11 +++++++++++ gcc/testsuite/gcc.dg/pr71104-2.c | 12 ++++++++++++ 5 files changed, 48 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr71104-1.c create mode 100644 gcc/testsuite/gcc.dg/pr71104-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index db920bd90a4..e42e288653f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-07-13 Richard Biener + + PR middle-end/71104 + * gimplify.c (gimplify_modify_expr): Gimplify the RHS before + gimplifying the LHS. Make sure to gimplify a returning twice + call LHS without using SSA names. + 2016-07-12 Trevor Saunders * tree-data-ref.c (find_data_references_in_stmt): Remove diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 2ea1e571bdd..fb27dd0e75a 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -4810,7 +4810,19 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, return ret; /* Then gimplify the LHS. */ + /* If we gimplified the RHS to a CALL_EXPR and that call may return + twice we have to make sure to gimplify into non-SSA as otherwise + the abnormal edge added later will make those defs not dominate + their uses. + ??? Technically this applies only to the registers used in the + resulting non-register *TO_P. */ + bool saved_into_ssa = gimplify_ctxp->into_ssa; + if (saved_into_ssa + && TREE_CODE (*from_p) == CALL_EXPR + && call_expr_flags (*from_p) & ECF_RETURNS_TWICE) + gimplify_ctxp->into_ssa = false; ret = gimplify_expr (to_p, pre_p, post_p, is_gimple_lvalue, fb_lvalue); + gimplify_ctxp->into_ssa = saved_into_ssa; if (ret == GS_ERROR) return ret; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cb2c9e0afc2..d4e0fcabdc0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-07-13 Richard Biener + + PR middle-end/71104 + * gcc.dg/pr71104-1.c: New testcase. + * gcc.dg/pr71104-2.c: Likewise. + 2016-07-12 Michael Meissner PR target/71805 diff --git a/gcc/testsuite/gcc.dg/pr71104-1.c b/gcc/testsuite/gcc.dg/pr71104-1.c new file mode 100644 index 00000000000..20c055ad817 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr71104-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +void foo(void); +int vfork(void); +int *p; + +void bar(void) +{ + foo(); + *p = vfork(); +} diff --git a/gcc/testsuite/gcc.dg/pr71104-2.c b/gcc/testsuite/gcc.dg/pr71104-2.c new file mode 100644 index 00000000000..03c52a338c3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr71104-2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +struct Foo { char c[1024]; }; +void foo(void); +struct Foo baz(void) __attribute__((returns_twice)); +struct Foo *p; + +void bar(void) +{ + foo(); + *p = baz(); +} -- 2.30.2