From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 55212 invoked by alias); 22 Dec 2016 17:21:51 -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 55187 invoked by uid 89); 22 Dec 2016 17:21:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=0.00, differentiate, hash_map, src_fn X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Dec 2016 17:21:49 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 428097FD59; Thu, 22 Dec 2016 17:21:48 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-54.ams2.redhat.com [10.36.116.54]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uBMHLjst002139 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 22 Dec 2016 12:21:47 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id uBMHLhiT006384; Thu, 22 Dec 2016 18:21:44 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id uBMHLeVx006373; Thu, 22 Dec 2016 18:21:40 +0100 Date: Thu, 22 Dec 2016 17:28:00 -0000 From: Jakub Jelinek To: Martin =?utf-8?B?TGnFoWth?= Cc: Richard Biener , GCC Patches Subject: Re: [PATCH] Speed-up use-after-scope (re-writing to SSA) (version 2) Message-ID: <20161222172140.GF21933@tucnak> Reply-To: Jakub Jelinek References: <20161102130612.GR3541@tucnak.redhat.com> <774a5d54-30f6-3212-ea4c-21e751356055@suse.cz> <20161116130733.GT3541@tucnak.redhat.com> <469bf86a-e43c-c571-66e4-87db78b6fb11@suse.cz> <20161116162841.GX3541@tucnak.redhat.com> <20161221085200.GS21933@tucnak> <4ec48432-9df6-154a-1b13-065b9772cbbf@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4ec48432-9df6-154a-1b13-065b9772cbbf@suse.cz> User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes X-SW-Source: 2016-12/txt/msg01856.txt.bz2 On Thu, Dec 22, 2016 at 06:03:50PM +0100, Martin Liška wrote: > Done by hash_map. Ok. > > 3) I think you just want to do copy_node, plus roughly what > > copy_decl_for_dup_finish does (and set DECL_ARTIFICIAL and > > DECL_IGNORED_P) - except that you don't have copy_body_data > > so you can't use it directly (well, you could create copy_body_data > > just for that purpose and set src_fn and dst_fn to current_function_decl > > and the rest to NULL) > > I decided to use the function with prepared copy_body_data ;) Ok. > > I'd really like to see the storing to poisoned var becoming non-addressable > > in action (if it can ever happen, so it isn't just theoretical) to look at > > what it does. > > Well, having following sample: > > int > main (int argc, char **argv) > { > int *ptr = 0; > > { > int a; > ptr = &a; > *ptr = 12345; > } > > *ptr = 12345; > return *ptr; > } > > Right after rewriting into SSA it looks as follows: > > main (int argc, char * * argv) > { > int a; > int * ptr; > int _8; > > [0.00%]: > a_9 = 12345; > a_10 = ASAN_POISON (); > a_11 = 12345; > _8 = a_11; > return _8; > > } But we do not want to rewrite into SSA that way, but instead as main (int argc, char * * argv) { int a; int * ptr; int _8; [0.00%]: a_9 = 12345; a_10 = ASAN_POISON (); ASAN_POISON (a_10); a_11 = 12345; _8 = a_11; return _8; } or something similar, so that you can 1) emit a diagnostics at the spot where the out of scope store happens 2) differentiate between reads from out of scope var and stores to out of scope var What we need is to hook into tree-into-ssa.c for this, where a_11 is created, find out that there is a store to a var that has ASAN_POISON result as currently active definition. Something like if we emit ASAN_POISON for some var, during tree-into-ssa.c if we see a store to that var that we need to rewrite into SSA pretend there is a read from that var first at that location and if it is result of ASAN_POISON, emit the additional stmt. Jakub