From cb6332333854a698cbfc2ea4b1e52ce9bd59f664 Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Thu, 21 Dec 2017 18:14:06 +0000 Subject: [PATCH] [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 --- gcc/ChangeLog | 6 ++++++ gcc/c-family/c-semantics.c | 9 +++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr83419.c | 16 ++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr83419.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d3c4063a5ce..2851eb67cc4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-12-21 Alexandre Oliva + + 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 * 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 cd872d8ac74..3a972c32c8e 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 7171973d969..8cc163adac0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-12-21 Alexandre Oliva + + PR debug/83419 + * gcc.dg/pr83419.c: New. + 2017-12-21 James Greenhalgh * 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 00000000000..3d4f1d27701 --- /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); +} -- 2.30.2