Hi Marcus, I have re-based the patch and tested for aarch64-none-elf with no regressions. Also for aarch64-unknown-linux-gnu the following test cases passes.
Before: -------- UNSUPPORTED: gcc.dg/nested-func-4.c UNSUPPORTED: gcc.dg/pr43643.c: UNSUPPORTED: gcc.dg/nest.c UNSUPPORTED: gcc.dg/20021014-1.c UNSUPPORTED: gcc.dg/pr32450.c UNSUPPORTED: g++.dg/other/profile1.C -std=gnu++98 UNSUPPORTED: g++.dg/other/profile1.C -std=gnu++11 After: ------- PASS: gcc.dg/nested-func-4.c (test for excess errors) PASS: gcc.dg/nested-func-4.c execution test PASS: gcc.dg/pr43643.c (test for excess errors) PASS: gcc.dg/pr43643.c execution test PASS: gcc.dg/nest.c (test for excess errors) PASS: gcc.dg/nest.c execution test PASS: gcc.dg/20021014-1.c (test for excess errors) PASS: gcc.dg/20021014-1.c execution test PASS: gcc.dg/pr32450.c (test for excess errors) PASS: gcc.dg/pr32450.c execution test PASS: g++.dg/other/profile1.C -std=gnu++98 (test for excess errors) PASS: g++.dg/other/profile1.C -std=gnu++98 execution test PASS: g++.dg/other/profile1.C -std=gnu++11 (test for excess errors) PASS: g++.dg/other/profile1.C -std=gnu++11 execution test Please let me know if I can commit it to trunk, given that glibc patches are upstreamed. 2013-10-28 Venkataramanan Kumar <venkataramanan.ku...@linaro.org> * config/aarch64/aarch64.h (MCOUNT_NAME): Define. (NO_PROFILE_COUNTERS): Likewise. (PROFILE_HOOK): Likewise. (FUNCTION_PROFILER): Likewise. * config/aarch64/aarch64.c (aarch64_function_profiler): Remove. regards, Venkat. On 27 August 2013 13:05, Marcus Shawcroft <marcus.shawcr...@gmail.com> wrote: > Hi Venkat, > > On 3 August 2013 19:01, Venkataramanan Kumar > <venkataramanan.ku...@linaro.org> wrote: > >> This patch adds macros to support gprof in Aarch64. The difference >> from the previous patch is that the compiler, while generating >> "mcount" routine for an instrumented function, also passes the return >> address as argument. >> >> The "mcount" routine in glibc will be modified as follows. >> >> (-----Snip-----) >> #define MCOUNT \ >> -void __mcount (void) >> \ >> +void __mcount (void* frompc) >> \ >> { >> \ >> - mcount_internal ((u_long) RETURN_ADDRESS (1), (u_long) RETURN_ADDRESS >> (0)); \ >> + mcount_internal ((u_long) frompc, (u_long) RETURN_ADDRESS (0)); \ >> } >> (-----Snip-----) > > >> If this is Ok I will send the patch to glibc as well. > >> 2013-08-02 Venkataramanan Kumar <venkataramanan.ku...@linaro.org> >> >> * config/aarch64/aarch64.h (MCOUNT_NAME): Define. >> (NO_PROFILE_COUNTERS): Likewise. >> (PROFILE_HOOK): Likewise. >> (FUNCTION_PROFILER): Likewise. >> * config/aarch64/aarch64.c (aarch64_function_profiler): Remove. >> . >> >> regards, >> Venkat. > > + emit_library_call (fun, LCT_NORMAL, VOIDmode, 1,lr,Pmode); \ > +} > > GNU coding style requires spaces after the commas, but otherwise I > have no further comments on this patch. Post the glibc patch please. > > Thanks > /Marcus
Index: gcc/config/aarch64/aarch64.c =================================================================== --- gcc/config/aarch64/aarch64.c (revision 202934) +++ gcc/config/aarch64/aarch64.c (working copy) @@ -3857,13 +3857,6 @@ output_addr_const (f, x); } -void -aarch64_function_profiler (FILE *f ATTRIBUTE_UNUSED, - int labelno ATTRIBUTE_UNUSED) -{ - sorry ("function profiling"); -} - bool aarch64_label_mentioned_p (rtx x) { Index: gcc/config/aarch64/aarch64.h =================================================================== --- gcc/config/aarch64/aarch64.h (revision 202934) +++ gcc/config/aarch64/aarch64.h (working copy) @@ -783,9 +783,23 @@ #define PRINT_OPERAND_ADDRESS(STREAM, X) \ aarch64_print_operand_address (STREAM, X) -#define FUNCTION_PROFILER(STREAM, LABELNO) \ - aarch64_function_profiler (STREAM, LABELNO) +#define MCOUNT_NAME "_mcount" +#define NO_PROFILE_COUNTERS 1 + +/* Emit rtl for profiling. Output assembler code to FILE + to call "_mcount" for profiling a function entry. */ +#define PROFILE_HOOK(LABEL) \ +{ \ + rtx fun,lr; \ + lr = get_hard_reg_initial_val (Pmode, LR_REGNUM); \ + fun = gen_rtx_SYMBOL_REF (Pmode, MCOUNT_NAME); \ + emit_library_call (fun, LCT_NORMAL, VOIDmode, 1, lr, Pmode); \ +} + +/* All the work done in PROFILE_HOOK, but still required. */ +#define FUNCTION_PROFILER(STREAM, LABELNO) do { } while (0) + /* For some reason, the Linux headers think they know how to define these macros. They don't!!! */ #undef ASM_APP_ON Index: gcc/testsuite/lib/target-supports.exp =================================================================== --- gcc/testsuite/lib/target-supports.exp (revision 202934) +++ gcc/testsuite/lib/target-supports.exp (working copy) @@ -494,13 +494,6 @@ return 0 } - # We don't yet support profiling for AArch64. - if { [istarget aarch64*-*-*] - && ([lindex $test_what 1] == "-p" - || [lindex $test_what 1] == "-pg") } { - return 0 - } - # cygwin does not support -p. if { [istarget *-*-cygwin*] && $test_what == "-p" } { return 0