------- Comment #4 from matz at gcc dot gnu dot org 2009-05-01 17:22 -------
That shouldn't happen yes. We are trying to expand
__fixunstfdi (D.1248_5)
As far as the gimple side is concerned this is a normal pass-by-value call
hence the SSA name therein is perfectly fine. But it seems the setup for
this call transforms it into actually being passed by reference:
#6 0x00000000005b0d41 in precompute_register_parameters (num_actuals=1,
args=0x7fffffff6340, reg_parm_seen=0x7fffffff654c)
at ../../gcc/gcc/calls.c:677
677 args[i].value = expand_normal (args[i].tree_value);
(gdb) p debug_generic_expr (args[i].tree_value)
&D.1248_5
That comes at a surprise for the expander because you can't take addresses
of SSA names as easily, the object therein needs to be marked as having the
address taken. Even if we would handle SSA names like VAR_DECLs in
expand_expr_addr_expr_1 it wouldn't help. Those are simply expanded and
then its expected that the returned thing is a MEM_P. Which it normally
isn't for SSA names, it will be a pseudo reg, so the other assert would
trigger:
if (DECL_P (exp)
...
result = expand_expr (exp, target, tmode,
modifier == EXPAND_INITIALIZER
? EXPAND_INITIALIZER : EXPAND_CONST_ADDRESS);
/* If the DECL isn't in memory, then the DECL wasn't properly
marked TREE_ADDRESSABLE, which will be either a front-end
or a tree optimizer bug. */
gcc_assert (MEM_P (result));
I see code in initialize_argument_information (around calls.c:1072) which
reads as if it wants to deal with this issue, copying the real argument to
some temporary storage and passing the address of that temporary storage.
But it takes the shortcut route at calls.c:1061:
if (call_from_thunk_p
|| (callee_copies
&& !TREE_ADDRESSABLE (type)
&& (base = get_base_address (args[i].tree_value))
&& (!DECL_P (base) || MEM_P (DECL_RTL (base)))))
{
/* We can't use sibcalls if a callee-copied argument is
stored in the current function's frame. */
if (!call_from_thunk_p && DECL_P (base) && !TREE_STATIC (base))
*may_tailcall = false;
args[i].tree_value = build_fold_addr_expr (args[i].tree_value);
It is taken because SSA-names are !DECL_P. We probably have to handle SSA
names here as if they are DECLs with a REG_P DECL_RTL. At least the patch
below will fix the compilation of the testcase, if you could give it a test
that would be nice:
Index: calls.c
===================================================================
--- calls.c (Revision 146955)
+++ calls.c (Arbeitskopie)
@@ -1054,6 +1054,7 @@ initialize_argument_information (int num
|| (callee_copies
&& !TREE_ADDRESSABLE (type)
&& (base = get_base_address (args[i].tree_value))
+ && TREE_CODE (base) != SSA_NAME
&& (!DECL_P (base) || MEM_P (DECL_RTL (base)))))
{
/* We can't use sibcalls if a callee-copied argument is
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39977