https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90746
--- Comment #3 from Dmitry Vyukov <dvyukov at google dot com> --- > It would probably useful to have __attribute__((notailcall)) which the > sanitizers then could stick on the function types. It should be on _declaration_, right? Sanitizers only provide a definition. The declaration is provided by gcc itself: sanitizer.def-DEF_SANITIZER_BUILTIN(BUILT_IN_SANITIZER_COV_TRACE_PC, sanitizer.def: "__sanitizer_cov_trace_pc", sanitizer.def- BT_FN_VOID, ATTR_NOTHROW_LEAF_LIST) But I guess we could still plum that attribute there. This also makes me wonder: find_tail_calls has fndecl_built_in_p check, the callback is declared with DEF_SANITIZER_BUILTIN, yet it's not a builtin somehow? > We could also make noinline imply no tailcalls, noinline is already mentioned > in the docs for __builtin_return_address. That wouldn't work for indirect > calls though. I would expect that C programmers want more control over this. C programmers really like to keep things in control :) That aside, this will introduce performance regressions for existing code, right? > Of course, for a builtin we can check that manually in tree-tailcall.c This looks like the simplest solution for the problem at hand. What would it be? I guess something more fancy that this: :) diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c index afe8931b5f0..b83b8ba446e 100644 --- a/gcc/tree-tailcall.c +++ b/gcc/tree-tailcall.c @@ -477,6 +477,7 @@ find_tail_calls (basic_block bb, struct tailcall **ret) func = gimple_call_fndecl (call); if (func && !fndecl_built_in_p (func) + && func != builtin_decl_implicit (BUILT_IN_SANITIZER_COV_TRACE_PC) && recursive_call_p (current_function_decl, func)) { tree arg;