From patchwork Tue Oct 14 13:02:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Bruel X-Patchwork-Id: 399460 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 B96D314014D for ; Wed, 15 Oct 2014 00:03:19 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=lW7iJ7wXdqlUhAhcOvpialHNEs9rY+Hh7+uu8rcfhnm G3Ke4uuDlMxPbtAQhu8c0+rDf+Vg9OEVMr4D3zefN0z775SSrXglLlSM2y+MZ4qH xYMyfnUcuyQmREp8bdc4gBKNlFRZUYl/yMju7RSgjL3M0j13/MdxzpR5qtrSYFnQ = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=YEHUtiwVlTzR3rNrA6gy8WJp3hw=; b=vEBzyeYufsxMjVIsu HgQwSX58IMI7O8uqJ36747UY8YmEj8Ocw6fZOCDLczZvOfpAc82nwEAjHM4/GyvR s8bMnfS5L5ebGrRY/i2fVGNu0F1T+Qb2//CZtyjUtELHkeYQDw+2mohqEOQPS8Df 7vgNP8vtYGPOYw8+rBnGqi6a0w= Received: (qmail 11317 invoked by alias); 14 Oct 2014 13:03:12 -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 11308 invoked by uid 89); 14 Oct 2014 13:03:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mx07-00178001.pphosted.com Received: from mx07-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (62.209.51.94) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 14 Oct 2014 13:03:08 +0000 Received: from pps.filterd (m0046670.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.14.5/8.14.5) with SMTP id s9ED2v3j012883; Tue, 14 Oct 2014 15:03:03 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 1q0cy86nq3-1 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 14 Oct 2014 15:03:02 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 9532948; Tue, 14 Oct 2014 13:02:32 +0000 (GMT) Received: from Webmail-eu.st.com (safex1hubcas6.st.com [10.75.90.73]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 72B35162A3; Tue, 14 Oct 2014 13:02:54 +0000 (GMT) Received: from [164.129.122.166] (164.129.122.166) by webmail-eu.st.com (10.75.90.13) with Microsoft SMTP Server (TLS) id 8.3.342.0; Tue, 14 Oct 2014 15:02:54 +0200 Message-ID: <543D1EEE.5070903@st.com> Date: Tue, 14 Oct 2014 15:02:38 +0200 From: Christian Bruel User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 MIME-Version: 1.0 To: Cary Coutant , Jason Merrill Cc: "gcc-patches@gcc.gnu.org" , Ramana Radhakrishnan , Subject: [PATCH, DWARF] re-init dw_frame_pointer_regnum between functions X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.12.52, 1.0.28, 0.0.0000 definitions=2014-10-14_05:2014-10-14, 2014-10-14, 1970-01-01 signatures=0 X-IsSubscribed: yes Hello, ARM and Thumb modes use different hard_frame_pointer_regnum ABIs. The problem is that dwarf2cfi.c:dw_frame_pointer_regnum cache is initialized only once per file, when creating the CIE. While testing the ARM attribute target to switch modes between functions, I got a few assertion with -g, because this value gets inconsistent with the respective FDEs that have different hard_frame_pointer_rtx... The snippet from dwarf2cfi.c illustrates the potential issue with the mismatch between hard_frame_pointer_rtx and a badly set CFA register : if (dest == hard_frame_pointer_rtx) ... cur_cfa->reg = dw_frame_pointer_regnum; ... I'm not aware of other targets giving the possibility to change the frame_pointer_regnum ABI in a file, so the issue will only be show up with the ARM target attribute. However I'd like very much your feedback on this change, before I can send the remaining ARM parts. Tested manually for arm-none-eabi with gdb, unwinding and frame access seem OK when mixing modes. x86 bootstrapped and regressions tests are running. Many thanks, Christian 2014-09-23 Christian Bruel * execute_dwarf2_frame (dw_frame_pointer_regnum): Reinitialize for each function. Index: dwarf2cfi.c =================================================================== --- dwarf2cfi.c (revision 216146) +++ dwarf2cfi.c (working copy) @@ -2860,7 +2860,6 @@ dw_trace_info cie_trace; dw_stack_pointer_regnum = DWARF_FRAME_REGNUM (STACK_POINTER_REGNUM); - dw_frame_pointer_regnum = DWARF_FRAME_REGNUM (HARD_FRAME_POINTER_REGNUM); memset (&cie_trace, 0, sizeof (cie_trace)); cur_trace = &cie_trace; @@ -2913,6 +2912,9 @@ static unsigned int execute_dwarf2_frame (void) { + /* Different HARD_FRAME_POINTER_REGNUM might coexist in the same file. */ + dw_frame_pointer_regnum = DWARF_FRAME_REGNUM (HARD_FRAME_POINTER_REGNUM); + /* The first time we're called, compute the incoming frame state. */ if (cie_cfi_vec == NULL) create_cie_data ();