This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Speed-up use-after-scope (re-writing to SSA) (version 2)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Martin Liška <mliska at suse dot cz>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 19 Jan 2017 17:33:58 +0100
- Subject: Re: [PATCH] Speed-up use-after-scope (re-writing to SSA) (version 2)
- Authentication-results: sourceware.org; auth=none
- References: <20161116162841.GX3541@tucnak.redhat.com> <c02f7364-44ed-406f-cee4-7b1fc8899f75@suse.cz> <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> <c371b68c-6d86-abe2-8eec-1438376b4c10@suse.cz>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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