Skip to content

Instantly share code, notes, and snippets.

@gnzlbg
Last active October 30, 2019 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gnzlbg/68af7c4872ef96c7df160488d62ce567 to your computer and use it in GitHub Desktop.
Save gnzlbg/68af7c4872ef96c7df160488d62ce567 to your computer and use it in GitHub Desktop.
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?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment