From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9424 invoked by alias); 25 Jul 2017 13:58:12 -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 9403 invoked by uid 89); 25 Jul 2017 13:58:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.7 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-DB5-obe.outbound.protection.outlook.com Received: from mail-db5eur01on0068.outbound.protection.outlook.com (HELO EUR01-DB5-obe.outbound.protection.outlook.com) (104.47.2.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 25 Jul 2017 13:58:08 +0000 Received: from DB6PR0801MB2053.eurprd08.prod.outlook.com (10.168.86.22) by DB6PR08MB2664.eurprd08.prod.outlook.com (10.175.234.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1304.14; Tue, 25 Jul 2017 13:58:05 +0000 Received: from DB6PR0801MB2053.eurprd08.prod.outlook.com ([fe80::cd9d:80f1:82d8:5181]) by DB6PR0801MB2053.eurprd08.prod.outlook.com ([fe80::cd9d:80f1:82d8:5181%18]) with mapi id 15.01.1282.020; Tue, 25 Jul 2017 13:58:05 +0000 From: Wilco Dijkstra To: GCC Patches , James Greenhalgh , Jeff Law CC: nd Subject: [PATCH][AArch64] Simplify frame layout for stack probing Date: Tue, 25 Jul 2017 13:58:00 -0000 Message-ID: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DB6PR08MB2664;7:S0DaQjh2//hwQ/QxbmqZBygauOFTTHddHIHVHBB+/xGOKgkYttJwKYPOObF/KXTkyRbfmxz4baAI75oMBJ/WMw51VwyjyIWXYOWKx/+c9A/a42Z1Pl3SS25GrDO0rP271JmAq7l3t09cc+U6D4TTO+j1A+VGrKgxMUAwP6dFRkDqERRdNUa6loxvGa6xovtPQ+4vbgJJ5f1iqOYWO9o5zK7Vdo8fkQSjgAREFgvKlmmzTy24VRmr0Mdfa1DMlnN6AH/0O2qVedobzgtE1m3HaadgUZqPwwOgptPu9LeI2JU5yLq68BfXTOPt6ogBm9a3PJk1Gqqwk1J+jJyMNPGoc68pqcOAOEUMrkFMvifJeRRcmG5tYKEQBwdqDoQ9K04dXxewz0vgJpGSJmg9wMEUrnDsFhb+sIcIv4ScZbaPDRhRkTty4kYt+qRZ/ryNHOjayx/tu0aZtEjdVXLytDB8Rg3E1WAnplZ8Vo+qFilJz79jUXQc4XGXI1PpQ9aN3QXrjtKmr9M+1Ww9BC4sFXnd3K0E7me4hP3GXgLWqZ+Y0L+6lLhk4BpwBHsm3J9SauEYUi9+W1KWakQusBbD27BY2f27dRCzj5QFS8L3Nz0steDfSSouOZZBPY9TSXBnJj66mc0ejro433X44nnhN5sxvbGjW6LOvLMFkK9NeQ1/dGkOshXi5BNlGayV/vJh7nI4uisEYn5EO6g9sBq3D5JSwe9zWGf7m+WInYAaXj2Y4rRt6GSHlClHM3IcmbG4b3GOAwlxl2XQZfVdyq+vQEtaeZIUyuU8DaL/UMLmHr6W8kw= x-ms-office365-filtering-correlation-id: b98781b8-7369-4786-9165-08d4d3652c1f x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254075)(300000503095)(300135400095)(48565401081)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:DB6PR08MB2664; x-ms-traffictypediagnostic: DB6PR08MB2664: 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)(8121501046)(5005006)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123564025)(20161123555025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123562025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DB6PR08MB2664;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DB6PR08MB2664; x-forefront-prvs: 03793408BA x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(39450400003)(39850400002)(39410400002)(39400400002)(39840400002)(39860400002)(54534003)(377424004)(199003)(189002)(4326008)(81166006)(305945005)(3846002)(53936002)(5250100002)(478600001)(9686003)(189998001)(6436002)(99286003)(72206003)(2900100001)(33656002)(106356001)(50986999)(3660700001)(105586002)(55016002)(3280700002)(54356999)(6506006)(8676002)(97736004)(8936002)(7736002)(5660300001)(66066001)(14454004)(81156014)(74316002)(102836003)(6116002)(7696004)(25786009)(101416001)(86362001)(38730400002)(575784001)(68736007)(2906002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR08MB2664;H:DB6PR0801MB2053.eurprd08.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) 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: 25 Jul 2017 13:58:04.9787 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR08MB2664 X-SW-Source: 2017-07/txt/msg01569.txt.bz2 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..3fc36ae28d18b9635480fd99f1f= a7719267e66e4 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -2875,7 +2875,8 @@ aarch64_frame_pointer_required (void) =20 /* 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 =3D R29_REGNUM; cfun->machine->frame.reg_offset[R30_REGNUM] =3D UNITS_PER_WORD; cfun->machine->frame.wb_candidate2 =3D R30_REGNUM; - offset +=3D 2 * UNITS_PER_WORD; + offset =3D 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] =3D 0; + cfun->machine->frame.wb_candidate1 =3D R30_REGNUM; + offset =3D UNITS_PER_WORD; } =20 /* Now assign stack slots for them. */ @@ -3025,20 +3033,6 @@ aarch64_layout_frame (void) cfun->machine->frame.final_adjust =3D 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 t= he - 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 =3D varargs_and_saved_regs_size; - cfun->machine->frame.final_adjust - =3D cfun->machine->frame.frame_size - cfun->machine->frame.callee_adjust; - cfun->machine->frame.hard_fp_offset =3D cfun->machine->frame.callee_= adjust; - cfun->machine->frame.locals_offset =3D cfun->machine->frame.hard_fp_= offset; - } else { /* Frame with large local area and outgoing arguments using frame po= inter: