HomePhabricator

[PowerPC] Add clang -msvr4-struct-return for 32-bit ELF

Authored by jhibbits on Apr 21 2020, 1:36 PM.

Description

[PowerPC] Add clang -msvr4-struct-return for 32-bit ELF

Summary:

Change the default ABI to be compatible with GCC. For 32-bit ELF
targets other than Linux, Clang now returns small structs in registers
r3/r4. This affects FreeBSD, NetBSD, OpenBSD. There is no change for
32-bit Linux, where Clang continues to return all structs in memory.

Add clang options -maix-struct-return (to return structs in memory) and
-msvr4-struct-return (to return structs in registers) to be compatible
with gcc. These options are only for PPC32; reject them on PPC64 and
other targets. The options are like -fpcc-struct-return and
-freg-struct-return for X86_32, and use similar code.

To actually return a struct in registers, coerce it to an integer of the
same size. LLVM may optimize the code to remove unnecessary accesses to
memory, and will return i32 in r3 or i64 in r3:r4.

Fixes PR#40736

Patch by George Koehler!

Reviewed By: jhibbits, nemanjai
Differential Revision: https://reviews.llvm.org/D73290

Details

Committed
jhibbitsApr 21 2020, 6:17 PM
Reviewer
jhibbits
Differential Revision
D73290: [PowerPC] Add clang -msvr4-struct-return for 32-bit ELF
Parents
rGa30e7ea88e75: Make SmallVector assert if it cannot grow.
Branches
Unknown
Tags
Unknown