The backend can't lower this correctly and will try to split the return value into multiple registers.
This patches forces it to return via memory similar to what was already done for arguments.
Fixes PR39501.
Differential D53919
[X86] Don't allow illegal vector types to return by direct value on x86-64. craig.topper on Oct 30 2018, 9:52 PM. Authored by
Details
Diff Detail
Event Timeline
Comment Actions Retitling to just the x86-64 case. 32-bit mode has issues on arguments too I think and will need more work. The IsIllegalVectorType function is a member of the X86_64ABIInfo so we need to refactor or add a new one for 32-bit. Comment Actions As far as I know, according to the ABI docs, it's impossible to return a 256-bit vector from a function if AVX is disabled. Given that we aren't rejecting the testcase, we're effectively implementing a new "no-AVX" ABI variant. That variant is not defined anywhere, so we might as well pick the fastest convention, returning the value in registers. I'm not sure why you would want to return the vector in memory instead. Comment Actions Whatever you call it, the question remains; what specification and/or compiler are we trying to be compatible with? Comment Actions The ABI document before AVX was introduced didn't say anything at all about 256-bit vectors. So we're talking about compatibility with some other compiler. Which compiler? Comment Actions X86-64 compilers created before AVX was introduced. Say clang 1.0 doesn't know AVX and returns it in memory. So should clang 7.0 with -mno-avx. Comment Actions I just tried clang 3.3, and as far as I can tell it behaves the same way as trunk. If the argument is that we should be compatible with gcc on Linux, that's fine, but we should explicitly state that in a comment. Comment Actions Try this with clang 3.3 and clang 7.0. [hjl@gnu-cfl-1 tmp]$ cat z.c v Comment Actions With both 3.3 and trunk (I don't have a 7.0 handy; I can build it if it would be helpful): movaps .LCPI0_0(%rip), %xmm0 # xmm0 = [48,49,50,51] movaps .LCPI0_1(%rip), %xmm1 # xmm1 = [52,53,54,55] movaps .LCPI0_2(%rip), %xmm2 # xmm2 = [56,57,97,98] movaps .LCPI0_3(%rip), %xmm3 # xmm3 = [99,100,101,102] retq Comment Actions From the releases: 23 Oct 2009 2.6 ... why would you care about a 9 year old version of clang? Comment Actions It is about ABI consistency. When AVX isn't enabled, the old and compilers should |
Doesn't -m32 have the same issue?