From patchwork Mon Jul 18 11:36:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 34 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a98:d5ce:0:b0:178:cc93:bf7d with SMTP id g14csp1797389eik; Mon, 18 Jul 2022 04:37:17 -0700 (PDT) X-Google-Smtp-Source: AGRyM1thKIWxx9OPUxUD1bhqzpY7P/6BC+oXLFy59jZlowwy7mp937JncHOEyDGJUxW1wPMV+TZd X-Received: by 2002:a17:907:a053:b0:72b:3051:b79b with SMTP id gz19-20020a170907a05300b0072b3051b79bmr24078777ejc.690.1658144237710; Mon, 18 Jul 2022 04:37:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658144237; cv=none; d=google.com; s=arc-20160816; b=j1rhQvlXDq6ymJAZxTM4NHSNgzd3fZvabQ9QC+cOcL1tHSsTFzko9rukNYwavnJ6Xk fclVL4gLSXYwVdE7OM4HSpEKNnNHKnGJyT+msB67vsvPx95tELyUgZJXrcSodkkRyaVc HIvoypRaUCywDPLQlwSUwfuIBUTzPMFzM1gfdO+IpalZw7xpdAcex8fS7m1KtFdTCPiL Olf7gnypk4giKguFM7fgLiQKXK1KTdct3kraLyG1Lts8UY8u2+k+H/XsxDXiByoCjjtU 3FlUtVhPpjbLTSe6wLg3YNKKw/Uq2bLuERFV7vv4e4Rq7GP0hUvfW2Y5nJhe/n8hUsO1 J6jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=+8raqENi0nKNLqX49iJdQtuNm2usr9DH+CNZXQmZWGE=; b=qWxiRx5XDt4Qvq8OGPGUd7peBI2kN9+cPqxFRx/wF7C58S0Fe8H6L4+7tdiPPUOWbG B7Z4qABJyFv6K/lDU6ZWJxUwXVNTWMfOV3SL9fRW0GXudZm1gw7LgyjuSpLeIuS2XIuU sTkc1ZwPWYaZuki9/9wISgy7egZ8+Na7+U8+f9sAlInJtS4AhPldn43lRNSskAUwmExU BqnhrSZ8LhQXFw68ZL8CJVE2dFy4NG63K7RX9cFEOmbVtillaa+WiSg5/180250d3jpf 4g+AdJAb1fhOtkwVCoXFgb2S31a8q/bqd6mPHKhMZt1Mxdni0J0sKhwKVzUt22nt+QRV 9aJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=OaxZDkJg; 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 o16-20020a1709061b1000b006feef404001si14475649ejg.801.2022.07.18.04.37.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 04:37:17 -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=OaxZDkJg; 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 7C91B38582BC for ; Mon, 18 Jul 2022 11:37:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7C91B38582BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658144236; bh=+8raqENi0nKNLqX49iJdQtuNm2usr9DH+CNZXQmZWGE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=OaxZDkJgcD2McnA+IR/Q8ulPSCTAHBcgCKtNVZ3CrRch1cTEBy0aR48wjtYCkgx39 T6i+EixICR/VvH89WfU4glvhtVlv1fuZNoIuRbEoul/WhuhPljWUYahOmzb5Oalfmi dk5/R97GMXp+ELyUg0zP8Ve3uqLUBsDgnlKcb6KI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id B79E63858D33 for ; Mon, 18 Jul 2022 11:36:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B79E63858D33 Received: by mail-wm1-x333.google.com with SMTP id x23-20020a05600c179700b003a30e3e7989so4964097wmo.0 for ; Mon, 18 Jul 2022 04:36:30 -0700 (PDT) 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=+8raqENi0nKNLqX49iJdQtuNm2usr9DH+CNZXQmZWGE=; b=cvmqTuaI22cr4PxAG3AUf/aDcUKjVk4z1NREZT9emO7gTY5cFZqES/cCOiZd3uP7LH 2N98GCi3C9vZqBYwObHD4DVUyARiIk3qITZj27Qa9t/o0cHQIutdAcHo4t+oJjvPJ6Uv vr7qjr2lfUOu6HnUoYJcKZccdLky0s4GQG0us5M7zxdsZOic3gwWtjrKMrgCh2xmAIch rQ8VNMzWy5nSoUFEvXEfmS30bzroPNbyh/lNIHlVUqkKdU3VOw1u29a4Mz1pRKiLjIGg GnJ42XAvxsRiG8NRuQeb9OcxoyblFUw8EpRjDUjOWFYxCNFi9Dk7Xg7ANjRMZdr9JzkE aG3A== X-Gm-Message-State: AJIora+pQsMFhZlE/5v7/kSIgGValtFsdJqm3L62NFs5LtFodX14vEIQ rDCsOEFcSRAUUfJtR2/7Y7cbVLqLw8E= X-Received: by 2002:a05:600c:3ca4:b0:3a0:1825:2e29 with SMTP id bg36-20020a05600c3ca400b003a018252e29mr25545183wmb.11.1658144189194; Mon, 18 Jul 2022 04:36:29 -0700 (PDT) Received: from fatty.nomansland ([193.187.151.25]) by smtp.gmail.com with ESMTPSA id z11-20020a05600c0a0b00b003a033177655sm21283260wmp.29.2022.07.18.04.36.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 04:36:28 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [committed] arc: Fix interrupt's epilogue. Date: Mon, 18 Jul 2022 14:36:27 +0300 Message-Id: <20220718113627.3288368-1-claziss@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 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 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: Claudiu Zissulescu via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: Claudiu Zissulescu Cc: fbedard@synopsys.com 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?1738690252429437103?= X-GMAIL-MSGID: =?utf-8?q?1738690252429437103?= The stack pointer adjustment in interrupt epilogue is happening after restoring the ZOL registers which is wrong. Fixing this. gcc/ * config/arc/arc.cc (arc_expand_epilogue): Adjust the frame pointer first when in interrupts. gcc/testsuite/ * gcc.target/arc/interrupt-13.c: New file. Signed-off-by: Claudiu Zissulescu --- gcc/config/arc/arc.cc | 2 +- gcc/testsuite/gcc.target/arc/interrupt-13.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/arc/interrupt-13.c diff --git a/gcc/config/arc/arc.cc b/gcc/config/arc/arc.cc index fbc17e684a0..77730c88e55 100644 --- a/gcc/config/arc/arc.cc +++ b/gcc/config/arc/arc.cc @@ -3965,7 +3965,7 @@ arc_expand_epilogue (int sibcall_p) if (size) emit_insn (gen_blockage ()); - if (ARC_INTERRUPT_P (fn_type) && restore_fp) + if (ARC_INTERRUPT_P (fn_type)) { /* We need to restore FP before any SP operation in an interrupt. */ diff --git a/gcc/testsuite/gcc.target/arc/interrupt-13.c b/gcc/testsuite/gcc.target/arc/interrupt-13.c new file mode 100644 index 00000000000..0ed8451c512 --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/interrupt-13.c @@ -0,0 +1,15 @@ +/* { dg-options "-O2" } */ + +extern int foo (int *); + +void __attribute__((interrupt("ilink"))) +irq (void) +{ + struct { + int x0; + int x1; + } a = {1 ,2}; + foo ((int *)&a); +} + +/* { dg-final { scan-assembler "add_s\\s+sp,sp,8.*pop_s\\s+r0" } } */