diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2005-10-26 07:25:57 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2005-10-26 07:25:57 +0000 |
commit | 694a2f6ea681d5e14af695d1c1848a1bd223d69c (patch) | |
tree | 8444f3b0059333dd1aea5f73488ac8d168dc139f /gcc | |
parent | 43f237b43f37cf15bd834e631aa82910cd9a50d8 (diff) | |
download | gcc-694a2f6ea681d5e14af695d1c1848a1bd223d69c.zip gcc-694a2f6ea681d5e14af695d1c1848a1bd223d69c.tar.gz gcc-694a2f6ea681d5e14af695d1c1848a1bd223d69c.tar.bz2 |
ia64.c (ia64_output_function_profiler): Emit an indirect call to _mcount if the function needs a static chain.
* config/ia64/ia64.c (ia64_output_function_profiler): Emit an
indirect call to _mcount if the function needs a static chain.
From-SVN: r105917
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/config/ia64/ia64.c | 40 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/nested-func-4.c | 21 |
4 files changed, 66 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c2bc164..3fed47d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2005-10-25 Eric Botcazou <ebotcazou@adacore.com> + + * config/ia64/ia64.c (ia64_output_function_profiler): Emit an + indirect call to _mcount if the function needs a static chain. + 2005-10-25 Eric Botcazou <ebotcazou@libertysurf.fr> Caroline Tice <ctice@apple.com> diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index 4dafbd2..2e1cc19 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -8802,9 +8802,27 @@ ia64_vector_mode_supported_p (enum machine_mode mode) } } +/* Implement the FUNCTION_PROFILER macro. */ + void ia64_output_function_profiler (FILE *file, int labelno) { + bool indirect_call; + + /* If the function needs a static chain and the static chain + register is r15, we use an indirect call so as to bypass + the PLT stub in case the executable is dynamically linked, + because the stub clobbers r15 as per 5.3.6 of the psABI. + We don't need to do that in non canonical PIC mode. */ + + if (cfun->static_chain_decl && !TARGET_NO_PIC && !TARGET_AUTO_PIC) + { + gcc_assert (STATIC_CHAIN_REGNUM == 15); + indirect_call = true; + } + else + indirect_call = false; + if (TARGET_GNU_AS) fputs ("\t.prologue 4, r40\n", file); else @@ -8812,7 +8830,7 @@ ia64_output_function_profiler (FILE *file, int labelno) fputs ("\talloc out0 = ar.pfs, 8, 0, 4, 0\n", file); if (NO_PROFILE_COUNTERS) - fputs ("\tmov out3 = r0\n\t;;\n", file); + fputs ("\tmov out3 = r0\n", file); else { char buf[20]; @@ -8824,16 +8842,30 @@ ia64_output_function_profiler (FILE *file, int labelno) fputs ("\taddl out3 = @ltoff(", file); assemble_name (file, buf); if (TARGET_AUTO_PIC) - fputs (")\n\t;;\n", file); + fputs (")\n", file); else - fputs ("), r1\n\t;;\n", file); + fputs ("), r1\n", file); } + if (indirect_call) + fputs ("\taddl r14 = @ltoff(@fptr(_mcount)), r1\n", file); + fputs ("\t;;\n", file); + fputs ("\t.save rp, r42\n", file); fputs ("\tmov out2 = b0\n", file); + if (indirect_call) + fputs ("\tld8 r14 = [r14]\n\t;;\n", file); fputs ("\t.body\n", file); fputs ("\tmov out1 = r1\n", file); - fputs ("\tbr.call.sptk.many b0 = _mcount\n\t;;\n", file); + if (indirect_call) + { + fputs ("\tld8 r16 = [r14], 8\n\t;;\n", file); + fputs ("\tmov b6 = r16\n", file); + fputs ("\tld8 r1 = [r14]\n", file); + fputs ("\tbr.call.sptk.many b0 = b6\n\t;;\n", file); + } + else + fputs ("\tbr.call.sptk.many b0 = _mcount\n\t;;\n", file); } static GTY(()) rtx mcount_func_rtx; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3ef1196..a59b549 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2005-10-25 Eric Botcazou <ebotcazou@adacore.com> + + * gcc.dg/nested-func-4.c: New test. + 2005-10-26 Paul Thomas <pault@gcc.gnu.org> PR fortran/24158 diff --git a/gcc/testsuite/gcc.dg/nested-func-4.c b/gcc/testsuite/gcc.dg/nested-func-4.c new file mode 100644 index 0000000..5a17f78 --- /dev/null +++ b/gcc/testsuite/gcc.dg/nested-func-4.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-options "-pg" } */ + +extern void abort(void); + +void foo(int i) +{ + void bar(void) + { + if (i != 2) + abort (); + } + + bar(); +} + +int main(void) +{ + foo (2); + return 0; +} |