From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Archive: List-Post: List-Help: Sender: gcc-patches-owner@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:27:00 -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 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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 X-SW-Source: 2017-08/txt/msg00954.txt.bz2 =A0=20 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 =A0=A0=A0=20 This patch makes some changes to the frame layout in order to simplify stack probing.=A0 We want to use the save of LR as a probe in any non-leaf function.=A0 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=A0 Wilco Dijkstra=A0 =A0=A0=A0=A0=A0=A0=A0 * config/aarch64/aarch64.c (aarch64_layout_frame): =A0=A0=A0=A0=A0=A0=A0 Ensure LR is always stored at the bottom of the calle= e-saves. =A0=A0=A0=A0=A0=A0=A0 Remove frame option which saves callee-saves at top o= f frame. -- diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index b8a4160d9de8e689ccd26cb9f0ce046ee65e0ef4..3fc36ae28d18b9635480fd99f1f= a7719267e66e4 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -2875,7 +2875,8 @@ aarch64_frame_pointer_required (void) =A0 =A0/* Mark the registers that need to be saved by the callee and calculate =A0=A0=A0 the size of the callee-saved registers area and frame record (bot= h FP -=A0=A0 and LR may be omitted).=A0 */ +=A0=A0 and LR may be omitted).=A0 If the function is not a leaf, ensure LR= is +=A0=A0 saved at the bottom of the callee-save area.=A0 */ =A0static void =A0aarch64_layout_frame (void) =A0{ @@ -2926,7 +2927,14 @@ aarch64_layout_frame (void) =A0=A0=A0=A0=A0=A0 cfun->machine->frame.wb_candidate1 =3D R29_REGNUM; =A0=A0=A0=A0=A0=A0 cfun->machine->frame.reg_offset[R30_REGNUM] =3D UNITS_PE= R_WORD; =A0=A0=A0=A0=A0=A0 cfun->machine->frame.wb_candidate2 =3D R30_REGNUM; -=A0=A0=A0=A0=A0 offset +=3D 2 * UNITS_PER_WORD; +=A0=A0=A0=A0=A0 offset =3D 2 * UNITS_PER_WORD; +=A0=A0=A0 } +=A0 else if (!crtl->is_leaf) +=A0=A0=A0 { +=A0=A0=A0=A0=A0 /* Ensure LR is saved at the bottom of the callee-saves.= =A0 */ +=A0=A0=A0=A0=A0 cfun->machine->frame.reg_offset[R30_REGNUM] =3D 0; +=A0=A0=A0=A0=A0 cfun->machine->frame.wb_candidate1 =3D R30_REGNUM; +=A0=A0=A0=A0=A0 offset =3D UNITS_PER_WORD; =A0=A0=A0=A0 } =A0 =A0=A0 /* Now assign stack slots for them.=A0 */ @@ -3025,20 +3033,6 @@ aarch64_layout_frame (void) =A0=A0=A0=A0=A0=A0 cfun->machine->frame.final_adjust =A0=A0=A0=A0=A0=A0=A0=A0 =3D cfun->machine->frame.frame_size - cfun->machin= e->frame.callee_adjust; =A0=A0=A0=A0 } -=A0 else if (!frame_pointer_needed -=A0=A0=A0=A0=A0=A0=A0=A0=A0 && varargs_and_saved_regs_size < max_push_offs= et) -=A0=A0=A0 { -=A0=A0=A0=A0=A0 /* Frame with large local area and outgoing arguments (thi= s pushes the -=A0=A0=A0=A0=A0=A0=A0 callee-saves first, followed by the locals and outgo= ing area): -=A0=A0=A0=A0=A0=A0=A0 stp reg1, reg2, [sp, -varargs_and_saved_regs_size]! -=A0=A0=A0=A0=A0=A0=A0 stp reg3, reg4, [sp, 16] -=A0=A0=A0=A0=A0=A0=A0 sub sp, sp, frame_size - varargs_and_saved_regs_size= =A0 */ -=A0=A0=A0=A0=A0 cfun->machine->frame.callee_adjust =3D varargs_and_saved_r= egs_size; -=A0=A0=A0=A0=A0 cfun->machine->frame.final_adjust -=A0=A0=A0=A0=A0=A0 =3D cfun->machine->frame.frame_size - cfun->machine->fr= ame.callee_adjust; -=A0=A0=A0=A0=A0 cfun->machine->frame.hard_fp_offset =3D cfun->machine->fra= me.callee_adjust; -=A0=A0=A0=A0=A0 cfun->machine->frame.locals_offset =3D cfun->machine->fram= e.hard_fp_offset; -=A0=A0=A0 } =A0=A0 else =A0=A0=A0=A0 { =A0=A0=A0=A0=A0=A0 /* Frame with large local area and outgoing arguments us= ing frame pointer: =A0=A0=A0=20=20=20=20=20