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

            Bug ID: 110406
           Summary: d: Wrong code-gen returning POD structs by value
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: d
          Assignee: ibuclaw at gdcproject dot org
          Reporter: ibuclaw at gcc dot gnu.org
  Target Milestone: ---

Since 13.1 (r13-1104?), structs have been set the wrong mode, causing them to
return differently to equivalent static arrays.

---
struct cpuid_abcd_t
{
    uint eax;
    uint ebx;
    uint ecx;
    uint edx;
};

cpuid_abcd_t
cpuid_insn(const uint in_eax)
{
        cpuid_abcd_t ret = void;
        asm {
            "cpuid"
            :
                "=a" ( ret.eax ),
                "=b" ( ret.ebx ),
                "=c" ( ret.ecx ),
                "=d" ( ret.edx )
            :
                "a"  ( in_eax )
            :
    ;}
        return ret;
}

uint[4]
cpuid_insn2(const uint in_eax)
{
        uint[4] ret = void;
        asm {
            "cpuid"
            :
                "=a" ( ret[0] ),
                "=b" ( ret[1] ),
                "=c" ( ret[2] ),
                "=d" ( ret[3] )
            :
                "a"  ( in_eax )
            :
    ;}
        return ret;
}
---


The first function erroneously being returned in vector registers.

  _15 = {ret$eax_3, ret$ebx_4, ret$ecx_5, ret$edx_6};
  MEM <vector(4) uint> [(void *)&D.1894] = _15;
  return D.1894;

Reply via email to