From patchwork Tue Mar 25 08:13:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhenqiang Chen X-Patchwork-Id: 26968 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4EC0220539 for ; Tue, 25 Mar 2014 08:13:54 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f10sf288456yha.3 for ; Tue, 25 Mar 2014 01:13:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:mime-version:date:message-id:subject:from:to:cc :x-original-sender:x-original-authentication-results:content-type; bh=cylyg/xf9Dj0cw6MzGMH8OMBvw96N3oy6BO6TWvFZpM=; b=eb9Stcg4S9jl1JZdrg23eEv+D8aLAP18DmqXS3DjUQfV48QIQnVHppyvUttN7E0wU1 lC62qSEG3eW0qUruqM9RhkxRHB8LbzvRrMyTxRScu7+0tpuS8TXdzW+enDvLyJT/Dq8V huekpJt1XMC6bc/5EuhNJBOR2DECliLBLfsY/T4sGYidRuiSMGGJB+Ab721ZeA/kJ7oy kywcLFzcPr2x0Kmafpq4AQRJ5/sFJpyop5SGGRWbHbLMk6bXgiFbl0+k/R774hB5rURq NT/COyurKUv3BuNFlLfbuXkl5GHnVkzGvtzxZA13iKqfWeL8a/SS0BnGQ20GHQvBDvDT 1ItQ== X-Gm-Message-State: ALoCoQnDGRaAucO0zZSSIPmgo9pOb7FJiJpWSN5wIez2VxR/SJwS/Rvufnz85gYHolIvTrN1PKHI X-Received: by 10.58.85.3 with SMTP id d3mr5100714vez.40.1395735234051; Tue, 25 Mar 2014 01:13:54 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.32.11 with SMTP id g11ls148618qgg.11.gmail; Tue, 25 Mar 2014 01:13:53 -0700 (PDT) X-Received: by 10.52.138.112 with SMTP id qp16mr7387vdb.40.1395735233905; Tue, 25 Mar 2014 01:13:53 -0700 (PDT) Received: from mail-vc0-x22a.google.com (mail-vc0-x22a.google.com [2607:f8b0:400c:c03::22a]) by mx.google.com with ESMTPS id h11si3570800veh.212.2014.03.25.01.13.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 01:13:53 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c03::22a is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c03::22a; Received: by mail-vc0-f170.google.com with SMTP id hu19so123973vcb.29 for ; Tue, 25 Mar 2014 01:13:53 -0700 (PDT) X-Received: by 10.220.161.8 with SMTP id p8mr54244976vcx.4.1395735233839; Tue, 25 Mar 2014 01:13:53 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp284891vck; Tue, 25 Mar 2014 01:13:53 -0700 (PDT) X-Received: by 10.68.178.1 with SMTP id cu1mr76078324pbc.34.1395735232941; Tue, 25 Mar 2014 01:13:52 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id wm7si11021451pab.110.2014.03.25.01.13.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Mar 2014 01:13:52 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-363877-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 11801 invoked by alias); 25 Mar 2014 08:13:38 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 11790 invoked by uid 89); 25 Mar 2014 08:13:37 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-la0-f44.google.com Received: from mail-la0-f44.google.com (HELO mail-la0-f44.google.com) (209.85.215.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 25 Mar 2014 08:13:36 +0000 Received: by mail-la0-f44.google.com with SMTP id hr13so86362lab.3 for ; Tue, 25 Mar 2014 01:13:33 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.153.7.200 with SMTP id de8mr48995348lad.19.1395735213273; Tue, 25 Mar 2014 01:13:33 -0700 (PDT) Received: by 10.112.135.105 with HTTP; Tue, 25 Mar 2014 01:13:33 -0700 (PDT) Date: Tue, 25 Mar 2014 16:13:33 +0800 Message-ID: Subject: [PATCH, ARM] Enable shrink-wrap for apcs frame From: Zhenqiang Chen To: "gcc-patches@gcc.gnu.org" Cc: Ramana Radhakrishnan X-IsSubscribed: yes X-Original-Sender: zhenqiang.chen@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c03::22a is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 Hi The patch enables shrink-wrap for apcs frame. Bootstrap and no make check regression in ARM, THUMB1 and THUMB2 modes. No make check regression with "-g/-mapcs/-marm". Build linux-3.14-rc7 without error. Is it OK for next stage1? Thanks! -Zhenqiang ChangeLog: 2014-03-25 Zhenqiang Chen * config/arm/arm.c (arm_option_override): Enable shrink-wrap for TARGET_APCS_FRAME. (arm_emit_multi_reg_pop): Set correct dwarf info. (arm_expand_epilogue_apcs_frame): Add more dwarf info. testsuite/ChangeLog: 2014-03-25 Zhenqiang Chen * gcc.target/arm/shrink-wrap-alloca.c: New test case. * gcc.target/arm/shrink-wrap-sibcall.c: New test case. diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 0240cc7..fa86942 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -2811,9 +2811,6 @@ arm_option_override (void) generate additional returns. */ if (optimize_function_for_size_p (cfun) && TARGET_THUMB2) flag_shrink_wrap = false; - /* TBD: Dwarf info for apcs frame is not handled yet. */ - if (TARGET_APCS_FRAME) - flag_shrink_wrap = false; /* We only support -mslow-flash-data on armv7-m targets. */ if (target_slow_flash_data @@ -19840,7 +19837,14 @@ arm_emit_multi_reg_pop (unsigned long saved_regs_mask) par = emit_insn (par); REG_NOTES (par) = dwarf; - if (!return_in_pc) + + if (!emit_update) + { + /* SP is restored from stack. So reset the frame info. */ + RTX_FRAME_RELATED_P (par) = 1; + add_reg_note (par, REG_CFA_DEF_CFA, stack_pointer_rtx); + } + else if (!return_in_pc) arm_add_cfa_adjust_cfa_note (par, UNITS_PER_WORD * num_regs, stack_pointer_rtx, stack_pointer_rtx); } @@ -27226,6 +27230,9 @@ arm_expand_epilogue_apcs_frame (bool really_return) REG_NOTES (insn) = alloc_reg_note (REG_CFA_RESTORE, gen_rtx_REG (SImode, IP_REGNUM), NULL_RTX); + arm_add_cfa_adjust_cfa_note (insn, UNITS_PER_WORD, + stack_pointer_rtx, + stack_pointer_rtx); } if (!really_return || (saved_regs_mask & (1 << PC_REGNUM))) diff --git a/gcc/testsuite/gcc.target/arm/shrink-wrap-alloca.c b/gcc/testsuite/gcc.target/arm/shrink-wrap-alloca.c new file mode 100644 index 0000000..318240b --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/shrink-wrap-alloca.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -mapcs " } */ + +int *p; + +void +test (int a) +{ + if (a > 0) + p = __builtin_alloca (4); +} diff --git a/gcc/testsuite/gcc.target/arm/shrink-wrap-sibcall.c b/gcc/testsuite/gcc.target/arm/shrink-wrap-sibcall.c new file mode 100644 index 0000000..2efe5d0 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/shrink-wrap-sibcall.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -mapcs " } */ + +unsigned char a, b, d, f, g; + +int test (void); + +int +baz (int c) +{ + if (c == 0) return test (); + if (b & 1) + { + g = 0; + int e = (a & 0x0f) - (g & 0x0f); + + if (!a) b |= 0x80; + a = e + test (); + f = g/5 + a*3879 + b *2985; + } + else + { + f = g + a*39879 + b *25; + } + return test (); +}