From patchwork Wed Sep 15 09:36:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Cederman X-Patchwork-Id: 45023 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 56CEB3857825 for ; Wed, 15 Sep 2021 09:38:30 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by sourceware.org (Postfix) with ESMTPS id 3C5D03857C6B for ; Wed, 15 Sep 2021 09:36:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3C5D03857C6B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gaisler.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gaisler.com X-Halon-ID: 61166b11-1608-11ec-8aa7-005056917f90 Authorized-sender: cederman@gaisler.com Received: from cederman.got.gaisler.com (h-98-128-223-123.na.cust.bahnhof.se [98.128.223.123]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id 61166b11-1608-11ec-8aa7-005056917f90; Wed, 15 Sep 2021 11:36:19 +0200 (CEST) From: Daniel Cederman To: gcc-patches@gcc.gnu.org Subject: [PATCH 3/4] sparc: Prevent atomic instructions in beginning of functions for UT700 Date: Wed, 15 Sep 2021 11:36:09 +0200 Message-Id: <20210915093610.3112669-5-cederman@gaisler.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210915093610.3112669-1-cederman@gaisler.com> References: <20210915093610.3112669-1-cederman@gaisler.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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: , Cc: ebotcazou@libertysurf.fr Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" A call to the function might have a load instruction in the delay slot and a load followed by an atomic function could cause a deadlock. gcc/ChangeLog: * config/sparc/sparc.c (sparc_do_work_around_errata): Do not begin functions with atomic instruction in the UT700 errata workaround. --- gcc/config/sparc/sparc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index b087c5b3fc8..5177d48793d 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -1106,6 +1106,7 @@ static unsigned int sparc_do_work_around_errata (void) { rtx_insn *insn, *next; + bool find_first_useful = true; /* Force all instructions to be split into their final form. */ split_all_insns_noflow (); @@ -1130,6 +1131,16 @@ sparc_do_work_around_errata (void) else jump = NULL; + /* Do not begin function with atomic instruction. */ + if (sparc_fix_ut700 + && find_first_useful + && USEFUL_INSN_P (insn)) + { + find_first_useful = false; + if (atomic_insn_for_leon3_p (insn)) + emit_insn_before (gen_nop (), insn); + } + /* Place a NOP at the branch target of an integer branch if it is a floating-point operation or a floating-point branch. */ if (sparc_fix_gr712rc