From patchwork Wed Jun 11 08:24:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 358511 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 B72C51400B2 for ; Wed, 11 Jun 2014 18:25:13 +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:subject:message-id:mime-version:content-type; q=dns; s= default; b=EeZbjIf66Uc0vVCfND6xOmZW/6+hlgTpB8HH5rXqn0jnJwSfuE62O PA2Rhx6cmS+VYod/CrbFHylkPKFUFmimt9LlUmMMdBUaFc93RHaNCixuO2EjIN8t DoXNIT2XM7EsOzRZ+ndGQFF2f2gGO17Rk52/a4MvlccCuCiCAqtiP4= 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:subject:message-id:mime-version:content-type; s= default; bh=d8Tc0RXfH266qZsFDOCfF2S9n6M=; b=siEBtUmsY8hCK4RZcKt1 QJBO2ACEyuIpDrWXgJg2qBVnokT/DPOwD34RJUVmc+b1US5CvxyK95cf2N2vx7fc CnTF7Msl+hzHB9XneBEbw4STCUcwm+xYHDaq95mC8A/z5g3xiFWCnr9XwrNjVait m01okn667IfuMxbfn02dOHg= Received: (qmail 9709 invoked by alias); 11 Jun 2014 08:25:06 -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 9699 invoked by uid 89); 11 Jun 2014 08:25:06 -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-f49.google.com Received: from mail-pa0-f49.google.com (HELO mail-pa0-f49.google.com) (209.85.220.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 11 Jun 2014 08:25:05 +0000 Received: by mail-pa0-f49.google.com with SMTP id lj1so785275pab.22 for ; Wed, 11 Jun 2014 01:25:03 -0700 (PDT) X-Received: by 10.68.234.2 with SMTP id ua2mr3156627pbc.81.1402475103279; Wed, 11 Jun 2014 01:25:03 -0700 (PDT) Received: from msticlxl57.ims.intel.com (fmdmzpr03-ext.fm.intel.com. [192.55.54.38]) by mx.google.com with ESMTPSA id jt7sm73597722pbc.46.2014.06.11.01.25.01 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jun 2014 01:25:02 -0700 (PDT) Date: Wed, 11 Jun 2014 12:24:57 +0400 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH, Pointer Bounds Checker 28/x] IPA CP Message-ID: <20140611081943.GB17894@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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)) { /* 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) { 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; + } + for (; (i < args_count) && (i < parms_count); i++) { struct ipa_jump_func *jump_func = ipa_get_ith_jump_func (args, i);