From: Claudiu Zissulescu Date: Tue, 13 Nov 2018 12:51:41 +0000 (+0100) Subject: [ARC] Add support for profiling in glibc. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9de6af4572105dbe63074d09b8c322464daec2e7;p=gcc.git [ARC] Add support for profiling in glibc. Use PROFILE_HOOK to add mcount library calls in each toolchain. gcc/ xxxx-xx-xx Claudiu Zissulescu * config/arc/arc.h (FUNCTION_PROFILER): Redefine to empty. * config/arc/elf.h (PROFILE_HOOK): Define. * config/arc/linux.h (PROFILE_HOOK): Likewise. From-SVN: r266068 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7ba3fd3f359..3f94aeb8080 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-11-13 Claudiu Zissulescu + + * config/arc/arc.h (FUNCTION_PROFILER): Redefine to empty. + * config/arc/elf.h (PROFILE_HOOK): Define. + * config/arc/linux.h (PROFILE_HOOK): Likewise. + 2018-11-13 Claudiu Zissulescu * config/arc/arc.c (hwloop_optimize): Bailout when detecting a diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h index 6e9b1e5ddb6..b81b0e7ba33 100644 --- a/gcc/config/arc/arc.h +++ b/gcc/config/arc/arc.h @@ -811,15 +811,9 @@ extern int arc_initial_elimination_offset(int from, int to); #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ (OFFSET) = arc_initial_elimination_offset ((FROM), (TO)) -/* Output assembler code to FILE to increment profiler label # LABELNO - for profiling a function entry. */ -#define FUNCTION_PROFILER(FILE, LABELNO) \ - do { \ - if (flag_pic) \ - fprintf (FILE, "\tbl\t__mcount@plt\n"); \ - else \ - fprintf (FILE, "\tbl\t__mcount\n"); \ - } while (0) +/* All the work done in PROFILE_HOOK, but still required. */ +#undef FUNCTION_PROFILER +#define FUNCTION_PROFILER(STREAM, LABELNO) do { } while (0) #define NO_PROFILE_COUNTERS 1 diff --git a/gcc/config/arc/elf.h b/gcc/config/arc/elf.h index 3472fd2e418..3aabcf8c9e6 100644 --- a/gcc/config/arc/elf.h +++ b/gcc/config/arc/elf.h @@ -78,3 +78,12 @@ along with GCC; see the file COPYING3. If not see #undef LINK_GCC_C_SEQUENCE_SPEC #define LINK_GCC_C_SEQUENCE_SPEC \ "--start-group %G %{!specs=*:%{!nolibc:-lc -lnosys}} --end-group" + +/* Emit rtl for profiling. Output assembler code to FILE + to call "_mcount" for profiling a function entry. */ +#define PROFILE_HOOK(LABEL) \ + { \ + rtx fun; \ + fun = gen_rtx_SYMBOL_REF (Pmode, "__mcount"); \ + emit_library_call (fun, LCT_NORMAL, VOIDmode); \ + } diff --git a/gcc/config/arc/linux.h b/gcc/config/arc/linux.h index 62ebe4de0fc..993f445d2a0 100644 --- a/gcc/config/arc/linux.h +++ b/gcc/config/arc/linux.h @@ -123,3 +123,13 @@ along with GCC; see the file COPYING3. If not see : "=r" (_beg) \ : "0" (_beg), "r" (_end), "r" (_xtr), "r" (_scno)); \ } + +/* Emit rtl for profiling. Output assembler code to FILE + to call "_mcount" for profiling a function entry. */ +#define PROFILE_HOOK(LABEL) \ + { \ + rtx fun, rt; \ + rt = get_hard_reg_initial_val (Pmode, RETURN_ADDR_REGNUM); \ + fun = gen_rtx_SYMBOL_REF (Pmode, "_mcount"); \ + emit_library_call (fun, LCT_NORMAL, VOIDmode, rt, Pmode); \ + }