http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46815

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2010-12-06 
15:39:51 UTC ---
Created attachment 22660
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22660
gcc46-pr46815.patch

Ugh.  So what happens is that we set DECL_VALUE_EXPR of the NRV optimized var
to RESULT_DECL, but then in cp_genericize as it is addressable change the
RESULT_DECL into DECL_BY_REFERENCE decl and convert_from_reference whenever it
is seen in the stmts (but don't adjust the DECL_VALUE_EXPR of the var).
Which means we end up using DW_OP_reg3 instead of DW_OP_breg3 0.

Either we can do something like this patch, i.e. replace DECL_VALUE_EXPR during
genericization, or we could do something similar, but faster by saving pointer
to the NRV optimized VAR_DECL somewhere in the lang specific stuff for the
FUNCTION_DECL, or, if we can be 100% sure by finalize_nrv time that
non-addressable RESULT_DECL isn't ever going to turn into TREE_ADDRESSABLE
RESULT_DECL, we could assume early what cp_genericize will do and set
DECL_VALUE_EXPR in finalize_nrv to INDIRECT_REF of the RESULT_DECL (which would
mean somewhat invalid tree until cp_genericize is run, but perhaps nothing
would notice), or we could teach dwarf2out.c if it uses DECL_VALUE_EXPR and it
points to DECL_BY_REFERENCE decl that it should add indirection automatically
(but then, the question is what all will actually break by that).

Jason, any preferences?

Reply via email to