From patchwork Mon Jul 18 12:00:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Zissulescu Ianculescu X-Patchwork-Id: 1657417 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=SwbKpufG; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LmgXb5RG0z9s2R for ; Mon, 18 Jul 2022 22:01:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A49013850224 for ; Mon, 18 Jul 2022 12:00:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A49013850224 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658145659; 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=SwbKpufGKcvx1iG7szRfrzVkmzdZNKn5N3pR7CMD+X+4nMMadjaxf5DdVUp8KrpGR 9ZJw3KgGZafMz7mB7jc79dkGXdT+QX3iMJqO3NTG78T4z0pAYnksJ+kyWi43Mer2Yu ddTud/tF5i7KGV/BUh31n84wKB/Rdl6U7/BTRko8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 6C065385085C for ; Mon, 18 Jul 2022 12:00:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6C065385085C Received: by mail-wr1-x431.google.com with SMTP id r14so16719060wrg.1 for ; Mon, 18 Jul 2022 05:00:39 -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=Dc62v36FaRy6kZr3I7EvisanwchymZiueNK8PR7ACsevweEpdS6Ye+8EpCC298nwxF gx2k4ACNU19MvBrcg3OGdj+36q/3T1pm2k/zfgUMvObODuSRpfyTlIrR0LeOh3soMPxR OYnwYyDIhGNVESIIFUQwOmoY5Kv1rmtJbD7Rp78HDcMPDNWafHT3wC5nIrnqresux3C7 84Z9l6ncyM3kjSAsebtzr9jvjWGrGCjGJsWIZvszAgdAUPKhajK1o6o9WTcmMmIUNIKf l/H2/tUAluTppUAs+t52P8ssf2N0uPVp1ifqL9HabvViYgu8sJBrtcBkz2CNUVG9OPX1 DcMg== X-Gm-Message-State: AJIora9nE91fiLwttTVVRlWuMcPlVEnJNRFhwql7+khvpKOZ1vUIIvb5 Xi/ShL1GWm88lCpcQAeUgQTobhKyMcA= X-Google-Smtp-Source: AGRyM1s9GjWh32LpSu5wTB4s4nicaHFliv5a9ByPdfPrmMYfCJnmlSTBabtcyHLLy5EfoKj+VxPUFQ== X-Received: by 2002:a05:6000:2ab:b0:21d:b410:5999 with SMTP id l11-20020a05600002ab00b0021db4105999mr22403854wry.517.1658145637829; Mon, 18 Jul 2022 05:00:37 -0700 (PDT) Received: from fatty.nomansland ([193.187.151.25]) by smtp.gmail.com with ESMTPSA id h7-20020adf9cc7000000b0021d8faf57d5sm11049233wre.74.2022.07.18.05.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 05:00:37 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [committed 1/2] arc: Fix interrupt's epilogue. Date: Mon, 18 Jul 2022 15:00:35 +0300 Message-Id: <20220718120036.3290240-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: Claudiu Zissulescu Ianculescu Reply-To: Claudiu Zissulescu Cc: fbedard@synopsys.com Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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" } } */