https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90448

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu.org,
                   |                            |segher at gcc dot gnu.org

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, seems the second argument of the call is some empty class - struct
._anon_2, 1 byte long, and the FE in the CALL_EXPR passes an empty CONSTRUCTOR
of that type.
The gimplifier then creates a temporary for that (and doesn't initialize it),
so we have:
  struct ._anon_2 D.3223;

  <bb 2> :
  <retval> = fooV<{const char*, int, double, char, float, short int, unsigned
int}>::<lambda(auto:1 ...)>::operator()<fooV<{const char*, int, doubl
e, char, float, short int, unsigned int}>::<lambda(auto:1 ...)>, const char*,
int, double, char, float, short int, unsigned int> (0B, D.3223, _2(D)
, _3(D), _4(D), _5(D), _6(D), _7(D), _8(D)); [return slot optimization]
up to *.optimized in a thunk, D.3223 is not initialized (contains just padding)
and is passed by value to the call.
Now, on powerpc -m32, the ABI wants to pass that by reference -
if (pass_by_reference (args_so_far_pnt, arg))
is true, and we enter:
          /* If we're compiling a thunk, pass through invisible references
             instead of making a copy.  */
          if (call_from_thunk_p
              || (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)))))
block because call_from_thunk_p is true.  But, base is a DECL with DECL_RTL of
a (reg:QI ...).
The code calls mark_addressable on args[i].tree_value, but that doesn't do
anything immediately, because currently_expanding_to_rtl is true (but even if
it would, that doesn't change DECL_RTL of the arg being passed).
Later the code calls build_fold_addr_expr_loc and ICEs when expanding that,
because trying to expand ADDR_EXPR on a VAR_DECL with DECL_RTL of (reg:QI ...)
doesn't work.

I don't see how this can be implemented other than actually making a copy,
so wonder if the condition shouldn't be
          if ((call_from_thunk_p || callee_copies)
              && !TREE_ADDRESSABLE (type)
              && ...
instead.  But what do I know about thunks.

Reply via email to