This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RFA: fix for mudflap 19319, tree_addressable aggregate returns
- From: "Frank Ch. Eigler" <fche at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 10 Jan 2005 18:29:10 -0500
- Subject: RFA: fix for mudflap 19319, tree_addressable aggregate returns
- Openpgp: id=0xE9BF653D
Hi -
This patch appears to fix the mudflap bug 19319. It may be controversial,
and it changes gimplify.c, so I need a formal ok/nok.
As a recap, the problem is that mudflap instrumentation was not applied
to aggregate variables (e.g. C++ classes) being returned by value from
functions. This was because those VAR_DECLs did not have the
TREE_ADDRESSABLE flag set, even though during rtl expansion, their
addresses are taken. Via those pointers, mudflap-instrumented code
may modify the objects, and thus trigger "valid" mudflap check errors.
This patch sets TREE_ADDRESSABLE on such implicitly addressed lvalues.
(It does so temporarily in that apparently the alias1 tree-ssa pass will
clear off these bits if not needed, in non-mudflap mode.)
Diego looked over the patch and pronounced nonideal but okay. It
passes a bootstrap and appears to cause no testsuite regressions.
(One alternative is making the mudflap1 pass do a nested tree
traversal to find "<aggregate> = CALL_EXPR (...)" occurrences,
instead of just locally checking BIND_EXPR variables, but that's
slow & ugly too.)
Any comments, rth/jason/others?
2005-01-10 Frank Ch. Eigler <fche@redhat.com>
* gimplify.c (gimplify_modify_expr): For mudflap1's benefit, mark
aggregate values being returned by CALL_EXPRs as addressable.
Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gimplify.c,v
retrieving revision 2.101
diff -u -p -r2.101 gimplify.c
--- gimplify.c 1 Jan 2005 01:43:08 -0000 2.101
+++ gimplify.c 10 Jan 2005 23:15:23 -0000
@@ -2949,6 +2949,18 @@ gimplify_modify_expr (tree *expr_p, tree
if (ret != GS_UNHANDLED)
return ret;
+ /* Handle aggregate returns from function calls. We need to mark
+ the LHS addressable, since the expanded call will pass its
+ address as a hidden argument. This necessary for the mudflap1
+ pass. Note that vector types need to be explicitly excluded,
+ or else gimplify_expr can fail. */
+ if ((TREE_CODE (*from_p) == CALL_EXPR)
+ && aggregate_value_p (*to_p, *from_p)
+ && (TREE_CODE (TREE_TYPE (*from_p)) != VECTOR_TYPE))
+ {
+ lang_hooks.mark_addressable (*to_p);
+ }
+
/* If we've got a variable sized assignment between two lvalues (i.e. does
not involve a call), then we can make things a bit more straightforward
by converting the assignment to memcpy or memset. */