[tree-ssa] Simplifying TARGET_EXPR

Jason Merrill jason@redhat.com
Tue Jul 16 09:52:00 GMT 2002


Thinking about simplifying TARGET_EXPR, I see two issues to be dealt with:

1) expand_expr's treatment of TARGET_EXPR depends on whether or not it is
   being expanded with a target: if so, it initializes the target object;
   if not, it initializes a new object.  There's no way to model that
   behavior with the current simplification code, as there's no concept
   of 'target'.

   However, I think that the copy-elision should only occur under an
   INIT_EXPR, so we can check for TARGET_EXPR in simplify_modify_expr.
   This should work fine.

2) Passing a TARGET_EXPR to a call means initializing the temporary on the
   stack and passing its address to the call.  There's no way to express
   this in a simplified form; if we replace the TARGET_EXPR with the
   variable it initializes, expand_call will make a bitwise copy, which is
   wrong.  I can think of two solutions to this:

   a) Change expand_call to not copy variables with DECL_ARTIFICIAL set.
   b) Pass an ADDR_EXPR of the variable instead, and change expand_call
      to handle that case.

   My preference is for (b), as (a) might have unintended consequences.

Thoughts?

Jason



More information about the Gcc mailing list