From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by sourceware.org (Postfix) with ESMTP id 54A58388702E for ; Wed, 8 Apr 2020 16:41:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 54A58388702E Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-96-r2qnIkIsPQedAfT5Jzxlwg-1; Wed, 08 Apr 2020 12:41:40 -0400 X-MC-Unique: r2qnIkIsPQedAfT5Jzxlwg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 30301DB63; Wed, 8 Apr 2020 16:41:39 +0000 (UTC) Received: from ovpn-114-204.phx2.redhat.com (ovpn-114-204.phx2.redhat.com [10.3.114.204]) by smtp.corp.redhat.com (Postfix) with ESMTP id D79725C296; Wed, 8 Apr 2020 16:41:38 +0000 (UTC) Message-ID: Subject: Re: [PATCH] x86: Insert ENDBR if function will be called indirectly From: Jeff Law Reply-To: law@redhat.com To: "H.J. Lu" Cc: GCC Patches Date: Wed, 08 Apr 2020 10:41:38 -0600 In-Reply-To: References: <20200331151134.483137-1-hjl.tools@gmail.com> <8b049744b21bf998300550f6f86bab46225a8ce2.camel@redhat.com> Organization: Red Hat User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no 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: , X-List-Received-Date: Wed, 08 Apr 2020 16:41:43 -0000 On Wed, 2020-04-08 at 09:23 -0700, H.J. Lu wrote: > On Wed, Apr 8, 2020 at 9:16 AM Jeff Law wrote: > > On Tue, 2020-03-31 at 08:11 -0700, H.J. Lu via Gcc-patches wrote: > > > Since constant_call_address_operand has > > > > > > ;; Test for a pc-relative call operand > > > (define_predicate "constant_call_address_operand" > > > (match_code "symbol_ref") > > > { > > > if (ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC > > > || flag_force_indirect_call) > > > return false; > > > if (TARGET_DLLIMPORT_DECL_ATTRIBUTES && SYMBOL_REF_DLLIMPORT_P (op)) > > > return false; > > > return true; > > > }) > > > > > > even if cgraph_node::get (cfun->decl)->only_called_directly_p () returns > > > false, the fuction may still be called indirectly. Copy the logic from > > > constant_call_address_operand to rest_of_insert_endbranch to insert ENDBR > > > at function entry if function will be called indirectly. > > > > > > gcc/ > > > > > > PR target/94417 > > > * config/i386/i386-features.c (rest_of_insert_endbranch): Insert > > > ENDBR at function entry if function will be called indirectly. > > Can you just call constant_call_address_operand rather than copying its > > contents? > > I wish I could. constant_call_address_operand uses SYMBOL_REF_DLLIMPORT_P (op) > But I need to use DECL_DLLIMPORT_P (cfun->decl)). Sigh. In that case I guess the patch is OK as-is. jeff >