diff mbox

Fix uninitialized memory use from ipa-prop.c (PR bootstrap/52041)

Message ID 20120131082105.GM18768@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Jan. 31, 2012, 8:21 a.m. UTC
Hi!

Another thing discovered by valgrind on the same testcase.
The problem was that ao.volatile_p field, added recently, hasn't
been initialized in this spot.  I think it is safer to use ao_ref_init,
so that the next time some field is added the situation won't repeat.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2012-01-31  Jakub Jelinek  <jakub@redhat.com>

	PR bootstrap/52041
	PR bootstrap/52039
	PR target/51974
	* ipa-prop.c (detect_type_change_1): Call ao_ref_init.


	Jakub

Comments

Richard Biener Jan. 31, 2012, 9:57 a.m. UTC | #1
On Tue, 31 Jan 2012, Jakub Jelinek wrote:

> Hi!
> 
> Another thing discovered by valgrind on the same testcase.
> The problem was that ao.volatile_p field, added recently, hasn't
> been initialized in this spot.  I think it is safer to use ao_ref_init,
> so that the next time some field is added the situation won't repeat.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2012-01-31  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR bootstrap/52041
> 	PR bootstrap/52039
> 	PR target/51974
> 	* ipa-prop.c (detect_type_change_1): Call ao_ref_init.
> 
> --- gcc/ipa-prop.c.jj	2011-12-14 08:11:03.000000000 +0100
> +++ gcc/ipa-prop.c	2012-01-30 23:05:03.270693995 +0100
> @@ -442,13 +442,11 @@ detect_type_change_1 (tree arg, tree bas
>    if (!flag_devirtualize || !gimple_vuse (call))
>      return false;
>  
> -  ao.ref = arg;
> +  ao_ref_init (&ao, arg);
>    ao.base = base;
>    ao.offset = offset;
>    ao.size = POINTER_SIZE;
>    ao.max_size = ao.size;
> -  ao.ref_alias_set = -1;
> -  ao.base_alias_set = -1;
>  
>    tci.offset = offset;
>    tci.object = get_base_address (arg);
> 
> 	Jakub
> 
>
diff mbox

Patch

--- gcc/ipa-prop.c.jj	2011-12-14 08:11:03.000000000 +0100
+++ gcc/ipa-prop.c	2012-01-30 23:05:03.270693995 +0100
@@ -442,13 +442,11 @@  detect_type_change_1 (tree arg, tree bas
   if (!flag_devirtualize || !gimple_vuse (call))
     return false;
 
-  ao.ref = arg;
+  ao_ref_init (&ao, arg);
   ao.base = base;
   ao.offset = offset;
   ao.size = POINTER_SIZE;
   ao.max_size = ao.size;
-  ao.ref_alias_set = -1;
-  ao.base_alias_set = -1;
 
   tci.offset = offset;
   tci.object = get_base_address (arg);