From: Uros Bizjak Date: Fri, 6 Jul 2007 10:54:03 +0000 (+0200) Subject: re PR rtl-optimization/32450 (-pg causes miscompilation) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=775d3e1aa6f5ab0999dae2b28130136d7db444a8;p=thirdparty%2Fgcc.git re PR rtl-optimization/32450 (-pg causes miscompilation) 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2fadd3d9b3d6..ea8b3338450f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2007-07-06 Uros Bizjak + + 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 PR tree-optimization/31966 diff --git a/gcc/function.c b/gcc/function.c index e9fdb66214b5..46408da0b21f 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -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 (); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2181c0f45685..9b9c02803686 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-07-06 Uros Bizjak + + PR rtl-optimization/32450 + * gcc.dg/pr32450.c: New runtime test. + 2007-07-04 Uros Bizjak PR tree-optimization/31966 diff --git a/gcc/testsuite/gcc.dg/pr32450.c b/gcc/testsuite/gcc.dg/pr32450.c new file mode 100644 index 000000000000..9b36ce42d8b9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr32450.c @@ -0,0 +1,33 @@ +/* Contributed by Joost VandeVondele */ + +/* { 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; +}