From patchwork Thu Nov 26 15:43:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1406748 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=adacore-com.20150623.gappssmtp.com header.i=@adacore-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=W4667Pzm; dkim-atps=neutral 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 (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4ChhqL0zRCz9s1l for ; Fri, 27 Nov 2020 02:43:10 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1DFAA3971C0B; Thu, 26 Nov 2020 15:43:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id C3C27386103A for ; Thu, 26 Nov 2020 15:43:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C3C27386103A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=botcazou@adacore.com Received: by mail-wm1-x334.google.com with SMTP id a186so2537651wme.1 for ; Thu, 26 Nov 2020 07:43:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=U3UJ2saWi9pPrbb7lYVWasvLnxLwxt9ME2nt3H64BtI=; b=W4667PzmKyvyq0pGfnbPXyGp8lcp3DvwNKG9hIHPdo2hd3DCXXWXAp7LRAfEQIY9Dn 3lyHJ/z+Lp4gwBZt5oRfjSt7N8UYAYPErHrTPH/Q0GMyknCa5TGHj9epT2I0ulnnFPj0 9dPifcUb1p44f3/qjWZ8BQKGdkZTdsrAozE/OU+nz5xDn3atoxTFCrivlPoBbfl+L9B7 Q/bJrSl6aD6zoUC4d2xTPYuQt4pO+RaKaqGGcC2qqPTM6+nGShTtX/ZLpv5pGGlHKTIj OB+kbFSrXaGIuAJgZZ8IraPanzZDCOKX3aRnKnRjHKbFm7qrlOpFBlbs1UO/N+OLo6Po Rg/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=U3UJ2saWi9pPrbb7lYVWasvLnxLwxt9ME2nt3H64BtI=; b=t/DY0mK6+4AzEyEif6fYejXQ2CE6PuJZzpX/6xQYLGFS0XG+6aK87yravoGzDwrAqt nZKWlUH/ya2O/tCEN4FjlCKCsG1cNUCh6yR2gVYzDxCeggaFaXyyMhFhNq5dVG3Pz2Dr seHhkBBsMHA3Fz22a2Ie935igBuKUz15ZyFi9PtAOo0RLSgmMW4iAAIb8cVeZaIudB7z +W1/TY09LelSkQnEeRf6nTCOiRAfskKJ4MlBuzz5GR/8sqPxKKY9nm+wa7dRRLe1nhk+ W5+vqoobUN19Uzd1zw1qSSzD3rEpfMrN6MY/2BTs5Usy9B+5+BHmBOYfUbWswBGsZqjO zMiw== X-Gm-Message-State: AOAM530strVTmPbcHH8Y5Umv12Yc6iRFRNscKh3nI1u6/qO50q672VFc 6d8WFKU4Nmil4uJ6SVKIJTcUQ8AhlKQsEg+U X-Google-Smtp-Source: ABdhPJxt4IScQwr/xWtRIH4P4auD3y8cdokMQo3k8ALpUD6mlKAf0jNWzNJpzXMqWAWKvg0TTHLrxA== X-Received: by 2002:a1c:2e16:: with SMTP id u22mr3972584wmu.149.1606405382475; Thu, 26 Nov 2020 07:43:02 -0800 (PST) Received: from fomalhaut.localnet ([2a01:e0a:41b:9230:7f82:53f4:769e:54b6]) by smtp.gmail.com with ESMTPSA id o203sm2590883wmb.0.2020.11.26.07.43.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Nov 2020 07:43:01 -0800 (PST) From: Eric Botcazou X-Google-Original-From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [SPARC] Fix PR target/96607 Date: Thu, 26 Nov 2020 16:43:00 +0100 Message-ID: <1993741.2QjuCtZ6X0@fomalhaut> MIME-Version: 1.0 X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" After 15 years trying to find out what can go into the delay slot of the call to __tls_get_addr with the Solaris linker, it's time to concede defeat. As Vita says in the PR: "Solaris linker doesn't expect anything in the branch delay slot of the above call instruction. An optimized sequence using a delay slot of call instruction related to R_SPARC_TLS_GD_CALL relocation confuses the linker and causes it to produce invalid code." Tested on SPARC64/Linux and SPARC/Solaris, applied on the mainline (for now). 2020-11-26 Eric Botcazou PR target/96607 * config/sparc/sparc-protos.h (eligible_for_call_delay): Delete. * config/sparc/sparc.c (eligible_for_call_delay): Likewise. * config/sparc/sparc.md (in_call_delay): Likewise. (tls_delay_slot): New attribute. (define_delay [call]): Use in_branch_delay. (tgd_call): Set type to call_no_delay_slot when tls_delay_slot is false. (tldm_call): Likewise. diff --git a/gcc/config/sparc/sparc-protos.h b/gcc/config/sparc/sparc-protos.h index f525cd7a422..5f9999a669c 100644 --- a/gcc/config/sparc/sparc-protos.h +++ b/gcc/config/sparc/sparc-protos.h @@ -86,7 +86,6 @@ extern int mems_ok_for_ldd_peep (rtx, rtx, rtx); extern rtx widen_mem_for_ldd_peep (rtx, rtx, machine_mode); extern int empty_delay_slot (rtx_insn *); extern int emit_cbcond_nop (rtx_insn *); -extern int eligible_for_call_delay (rtx_insn *); extern int eligible_for_return_delay (rtx_insn *); extern int eligible_for_sibcall_delay (rtx_insn *); extern int emit_move_sequence (rtx, machine_mode); diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 2780b4243b5..02138c5d478 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -3949,41 +3949,6 @@ emit_cbcond_nop (rtx_insn *insn) return 1; } -/* Return nonzero if TRIAL can go into the call delay slot. */ - -int -eligible_for_call_delay (rtx_insn *trial) -{ - rtx pat; - - if (get_attr_in_branch_delay (trial) == IN_BRANCH_DELAY_FALSE) - return 0; - - /* The only problematic cases are TLS sequences with Sun as/ld. */ - if ((TARGET_GNU_TLS && HAVE_GNU_LD) || !TARGET_TLS) - return 1; - - pat = PATTERN (trial); - - /* We must reject tgd_add{32|64}, i.e. - (set (reg) (plus (reg) (unspec [(reg) (symbol_ref)] UNSPEC_TLSGD))) - and tldm_add{32|64}, i.e. - (set (reg) (plus (reg) (unspec [(reg) (symbol_ref)] UNSPEC_TLSLDM))) - for Sun as/ld. */ - if (GET_CODE (pat) == SET - && GET_CODE (SET_SRC (pat)) == PLUS) - { - rtx unspec = XEXP (SET_SRC (pat), 1); - - if (GET_CODE (unspec) == UNSPEC - && (XINT (unspec, 1) == UNSPEC_TLSGD - || XINT (unspec, 1) == UNSPEC_TLSLDM)) - return 0; - } - - return 1; -} - /* Return nonzero if TRIAL, an insn, can be combined with a 'restore' instruction. RETURN_P is true if the v9 variant 'return' is to be considered in the test too. diff --git a/gcc/config/sparc/sparc.md b/gcc/config/sparc/sparc.md index 231c0d84778..edfb6353683 100644 --- a/gcc/config/sparc/sparc.md +++ b/gcc/config/sparc/sparc.md @@ -561,9 +561,9 @@ (set_attr "type" "multi")]) ;; Attributes for branch scheduling -(define_attr "in_call_delay" "false,true" - (symbol_ref "(eligible_for_call_delay (insn) - ? IN_CALL_DELAY_TRUE : IN_CALL_DELAY_FALSE)")) +(define_attr "tls_delay_slot" "false,true" + (symbol_ref "((TARGET_GNU_TLS && HAVE_GNU_LD) != 0 + ? TLS_DELAY_SLOT_TRUE : TLS_DELAY_SLOT_FALSE)")) (define_attr "in_sibcall_delay" "false,true" (symbol_ref "(eligible_for_sibcall_delay (insn) @@ -613,27 +613,24 @@ (const_string "true") ] (const_string "false"))) -(define_delay (eq_attr "type" "call") - [(eq_attr "in_call_delay" "true") (nil) (nil)]) - (define_delay (eq_attr "type" "sibcall") [(eq_attr "in_sibcall_delay" "true") (nil) (nil)]) (define_delay (eq_attr "type" "return") [(eq_attr "in_return_delay" "true") (nil) (nil)]) -(define_delay (and (eq_attr "type" "branch") - (not (eq_attr "branch_type" "icc"))) - [(eq_attr "in_branch_delay" "true") (nil) (eq_attr "in_branch_delay" "true")]) - -(define_delay (and (eq_attr "type" "branch") - (eq_attr "branch_type" "icc")) - [(eq_attr "in_branch_delay" "true") (nil) - (eq_attr "in_integer_branch_annul_delay" "true")]) - -(define_delay (eq_attr "type" "uncond_branch") +(define_delay (ior (eq_attr "type" "call") (eq_attr "type" "uncond_branch")) [(eq_attr "in_branch_delay" "true") (nil) (nil)]) +(define_delay (and (eq_attr "type" "branch") (not (eq_attr "branch_type" "icc"))) + [(eq_attr "in_branch_delay" "true") + (nil) + (eq_attr "in_branch_delay" "true")]) + +(define_delay (and (eq_attr "type" "branch") (eq_attr "branch_type" "icc")) + [(eq_attr "in_branch_delay" "true") + (nil) + (eq_attr "in_integer_branch_annul_delay" "true")]) ;; Include SPARC DFA schedulers @@ -7935,7 +7932,9 @@ visl") (clobber (reg:P O7_REG))] "TARGET_TLS" "call\t%a1, %%tgd_call(%a2)%#" - [(set_attr "type" "call")]) + [(set (attr "type") (if_then_else (eq_attr "tls_delay_slot" "true") + (const_string "call") + (const_string "call_no_delay_slot")))]) (define_insn "tldm_hi22" [(set (match_operand:P 0 "register_operand" "=r") @@ -7966,7 +7965,9 @@ visl") (clobber (reg:P O7_REG))] "TARGET_TLS" "call\t%a1, %%tldm_call(%&)%#" - [(set_attr "type" "call")]) + [(set (attr "type") (if_then_else (eq_attr "tls_delay_slot" "true") + (const_string "call") + (const_string "call_no_delay_slot")))]) (define_insn "tldo_hix22" [(set (match_operand:P 0 "register_operand" "=r")