From patchwork Mon Sep 18 07:50:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 814808 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-462355-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="sANLT1N6"; 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 3xwdVl1grSz9s3w for ; Mon, 18 Sep 2017 17:51:27 +1000 (AEST) 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=O5cUXquJiWHOCgso 1dhUvg2Th+fueWf0daE5ksbJEKAWbucupoDvJiYXbV+0t+SyqYG1U/ggruyuUt+E 8WbtAJKA9IkcMW7+YGjYF9VGrqPKoediOBJK8W8mCtMv+2g3BTfCaUdZ6pNLUw3R ndzWW+XD+XikhpN0cmqzWvlVLyY= 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=nyYjHFIwNsaUQHPH3sj8ky rjSQU=; b=sANLT1N6MKc+FzrilhsmNqJ7ttBMXJzQ9jFKBpQdV7JZptDJPW56KZ bFXRUagUjsqXj88s/YYf4x7pS37Uu3Un3pF4wghSHTYV3K4dh3Y2TrkIOWGC/Yfl AZ1GxDUZsEaa2mqrq7NeeiJNp3/alZA4KMJ0iN/qCJ06J7GPchp0I= Received: (qmail 114366 invoked by alias); 18 Sep 2017 07:51:16 -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 102931 invoked by uid 89); 18 Sep 2017 07:50:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= 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; Mon, 18 Sep 2017 07:50:50 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 9D6FD822AA for ; Mon, 18 Sep 2017 09:50:48 +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 eEjTnNEPQ4yP for ; Mon, 18 Sep 2017 09:50:48 +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 720E1822A7 for ; Mon, 18 Sep 2017 09:50:48 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Fix PR target/81361 Date: Mon, 18 Sep 2017 09:50:45 +0200 Message-ID: <2507479.MzcqCaxoQO@polaris> User-Agent: KMail/4.14.10 (Linux/3.16.7-53-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 Hi, exception handling is currently broken in all languages for Darwin at -O2 on the mainline because of what appears to be a bug in either the assembler or the system unwinder. The problem occurs when the compiler decides to split a function into hot & cold parts and the cold part is active wrt EH; in this case, the compiler generates a FDE for each part (the Darwin port doesn't use the CFI assembler directives) and the second FDE looks like: .set L$set$24,LEFDE3-LASFDE3 .long L$set$24 # FDE Length LASFDE3: .long LASFDE3-EH_frame1 # FDE CIE offset .quad LCOLDB1-. # FDE initial location .set L$set$25,LCOLDE1-LCOLDB1 .quad L$set$25 # FDE address range .byte 0x8 # uleb128 0x8; Augmentation size .quad LLSDAC5-. # Language Specific Data Area .byte 0x1 # DW_CFA_set_loc .quad LCFI1-. .byte 0xe # DW_CFA_def_cfa_offset .byte 0x10 # uleb128 0x10 .byte 0x83 # DW_CFA_offset, column 0x3 .byte 0x2 # uleb128 0x2 Note the DW_CFA_set_loc operation: it's the only case where the compiler emits it (DW_CFA_advance_loc4 is usually emitted) and is the source of the problem, since it appears that the PC-relative relocation is not applied to the operand of the DW_CFA_set_loc (unlike to the 2 other cases in the FDE). This DW_CFA_set_loc instruction is emitted by add_cfis_to_fde for the second FDE generated for the cold part of a function but doesn't seem necessary any more, since there is a label (LCOLDB1) to be used now (this can also be seen on Linux with the -fno-dwarf2-cfi-asm option). Bootstrapped/regtested on x86-64/Linux by me and various versions of Darwin by Iain, Dominique and myself. OK for the mainline? 2017-09-18 Eric Botcazou PR target/81361 * dwarf2cfi.c (add_cfis_to_fde): Do not generate DW_CFA_set_loc after switching to a new text section. Index: dwarf2cfi.c =================================================================== --- dwarf2cfi.c (revision 252749) +++ dwarf2cfi.c (working copy) @@ -2209,20 +2209,13 @@ add_cfis_to_fde (void) { dw_fde_ref fde = cfun->fde; rtx_insn *insn, *next; - /* We always start with a function_begin label. */ - bool first = false; for (insn = get_insns (); insn; insn = next) { next = NEXT_INSN (insn); if (NOTE_P (insn) && NOTE_KIND (insn) == NOTE_INSN_SWITCH_TEXT_SECTIONS) - { - fde->dw_fde_switch_cfi_index = vec_safe_length (fde->dw_fde_cfi); - /* Don't attempt to advance_loc4 between labels - in different sections. */ - first = true; - } + fde->dw_fde_switch_cfi_index = vec_safe_length (fde->dw_fde_cfi); if (NOTE_P (insn) && NOTE_KIND (insn) == NOTE_INSN_CFI) { @@ -2247,8 +2240,7 @@ add_cfis_to_fde (void) /* Set the location counter to the new label. */ xcfi = new_cfi (); - xcfi->dw_cfi_opc = (first ? DW_CFA_set_loc - : DW_CFA_advance_loc4); + xcfi->dw_cfi_opc = DW_CFA_advance_loc4; xcfi->dw_cfi_oprnd1.dw_cfi_addr = label; vec_safe_push (fde->dw_fde_cfi, xcfi); @@ -2263,7 +2255,6 @@ add_cfis_to_fde (void) insn = NEXT_INSN (insn); } while (insn != next); - first = false; } } }