From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 78515 invoked by alias); 19 Jan 2017 16:34:07 -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 78463 invoked by uid 89); 19 Jan 2017 16:34:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.1 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=sk:tree_th, sk:TREE_TH, gsi_remove, Hx-languages-length:1282 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, 19 Jan 2017 16:34:05 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (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 0EE9C76E4; Thu, 19 Jan 2017 16:34:05 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-250.ams2.redhat.com [10.36.116.250]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0JGY3CY003607 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 19 Jan 2017 11:34:04 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id v0JGY0U6030647; Thu, 19 Jan 2017 17:34:01 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v0JGXxGD030646; Thu, 19 Jan 2017 17:33:59 +0100 Date: Thu, 19 Jan 2017 16:43: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: <20170119163358.GQ1867@tucnak> Reply-To: Jakub Jelinek References: <20161116162841.GX3541@tucnak.redhat.com> <20161221085200.GS21933@tucnak> <4ec48432-9df6-154a-1b13-065b9772cbbf@suse.cz> <20161222172140.GF21933@tucnak> <29d32a7c-a95d-ddb1-d64e-ae8f659d3a4b@suse.cz> <20170116142025.GO1867@tucnak> <7e7f795d-a7a7-584e-8c77-61ea01207c40@suse.cz> <20170117164721.GE1867@tucnak> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes X-SW-Source: 2017-01/txt/msg01491.txt.bz2 On Wed, Jan 18, 2017 at 04:34:48PM +0100, Martin Liška wrote: > Hello. > > During bootstrap, I came to following test-case: > > struct A > { > int regno; > }; > struct > { > A base; > } typedef *df_ref; > int *a; > void > fn1 (int N) > { > for (int i = 0; i < N; i++) > { > df_ref b; > a[(b)->base.regno]++; > } > } Well, in this case it is UB too, just not actually out of bounds access, but use of uninitialized variable. Perhaps what we should do, in addition to turning ASAN_MARK (POISON, &b, ...) into b = ASAN_POISON (); turn ASAN_MARK (UNPOISON, &b, ...) into b = b_YYY(D); The following seems to do the job: --- gcc/tree-ssa.c.jj 2017-01-19 17:20:15.000000000 +0100 +++ gcc/tree-ssa.c 2017-01-19 17:29:58.015356370 +0100 @@ -1911,7 +1911,16 @@ execute_update_addresses_taken (void) gsi_replace (&gsi, call, GSI_SAME_STMT); } else - gsi_remove (&gsi, true); + { + /* In ASAN_MARK (UNPOISON, &b, ...) the variable + is uninitialized. Avoid dependencies on + previous out of scope value. */ + tree clobber + = build_constructor (TREE_TYPE (var), NULL); + TREE_THIS_VOLATILE (clobber) = 1; + gimple *g = gimple_build_assign (var, clobber); + gsi_replace (&gsi, g, GSI_SAME_STMT); + } continue; } } Jakub