This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix lto bootstrap


On Mon, 4 Oct 2010, Jan Hubicka wrote:

> > 
> > Please use mem_ref_offset (base).low * BITS_PER_UNIT.  Note that
> > the overflow check is wrong as you are multiplying with BITS_PER_UNIT.
> 
> Updated, thanks. I am aware that the overflow checks are off, still hope to
> solve it with double_ints along wth same problem at the side of
> get_ref_base_and_offset.
> > 
> > Using get_addr_base_and_unit_offset () throughout folding and
> > handling bit-field references explicitly would avoid this.
> > Consider following up with such cleanup (or I might take a stab
> > at the code if you like).
> 
> Well, I see here two options.  Either stick with bit offsets and convert
> to double_ints or convert to get_addr_base_and_unit_offset and add one
> extra function for consturctor walks handling bitfields.
> 
> In a way first option seems better for me since
> 
>  1) we avoid code duplication in constructor walking
>  2) it fits better to the existing aliasing machinery (i.e. my patch
>     to take use of sccvn's ao_* function I sent yesterday)
>  3) pretty much all aritmetics in the folding is already double int as
>     we take user declarations and can't assume much about them...
>  4) this example shows how recursive handling of references have problem.
>     Consider bitfield reference of type
>     MEM[base+40].bitfield.
>     Where base is array of structures of size 40. 
> 
> But it is your area, so if you think get_addr_base_and_unit_offset
> works better, I will update the code, it is not difficult.  I see that pros
> for the section option si
> 
>  1) it would be bit faster
>  2) get_addr_base_and_unit_offset already give up on variable array accesses.

I'd like to convert the alias-oracle to use byte-offsets as well,
bits aren't addressable.  The extra loop over constructors would be
one simply matching field-decls, as you'd always have these.
Again we'll eventually have lowered bitfield accesses already.

So yes, I think get_addr_base_and_unit_offset is exactly what we want
here.

Richard.

> Honza
> > 
> > Ok with that change.
> > 
> > Thanks,
> > Richard.
> > 
> > > ! 	}
> > >   
> > >         base = get_constant_value (TREE_OPERAND (base, 0));
> > >         if (!base || TREE_CODE (base) != ADDR_EXPR)
> > > *************** get_base_constructor (tree base, tree *o
> > > *** 1359,1365 ****
> > >   
> > >       case ARRAY_REF:
> > >       case COMPONENT_REF:
> > > !       return fold_const_aggregate_ref (base);
> > >         break;
> > >   
> > >       case STRING_CST:
> > > --- 1367,1377 ----
> > >   
> > >       case ARRAY_REF:
> > >       case COMPONENT_REF:
> > > !       base = get_ref_base_and_extent (base, &bit_offset2, &size, &max_size);
> > > !       if (max_size == -1 || size != max_size)
> > > ! 	return NULL_TREE;
> > > !       *bit_offset +=  bit_offset2;
> > > !       return get_base_constructor (base, bit_offset);
> > >         break;
> > >   
> > >       case STRING_CST:
> > > *************** fold_const_aggregate_ref (tree t)
> > > *** 1597,1603 ****
> > >     tree ctor, idx, base;
> > >     HOST_WIDE_INT offset, size, max_size;
> > >     tree tem;
> > > -   tree ctr_offset;
> > >   
> > >     if (TREE_CODE_CLASS (TREE_CODE (t)) == tcc_declaration)
> > >       return get_symbol_constant_value (t);
> > > --- 1609,1614 ----
> > > *************** fold_const_aggregate_ref (tree t)
> > > *** 1633,1645 ****
> > >   	      offset *= BITS_PER_UNIT;
> > >   
> > >   	      base = TREE_OPERAND (t, 0);
> > > ! 	      ctor = get_base_constructor (base, &ctr_offset);
> > > ! 	      if (ctr_offset)
> > > ! 		{
> > > ! 		  if (!host_integerp (ctr_offset, 1))
> > > ! 		    return NULL_TREE;
> > > ! 		  offset += TREE_INT_CST_LOW (ctr_offset) * BITS_PER_UNIT;
> > > ! 		}
> > >   	      /* Empty constructor.  Always fold to 0. */
> > >   	      if (ctor == error_mark_node)
> > >   		return build_zero_cst (TREE_TYPE (t));
> > > --- 1644,1650 ----
> > >   	      offset *= BITS_PER_UNIT;
> > >   
> > >   	      base = TREE_OPERAND (t, 0);
> > > ! 	      ctor = get_base_constructor (base, &offset);
> > >   	      /* Empty constructor.  Always fold to 0. */
> > >   	      if (ctor == error_mark_node)
> > >   		return build_zero_cst (TREE_TYPE (t));
> > > *************** fold_const_aggregate_ref (tree t)
> > > *** 1661,1667 ****
> > >       case TARGET_MEM_REF:
> > >       case MEM_REF:
> > >         base = get_ref_base_and_extent (t, &offset, &size, &max_size);
> > > !       ctor = get_base_constructor (base, &ctr_offset);
> > >   
> > >         /* Empty constructor.  Always fold to 0. */
> > >         if (ctor == error_mark_node)
> > > --- 1666,1672 ----
> > >       case TARGET_MEM_REF:
> > >       case MEM_REF:
> > >         base = get_ref_base_and_extent (t, &offset, &size, &max_size);
> > > !       ctor = get_base_constructor (base, &offset);
> > >   
> > >         /* Empty constructor.  Always fold to 0. */
> > >         if (ctor == error_mark_node)
> > > *************** fold_const_aggregate_ref (tree t)
> > > *** 1673,1684 ****
> > >         if (!ctor)
> > >   	return NULL_TREE;
> > >   
> > > -       if (ctr_offset)
> > > - 	{
> > > - 	  if (!host_integerp (ctr_offset, 1))
> > > - 	    return NULL_TREE;
> > > - 	  offset += TREE_INT_CST_LOW (ctr_offset) * BITS_PER_UNIT;
> > > - 	}
> > >         /* Out of bound array access.  Value is undefined, but don't fold. */
> > >         if (offset < 0)
> > >   	return NULL_TREE;
> > > --- 1678,1683 ----
> > > 
> > > 
> > 
> > -- 
> > Richard Guenther <rguenther@suse.de>
> > Novell / SUSE Labs
> > SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex
> 
> 

-- 
Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]