From patchwork Fri Oct 14 10:00:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 2634 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp93495wrs; Fri, 14 Oct 2022 03:01:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5z0HaebhO6gZLtAbAwXlTNuhogcc7JGKz62VjmMTb30on5jOjjZUcQfMhfK7Q51EQ8Q7S3 X-Received: by 2002:a17:907:2c4b:b0:78d:bb0c:4a42 with SMTP id hf11-20020a1709072c4b00b0078dbb0c4a42mr3021283ejc.546.1665741707348; Fri, 14 Oct 2022 03:01:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665741707; cv=none; d=google.com; s=arc-20160816; b=ZgGalA/YejLTu1YrZsuipIWvyvvo0j9X7jomHI4bHPIzGRpWXtNyHSScNySqRbj//i 61OtTSbobNG5IB9PMhEQoU/sqhVcb9HigWSnjP4wmrmJRjhHeXktPRv9P3OuiYQUJhg0 YmjM/EsYGB9Jv+aVojRgS4shcI4XUn4NpZl8SSLzHOxmJYx7cx9iFmzZSEnLJ8I1jeVc 9unpx2mYKaOp9qGgtNecRsSjm5rnWnh0/B86jCknkSOOaCPvOXl0Itd0F10Mcud7nBwH CG2IJTpzH9ACD2iGvbP5qIY8pFzLN+uUdDJQFXgf/7WTaxfxYe+VHY2EDo/Z7OZGQEqW PJzw== 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=9jKEHiBbhM7Tpz9EBnjy7MKrlZW/Naw8JDy5bMtT5BE=; b=ASYhpCJxcnJCzKgzv6jJC1S+n5a3RUyz5KS4B6b8vSSvUH+U3Olo+kKtnUKliBa0vr eEbFdaNXEmLejdkBIjKCgVEyTbivKWXQj6YBy0AQ1LXQozuCOfGfsTRab5M6evXk+ZXW J1BnFC/42hHjUlH3uzVhW7SycGoy0+/K7Y2RVr4FYG9KBN3/kZvPp0DigP9eUAGU90Qd NGehwlZA4rBEj2lT1UcgPcplByQWEClAqi6DbdFynXj0Enq6gh9qCjJshVPvBJEBXAh1 S2CbxyBkB4q4SGvkd7QE4qW9uX4nRapt/JuMDOixbb8ACDsMDVxPt1ZgR986J6iHOsi+ AuLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=iP24a4Cg; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id e18-20020a50a692000000b004511944f801si1789595edc.270.2022.10.14.03.01.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 03:01:47 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=iP24a4Cg; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 1FCF63850845 for ; Fri, 14 Oct 2022 10:01:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1FCF63850845 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665741691; bh=9jKEHiBbhM7Tpz9EBnjy7MKrlZW/Naw8JDy5bMtT5BE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=iP24a4CgsOM1R93VNDbfxuXJClLpkZQfxDFtKe67Vgan4TZCD6E14+IIFKglxWDni fpZvIGOY+QV+u6pKkJXBBtMCJvEEoNKcSDAR/XxH4Xkoh/D9nGT1NNK3P/wWuzgmMn cZFHdv5MHhre+7XRNo/KaviSBNxsOsTJnC6scO0A= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id 78FFD385356C for ; Fri, 14 Oct 2022 10:00:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 78FFD385356C Received: by mail-wm1-x32f.google.com with SMTP id c7-20020a05600c0ac700b003c6cad86f38so5026752wmr.2 for ; Fri, 14 Oct 2022 03:00:47 -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=9jKEHiBbhM7Tpz9EBnjy7MKrlZW/Naw8JDy5bMtT5BE=; b=UyvaOAP0TXtehpIcl5LOId+VTyF3qzdWs3ameOPPkVH8U6FoB7lFHxPfSfCiogq0uj wmc3IeJKjy/CawW7ub1fL9ybuTUt61uNsqrurSWZP1uMjo33HDpX+WQjdBQphjhk23xU hEsXz76oiARPPYcxjIKLkEYT3rYukCMmDmMiUVHNpcN2WZCfuoLB1g37ESxURR6fTe98 uPvzU5w0+gHS6X+1HakSVNNUtYJVGAaMc8+SiS8TnkEIgGYyiSiAgmBeq2XK45brGajY d8PyCE4Ed5yKVNSW5jS+u0oFxg0fqE/Wcs1icM6HW4uEbsBOBVnU54ocAmWgMi7Ir+2F Ufnw== X-Gm-Message-State: ACrzQf0dbijJJfpaDVqDf8OF/zYDKygRc+jhIUhw7APegYgmX1dj+OV6 33JRxouHlfKeV9Y9hNat9W4ei5syGmjF7g== X-Received: by 2002:a05:600c:4448:b0:3c6:dddf:8451 with SMTP id v8-20020a05600c444800b003c6dddf8451mr2967558wmn.1.1665741646053; Fri, 14 Oct 2022 03:00:46 -0700 (PDT) Received: from fomalhaut.localnet ([2a01:e0a:8d5:d990:e654:e8ff:fe8f:2ce6]) by smtp.gmail.com with ESMTPSA id i11-20020adfefcb000000b0022cc895cc11sm1462894wrp.104.2022.10.14.03.00.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 03:00:45 -0700 (PDT) X-Google-Original-From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [SPARC] Fix PR target/107248 Date: Fri, 14 Oct 2022 12:00:44 +0200 Message-ID: <2850050.e9J7NaK4W3@fomalhaut> MIME-Version: 1.0 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, 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?1746656776851459126?= X-GMAIL-MSGID: =?utf-8?q?1746656776851459126?= This is the infamous PR rtl-optimization/38644 rearing its ugly head for leaf functions on SPARC more than a decade later... Richard E.'s generic solution has never been implemented so let's do as other RISC back-ends did. Tested on SPARC64/Linux, applied on all active branches. 2022-10-14 Eric Botcazou PR target/107248 * config/sparc/sparc.cc (sparc_expand_prologue): Emit a frame blockage for leaf functions. (sparc_flat_expand_prologue): Emit frame instead of full blockage. (sparc_expand_epilogue): Emit a frame blockage for leaf functions. (sparc_flat_expand_epilogue): Emit frame instead of full blockage. diff --git a/gcc/config/sparc/sparc.cc b/gcc/config/sparc/sparc.cc index c72c38e1999..10c0f52d3d9 100644 --- a/gcc/config/sparc/sparc.cc +++ b/gcc/config/sparc/sparc.cc @@ -6051,6 +6051,9 @@ sparc_expand_prologue (void) } RTX_FRAME_RELATED_P (insn) = 1; + + /* Ensure no memory access is done before the frame is established. */ + emit_insn (gen_frame_blockage ()); } else { @@ -6065,13 +6068,7 @@ sparc_expand_prologue (void) /* %sp is not the CFA register anymore. */ emit_insn (gen_stack_pointer_inc (GEN_INT (4096 - size))); - /* Make sure no %fp-based store is issued until after the frame is - established. The offset between the frame pointer and the stack - pointer is calculated relative to the value of the stack pointer - at the end of the function prologue, and moving instructions that - access the stack via the frame pointer between the instructions - that decrement the stack pointer could result in accessing the - register window save area, which is volatile. */ + /* Likewise. */ emit_insn (gen_frame_blockage ()); } else @@ -6167,8 +6164,8 @@ sparc_flat_expand_prologue (void) } RTX_FRAME_RELATED_P (insn) = 1; - /* Ensure nothing is scheduled until after the frame is established. */ - emit_insn (gen_blockage ()); + /* Ensure no memory access is done before the frame is established. */ + emit_insn (gen_frame_blockage ()); if (frame_pointer_needed) { @@ -6255,6 +6252,9 @@ sparc_expand_epilogue (bool for_eh) ; /* do nothing. */ else if (sparc_leaf_function_p) { + /* Ensure no memory access is done after the frame is destroyed. */ + emit_insn (gen_frame_blockage ()); + if (size <= 4096) emit_insn (gen_stack_pointer_inc (GEN_INT (size))); else if (size <= 8192) @@ -6305,15 +6305,15 @@ sparc_flat_expand_epilogue (bool for_eh) ; /* do nothing. */ else if (frame_pointer_needed) { - /* Make sure the frame is destroyed after everything else is done. */ - emit_insn (gen_blockage ()); + /* Ensure no memory access is done after the frame is destroyed. */ + emit_insn (gen_frame_blockage ()); emit_move_insn (stack_pointer_rtx, gen_rtx_REG (Pmode, 1)); } else { /* Likewise. */ - emit_insn (gen_blockage ()); + emit_insn (gen_frame_blockage ()); if (size <= 4096) emit_insn (gen_stack_pointer_inc (GEN_INT (size)));