From patchwork Mon Mar 7 13:57:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1602190 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=NV1E/nnl; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KC0R33mpdz9sFr for ; Tue, 8 Mar 2022 00:58:06 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 548383858436 for ; Mon, 7 Mar 2022 13:58:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 548383858436 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1646661483; bh=rmga+W3E3dFVgc1oUXdF90uRHSB+N7/VFnlqZv6rL+s=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=NV1E/nnlLiZSBJZfWMxwMIJumU0ly4I2m3zGDpzxmtsRl+1GH1iOdA//kex84HsbA G/BjAUphxOwPDYPmqASWWQMlUfrRj+xp+Cc13srI7hRoNZ79vXCgKyRBLu1BYGbjDj O+c4OkAt5wXhQP1OGs/NvOqIwuPH3FSXWp4rP80A= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by sourceware.org (Postfix) with ESMTPS id 9538C3858D35 for ; Mon, 7 Mar 2022 13:57:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9538C3858D35 Received: by mail-pl1-x62f.google.com with SMTP id m2so7849125pll.0 for ; Mon, 07 Mar 2022 05:57:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rmga+W3E3dFVgc1oUXdF90uRHSB+N7/VFnlqZv6rL+s=; b=1hsTic/cH68PUGsGb9IcHYf0Erojeaz53R9xzTdPhUy3LaX7HLaKgiNkN0VtPGqZ58 2Bqpuvf7mxnyZgwKpmRiEhtKZoFYnoF3OveBN1XggKjJsNKqIwvprUaVeO612vlyO6FP rjFTY5ZAXZWAXCCBSCtpBPIBY0Vi351eiXSNafgn/pZfBwJXwGkJJNwmrl115fgCTn2t AeEN/bDX7W8Zsjzr6J1Ffwzqq2rFox5D4mWgL4sNYt3fjhvIBh9IJeJiczvfI1+hutWx +S1Y7NkIHt/Tst1T8htSeiXrVge/0ikkXh+EJ0G6ol4BrcPajJ+k0pkzbmB5MkQrLfRW /VRQ== X-Gm-Message-State: AOAM530RQ/lYCSe485722/VMhp1iX807iOLoj5jnCN64Q3oc1uGmjPpp nJm8d/d4UcgUaDnlGyb7mlw= X-Google-Smtp-Source: ABdhPJzwOhXep0zP0xPMSj2qcQAAmvft06Gy4DFkSOcGsSU5gPPXEfBQFO8mc10JQB5e/nymL9Z0TA== X-Received: by 2002:a17:902:7407:b0:151:f6d0:f54e with SMTP id g7-20020a170902740700b00151f6d0f54emr1308989pll.129.1646661462069; Mon, 07 Mar 2022 05:57:42 -0800 (PST) Received: from gnu-tgl-3.localdomain ([172.58.35.24]) by smtp.gmail.com with ESMTPSA id d14-20020a056a0024ce00b004f3c87df62bsm16810526pfv.81.2022.03.07.05.57.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 05:57:41 -0800 (PST) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id AD237C0249; Mon, 7 Mar 2022 05:57:40 -0800 (PST) To: gcc-patches@gcc.gnu.org Subject: [PATCH v2] x86: Disable SSE on unwind-c.c and unwind-dw2.c Date: Mon, 7 Mar 2022 05:57:40 -0800 Message-Id: <20220307135740.51344-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3029.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: "H.J. Lu via Gcc-patches" From: "H.J. Lu" Reply-To: "H.J. Lu" Cc: Eric Botcazou Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Since eh_return doesn't work with stack realignment, disable SSE on unwind-c.c and unwind-dw2.c to avoid stack realignment with the 4-byte incoming stack to avoid SSE usage which is caused by commit 609e8c492d62d92465460eae3d43dfc4b2c68288 Author: H.J. Lu Date: Sat Feb 26 14:17:23 2022 -0800 x86: Always return pseudo register in ix86_gen_scratch_sse_rtx when pseudo vector registers are used to expand memset. gcc/ PR target/104781 * config/i386/i386.cc (ix86_expand_epilogue): Assert there is no stack realignment for eh_return. gcc/testsuite/ PR target/104781 * gcc.target/i386/eh_return-1.c: Add -mincoming-stack-boundary=4. * gcc.target/i386/eh_return-2.c: Likewise. libgcc/ PR target/104781 * config.host (tmake_file): Add i386/32/t-eh-return-no-sse for 32-bit x86 Cygwin, MinGW and Solaris. * config/i386/32/t-eh-return-no-sse: New file. --- gcc/config/i386/i386.cc | 5 ++--- gcc/testsuite/gcc.target/i386/eh_return-1.c | 2 +- gcc/testsuite/gcc.target/i386/eh_return-2.c | 2 +- libgcc/config.host | 13 +++++++++++++ libgcc/config/i386/32/t-eh-return-no-sse | 5 +++++ 5 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 libgcc/config/i386/32/t-eh-return-no-sse diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index 95219902694..1c675304e32 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -9444,9 +9444,8 @@ ix86_expand_epilogue (int style) rtx sa = EH_RETURN_STACKADJ_RTX; rtx_insn *insn; - /* %ecx can't be used for both DRAP register and eh_return. */ - if (crtl->drap_reg) - gcc_assert (REGNO (crtl->drap_reg) != CX_REG); + /* Stack realignment doesn't work with eh_return. */ + gcc_assert (!crtl->stack_realign_needed); /* regparm nested functions don't work with eh_return. */ gcc_assert (!ix86_static_chain_on_stack); diff --git a/gcc/testsuite/gcc.target/i386/eh_return-1.c b/gcc/testsuite/gcc.target/i386/eh_return-1.c index b21fd75fc93..43f94f01a97 100644 --- a/gcc/testsuite/gcc.target/i386/eh_return-1.c +++ b/gcc/testsuite/gcc.target/i386/eh_return-1.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -march=haswell -mno-avx512f -mtune-ctrl=avx256_move_by_pieces" } */ +/* { dg-options "-O2 -mincoming-stack-boundary=4 -march=haswell -mno-avx512f -mtune-ctrl=avx256_move_by_pieces" } */ struct _Unwind_Context { diff --git a/gcc/testsuite/gcc.target/i386/eh_return-2.c b/gcc/testsuite/gcc.target/i386/eh_return-2.c index f23f4492dac..cb762f92cc2 100644 --- a/gcc/testsuite/gcc.target/i386/eh_return-2.c +++ b/gcc/testsuite/gcc.target/i386/eh_return-2.c @@ -1,6 +1,6 @@ /* PR target/101772 */ /* { dg-do compile } */ -/* { dg-additional-options "-O0 -march=x86-64 -mstackrealign" } */ +/* { dg-additional-options "-O0 -mincoming-stack-boundary=4 -march=x86-64 -mstackrealign" } */ struct _Unwind_Context _Unwind_Resume_or_Rethrow_this_context; diff --git a/libgcc/config.host b/libgcc/config.host index 094fd3ad254..1588ab6cf20 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -1583,3 +1583,16 @@ case ${host} in tmake_file="$tmake_file t-gthr-noweak" ;; esac + +case ${host} in +i[34567]86-*-* | x86_64-*-*) + if test "${host_address}" = 32; then + case ${host} in + *-*-cygwin* | *-*-mingw* | *-*-solaris2*) + # Disable SSE on unwind-c.c and unwind-dw2.c to avoid stack + # realignment with the 4-byte aligned incoming stack. + tmake_file="${tmake_file} i386/${host_address}/t-eh-return-no-sse" + ;; + esac + fi +esac diff --git a/libgcc/config/i386/32/t-eh-return-no-sse b/libgcc/config/i386/32/t-eh-return-no-sse new file mode 100644 index 00000000000..5a8c3135911 --- /dev/null +++ b/libgcc/config/i386/32/t-eh-return-no-sse @@ -0,0 +1,5 @@ +# Since eh_return doesn't work with stack realignment, disable SSE on +# unwind-c.c and unwind-dw2.c to avoid stack realignment with the 4-byte +# incoming stack. + +unwind-c.o unwind-c_s.o unwind-dw2.o unwind-dw2_s.o : HOST_LIBGCC2_CFLAGS += -mno-sse