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

            Bug ID: 92287
           Summary: Mismatches in the calling convention for zero sized
                    types
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gonzalobg88 at gmail dot com
  Target Milestone: ---

Consider this code:

struct foo {};
int id_foo(struct foo bar, int x) {
    return x;
}
int id(int x) {
    return x;
}

This link shows the assembly generated for MSP430, MIPS64el, PPC32 and PPC64
(https://godbolt.org/z/yOCJ-z), reproduced here for completeness:

;; MIPS64:
id_foo:
        j       $31
        move    $2,$4

id:
        j       $31
        move    $2,$4

;; MSP430:
id_foo:
        MOV.W   R13, R12
        RET
id:
        RET

;; POWERPC64LE
id_foo:
        blr
        .long 0
        .byte 0,0,0,0,0,0,0,0
id:
        blr
        .long 0
        .byte 0,0,0,0,0,0,0,0

;; POWERPC
id_foo:
        mr 3,4
        blr
id:
        blr


Notice how MSP430 and POWERPC passes ZSTs in the calling convention, while
MIPS64 and POWERPC64LE ignore them. 

I can't find an ABI specification document for the MSP430 and POWERPC targets,
so I was wondering whether this is 
a bug in the GCC implementation of the ABI for these targets. And if not, then
why do these targets care
about passing zero-sized types in their calling convention? Is this documented
anywhere?

(Note: other targets might be affected as well)

Reply via email to