From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id A305B3856DD3 for ; Fri, 28 Oct 2022 09:10:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A305B3856DD3 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wm1-x331.google.com with SMTP id b20-20020a05600c4e1400b003cc28585e2fso3194356wmq.1 for ; Fri, 28 Oct 2022 02:10:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=/SFSwbuF3DLZGmAytmqm+8ONTHgaQmXbYceCr0fmuDo=; b=aIz1okv6mTLzhTAz0lGYz6uf8Qv3HpJ+62eH/Ffkf9EIwCG5lrZeoFfmBbhF/cFAgm sEf0iDEflzDkPayrR1gP4Gx9cq7Cw049FCZ3NcMAB7IGM8E2EFIq253f0tYsjP1cdULE NHDK5fYCuvOl0C11VKo5sEktigR/cbvrFM0QJ7eL5nyxaBVal/ddFY7F9uSGbzSJ8BMF NkKtWqGi1ufeYdQPLySgBBNWtNxRfB2TtB2tY0nfMOcnZ44cDRZ8gjbZq/d/HjcO/hii dj+regrwczpTojQ4D4ypAWg8Cky8PrRxfK1FLQJ60gw2QGlGPdlsV2UaUvBMVylYU5/K zk4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/SFSwbuF3DLZGmAytmqm+8ONTHgaQmXbYceCr0fmuDo=; b=Hwmr5FeV2QPM5BUiehQ+qWj2cygpq/JMEe7zFpUkmUD70aXczG2c0CIvZmEkoV5qfj r8/0UqhV0Zlc8T5vTijviLUO0LgfQ7OCk2pf1uObVPJqnwBQpbDhVFhyuX5GyYPRupqX 0bq8EcPZimYE5UuawZYY7te0Zx/TwuPWqC4MytDfJxykc32ISszN4ZfGalLY8ocGxk6m mtvjcj9627m1beleLzRJ/SPdfV1jG9QLsGPSOlzsGnA8ioUMSKYBaA52LDfS36ABy5Ok k2tTkpWNjovQK4Ktfljhd965RGmxbqk2utseNPtYV45ivogRQsC3ddTPl0kpWpG0plF9 u8iQ== X-Gm-Message-State: ACrzQf2FFKxvu5q8Id9Pw2MYpMj2nFvSztJy1vzt5q3/yfIns9l06c2t CPxyISewb3cntbrz6j5T97Ar3xGgmCqT4g== X-Google-Smtp-Source: AMsMyM6H5eRLemvMymLBQVY3QSk3bDMJVniU7koE716vw5JrMH/diAA2Pz7ADdW5G0AtbsAXanD6yg== X-Received: by 2002:a05:600c:4f81:b0:3c8:3424:8b9 with SMTP id n1-20020a05600c4f8100b003c8342408b9mr8414168wmq.149.1666948230826; Fri, 28 Oct 2022 02:10:30 -0700 (PDT) Received: from fomalhaut.localnet ([2a01:e0a:8d5:d990:e654:e8ff:fe8f:2ce6]) by smtp.gmail.com with ESMTPSA id q8-20020a05600c46c800b003cf5e445f5dsm1151462wmo.25.2022.10.28.02.10.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 02:10:30 -0700 (PDT) From: Eric Botcazou X-Google-Original-From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [PATCH] Restore RTL alias analysis for hard frame pointer Date: Fri, 28 Oct 2022 11:10:29 +0200 Message-ID: <1930502.usQuhbGJ8B@fomalhaut> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart3384628.QJadu78ljV" Content-Transfer-Encoding: 7Bit X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This is a multi-part message in MIME format. --nextPart3384628.QJadu78ljV Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Hi, the following change: 2021-07-28 Bin Cheng * alias.c (init_alias_analysis): Don't skip prologue/epilogue. broke the alias analysis for the hard frame pointer (when it is used as a frame pointer, i.e. when the frame pointer is not eliminated) described in the large comment at the top of the file, because static_reg_base_value is set for it and, consequently, new_reg_base_value too. So when the instruction saving the stack pointer into the hard frame pointer in the prologue is processed, it is viewed as a second set of the hard frame pointer and to a different value by record_set, which then resets new_reg_base_value to 0 and the game is over. This e.g. hampers the performance of the var-tracking RTL pass for parameters passed on the stack like on x86, leading to regressions when debugging, but code generation is very likely affected too. Bootstrapped/regtested on x86-64/Linux, OK for mainline and 12 branch? 2022-10-28 Eric Botcazou * alias.cc (init_alias_analysis): Do not record sets to the hard frame pointer if the frame pointer has not been eliminated. -- Eric Botcazou --nextPart3384628.QJadu78ljV Content-Disposition: attachment; filename="p.diff" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="utf-8"; name="p.diff" diff --git a/gcc/alias.cc b/gcc/alias.cc index d54feb15268..c62837dd854 100644 --- a/gcc/alias.cc +++ b/gcc/alias.cc @@ -3369,6 +3369,10 @@ memory_modified_in_insn_p (const_rtx mem, const_rtx insn) void init_alias_analysis (void) { + const bool frame_pointer_eliminated + = reload_completed + && !frame_pointer_needed + && targetm.can_eliminate (FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM); unsigned int maxreg = max_reg_num (); int changed, pass; int i; @@ -3446,12 +3450,8 @@ init_alias_analysis (void) for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) if (static_reg_base_value[i] /* Don't treat the hard frame pointer as special if we - eliminated the frame pointer to the stack pointer instead. */ - && !(i == HARD_FRAME_POINTER_REGNUM - && reload_completed - && !frame_pointer_needed - && targetm.can_eliminate (FRAME_POINTER_REGNUM, - STACK_POINTER_REGNUM))) + eliminated the frame pointer to the stack pointer. */ + && !(i == HARD_FRAME_POINTER_REGNUM && frame_pointer_eliminated)) { new_reg_base_value[i] = static_reg_base_value[i]; bitmap_set_bit (reg_seen, i); @@ -3467,10 +3467,15 @@ init_alias_analysis (void) { rtx note, set; + /* Treat the hard frame pointer as special unless we + eliminated the frame pointer to the stack pointer. */ + if (!frame_pointer_eliminated + && modified_in_p (hard_frame_pointer_rtx, insn)) + continue; + /* If this insn has a noalias note, process it, Otherwise, scan for sets. A simple set will have no side effects which could change the base value of any other register. */ - if (GET_CODE (PATTERN (insn)) == SET && REG_NOTES (insn) != 0 && find_reg_note (insn, REG_NOALIAS, NULL_RTX)) --nextPart3384628.QJadu78ljV--