From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21195 invoked by alias); 19 Jan 2015 13:55:56 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 21135 invoked by uid 48); 19 Jan 2015 13:55:51 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/64313] [5 Regression] gcc.dg/torture/builtin-explog-1.c fails on bare-metal targets Date: Mon, 19 Jan 2015 13:55:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 5.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-01/txt/msg01835.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64313 --- Comment #6 from Richard Biener --- 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.