From patchwork Wed Jun 11 13:47:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 358678 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3A1431400A6 for ; Wed, 11 Jun 2014 23:47:55 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=Kg7Hg+FBESHZrUcHB wlXNC7jqfBwhG6AbR2Vch4YYZMyLqnBDkk0XEcC+TYkCWmxUyFBmx9relcqY1EOY AXyAQUNBYsjYlkewyR2eEPF7TOvQ0ve76ZAgqfULnNSaVWRNcLEyGAuo3ldWgx60 DDpN7F1b1Bx/D38FFTzE6NiOiI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=EqWRry+DV/mKniFjVBNrBf5 hJ6s=; b=TkYEDJJuYRFpn3EjEfyO3x9F1iHBSG9IYMEkzMazNR/NJM9qZ2RKEj2 7crIFdWU+Aj6w15X1CvbA/wCB6BCx3kX8aO9UDLE3B+aBMA+MMVvP1Clu2hrd635 nbLwpcEgbMtHxWy9o0B0E8Cod7oMZbhsktWv9JwNiXw0zox2EH1Q= Received: (qmail 11931 invoked by alias); 11 Jun 2014 13:47:48 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 11918 invoked by uid 89); 11 Jun 2014 13:47:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f46.google.com Received: from mail-pa0-f46.google.com (HELO mail-pa0-f46.google.com) (209.85.220.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 11 Jun 2014 13:47:45 +0000 Received: by mail-pa0-f46.google.com with SMTP id eu11so1906517pac.5 for ; Wed, 11 Jun 2014 06:47:43 -0700 (PDT) X-Received: by 10.68.171.193 with SMTP id aw1mr5254847pbc.117.1402494462444; Wed, 11 Jun 2014 06:47:42 -0700 (PDT) Received: from msticlxl57.ims.intel.com ([192.55.55.41]) by mx.google.com with ESMTPSA id gr10sm75113707pbc.84.2014.06.11.06.47.40 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jun 2014 06:47:41 -0700 (PDT) Date: Wed, 11 Jun 2014 17:47:36 +0400 From: Ilya Enkovich To: gcc-patches Cc: mjambor@suse.cz Subject: Re: [PATCH, Pointer Bounds Checker 28/x] IPA CP Message-ID: <20140611134736.GE17894@msticlxl57.ims.intel.com> References: <20140611081943.GB17894@msticlxl57.ims.intel.com> <20140611094556.GB29831@virgil.suse> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes On 11 Jun 15:07, Ilya Enkovich wrote: > 2014-06-11 13:45 GMT+04:00 Martin Jambor : > > Hi, > > > > On Wed, Jun 11, 2014 at 12:24:57PM +0400, Ilya Enkovich wrote: > >> Hi, > >> > >> This patch fixes IPA CP pass to handle instrumented code correctly. > >> > >> Bootstrapped and tested on linux-x86_64. > >> > >> Thanks, > >> Ilya > >> -- > >> gcc/ > >> > >> 2014-06-11 Ilya Enkovich > >> > >> * ipa-cp.c (initialize_node_lattices): Check original > >> version locality for instrumentation clones. > >> (propagate_constants_accross_call): Do not propagate > >> through instrumentation thunks. > >> > >> > >> diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c > >> index 689378a..683b9f0 100644 > >> --- a/gcc/ipa-cp.c > >> +++ b/gcc/ipa-cp.c > >> @@ -699,7 +699,10 @@ initialize_node_lattices (struct cgraph_node *node) > >> int i; > >> > >> gcc_checking_assert (cgraph_function_with_gimple_body_p (node)); > >> - if (!node->local.local) > >> + if (!node->local.local > >> + || (node->instrumentation_clone > >> + && node->instrumented_version > >> + && !node->instrumented_version->local.local)) > > > > This looks quite convoluted, can you please put the test into a new > > predicate in cgraph.c? I assume you had to change other tests of the > > local flag in a similar fashion anyway. > > You are right. Would cgraph_node_local_p be OK? > > > > >> { > >> /* When cloning is allowed, we can assume that externally visible > >> functions are not called. We will compensate this by cloning > >> @@ -1440,7 +1443,8 @@ propagate_constants_accross_call (struct cgraph_edge *cs) > >> alias_or_thunk = cs->callee; > >> while (alias_or_thunk->alias) > >> alias_or_thunk = cgraph_alias_target (alias_or_thunk); > >> - if (alias_or_thunk->thunk.thunk_p) > >> + if (alias_or_thunk->thunk.thunk_p > >> + && !alias_or_thunk->thunk.add_pointer_bounds_args) > > > > so there are thunks that do not change the first argument and so we do > > want to propagate to/through it? > > Yes. Thunks marked as add_pointer_bounds_args do not change arguments, > but add default pointer bounds for all pointer arguments. > > >> { > >> ret |= set_all_contains_variable (ipa_get_parm_lattices (callee_info, > >> 0)); > >> @@ -1449,6 +1453,20 @@ propagate_constants_accross_call (struct cgraph_edge *cs) > >> else > >> i = 0; > >> > >> + /* No propagation through instrumentation thunks is available yet. > >> + It should be possible with proper mapping of call args and > >> + instrumented callee params in the propagation loop below. But > >> + this case mostly occurs when legacy code calls instrumented code > >> + and it is not a primary target for optimizations. */ > >> + if (!alias_or_thunk->instrumentation_clone > >> + && callee->instrumentation_clone) > >> + { > >> + for (; i < parms_count; i++) > >> + ret |= set_all_contains_variable (ipa_get_parm_lattices (callee_info, > >> + i)); > >> + return ret; > >> + } > >> + > > > > and these thunks are different from those marked as > > thunk.add_pointer_bounds_args? If they are not, the previous hunk is > > redundant. > > This check covers more cases. It catches all chains of aliases and > thunks where thunk.add_pointer_bounds_args is met. It does not mean > the first met thunk has thunk.add_pointer_bounds_args (as is in > previous check). I suppose you are right about previous hunk. It > would be better to make wider check first and make exit earlier. Will > fix it. > > > > > My apologies for not looking at the patches introducing all the new > > cgraph_node fields but it is quite difficult to figure out what the > > new tests actually mean (that is why I'd really prefer predicates with > > more explanatory names). > > New predicates are good but do we need them for single usage? Locality > check are used during output and new predicate would be nice for it. > But there is no another thunk.add_pointer_bounds_args chain check used > somewhere else. Will try to make more explanatory comment for it for > now. > > Thanks, > Ilya > > > > > Thanks, > > > > Martin Here is fixed verison. Thanks, Ilya --- gcc/ 2014-06-11 Ilya Enkovich * cgraph.h (cgraph_local_p): New. * ipa-cp.c (initialize_node_lattices): Use cgraph_local_p to handle instrumentation clones properly. (propagate_constants_accross_call): Do not propagate through instrumentation thunks. diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 5e702a7..b225ebe 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -1556,4 +1556,17 @@ symtab_in_same_comdat_p (symtab_node *one, symtab_node *two) { return DECL_COMDAT_GROUP (one->decl) == DECL_COMDAT_GROUP (two->decl); } + +/* Return true if NODE is local. Instrumentation clones are counted as local + only when originla function is local. */ + +static inline bool +cgraph_local_p (cgraph_node *node) +{ + if (!node->instrumentation_clone || !node->instrumented_version) + return node->local.local; + + return node->local.local && node->instrumented_version->local.local; +} + #endif /* GCC_CGRAPH_H */ diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 689378a..4318789 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -699,7 +699,7 @@ initialize_node_lattices (struct cgraph_node *node) int i; gcc_checking_assert (cgraph_function_with_gimple_body_p (node)); - if (!node->local.local) + if (!cgraph_local_p (node)) { /* When cloning is allowed, we can assume that externally visible functions are not called. We will compensate this by cloning @@ -1434,6 +1434,24 @@ propagate_constants_accross_call (struct cgraph_edge *cs) if (parms_count == 0) return false; + /* No propagation through instrumentation thunks is available yet. + It should be possible with proper mapping of call args and + instrumented callee params in the propagation loop below. But + this case mostly occurs when legacy code calls instrumented code + and it is not a primary target for optimizations. + We detect instrumentation thunks in aliases and thunks chain by + checking instrumentation_clone flag for chain source and target. + Going through instrumentation thunks we always have it changed + from 0 to 1 and all other nodes do not change it. */ + if (!cs->callee->instrumentation_clone + && callee->instrumentation_clone) + { + for (i = 0; i < parms_count; i++) + ret |= set_all_contains_variable (ipa_get_parm_lattices (callee_info, + i)); + return ret; + } + /* If this call goes through a thunk we must not propagate to the first (0th) parameter. However, we might need to uncover a thunk from below a series of aliases first. */