https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78333

            Bug ID: 78333
           Summary: Intrinsics lack no_instrument_function attribute and
                    thus breaks -finstrument-functions
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cube2killfield at gmail dot com
  Target Milestone: ---

When using option -finstrument-functions, compiler-provided intrinsics cannot
be used. Intrinsics are not functions, so when the compiler tries to evaluate
the address of them for the caller argument of __cyg_profile_func_{enter,exit}
the symbol cannot be resolved by the linker as the function doesn't actually
exist.

A minimal test case is provided below:
/* gcc -std=c99 -finstrument-functions t.c */
#include <xmmintrin.h>
void __cyg_profile_func_enter (void *, void *)
__attribute__((no_instrument_function));
void __cyg_profile_func_exit (void *, void *)
__attribute__((no_instrument_function));
void __cyg_profile_func_enter (void *a, void *b) { }
void __cyg_profile_func_exit (void *a, void *b) { }
int main() {
  volatile __m128 x = _mm_set1_ps(1.0f);
}

This code will only compile for hosts that support SSE. Though you can trigger
the same issue with any intrinsic header (AVX, NEON, AltiVec, etc.)

One way to fix it would be to add the no_instrument_function attribute to all
of the intrinsics. I think a more general solution should be applied, i.e
ignore generating the instrumentation when the function is an intrinsic.

I've tested on multiple versions of GCC and the bug appears to exist in both
GCC 4, 5 and 6.

Reply via email to