Page MenuHomePhabricator

[X86] Disable argument copy elision for arguments passed via pointers
ClosedPublic

Authored by craig.topper on Apr 16 2019, 3:27 PM.

Details

Summary

If you pass two 1024 bit vectors in IR with AVX2 on Windows 64. Both vectors will be split in four 256 bit pieces. The four pieces of the first argument will be passed indirectly using 4 gprs. The second argument will get passed via pointers in memory.

The PartOffsets stored for the second argument are all in terms of its original 1024 bit size. So the PartOffsets for each piece are 32 bytes apart. So if we consider it for copy elision we'll only load an 8 byte pointer, but we'll move the address 32 bytes. The stack object size we create for the first part is probably wrong too.

This issue was encountered by ISPC. I'm working on getting a reduce test case, but wanted to go ahead and get feedback on the fix.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Apr 16 2019, 3:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 16 2019, 3:27 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
rnk added a comment.Apr 18 2019, 1:49 PM

The code change seems reasonable to me. I looked at it for a while, but I struggled to find a way to simplify it.

llvm/lib/Target/X86/X86ISelLowering.cpp
3013–3014 ↗(On Diff #195474)

I think this comment needs to be reworked, since things aren't as simple as I thought they were. Something like:

// If the argument is passed directly in memory without any extension, then we can perform copy elision.
// Large vector types, for example, may be passed indirectly by pointer.
rnk accepted this revision.Apr 19 2019, 3:23 PM

lgtm

This is a really strange legalization. =/ I'm surprised we split the vector, and then pass the pieces indirectly instead of passing the entire <16 x double> indirectly.

This revision is now accepted and ready to land.Apr 19 2019, 3:23 PM
This revision was automatically updated to reflect the committed changes.