[PATCH] middle-end/95493 - bogus MEM_ATTRS for variable array access

Eric Botcazou botcazou@adacore.com
Thu Jun 4 16:20:36 GMT 2020


> I'll go with this variant since it is more obvious unless I hear
> otherwise.

Yes, at least this one doesn't appear to further confuse an already confusing 
implementation. ;-)

> Thanks,
> Richard.
> 
> 
> The following patch avoids keeping the inherited MEM_ATTRS when
> set_mem_attributes_minus_bitpos is called with a variable ARRAY_REF.
> The inherited ones may not reflect the correct offset and neither
> does the updated alias-set match the inherited MEM_EXPR.  This all
> ends up confusing path-based alias-analysis, causing wrong-code.

"variable ARRAY_REF" is just an ARRAY_REF with variable index or an ARRAY_REF 
whose base is variable?  In other words, do we end up taking the 

	  /* Else do not record a MEM_EXPR.  */

path instead of setting attrs.expr again?

> The fix is to stop not adopting a MEM_EXPR for certain kinds of
> expressions and instead handle everything we can.  There's still
> the constant kind trees case which I'm too lazy to look into right
> now.  I did refrain from adding SSA_NAME there and instead avoided
> calling set_mem_attributes_minus_bitpos when debug expression
> expansion ended up expanding a SSA definition RHS which should
> already have taken care of setting the appropriate MEM_ATTRS.

Do we really need to ditch the entire ARRAY_REF path though?  Aren't we going 
to lose some (trivial) disambiguation possibilities later on by recording the 
ARRAY_REF instead of DECL or COMPONENT_REF (+ offset)?

-- 
Eric Botcazou


More information about the Gcc-patches mailing list