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

--- Comment #4 from Kewen Lin <linkw at gcc dot gnu.org> ---
(In reply to Kewen Lin from comment #3)
> There seem to be two alternatives to fix this, one is to raise error in
> rs6000_pass_by_reference like what we do in rs6000_function_arg, but we need
> something like mma_return_type_error to avoid re-erroring; the other is to
> teach the function rs6000_opaque_type_invalid_use_p about function call
> statement on arguments and return values. For now, the argument and return
> value checking is against the modes directly rather than the types, maybe to
> unique them into rs6000_opaque_type_invalid_use_p is better?
> 
> Hi @Segher and @Peter, what do you think of this?


Ah, the later is a bad idea, as the current checking is for non MMA but the
function argument and return values checking should happen all the time. With
further thinking, the fix can be: (always return false for MMA modes, let
rs6000_function_arg to raise error msg.)

diff --git a/gcc/config/rs6000/rs6000-call.cc
b/gcc/config/rs6000/rs6000-call.cc
index 59c51fa3579..6767a1f541c 100644
--- a/gcc/config/rs6000/rs6000-call.cc
+++ b/gcc/config/rs6000/rs6000-call.cc
@@ -2013,6 +2013,11 @@ rs6000_pass_by_reference (cumulative_args_t, const
function_arg_info &arg)
     {
       if (TARGET_DEBUG_ARG)
         fprintf (stderr, "function_arg_pass_by_reference: AltiVec\n");
+      /* We do not allow MMA types being used as function arguments,
+         return false to avoid the ICE on the copying for passing by
+         reference.  */
+      if (TYPE_MODE (arg.type) == OOmode || TYPE_MODE (arg.type) == XOmode)
+        return 0;
       return 1;
     }

Reply via email to