[Bug target/68273] [5/6 Regression] Wrong code on mips/mipsel due to (invalid?) peeking at alignments in function_arg.

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Feb 4 13:07:00 GMT 2016


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

--- Comment #14 from Richard Biener <rguenth at gcc dot gnu.org> ---
I am currently testing the following patch to eventually mitigate the issue
somewhat by forcing all "registers" to have non-qualified type (their
qualification does not matter nor does their alignment).  The create_tmp_reg
hunk is more risky (in case we have bogus callers ending up forcing the
result to memory).

It will hide the PRE bug (well, still if the user wrote a 64bit aligned
type and a 32bit aligned type PRE might change one for the other - in
fact it will even end up using a 32bit aligned type if the code consistently
uses 64bit aligned types).

But as said earlier, the GCC implemented ABI is simply seriously broken
if you consider the user can control "alignment" of (register-typed) values.

Index: gcc/gimple-expr.c
===================================================================
--- gcc/gimple-expr.c   (revision 233136)
+++ gcc/gimple-expr.c   (working copy)
@@ -484,9 +484,8 @@ create_tmp_var (tree type, const char *p
 tree
 create_tmp_reg (tree type, const char *prefix)
 {
-  tree tmp;
-
-  tmp = create_tmp_var (type, prefix);
+  gcc_assert (is_gimple_reg_type (type));
+  tree tmp = create_tmp_var (TYPE_MAIN_VARIANT (type), prefix);
   if (TREE_CODE (type) == COMPLEX_TYPE
       || TREE_CODE (type) == VECTOR_TYPE)
     DECL_GIMPLE_REG_P (tmp) = 1;
Index: gcc/tree-ssanames.c
===================================================================
--- gcc/tree-ssanames.c (revision 233136)
+++ gcc/tree-ssanames.c (working copy)
@@ -286,7 +286,7 @@ make_ssa_name_fn (struct function *fn, t

   if (TYPE_P (var))
     {
-      TREE_TYPE (t) = var;
+      TREE_TYPE (t) = TYPE_MAIN_VARIANT (var);
       SET_SSA_NAME_VAR_OR_IDENTIFIER (t, NULL_TREE);
     }
   else


More information about the Gcc-bugs mailing list