diff options
author | Alexandre Oliva <aoliva@redhat.com> | 2017-12-21 18:14:06 +0000 |
---|---|---|
committer | Alexandre Oliva <aoliva@gcc.gnu.org> | 2017-12-21 18:14:06 +0000 |
commit | cb6332333854a698cbfc2ea4b1e52ce9bd59f664 (patch) | |
tree | 1fc2746b579d67b45f98cfb65ac4f0839237650a /gcc | |
parent | 6b6d8f38f7b3bd8a2f4e4dbeb3014ba1339afa89 (diff) | |
download | gcc-cb6332333854a698cbfc2ea4b1e52ce9bd59f664.zip gcc-cb6332333854a698cbfc2ea4b1e52ce9bd59f664.tar.gz gcc-cb6332333854a698cbfc2ea4b1e52ce9bd59f664.tar.bz2 |
[SFN] propagate single-nondebug-stmt's side effects to enclosing list
Statements without side effects, preceded by debug begin stmt markers,
would become a statement list with side effects, although the stmt on
its own would be extracted from the list and remain not having side
effects. This causes debug info and possibly codegen differences.
This patch fixes it, identifying the situation in which the stmt would
have been extracted from the stmt list, and propagating the side
effects flag from the stmt to the list.
for gcc/ChangeLog
PR debug/83419
* c-family/c-semantics.c (pop_stmt_list): Propagate side
effects from single nondebug stmt to container list.
for gcc/testsuite/ChangeLog
PR debug/83419
* gcc.dg/pr83419.c: New.
From-SVN: r255947
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-family/c-semantics.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr83419.c | 16 |
4 files changed, 36 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d3c4063..2851eb6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-12-21 Alexandre Oliva <aoliva@redhat.com> + + PR debug/83419 + * c-family/c-semantics.c (pop_stmt_list): Propagate side + effects from single nondebug stmt to container list. + 2017-12-21 James Greenhalgh <james.greenhalgh@arm.com> * config/aarch64/aarch64.c (aarch64_expand_vector_init): Modify code diff --git a/gcc/c-family/c-semantics.c b/gcc/c-family/c-semantics.c index cd872d8..3a972c3 100644 --- a/gcc/c-family/c-semantics.c +++ b/gcc/c-family/c-semantics.c @@ -96,6 +96,15 @@ pop_stmt_list (tree t) t = l; tsi_link_before (&i, u, TSI_SAME_STMT); } + while (!tsi_end_p (i) + && TREE_CODE (tsi_stmt (i)) == DEBUG_BEGIN_STMT) + tsi_next (&i); + /* If there's only one nondebug stmt in the list, we'd have + extracted the stmt and dropped the list, and we'd take + TREE_SIDE_EFFECTS from that statement, so keep the list's + TREE_SIDE_EFFECTS in sync. */ + if (tsi_one_before_end_p (i)) + TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (tsi_stmt (i)); } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7171973..8cc163a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-12-21 Alexandre Oliva <aoliva@redhat.com> + + PR debug/83419 + * gcc.dg/pr83419.c: New. + 2017-12-21 James Greenhalgh <james.greenhalgh@arm.com> * gcc.target/aarch64/vect-slp-dup.c: New. diff --git a/gcc/testsuite/gcc.dg/pr83419.c b/gcc/testsuite/gcc.dg/pr83419.c new file mode 100644 index 0000000..3d4f1d2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr83419.c @@ -0,0 +1,16 @@ +/* PR debug/83419 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +int a, b; +void foo (int, ...); + +void +bar (void) +{ + if (a || 1 == b) + foo (1); + else + 0; + foo (1, 0); +} |