https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64313
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> --- So sth like Index: gcc/c-family/c-gimplify.c =================================================================== --- gcc/c-family/c-gimplify.c (revision 219839) +++ gcc/c-family/c-gimplify.c (working copy) @@ -300,6 +300,20 @@ c_gimplify_expr (tree *expr_p, gimple_se break; } + case ADDR_EXPR: + { + /* If we see a call to a declared builtin or see its address + being taken (we can unify those cases) then we can mark + the builtin for implicit generation by GCC. */ + tree fndecl = TREE_OPERAND (*expr_p, 0); + if (TREE_CODE (fndecl) == FUNCTION_DECL + && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL + /* C_DECL_DECLARED_BUILTIN */ + && DECL_LANG_FLAG_3 (fndecl)) + set_builtin_decl_implicit_p (DECL_FUNCTION_CODE (fndecl), true); + break; + } + case CILK_SPAWN_STMT: gcc_assert (fn_contains_cilk_spawn_p (cfun) works for C (yeah, that flag check needs to become a new langhook due to the way we share c_gimplify across frontends... :/). For C++ there isn't anything similar to C_DECL_DECLARED_BUILTIN, but of course the testcase is only exercised for C. Alternatively we can add a flag to the middle-end that FEs can set to treat a builtin as candidate for implicit use if it is used (but that way we can't distinguish uses of __builtin_log10 from declared log10). Thus, similar to [set_]builtin_decl_implicit_p have a [set_]builtin_decl_declared_p - then we can handle the above in generic gimplifier routines.