From patchwork Tue Aug 15 16:26:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 801671 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-460394-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="swA8pgSb"; 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 3xWycF2Rgvz9sPm for ; Wed, 16 Aug 2017 02:29:33 +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:cc:subject:date:message-id:references:in-reply-to :content-type:content-transfer-encoding:mime-version; q=dns; s= default; b=h+DDifeHGJRHGh8QdoQ1RIFLAzJrKJR81817vrxk8QSRi2+2vbpum I4YJxqkdbD37PbJrYsFuUJ8BISMD+N03MyE8lDAztNi1xy5Xz30FL2Xr9JNAXGtY Tr6HTIVSw5XTqqbewYnjzVh0blZGZRnNRJIreIYZk9r5ARpcL1Bamw= 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:cc:subject:date:message-id:references:in-reply-to :content-type:content-transfer-encoding:mime-version; s=default; bh=gFUt8CDF7C1fqaJPKWQlh4qK5f4=; b=swA8pgSb7oOahfxDul9lPp9OsBKp H/lymP7Q5Xhw7jodgupAbQSPUmgNWPQdfQBPqX9qyTzsMZ4rYMzJ6do4zCQQ6cJO zL5Iz3E1cPEVuwniLEK9JRr62Q+0xfQruKntbbQWWO/dUzEJrRRWMEmJzsDG/vMI Zy2qSj5WdaFeyms= Received: (qmail 127224 invoked by alias); 15 Aug 2017 16:27:17 -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 126768 invoked by uid 89); 15 Aug 2017 16:27:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: EUR01-HE1-obe.outbound.protection.outlook.com Received: from mail-he1eur01on0068.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) (104.47.0.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 15 Aug 2017 16:27:01 +0000 Received: from DB6PR0801MB2053.eurprd08.prod.outlook.com (10.168.86.22) by AM4PR08MB2658.eurprd08.prod.outlook.com (10.171.190.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1341.21; Tue, 15 Aug 2017 16:26:57 +0000 Received: from DB6PR0801MB2053.eurprd08.prod.outlook.com ([fe80::2d78:6ac0:142:cc9a]) by DB6PR0801MB2053.eurprd08.prod.outlook.com ([fe80::2d78:6ac0:142:cc9a%18]) with mapi id 15.01.1341.020; Tue, 15 Aug 2017 16:26:57 +0000 From: Wilco Dijkstra To: GCC Patches , James Greenhalgh , Jeff Law CC: nd Subject: Re: [PATCH][AArch64] Simplify frame layout for stack probing Date: Tue, 15 Aug 2017 16:26:57 +0000 Message-ID: References: , In-Reply-To: x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM4PR08MB2658; 6:mFb3GGrB6IU1zQv/0DrVslGbizRRetGYAGQXT1Z322Jxt5nm/H7pl/oWxnHLTFX540+dWpogswIF6wiKIhFXd/Il8w86yIyX2w1a8IfU/03rlKcYozsgRsTDitBf72eo4viKYJCOA0ddszi8uYSHlSQNEJWAv/RM48qDqZNPigqpC9dkbzNns1Vhja6IOMXE2L+ch+Oy3D/otqdpza7C/INbgNkfLP7TTqAorgBM7F6nvR/FErVf/4KzFfvmK5VITX2kVT+Yg0rYFZu2poJ1zx7UDGq3ukR6ergvPKBvHDiQtm1GOD96I9Pn+NpVAz6NUe5hHITBFb8tQt95FNaBXg==; 5:N/xaapbgl7KhDgTyw8EnDa6VQ1cD/tCc61bOfNYzJVFecEBj0LJrZM7knVbAJFP4oIYueHrkYwWIrvQdN6PjIPwqZdU/DVdOywLA3c5nElQMEADR34dvl+sVB9cFGC9Lnkwx3jPh2kKxZGNaOeO07w==; 24:lrSFYljzFaX2RvI4iu1hQnrETyICrN4Tw0TfjltHLRSyeDKV98sq2/JB7e1gGnQAGRpCPhNDM0T9MeVvvEI0NUyeWweZRTHUzpocoRzLm+E=; 7:9qVrM9vG8BX9dk61CSy2aF2knsy2wRT2BbcgnV91swLGSUHymnTRE3rpNgrOC1ZiMFifyimkJTatxF41lKrmP5BPwEbPeVvzSJMh8lw4VUP5kZgXAiJngEXbchxA42UaQXKQLS8DQosnH8F4ojIRiAZOEM7hR38BTL9eN2hLH6WwuTVu/4Yons8SmLw6ocezWOG6jwPRw856045KZJXtw/NRVD1DCgQ89AZEC0W0Jf8= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: cc7e80e5-d056-40f0-e57e-08d4e3fa72e9 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(48565401081)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:AM4PR08MB2658; x-ms-traffictypediagnostic: AM4PR08MB2658: nodisclaimer: True x-exchange-antispam-report-test: UriScan:(180628864354917); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(10201501046)(6055026)(6041248)(20161123555025)(20161123558100)(20161123560025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM4PR08MB2658; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM4PR08MB2658; x-forefront-prvs: 04004D94E2 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(377424004)(189002)(199003)(54534003)(6116002)(2900100001)(229853002)(102836003)(3846002)(53546010)(68736007)(6436002)(8936002)(55016002)(25786009)(4326008)(6246003)(97736004)(14454004)(2950100002)(54356999)(72206003)(101416001)(6506006)(5250100002)(76176999)(50986999)(5660300001)(575784001)(86362001)(99286003)(66066001)(2906002)(33656002)(189998001)(305945005)(3660700001)(7696004)(81166006)(74316002)(3280700002)(53936002)(7736002)(105586002)(81156014)(478600001)(106356001)(9686003)(8676002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR08MB2658; H:DB6PR0801MB2053.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Aug 2017 16:26:57.4092 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2658 ping From: Wilco Dijkstra Sent: 25 July 2017 14:58 To: GCC Patches; James Greenhalgh; Jeff Law Cc: nd Subject: [PATCH][AArch64] Simplify frame layout for stack probing     This patch makes some changes to the frame layout in order to simplify stack probing.  We want to use the save of LR as a probe in any non-leaf function.  With shrinkwrapping we may only save LR before a call, so it is useful to define a fixed location in the callee-saves. So force LR at the bottom of the callee-saves even with -fomit-frame-pointer. Also remove a rarely used frame layout that saves the callee-saves first with -fomit-frame-pointer. OK for commit (and backport to GCC7)? ChangeLog: 2017-07-25  Wilco Dijkstra          * config/aarch64/aarch64.c (aarch64_layout_frame):         Ensure LR is always stored at the bottom of the callee-saves.         Remove frame option which saves callee-saves at top of frame. diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index b8a4160d9de8e689ccd26cb9f0ce046ee65e0ef4..3fc36ae28d18b9635480fd99f1fa7719267e66e4 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -2875,7 +2875,8 @@ aarch64_frame_pointer_required (void)    /* Mark the registers that need to be saved by the callee and calculate     the size of the callee-saved registers area and frame record (both FP -   and LR may be omitted).  */ +   and LR may be omitted).  If the function is not a leaf, ensure LR is +   saved at the bottom of the callee-save area.  */  static void  aarch64_layout_frame (void)  { @@ -2926,7 +2927,14 @@ aarch64_layout_frame (void)        cfun->machine->frame.wb_candidate1 = R29_REGNUM;        cfun->machine->frame.reg_offset[R30_REGNUM] = UNITS_PER_WORD;        cfun->machine->frame.wb_candidate2 = R30_REGNUM; -      offset += 2 * UNITS_PER_WORD; +      offset = 2 * UNITS_PER_WORD; +    } +  else if (!crtl->is_leaf) +    { +      /* Ensure LR is saved at the bottom of the callee-saves.  */ +      cfun->machine->frame.reg_offset[R30_REGNUM] = 0; +      cfun->machine->frame.wb_candidate1 = R30_REGNUM; +      offset = UNITS_PER_WORD;      }      /* Now assign stack slots for them.  */ @@ -3025,20 +3033,6 @@ aarch64_layout_frame (void)        cfun->machine->frame.final_adjust          = cfun->machine->frame.frame_size - cfun->machine->frame.callee_adjust;      } -  else if (!frame_pointer_needed -          && varargs_and_saved_regs_size < max_push_offset) -    { -      /* Frame with large local area and outgoing arguments (this pushes the -        callee-saves first, followed by the locals and outgoing area): -        stp reg1, reg2, [sp, -varargs_and_saved_regs_size]! -        stp reg3, reg4, [sp, 16] -        sub sp, sp, frame_size - varargs_and_saved_regs_size  */ -      cfun->machine->frame.callee_adjust = varargs_and_saved_regs_size; -      cfun->machine->frame.final_adjust -       = cfun->machine->frame.frame_size - cfun->machine->frame.callee_adjust; -      cfun->machine->frame.hard_fp_offset = cfun->machine->frame.callee_adjust; -      cfun->machine->frame.locals_offset = cfun->machine->frame.hard_fp_offset; -    }    else      {        /* Frame with large local area and outgoing arguments using frame pointer: