From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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-x32f.google.com with SMTP id c7-20020a05600c0ac700b003c6cad86f38so5026752wmr.2 for ; Fri, 14 Oct 2022 03:00:47 -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=9jKEHiBbhM7Tpz9EBnjy7MKrlZW/Naw8JDy5bMtT5BE=; b=UnXpbBmMz+dBbPjlquXZlfrzB7PNdETbb5+iMkYxp2L2RBD82jSdd3NTLuVpvC18og khc2YG4mGNcjTuaNw9B+9mUugr+SG/2783lEbkz6Nm4n8RgdffLyZiGpmvk/QDJ+Bg6q OssE+VbZICV/VAQsJrTin3YU3/ZyZgXRXsOlO3SpI482wLXq6/eiJn6Uk3yyUlmIrQve CK2c5BwtgTUU9t6/rXLFyEy0pFvMDufRHUDxxtIYhqMRVPJUZnH30SD2HsdNBDR6iK9s tW5k3z2ypDPLm22ECxmy9sr5nQf3yKzwtrFqLLeysSPGmF5m2jKTW/CfomDdgIXLso/3 gjWg== 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-Google-Smtp-Source: AMsMyM79qaYcN0Z2k5lYA577tccmsySEtj8jbin66+n4gmqFMC8Qub7FVH7SueUHDX5QTM6gJTBwjA== 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) From: Eric Botcazou 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 Content-Type: multipart/mixed; boundary="nextPart3193704.aeNJFYEL58" Content-Transfer-Encoding: 7Bit 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 List-Id: This is a multi-part message in MIME format. --nextPart3193704.aeNJFYEL58 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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. -- Eric Botcazou --nextPart3193704.aeNJFYEL58 Content-Disposition: attachment; filename="pr107248.diff" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="utf-8"; name="pr107248.diff" 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))); --nextPart3193704.aeNJFYEL58--