On Thu, Dec 07, 2023 at 01:08:27PM +0100, Ilya Leoshkevich wrote: > GCC can emit code between the function label and the .LASANPC label, > making the latter unaligned. Some architectures cannot load unaligned > labels directly and require literal pool entries, which is inefficient. > > Move the invocation of asan_function_start to > ASM_OUTPUT_FUNCTION_LABEL, which guarantees that no additional code is > emitted. This allows setting the .LASANPC label alignment to the > respective function alignment.
> --- a/gcc/output.h > +++ b/gcc/output.h > @@ -178,6 +178,10 @@ extern void assemble_asm (tree); > /* Get the function's name from a decl, as described by its RTL. */ > extern const char *get_fnname_from_decl (tree); > > +/* Output function label, possibly with accompanying metadata. No additional > + code or data is output after the label. */ Please copy the above comment also > --- a/gcc/varasm.cc > +++ b/gcc/varasm.cc > @@ -61,6 +61,7 @@ along with GCC; see the file COPYING3. If not see > #include "alloc-pool.h" > #include "toplev.h" > #include "opts.h" > +#include "asan.h" > > /* The (assembler) name of the first globally-visible object output. */ > extern GTY(()) const char *first_global_object_name; > @@ -1835,6 +1836,15 @@ get_fnname_from_decl (tree decl) > return XSTR (x, 0); > } > here. > +void assemble_function_label_raw (FILE *file, const char *name) Also, newline rather than space after void. > +{ > + ASM_OUTPUT_LABEL (file, name); > + if ((flag_sanitize & SANITIZE_ADDRESS) > + /* Notify ASAN only about the first function label. */ > + && (in_cold_section_p == first_function_block_is_cold)) > + asan_function_start (); > +} With this the asan.cc/varasm.cc changes look good to me, for the rest I'd prefer to hear what Jeff says. Jakub