]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/32450 (-pg causes miscompilation)
authorUros Bizjak <ubizjak@gmail.com>
Fri, 6 Jul 2007 10:54:03 +0000 (12:54 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Fri, 6 Jul 2007 10:54:03 +0000 (12:54 +0200)
        PR rtl-optimization/32450
        * function.c (thread_prologue_and_epilogue_insns): Emit blockage insn
        to ensure that instructions are not moved into the prologue when
        profiling is on.

testsuite/ChangeLog:

        PR rtl-optimization/32450
        * gcc.dg/pr32450.c: New runtime test.

From-SVN: r126411

gcc/ChangeLog
gcc/function.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr32450.c [new file with mode: 0644]

index 2fadd3d9b3d6a5ded2e8e9a09efbfc3b795dc52d..ea8b3338450f17eb36714abae3e226f4af66ca13 100644 (file)
@@ -1,3 +1,10 @@
+2007-07-06  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR rtl-optimization/32450
+       * function.c (thread_prologue_and_epilogue_insns): Emit blockage insn
+       to ensure that instructions are not moved into the prologue when
+       profiling is on.
+
 2007-07-04  Uros Bizjak  <ubizjak@gmail.com>
 
        PR tree-optimization/31966
index e9fdb66214b54f6040139a01cfd52ea895cd41ce..46408da0b21f6ab2096cd4c0e067d51a4b659cf6 100644 (file)
@@ -5103,6 +5103,14 @@ thread_prologue_and_epilogue_insns (rtx f ATTRIBUTE_UNUSED)
       /* Retain a map of the prologue insns.  */
       record_insns (seq, &prologue);
       prologue_end = emit_note (NOTE_INSN_PROLOGUE_END);
+#ifndef PROFILE_BEFORE_PROLOGUE
+      /* Ensure that instructions are not moved into the prologue when
+        profiling is on.  The call to the profiling routine can be
+        emitted within the live range of a call-clobbered register.  */
+      if (current_function_profile)
+       emit_insn (gen_rtx_ASM_INPUT (VOIDmode, ""));
+#endif
 
       seq = get_insns ();
       end_sequence ();
index 2181c0f45685a1dedf80ba5e14796cfee08d72ba..9b9c0280368612a3bc00409d658d5b947dcde159 100644 (file)
@@ -1,3 +1,8 @@
+2007-07-06  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR rtl-optimization/32450
+       * gcc.dg/pr32450.c: New runtime test.
+
 2007-07-04  Uros Bizjak  <ubizjak@gmail.com>
 
        PR tree-optimization/31966
diff --git a/gcc/testsuite/gcc.dg/pr32450.c b/gcc/testsuite/gcc.dg/pr32450.c
new file mode 100644 (file)
index 0000000..9b36ce4
--- /dev/null
@@ -0,0 +1,33 @@
+/* Contributed by Joost VandeVondele  <jv244@cam.ac.uk> */
+
+/* { dg-do run } */
+/* { dg-require-profiling "-pg" } */
+/* { dg-options "-O2 -pg" } */
+/* { dg-options "-O2 -pg -static" { target hppa*-*-hpux* } } */
+
+extern void abort (void);
+
+int stack_pointer;
+
+void
+__attribute__((noinline))
+mystop ()
+{
+  abort ();
+}
+
+void
+__attribute__((noinline))
+add ()
+{
+  if (stack_pointer + 1 > 10)
+    mystop ();
+
+  stack_pointer = stack_pointer + 1;
+}
+
+int main ()
+{
+  add ();
+  return stack_pointer - 1;
+}