From patchwork Fri Oct 28 09:10:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 12168 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp713007wru; Fri, 28 Oct 2022 02:11:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6EsnYXYZWABNGojGHNmSKu/eKmIbOvpce/TJ0XRgtCXEXOi0ce2pW7sXmu9uS3+wD/5sEE X-Received: by 2002:a17:907:9807:b0:797:a5ba:1327 with SMTP id ji7-20020a170907980700b00797a5ba1327mr39498426ejc.274.1666948282346; Fri, 28 Oct 2022 02:11:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666948282; cv=none; d=google.com; s=arc-20160816; b=oc43Mjw+ua+g+QUXUmdK8/3ZKHQKBfPCbnZ3sM/Xn2m7T+1CNiWPfos+yhU6XdD03F UJAy3W8pB2ynNwA/GzxLEbIS2hrfC36TeSe8uIJ0x8iz/nh/PS8fPmfSDl+bOiQTCZso tepUX7HF/j9xHJTegEnBlG9jzgWJcm2D8typ99IxNYe7USv9LnsdtZUDh6pOLiwWdS+C prjAvG2I3KSBMv5ZGweTgj1cInDlk76tSKke8Jvyb69YSUwfhtXajNHlSQ6z9/o8Deot KpeB6YWSMt/flw7Ipt5mM+Wo98Yj4D++0khWjMm2IPEIvNEJvX46A5/gXDfvyh3kwcJm N4sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=/SFSwbuF3DLZGmAytmqm+8ONTHgaQmXbYceCr0fmuDo=; b=c/XVmUh8DeLO3dV43HGAOrnmCGVBJnDAcWmr9Gf42KY0LRuRYLliO0tNfVgNV4MjNi ahn7IbNhRSSmbaCw9yK53A1JyUiRaZeq/tbRqS1TyrlxMAvoYYID5xt3cixVZsdaiuP0 dCWELSj/295jXNXtDts4O2RmtjeiPibdW0O21avHo5wkdYMAPwmnDkUQZKPTpzhD2Xg6 d7q2uC8mHXrTsfxSPAfXHoi5A2QcCNmbIJPPovkY4NtmFMHYo5SPshZZ7buxcl0MiATX aerDEoJ7cHth7+WlFzvv9JNpNyRE0DpXBwCbIdw6ZW0bwK0a+I1whVd+99ERXIDyXAtz GMrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=EtIb2p8O; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id jz12-20020a170906bb0c00b0078306c5c48asi3738698ejb.250.2022.10.28.02.11.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 02:11:22 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=EtIb2p8O; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4E8EB3858C20 for ; Fri, 28 Oct 2022 09:11:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E8EB3858C20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666948281; bh=/SFSwbuF3DLZGmAytmqm+8ONTHgaQmXbYceCr0fmuDo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=EtIb2p8O3mv/9ZemIomTCs4EZtxRcAflBIWK0Hn//Z8awkhLZDG/1OvkAJGiwxSof Khm+Fq/3TXHiHTYvJ1cuiLRRZtcbOSwKvXZ8GaU0wl9x1QUVGL2e+BMSgn7qBKqFw7 w6iS224FyyGe/oRNW+kP17Z7RlFCePkxbv1kbxes= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 Received: by mail-wm1-x331.google.com with SMTP id b20-20020a05600c4e1400b003cc28585e2fso3194356wmq.1 for ; Fri, 28 Oct 2022 02:10:32 -0700 (PDT) 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-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) 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 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Eric Botcazou via Gcc-patches From: Eric Botcazou Reply-To: Eric Botcazou Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747921961773070946?= X-GMAIL-MSGID: =?utf-8?q?1747921961773070946?= 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. 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))