From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52171 invoked by alias); 25 Feb 2015 09:19:50 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 52159 invoked by uid 89); 25 Feb 2015 09:19:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KAM_FROM_URIBL_PCCC,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-wg0-f51.google.com Received: from mail-wg0-f51.google.com (HELO mail-wg0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 25 Feb 2015 09:19:48 +0000 Received: by wghl2 with SMTP id l2so2294473wgh.9 for ; Wed, 25 Feb 2015 01:19:45 -0800 (PST) X-Received: by 10.180.108.177 with SMTP id hl17mr38267472wib.35.1424855985171; Wed, 25 Feb 2015 01:19:45 -0800 (PST) Received: from msticlxl57.ims.intel.com ([192.55.55.41]) by mx.google.com with ESMTPSA id lu13sm24234816wic.10.2015.02.25.01.19.42 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Feb 2015 01:19:44 -0800 (PST) Date: Wed, 25 Feb 2015 09:36:00 -0000 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH, CHKP, PR target/65183] Avoid wrong pass local data usage Message-ID: <20150225091930.GA65329@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes X-SW-Source: 2015-02/txt/msg01455.txt.bz2 Hi, This patch fixes a case when outdated checker local data is used to process external calls. Bootstrapped and tested on x86_64-unknown-linux-gnu. OK for trunk? Thanks, Ilya -- gcc/ 2015-02-25 Ilya Enkovich PR target/65183 * tree-chkp.c (chkp_check_lower): Don't check against zero bounds for already instrumented functions. (chkp_check_upper): Likewise. (chkp_fini): Clean pass local data to avoid wrong reusage. gcc/testsuite/ 2015-02-25 Ilya Enkovich PR target/65183 * gcc.target/i386/pr65183.c: New. diff --git a/gcc/testsuite/gcc.target/i386/pr65183.c b/gcc/testsuite/gcc.target/i386/pr65183.c new file mode 100644 index 0000000..069a543 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr65183.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ +/* { dg-options "-O -fcheck-pointer-bounds -fchkp-use-nochk-string-functions -mmpx" } */ + +extern void bar(void *); +extern void baz(void); + +static int lc[32]; + +void foobar(void *c) +{ + bar(&c); + __builtin_memcpy (lc, c, lc[0]); +} + +void foo () +{ + baz (); + foobar(0); +} diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index b0a3a15..d2df4ba 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -1268,7 +1268,8 @@ chkp_check_lower (tree addr, tree bounds, gimple check; tree node; - if (bounds == chkp_get_zero_bounds ()) + if (!chkp_function_instrumented_p (current_function_decl) + && bounds == chkp_get_zero_bounds ()) return; if (dirflag == integer_zero_node @@ -1314,7 +1315,8 @@ chkp_check_upper (tree addr, tree bounds, gimple check; tree node; - if (bounds == chkp_get_zero_bounds ()) + if (!chkp_function_instrumented_p (current_function_decl) + && bounds == chkp_get_zero_bounds ()) return; if (dirflag == integer_zero_node @@ -4306,6 +4308,10 @@ chkp_fini (void) free_dominance_info (CDI_POST_DOMINATORS); bitmap_obstack_release (NULL); + + entry_block = NULL; + zero_bounds = NULL_TREE; + none_bounds = NULL_TREE; } /* Main instrumentation pass function. */