This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PR middle-end/44878 & REFERENCE variable mode & IA64 32 bit mode


I am looking at PR 44787 where IA64 HP-UX (in 32 bit mode) is failing to
compile this test case:

class e {
      public:
      e(void* __e);
      e(const e&);
    };
void * v() { }
e foo() { return e(v()); }

This test dies trying to copy an SImode register to a DImode register
and emit_move_insn complains because the modes don't match.  Tracking
this back showed me that the failure starts with r161898 (partial inlining)
where needs_to_live_in_memory was changed so that it no longer returns
true for reference arguments.  Undoing that change results in a good compiler
but I think the code (as it is) should be OK, we can just pass the
reference as a pointer which I think is what the compiler is trying to do,
it is just confused about whether to pass it in SImode (ptr_mode) or
DImode (Pmode) on IA64 in 32 bit mode.

I am looking for advice on where and how to fix it (should I pass reference
arguments in SImode or DImode).  I think they should be passed like pointers
in SImode (since pointers are SImode 

I had good luck modifying assign_parms with this patch:

Index: function.c
===================================================================
--- function.c  (revision 161898)
+++ function.c  (working copy)
@@ -3317,7 +3317,7 @@ assign_parms (tree fndecl)
       rtx x;
 
       if (DECL_BY_REFERENCE (result))
-       x = addr;
+       x = convert_memory_address (ptr_mode, addr);
       else
        {
          addr = convert_memory_address (Pmode, addr);

But I am not sure if this is the right fix either.  I looked into
why addr was in Pmode (instead of ptr_mode) to begin with and it
seems to come from promote_mode. assign_parm_setup_reg is calling
promote_function_mode (with a reference), that calls promote_mode,
and for a reference promote_mode calls targetm.addr_space.address_mode
which returns Pmode.  So that is how I get Pmode to start with.

I modified the IA64 specific promote_function_mode to return ptr_mode
for reference types:

#ifdef POINTERS_EXTEND_UNSIGNED
  if (TREE_CODE (type) == REFERENCE_TYPE)
    return ptr_mode;
#endif

but that resulted in a ICE in expand_expr_real_1.  Any attempts to
change this function (or the address_mode function) seem to affect
other areas of the compilation and result in various ICE failures.

Any comments on the working patch or on where this change should
be made?

Steve Ellcey
sje@cup.hp.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]