This is the mail archive of the gcc-bugs@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]

[Bug target/61976] aix64: Data corruption in struct passed by value


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

David Edelsohn <dje at gcc dot gnu.org> changed:

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

--- Comment #3 from David Edelsohn <dje at gcc dot gnu.org> ---
GCC is passing aggregates containing a single member in the mode of the member
instead of following the ABI for aggregates.

USE_FP_FOR_ARG_P tests the MODE of the argument, which GCC presents as the
underlying MODE, e.g., the mode of the "byval" argument is SFmode, not SImode.

This ABI bug also is present for the PPC64 ELFv1 ABI, but is silently hidden
because PPC64 ELFv1 pads arguments downward like a numerical value while AIX
pads arguments upwards like a string.

The following patch seems to fix the oversight. I suspect that this only should
be fixed for AIX and not for Linux.

Index: rs6000.c
===================================================================
--- rs6000.c    (revision 265577)
+++ rs6000.c    (working copy)
@@ -11915,7 +11915,8 @@
       if (elt_mode == TDmode && (cum->fregno % 2) == 1)
        cum->fregno++;

-      if (USE_FP_FOR_ARG_P (cum, elt_mode))
+      if (USE_FP_FOR_ARG_P (cum, elt_mode)
+         && (TREE_CODE (type) != RECORD_TYPE || DEFAULT_ABI != ABI_AIX))
        {
          rtx rvec[GP_ARG_NUM_REG + AGGR_ARG_NUM_REG + 1];
          rtx r, off;

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