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. 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. It also avoids calling set_mem_attributes on the DECL_INITIAL of a CONST_DECL which seems pointless since there cannot be a sensible MEM_EXPR derived from that. We're overwriting both other possibly useful info, alias-set and alignment immediately so the following patch simply removes the call instead of making the function deal with even more (unexpected) trees that are not memory accesses. 2020-06-23 Richard Biener <rguenther@suse.de> PR middle-end/95493 PR middle-end/95690 * cfgexpand.c (expand_debug_expr): Avoid calling set_mem_attributes_minus_bitpos when we were expanding an SSA name. * emit-rtl.c (set_mem_attributes_minus_bitpos): Remove ARRAY_REF special-casing, add CONSTRUCTOR to the set of special-cases we do not want MEM_EXPRs for. Assert we end up with reasonable MEM_EXPRs. * varasm.c (build_constant_desc): Remove set_mem_attributes call. * g++.dg/torture/pr95493.C: New testcase. * g++.dg/torture/pr95493-1.C: Likewise. * gfortran.dg/pr95690.f90: Likewise.
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
ada | Loading commit data... | |
brig.dg | Loading commit data... | |
c-c++-common | Loading commit data... | |
config | Loading commit data... | |
g++.dg | Loading commit data... | |
g++.old-deja | Loading commit data... | |
g++.target | Loading commit data... | |
gcc.c-torture | Loading commit data... | |
gcc.dg | Loading commit data... | |
gcc.dg-selftests | Loading commit data... | |
gcc.misc-tests | Loading commit data... | |
gcc.src | Loading commit data... | |
gcc.target | Loading commit data... | |
gcc.test-framework | Loading commit data... | |
gdc.dg | Loading commit data... | |
gdc.test | Loading commit data... | |
gfortran.dg | Loading commit data... | |
gfortran.fortran-torture | Loading commit data... | |
gnat.dg | Loading commit data... | |
go.dg | Loading commit data... | |
go.go-torture/execute | Loading commit data... | |
go.test | Loading commit data... | |
jit.dg | Loading commit data... | |
lib | Loading commit data... | |
obj-c++.dg | Loading commit data... | |
objc | Loading commit data... | |
objc-obj-c++-shared | Loading commit data... | |
objc.dg | Loading commit data... | |
selftests | Loading commit data... | |
.gitattributes | Loading commit data... | |
ChangeLog | Loading commit data... | |
ChangeLog-1993-2007 | Loading commit data... | |
ChangeLog-2008 | Loading commit data... | |
ChangeLog-2009 | Loading commit data... | |
ChangeLog-2010 | Loading commit data... | |
ChangeLog-2011 | Loading commit data... | |
ChangeLog-2012 | Loading commit data... | |
ChangeLog-2013 | Loading commit data... | |
ChangeLog-2014 | Loading commit data... | |
ChangeLog-2015 | Loading commit data... | |
ChangeLog-2016 | Loading commit data... | |
ChangeLog-2017 | Loading commit data... | |
ChangeLog-2018 | Loading commit data... | |
ChangeLog-2019 | Loading commit data... | |
ChangeLog.graphite | Loading commit data... | |
ChangeLog.jit | Loading commit data... | |
ChangeLog.ptr | Loading commit data... | |
ChangeLog.tree-ssa | Loading commit data... | |
README | Loading commit data... | |
README.compat | Loading commit data... | |
README.gcc | Loading commit data... |