PR target/55023
authordanglin <danglin@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 22 Dec 2014 23:10:18 +0000 (23:10 +0000)
committerdanglin <danglin@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 22 Dec 2014 23:10:18 +0000 (23:10 +0000)
* dse.c (scan_insn): Treat sibling call as though it does a wild read.
* testsuite/gcc.dg/pr55023.c: New file.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@219037 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/dse.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr55023.c [new file with mode: 0644]

index e096b52..9f04085 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-22  John David Anglin  <danglin@gcc.gnu.org>
+
+       PR target/55023
+       * dse.c (scan_insn): Treat sibling call as though it does a wild read.
+
 2014-12-22  Bin Cheng  <bin.cheng@arm.com>
 
        PR rtl-optimization/62151
index 2555bd1..3a7f31c 100644 (file)
--- a/gcc/dse.c
+++ b/gcc/dse.c
@@ -2483,6 +2483,17 @@ scan_insn (bb_info_t bb_info, rtx_insn *insn)
 
       insn_info->cannot_delete = true;
 
+      /* Arguments for a sibling call that are pushed to memory are passed
+        using the incoming argument pointer of the current function.  These
+        may or may not be frame related depending on the target.  Since
+        argument pointer related stores are not currently tracked, we treat
+        a sibling call as though it does a wild read.  */
+      if (SIBLING_CALL_P (insn))
+       {
+         add_wild_read (bb_info);
+         return;
+       }
+
       /* Const functions cannot do anything bad i.e. read memory,
         however, they can read their parameters which may have
         been pushed onto the stack.
index 4fb6638..9337c95 100644 (file)
@@ -1,3 +1,7 @@
+2014-12-22  John David Anglin  <danglin@gcc.gnu.org>
+
+       * gcc.dg/pr55023.c: New file.
+
 2014-12-22  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
        * lib/ubsan-dg.exp: Add library path for libstdc++.
diff --git a/gcc/testsuite/gcc.dg/pr55023.c b/gcc/testsuite/gcc.dg/pr55023.c
new file mode 100644 (file)
index 0000000..8f6b300
--- /dev/null
@@ -0,0 +1,33 @@
+/* PR rtl-optimization/55023 */
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-inline" } */
+
+extern void abort (void);
+typedef long long int64_t;
+
+struct foo {
+    int x;
+    int y;
+};
+
+int64_t foo(int64_t a, int64_t b, int64_t c)
+{
+    return a + b + c;
+}
+
+int64_t bar(int64_t a, struct foo bq, struct foo cq)
+{
+    int64_t b = bq.x + bq.y;
+    int64_t c = cq.x + cq.y;
+    return foo(a, b, c);
+}
+
+int main(void)
+{
+  int64_t a = 1;
+  struct foo b = { 2, 3 };
+  struct foo c = { 4, 5 };
+  if (bar (a, b, c) != 15)
+    abort ();
+  return 0;
+}