aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2011-03-02 13:25:10 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2011-03-02 13:25:10 +0000
commit34161e98f7d52dcd069e70d7ce0b4f4c901eaa1b (patch)
treeef8fb861ebff6b9fa90feb055763a53d2b76bb0a /gcc
parentb2e2ea671c7653b299435ed4e96c50460bfad48b (diff)
downloadgcc-34161e98f7d52dcd069e70d7ce0b4f4c901eaa1b.zip
gcc-34161e98f7d52dcd069e70d7ce0b4f4c901eaa1b.tar.gz
gcc-34161e98f7d52dcd069e70d7ce0b4f4c901eaa1b.tar.bz2
re PR rtl-optimization/47925 (delete_trivially_dead_insns mishandles volatile mems)
gcc/ PR rtl-optimization/47925 * cse.c (count_reg_usage): Don't ignore the SET_DEST of instructions with side effects. Remove the more-specific check for volatile asms. gcc/testsuite/ PR rtl-optimization/47925 * gcc.c-torture/execute/pr47925.c: New test. From-SVN: r170613
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/cse.c16
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr47925.c24
4 files changed, 42 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1bdc9ba..3f58172 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2011-03-02 Richard Sandiford <richard.sandiford@linaro.org>
+
+ PR rtl-optimization/47925
+ * cse.c (count_reg_usage): Don't ignore the SET_DEST of instructions
+ with side effects. Remove the more-specific check for volatile asms.
+
2011-03-02 Alan Modra <amodra@gmail.com>
PR target/47935
diff --git a/gcc/cse.c b/gcc/cse.c
index 3ab6b37..f7b477c 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -6575,8 +6575,9 @@ check_for_label_ref (rtx *rtl, void *data)
Don't count a usage of DEST, which is the SET_DEST of a SET which
contains X in its SET_SRC. This is because such a SET does not
modify the liveness of DEST.
- DEST is set to pc_rtx for a trapping insn, which means that we must count
- uses of a SET_DEST regardless because the insn can't be deleted here. */
+ DEST is set to pc_rtx for a trapping insn, or for an insn with side effects.
+ We must then count uses of a SET_DEST regardless, because the insn can't be
+ deleted here. */
static void
count_reg_usage (rtx x, int *counts, rtx dest, int incr)
@@ -6629,9 +6630,10 @@ count_reg_usage (rtx x, int *counts, rtx dest, int incr)
case CALL_INSN:
case INSN:
case JUMP_INSN:
- /* We expect dest to be NULL_RTX here. If the insn may trap, mark
- this fact by setting DEST to pc_rtx. */
- if (insn_could_throw_p (x))
+ /* We expect dest to be NULL_RTX here. If the insn may trap,
+ or if it cannot be deleted due to side-effects, mark this fact
+ by setting DEST to pc_rtx. */
+ if (insn_could_throw_p (x) || side_effects_p (PATTERN (x)))
dest = pc_rtx;
if (code == CALL_INSN)
count_reg_usage (CALL_INSN_FUNCTION_USAGE (x), counts, dest, incr);
@@ -6671,10 +6673,6 @@ count_reg_usage (rtx x, int *counts, rtx dest, int incr)
return;
case ASM_OPERANDS:
- /* If the asm is volatile, then this insn cannot be deleted,
- and so the inputs *must* be live. */
- if (MEM_VOLATILE_P (x))
- dest = NULL_RTX;
/* Iterate over just the inputs, not the constraints as well. */
for (i = ASM_OPERANDS_INPUT_LENGTH (x) - 1; i >= 0; i--)
count_reg_usage (ASM_OPERANDS_INPUT (x, i), counts, dest, incr);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 49a1c1d..ebe736c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2011-03-02 Richard Sandiford <richard.sandiford@linaro.org>
+
+ PR rtl-optimization/47925
+ * gcc.c-torture/execute/pr47925.c: New test.
+
2011-03-01 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/decltype25.C: New.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr47925.c b/gcc/testsuite/gcc.c-torture/execute/pr47925.c
new file mode 100644
index 0000000..89f54c1
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr47925.c
@@ -0,0 +1,24 @@
+struct s { volatile struct s *next; };
+
+void __attribute__((noinline))
+bar (int ignored, int n)
+{
+ asm volatile ("");
+}
+
+int __attribute__((noinline))
+foo (volatile struct s *ptr, int n)
+{
+ int i;
+
+ bar (0, n);
+ for (i = 0; i < n; i++)
+ ptr = ptr->next;
+}
+
+int main (void)
+{
+ volatile struct s rec = { &rec };
+ foo (&rec, 10);
+ return 0;
+}