* Claudiu Zissulescu <claz...@gmail.com> [2018-11-12 13:25:13 +0200]:
> Use PROFILE_HOOK to add mcount library calls in each toolchain. > > gcc/ > xxxx-xx-xx Claudiu Zissulescu <claz...@synopsys.com> > > * config/arc/arc.h (FUNCTION_PROFILER): Redefine to empty. > * config/arc/elf.h (PROFILE_HOOK): Define. > * config/arc/linux.h (PROFILE_HOOK): Likewise. Looks good. Thanks, Andrew > --- > gcc/config/arc/arc.h | 12 +++--------- > gcc/config/arc/elf.h | 9 +++++++++ > gcc/config/arc/linux.h | 10 ++++++++++ > 3 files changed, 22 insertions(+), 9 deletions(-) > > diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h > index a0a84900917..f75c273691c 100644 > --- a/gcc/config/arc/arc.h > +++ b/gcc/config/arc/arc.h > @@ -775,15 +775,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); \ > + } > -- > 2.19.1 >