Reuse non-gimple_reg variable for inlining
When a call to a function is inlined and takes a parameter whose type is not
gimple_reg, a local variable is created in the caller to hold a copy of the
argument passed in the call with the following comment:
/* We may produce non-gimple trees by adding NOPs or introduce
invalid sharing when operand is not really constant.
It is not big deal to prohibit constant propagation here as
we will constant propagate in DOM1 pass anyway. *
Of course the second sentence of the comment does not apply to non-gimple_reg
values, unless they get SRAed later, because we don't do constant propagation
for them. This for example prevents two identical calls to a pure function
from being merged in the attached Ada testcase.
Therefore the attached patch attempts to reuse a read-only or non-addressable
local DECL of the caller, the hitch being that expand_call_inline needs to be
prevented from creating a CLOBBER for the case where it ends uo being reused.
gcc/
* tree-inline.c (insert_debug_decl_map): Delete.
(copy_debug_stmt): Minor tweak.
(setup_one_parameter): Do not use a variable if the value is either
a read-only DECL or a non-addressable local variable in the caller.
In this case, insert the debug-only variable in the map manually.
(expand_call_inline): Do not generate a CLOBBER for these values.
* tree-inline.h (debug_map): Minor tweak.