This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[vta,vta4.3] don't change attributes of DECL_RTXs expanding debug stmts
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 10 Sep 2008 05:20:27 -0300
- Subject: [vta,vta4.3] don't change attributes of DECL_RTXs expanding debug stmts
Another difference detected with -fcompare-debug. A DECL for a
struct-typed variable, having its single field accessed in a debug
stmt, would cause the attributes of the MEM in the DECL's DECL_RTL to
be modified.
The difference I ran into was an unexpected /j (MEM_KEEP_ALIAS_SET_P)
showing up in the MEM, which IIRC caused even differences in alias
analysis. Nothing that caused differences in executable code, in the
testcase I had, but I'm pretty sure it could cause such differences
for more elaborate testcases.
This patch ensures the MEM is preserved, making a shallow copy and
modifying the attributes of the copy.
for gcc/ChangeLog.vta
from Alexandre Oliva <aoliva@redhat.com>
* cfgexpand.c (expand_debug_expr): Don't modify pre-existing MEMs.
Index: gcc/cfgexpand.c
===================================================================
--- gcc/cfgexpand.c.orig 2008-09-05 03:09:53.000000000 -0300
+++ gcc/cfgexpand.c 2008-09-05 03:11:29.000000000 -0300
@@ -2151,8 +2151,9 @@ expand_debug_expr (tree exp)
int volatilep = 0;
tree tem = get_inner_reference (exp, &bitsize, &bitpos, &offset,
&mode1, &unsignedp, &volatilep, false);
+ rtx orig_op0;
- op0 = expand_debug_expr (tem);
+ orig_op0 = op0 = expand_debug_expr (tem);
if (!op0)
return NULL;
@@ -2181,6 +2182,8 @@ expand_debug_expr (tree exp)
op0 = adjust_address_nv (op0, mode1, 0);
else
op0 = copy_rtx (op0);
+ if (op0 == orig_op0)
+ op0 = shallow_copy_rtx (op0);
set_mem_attributes (op0, exp, 0);
}
--
Alexandre Oliva http://www.lsd.ic.unicamp.br/~oliva/
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}
FSFLA Board Member ÂSÃ Libre! => http://www.fsfla.org/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}