From patchwork Wed Nov 17 20:32:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 47849 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 921CC385840C for ; Wed, 17 Nov 2021 20:35:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 921CC385840C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1637181305; bh=cxCeFxVSY2QkkqpI5Z0WH0EMDN4dW3c+x216T0+dmoc=; h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=CnmuGcO9B9xQ/YLiNsiW4KB7HU0D39xSwwuK8yDZyNU+WwSpsY73gaUITOuWatXUX 32ab3cefWKKVj4zWtPaodBccbTrvXJzcHzzbr1CEvBmTyCyNmhijjUkZ2PmQ98g9I4 fCeUwRkRI23MZe2AaYEfs1+VqZjch7by63vFRIq4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 40ABA3857C7B for ; Wed, 17 Nov 2021 20:33:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 40ABA3857C7B Received: by mail-pf1-x42c.google.com with SMTP id b68so3719982pfg.11 for ; Wed, 17 Nov 2021 12:33:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cxCeFxVSY2QkkqpI5Z0WH0EMDN4dW3c+x216T0+dmoc=; b=Yt5fl4feRtsPu+fAVEzVgSFuzfdIyDaB83I78fFDhNSQ8Uy/cqmiNqe0/MLlYXH2ZE UDZtQNkKcC4saisU0EuLD1WidKqdtu3UpXPTtg2wQQo3LGwhIwW1KAd/P3hHJvpx6TSU I1Hz/7FnqLfX1C9xIkOuzxRyX671Xg3OGkOiC04uMuV+IMF8u699GdqMGpbQdXAGsrvA 4i/8GGoQzUr2QSfHP8CTpXroKk/C3np9BX1pmKRnPZ83Qt1BwmFJnNT2vv78DVoOObfw sg+Kv5pOlqpHfitzkZLdPc1QpaaNyvWDZKMDcE0GSejEQTZ0qOqiGQPrzPCNlcizTNo6 qSsA== X-Gm-Message-State: AOAM5329BnDKAX9IKeVD3IPVHBr67tAe0pSFqhF38Q9JJ7EIxeYHYusb lUGcpRYmqQ03UkC2VsfIOz+aBkIoM6ieye9krdE= X-Google-Smtp-Source: ABdhPJyUEDN3YziQhgldSBiRWMH98b0Xw0mzdow8/RuYlvV6mQHXYWwbH1twR6b7ecSLIl22/rPBN9knGz/cTLnVJu4= X-Received: by 2002:a63:8042:: with SMTP id j63mr7251563pgd.225.1637181188173; Wed, 17 Nov 2021 12:33:08 -0800 (PST) MIME-Version: 1.0 References: <20211117194426.31538-1-hjl.tools@gmail.com> In-Reply-To: Date: Wed, 17 Nov 2021 12:32:32 -0800 Message-ID: Subject: [PATCH v2] x86: Remove "%!" before ret To: Uros Bizjak X-Spam-Status: No, score=-3029.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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: , X-Patchwork-Original-From: "H.J. Lu via Gcc-patches" From: "H.J. Lu" Reply-To: "H.J. Lu" Cc: "gcc-patches@gcc.gnu.org" Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" On Wed, Nov 17, 2021 at 11:46 AM Uros Bizjak wrote: > > On Wed, Nov 17, 2021 at 8:44 PM H.J. Lu wrote: > > > > Before MPX was removed, "%!" was mapped to > > > > case '!': > > if (ix86_bnd_prefixed_insn_p (current_output_insn)) > > fputs ("bnd ", file); > > return; > > > > After CET was added and MPX was removed, "%!" was mapped to > > > > case '!': > > if (ix86_notrack_prefixed_insn_p (current_output_insn)) > > fputs ("notrack ", file); > > return; > > > > ix86_notrack_prefixed_insn_p always returns false on ret since the > > notrack prefix is only for indirect branches. Remove the unused "%!" > > before ret. > > > > PR target/103307 > > * config/i386/i386.c (ix86_code_end): Remove "%!" before ret. > > (ix86_output_function_return): Likewise. > > * config/i386/i386.md (simple_return_pop_internal): Likewise. > > --- > > gcc/config/i386/i386.c | 4 ++-- > > gcc/config/i386/i386.md | 2 +- > > 2 files changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c > > index 73c4d5115bb..95d238e9efc 100644 > > --- a/gcc/config/i386/i386.c > > +++ b/gcc/config/i386/i386.c > > @@ -6116,7 +6116,7 @@ ix86_code_end (void) > > xops[0] = gen_rtx_REG (Pmode, regno); > > xops[1] = gen_rtx_MEM (Pmode, stack_pointer_rtx); > > output_asm_insn ("mov%z0\t{%1, %0|%0, %1}", xops); > > - output_asm_insn ("%!ret", NULL); > > + output_asm_insn ("ret", NULL); > > This can use fputs. Fixed. Here is the v2 patch. > Uros. > > > final_end_function (); > > init_insn_lengths (); > > free_after_compilation (cfun); > > @@ -16278,7 +16278,7 @@ ix86_output_function_return (bool long_p) > > } > > > > if (!long_p) > > - return "%!ret"; > > + return "ret"; > > > > return "rep%; ret"; > > } > > diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md > > index 73d15de88b2..7b2de60706d 100644 > > --- a/gcc/config/i386/i386.md > > +++ b/gcc/config/i386/i386.md > > @@ -14705,7 +14705,7 @@ (define_insn_and_split "simple_return_pop_internal" > > [(simple_return) > > (use (match_operand:SI 0 "const_int_operand"))] > > "reload_completed" > > - "%!ret\t%0" > > + "ret\t%0" > > "&& cfun->machine->function_return_type != indirect_branch_keep" > > [(const_int 0)] > > "ix86_split_simple_return_pop_internal (operands[0]); DONE;" > > -- > > 2.33.1 > > From 594391d282f0066cb046dd06062e3efad8c74a08 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Wed, 17 Nov 2021 11:41:12 -0800 Subject: [PATCH v2] x86: Remove "%!" before ret Before MPX was removed, "%!" was mapped to case '!': if (ix86_bnd_prefixed_insn_p (current_output_insn)) fputs ("bnd ", file); return; After CET was added and MPX was removed, "%!" was mapped to case '!': if (ix86_notrack_prefixed_insn_p (current_output_insn)) fputs ("notrack ", file); return; ix86_notrack_prefixed_insn_p always returns false on ret since the notrack prefix is only for indirect branches. Remove the unused "%!" before ret. PR target/103307 * config/i386/i386.c (ix86_code_end): Remove "%!" before ret. (ix86_output_function_return): Likewise. * config/i386/i386.md (simple_return_pop_internal): Likewise. --- gcc/config/i386/i386.c | 4 ++-- gcc/config/i386/i386.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index c9129ae25e4..a5bfb9efca9 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -6115,7 +6115,7 @@ ix86_code_end (void) xops[0] = gen_rtx_REG (Pmode, regno); xops[1] = gen_rtx_MEM (Pmode, stack_pointer_rtx); output_asm_insn ("mov%z0\t{%1, %0|%0, %1}", xops); - output_asm_insn ("%!ret", NULL); + fputs ("\tret\n", asm_out_file); final_end_function (); init_insn_lengths (); free_after_compilation (cfun); @@ -16273,7 +16273,7 @@ ix86_output_function_return (bool long_p) } if (!long_p) - return "%!ret"; + return "ret"; return "rep%; ret"; } diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 73d15de88b2..7b2de60706d 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -14705,7 +14705,7 @@ (define_insn_and_split "simple_return_pop_internal" [(simple_return) (use (match_operand:SI 0 "const_int_operand"))] "reload_completed" - "%!ret\t%0" + "ret\t%0" "&& cfun->machine->function_return_type != indirect_branch_keep" [(const_int 0)] "ix86_split_simple_return_pop_internal (operands[0]); DONE;" -- 2.33.1