From patchwork Sat Oct 7 22:17:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 822939 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-463702-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Hyq9F+5Z"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y8gql24chz9t3r for ; Sun, 8 Oct 2017 09:17:52 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=VyaV7HcIyCsLqdnV w/w0DjxH/1AeoKnJ0FfIvFmQFUoxVTZxaD2+JA5D76e7eU8A04+V9T1fwayOs/Y8 0w5UiomEz1pda/x3vSsO6wgpIC6rtS7LhDzCOOwQzS5D0zRbpjA+3ngD43xR8iKx elHSjQqgKGv+FSVRjo6acSW3mcQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=zP3rP1NVAuC7SvmdN3IKTQ IGYRw=; b=Hyq9F+5Znwz5Y4aYfcLbv8StRu07vAHfdRG2affcKJ1U6TSHCWvb92 Yxi3/FB28j8Bk+XMaUe9UpYWf4sgZGh8eHPWUKI2PO2xQSlVkY8/4HxWrw17FLYi uV8f5YTMC1M9Rxf8x/LRQrcv3fIv1bxrgRYZC6+43t3DpkvuZoeT4= Received: (qmail 74229 invoked by alias); 7 Oct 2017 22:17:45 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 74220 invoked by uid 89); 7 Oct 2017 22:17:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=restores X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 07 Oct 2017 22:17:43 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 5ADCB823B2 for ; Sun, 8 Oct 2017 00:17:40 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OqvRocDDR6i5 for ; Sun, 8 Oct 2017 00:17:40 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 341D4823AA for ; Sun, 8 Oct 2017 00:17:40 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Restore functional DONT_USE_BUILTIN_SETJMP support Date: Sun, 08 Oct 2017 00:17:39 +0200 Message-ID: <2067154.q9SCchci8G@polaris> User-Agent: KMail/4.14.10 (Linux/3.16.7-53-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 DONT_USE_BUILTIN_SETJMP is an old configuration macro that instructs the compiler to use the usual setjmp/longjmp routines instead of their built-in variants to implement SJLJ exceptions. It's less efficient but, sometimes, the setjmp/longjmp routines have specific features that cannot be easily implemented by the built-in. Only IA-64 and Aarch64 define it. The support is currently broken at compile time (because of a broken CFG) and at link time (an unresolved symbol). The attached small patch restores it. Bootstrapped & tested on Aarch64/Linux with --enable-sjlj-exceptions, applied on the mainline as obvious. 2017-10-07 Eric Botcazou * builtins.def (BUILT_IN_SETJMP): Declare as library builtin instead of GCC builtin if DONT_USE_BUILTIN_SETJMP is defined. * except.c (sjlj_emit_function_enter): If DONT_USE_BUILTIN_SETJMP is defined, force the creation of a new block for a dispatch label. Index: builtins.def =================================================================== --- builtins.def (revision 253506) +++ builtins.def (working copy) @@ -890,7 +890,11 @@ DEF_LIB_BUILTIN (BUILT_IN_REALLOC DEF_GCC_BUILTIN (BUILT_IN_RETURN, "return", BT_FN_VOID_PTR, ATTR_NORETURN_NOTHROW_LEAF_LIST) DEF_GCC_BUILTIN (BUILT_IN_RETURN_ADDRESS, "return_address", BT_FN_PTR_UINT, ATTR_LEAF_LIST) DEF_GCC_BUILTIN (BUILT_IN_SAVEREGS, "saveregs", BT_FN_PTR_VAR, ATTR_NULL) +#ifdef DONT_USE_BUILTIN_SETJMP +DEF_LIB_BUILTIN (BUILT_IN_SETJMP, "setjmp", BT_FN_INT_PTR, ATTR_RT_NOTHROW_LEAF_LIST) +#else DEF_GCC_BUILTIN (BUILT_IN_SETJMP, "setjmp", BT_FN_INT_PTR, ATTR_RT_NOTHROW_LEAF_LIST) +#endif DEF_EXT_LIB_BUILTIN (BUILT_IN_STRFMON, "strfmon", BT_FN_SSIZE_STRING_SIZE_CONST_STRING_VAR, ATTR_FORMAT_STRFMON_NOTHROW_3_4) DEF_LIB_BUILTIN (BUILT_IN_STRFTIME, "strftime", BT_FN_SIZE_STRING_SIZE_CONST_STRING_CONST_TM_PTR, ATTR_FORMAT_STRFTIME_NOTHROW_3_0) DEF_GCC_BUILTIN (BUILT_IN_TRAP, "trap", BT_FN_VOID, ATTR_NORETURN_NOTHROW_LEAF_COLD_LIST) Index: except.c =================================================================== --- except.c (revision 253506) +++ except.c (working copy) @@ -1209,6 +1209,28 @@ sjlj_emit_function_enter (rtx_code_label fn_begin_outside_block = false; } +#ifdef DONT_USE_BUILTIN_SETJMP + if (dispatch_label) + { + /* The sequence contains a branch in the middle so we need to force + the creation of a new basic block by means of BB_SUPERBLOCK. */ + if (fn_begin_outside_block) + { + basic_block bb + = split_edge (single_succ_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun))); + if (JUMP_P (BB_END (bb))) + emit_insn_before (seq, BB_END (bb)); + else + emit_insn_after (seq, BB_END (bb)); + } + else + emit_insn_after (seq, fn_begin); + + single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun))->flags |= BB_SUPERBLOCK; + return; + } +#endif + if (fn_begin_outside_block) insert_insn_on_edge (seq, single_succ_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun))); else