From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id EF03F3858D33 for ; Fri, 31 Mar 2023 07:20:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF03F3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 107231FE42; Fri, 31 Mar 2023 07:20:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680247250; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=tUoKykZbIBMHLJ15BZUKGqmzwrUaqvF4CGAZVVzpLcc=; b=betULSKrKc/4UzAMV1GWSuNU3phcMZFhc3IUuvHD8cB++EmE/KeF5IKkil8pWtRoqQ0RPW 7bzO/AoxR2fxICcmu2TljOiK0n9wgtGL3T4zqaR9ze42+VdmfXcXyW9SrV0UB9WcSTE0In au8onTpRRexgKC9Brkzq4FEgA6cqUD4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680247250; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=tUoKykZbIBMHLJ15BZUKGqmzwrUaqvF4CGAZVVzpLcc=; b=+Y4SOKFX9vFILSL4XMLx/5EOvIpcHuZ/x+qLgKHWvdAhA9sGKGqEiqWklofN9R4J5CEO8K n9Ac68oUN9DwpfBg== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id F10B82C141; Fri, 31 Mar 2023 07:20:49 +0000 (UTC) Date: Fri, 31 Mar 2023 07:20:49 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: Jan Hubicka Subject: Re: [PATCH] tree-optimization/109304 - properly handle instrumented aliases Message-ID: User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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 List-Id: On Tue, 28 Mar 2023, Richard Biener wrote: > When adjusting calls to reflect instrumentation we failed to handle > calls to aliases since they appear to have no body. Instead resort > to symtab node availability. The patch also avoids touching > internal function calls in a more obvious way (builtins might > have a body available). > > profiledbootstrap & regtest running on x86_64-unknown-linux-gnu. > > Honza - does this look OK? Honza - ping! > PR tree-optimization/109304 > * tree-profile.cc (tree_profiling): Use symtab node > availability to decide whether to skip adjusting calls. > Do not adjust calls to internal functions. > > * gcc.dg/pr109304.c: New testcase. > --- > gcc/testsuite/gcc.dg/pr109304.c | 12 ++++++++++++ > gcc/tree-profile.cc | 9 ++++++--- > 2 files changed, 18 insertions(+), 3 deletions(-) > create mode 100644 gcc/testsuite/gcc.dg/pr109304.c > > diff --git a/gcc/testsuite/gcc.dg/pr109304.c b/gcc/testsuite/gcc.dg/pr109304.c > new file mode 100644 > index 00000000000..d435b04d4d5 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/pr109304.c > @@ -0,0 +1,12 @@ > +/* { dg-do compile } */ > +/* { dg-require-profiling "-fprofile-generate" } */ > +/* { dg-require-effective-target fpic } */ > +/* { dg-options "-O3 -fprofile-generate -fPIC -fno-semantic-interposition" } */ > + > +int PyUnicode_FindChar_i; > +int PyUnicode_FindChar() > +{ > + while (PyUnicode_FindChar_i) > + if (PyUnicode_FindChar()) > + break; > +} > diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc > index 6f9a43e4bd5..da300d5f9e8 100644 > --- a/gcc/tree-profile.cc > +++ b/gcc/tree-profile.cc > @@ -808,7 +808,7 @@ tree_profiling (void) > { > if (!gimple_has_body_p (node->decl) > || !(!node->clone_of > - || node->decl != node->clone_of->decl)) > + || node->decl != node->clone_of->decl)) > continue; > > /* Don't profile functions produced for builtin stuff. */ > @@ -842,12 +842,15 @@ tree_profiling (void) > for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) > { > gcall *call = dyn_cast (gsi_stmt (gsi)); > - if (!call) > + if (!call || gimple_call_internal_p (call)) > continue; > > /* We do not clear pure/const on decls without body. */ > tree fndecl = gimple_call_fndecl (call); > - if (fndecl && !gimple_has_body_p (fndecl)) > + cgraph_node *callee; > + if (fndecl > + && (callee = cgraph_node::get (fndecl)) > + && callee->get_availability (node) == AVAIL_NOT_AVAILABLE) > continue; > > /* Drop the const attribute from the call type (the pure > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)