From patchwork Tue Aug 15 16:23:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 801663 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-460387-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="QKUZCYa8"; 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 3xWyV72GnBz9sRV for ; Wed, 16 Aug 2017 02:24:12 +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=JGNWFIF2gTmgrDMn08/zpQ25y5NtZ9yu8QYtOL9JENR9ldHD/yXIi WbQ48IalfBuPtqrtzUwka4ryF753oP651HoBONWbBkkqGKjxGXcuXWp+k1y5BS/h yu7Rx6FNy/M5N9Ny5MkBKRuVeUqkIgFrFnX2DFQ6ZyOmS6aP8pYalM= 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=bpYVZiv3KZDmBgBaCFrvJ0livyA=; b=QKUZCYa8fkJH8f4IdytfHNQiiZ0u brJ1Tm4a81Q1GXkbm7ynEgVSZ8FHG5phB755CRVF3tb9GPeldxXTZeWvhVN1yCyP kCqtp8111XY3+uJT/RY1Al6hZQN14qogJAjwkPoIsU1UEhAtNx3EwTbwg6nZKF0A RGJuI+z9CnpkgWo= Received: (qmail 111527 invoked by alias); 15 Aug 2017 16:24:01 -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 111217 invoked by uid 89); 15 Aug 2017 16:23:56 -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=omission, Hx-spam-relays-external:sk:EUR03-A, HX-HELO:sk:EUR03-A, repeatable X-HELO: EUR03-AM5-obe.outbound.protection.outlook.com Received: from mail-eopbgr30071.outbound.protection.outlook.com (HELO EUR03-AM5-obe.outbound.protection.outlook.com) (40.107.3.71) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 15 Aug 2017 16:23:54 +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_256_CBC_SHA384_P256) id 15.1.1341.21; Tue, 15 Aug 2017 16:23:51 +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:23:51 +0000 From: Wilco Dijkstra To: GCC Patches , James Greenhalgh CC: nd Subject: Re: [PATCH][AArch64] PR60580: Fix frame pointer option magic Date: Tue, 15 Aug 2017 16:23:50 +0000 Message-ID: References: In-Reply-To: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB6PR08MB2664; 6:tKg6GBKvIXYDM2REivhzlPNyxa5g23/A0HBGkXbmcITMn2wqVMMQksHgvROFDBpNqVaJ02MIfA10RgNvbv/IilzTEav1v+d8IoYU1u+KE+GzZ3r7vwzil4L5Yr8RSPJ9HoRBNy6voSz88f++H65PXYOjlltf5hINIg9qccwxdS4gODuZI7vWzbDMB9BnUtwnBILaYU1KJnLj8HnD4av6nVQ5/S5qgZXYCwG1/5tiwWx0mEa+Sy4YnSwLfno2MmrTAwV9J/cfwI3o7EKOqbfCW4Vx8x0KEF+k/ogPv7m/0I/iku9bw/fE36KGr3N1CSYwkWvrbG9uff7fuIDtiaM/EA==; 5:NXw+5o5hv0SOvLuuoNmDDJj9hJWpNKKn1kVNrb0hl8dzmBiwkPoUO1E2uT84qEAJobGQAEKx5KJhtaBuRy/pTTwPEfMsMqMViNfg5kMflsRtr9s+EUYijb53iB44EjCxHfkS1Uk46TxwZ8oqAAacZQ==; 24:8VFbhiYbBfggLe1eEbFwm2bSmgnVlw8g31pLxnuGin0pHDe6wCse0Ij5SOZri69EDQ+NVZjSp+glWbQ00OdNJ/SsFJHzbvyiWhbH54RO5i8=; 7:0Snxzreta3RWa41Oylf2hYxqvSbqdlPCqqISpBEb0P+naGE+y2CwXzlIY4xvCteD6WRFyCeLh5Gomk6QilOns8NRqaJq5DjsVZ3YXh+PqL1ElEnhe6BsoTkL+ENtnzANuOTezyFnc3MLg0Y/L7mb1SjJRmh4yHg2Twe4E+2jDGJyGcQ+XSOM83hJdpBRlbAOPEJ7BIOnyoDxaUYf9wTjwtvJ7MfGj5lc6hiuA0dsX2U= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 5e534c7a-7307-4be7-47a1-08d4e3fa03bb 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: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)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6041248)(20161123562025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123555025)(20161123560025)(6072148)(201708071742011)(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: 04004D94E2 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(377424004)(189002)(199003)(54534003)(189998001)(55016002)(86362001)(50986999)(2906002)(305945005)(5250100002)(72206003)(99286003)(76176999)(102836003)(478600001)(3846002)(6506006)(6116002)(54356999)(3280700002)(229853002)(7736002)(2950100002)(97736004)(6246003)(8676002)(7696004)(8936002)(9686003)(68736007)(101416001)(106356001)(53936002)(33656002)(4326008)(3660700001)(66066001)(6636002)(74316002)(5660300001)(105586002)(81156014)(14454004)(81166006)(2900100001)(53546010)(6436002)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR08MB2664; 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) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Aug 2017 16:23:50.9079 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR08MB2664 ping From: Wilco Dijkstra Sent: 04 August 2017 16:46 To: GCC Patches; James Greenhalgh Cc: nd Subject: [PATCH][AArch64] PR60580: Fix frame pointer option magic   To fix PR60580 simplify the logic in aarch64_override_options_after_change_1 (). If the frame pointer is enabled, set it to a special value that behaves similar to frame pointer omission.  If we don't do this all leaf functions will get a frame pointer even if flag_omit_leaf_frame_pointer is set. If flag_omit_frame_pointer has this special value, we must force the frame pointer if not in a leaf function.  We also need to force it in a leaf function if flag_omit_frame_pointer is not set or if LR is used. Doing this allows both -fomit-frame-pointer and -fomit-leaf-frame-pointer to be independently set and changed in each function with the expected behaviour. OK for commit and backport to GCC7/GCC6? ChangeLog: 2017-08-04  Wilco Dijkstra      gcc/         PR middle-end/60580         * config/aarch64/aarch64.c (aarch64_frame_pointer_required)         Check special value of flag_omit_frame_pointer.         (aarch64_can_eliminate): Likewise.         (aarch64_override_options_after_change_1): Simplify handling of         -fomit-frame-pointer and -fomit-leaf-frame-pointer. diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index f90420bffe841155d2ea12dc7450fa699718e8ae..8ec196bca5e7203f2bb38381fe89b1aec43b9a29 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -2839,12 +2839,13 @@ aarch64_output_probe_stack_range (rtx reg1, rtx reg2)  static bool  aarch64_frame_pointer_required (void)  { -  /* In aarch64_override_options_after_change -     flag_omit_leaf_frame_pointer turns off the frame pointer by -     default.  Turn it back on now if we've not got a leaf -     function.  */ -  if (flag_omit_leaf_frame_pointer -      && (!crtl->is_leaf || df_regs_ever_live_p (LR_REGNUM))) +  /* Use the frame pointer if enabled and it is not a leaf function, unless +     leaf frame pointer omission is disabled.  If the frame pointer is enabled, +     force the frame pointer in leaf functions which use LR.  */ +  if (flag_omit_frame_pointer == 2 +      && !(flag_omit_leaf_frame_pointer +          && crtl->is_leaf +          && !df_regs_ever_live_p (LR_REGNUM)))      return true;      /* Force a frame pointer for EH returns so the return address is at FP+8.  */ @@ -5892,6 +5893,7 @@ aarch64_can_eliminate (const int from, const int to)           LR in the function, then we'll want a frame pointer after all, so           prevent this elimination to ensure a frame pointer is used.  */        if (to == STACK_POINTER_REGNUM +         && flag_omit_frame_pointer == 2            && flag_omit_leaf_frame_pointer            && df_regs_ever_live_p (LR_REGNUM))          return false; @@ -8914,24 +8916,16 @@ aarch64_parse_override_string (const char* input_string,  static void  aarch64_override_options_after_change_1 (struct gcc_options *opts)  { -  /* The logic here is that if we are disabling all frame pointer generation -     then we do not need to disable leaf frame pointer generation as a -     separate operation.  But if we are *only* disabling leaf frame pointer -     generation then we set flag_omit_frame_pointer to true, but in -     aarch64_frame_pointer_required we return false only for leaf functions. - -     PR 70044: We have to be careful about being called multiple times for the -     same function.  Once we have decided to set flag_omit_frame_pointer just -     so that we can omit leaf frame pointers, we must then not interpret a -     second call as meaning that all frame pointer generation should be -     omitted.  We do this by setting flag_omit_frame_pointer to a special, -     non-zero value.  */ -  if (opts->x_flag_omit_frame_pointer == 2) -    opts->x_flag_omit_frame_pointer = 0; - -  if (opts->x_flag_omit_frame_pointer) -    opts->x_flag_omit_leaf_frame_pointer = false; -  else if (opts->x_flag_omit_leaf_frame_pointer) +  /* PR 70044: We have to be careful about being called multiple times for the +     same function.  This means all changes should be repeatable.  */ + +  /* If the frame pointer is enabled, set it to a special value that behaves +     similar to frame pointer omission.  If we don't do this all leaf functions +     will get a frame pointer even if flag_omit_leaf_frame_pointer is set. +     If flag_omit_frame_pointer has this special value, we must force the +     frame pointer if not in a leaf function.  We also need to force it in a +     leaf function if flag_omit_frame_pointer is not set or if LR is used.  */ +  if (opts->x_flag_omit_frame_pointer == 0)      opts->x_flag_omit_frame_pointer = 2;      /* If not optimizing for size, set the default