ok. David
On Tue, Sep 23, 2014 at 10:27 AM, Teresa Johnson <tejohn...@google.com> wrote: > This patch fixes the support for patching for instrumentation so that it > works with function splitting, by using the correct helper method for locating > the current section. > > Added a couple tests cloned from existing function splitting tests that > I confirmed expose the problem. > > Passes regression tests. Ok for google branches? > > Thanks, > Teresa > > 2014-09-23 Teresa Johnson <tejohn...@google.com> > > Google ref b/17608598. > * config/i386/i386.c (ix86_output_function_nops_prologue_epilogue): > Ensure we switch to correct section. > * testsuite/gcc.dg/tree-prof/cold_partition_patch.c: New test. > * testsuite/g++.dg/tree-prof/partition_patch.C: Ditto. > > Index: config/i386/i386.c > =================================================================== > --- config/i386/i386.c (revision 215515) > +++ config/i386/i386.c (working copy) > @@ -11946,7 +11946,7 @@ ix86_output_function_nops_prologue_epilogue (FILE > fprintf (file, "\n"); > > /* Switching back to text section. */ > - switch_to_section (function_section (current_function_decl)); > + switch_to_section (current_function_section ()); > return true; > } > > Index: testsuite/gcc.dg/tree-prof/cold_partition_patch.c > =================================================================== > --- testsuite/gcc.dg/tree-prof/cold_partition_patch.c (revision 0) > +++ testsuite/gcc.dg/tree-prof/cold_partition_patch.c (revision 0) > @@ -0,0 +1,38 @@ > +/* Check if patching works with function splitting. */ > +/* { dg-do compile { target x86_64-*-* } } */ > +/* { dg-require-effective-target freorder } */ > +/* { dg-options "-O2 -freorder-blocks-and-partition -save-temps > -mpatch-functions-for-instrumentation -fno-optimize-sibling-calls " } > */ > + > +#define SIZE 10000 > + > +const char *sarr[SIZE]; > +const char *buf_hot; > +const char *buf_cold; > + > +__attribute__((noinline)) > +void > +foo (int path) > +{ > + int i; > + if (path) > + { > + for (i = 0; i < SIZE; i++) > + sarr[i] = buf_hot; > + } > + else > + { > + for (i = 0; i < SIZE; i++) > + sarr[i] = buf_cold; > + } > +} > + > +int > +main (int argc, char *argv[]) > +{ > + buf_hot = "hello"; > + buf_cold = "world"; > + foo (argc); > + return 0; > +} > + > +/* { dg-final-use { cleanup-saved-temps } } */ > Index: testsuite/g++.dg/tree-prof/partition_patch.C > =================================================================== > --- testsuite/g++.dg/tree-prof/partition_patch.C (revision 0) > +++ testsuite/g++.dg/tree-prof/partition_patch.C (revision 0) > @@ -0,0 +1,19 @@ > +// Check if patching works with function splitting. > +// { dg-do compile { target x86_64-*-* } } > +// { dg-require-effective-target freorder } > +// { dg-options "-O2 -fnon-call-exceptions > -freorder-blocks-and-partition -mpatch-functions-for-instrumentation > -fno-optimize-sibling-calls " } > + > +int k; > + > +int > +main () > +{ > + try > + { > + if (k) > + throw 6; > + } > + catch (...) > + { > + } > +} > > > -- > Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413