This is an archive of the discontinued LLVM Phabricator instance.

[X86] ABI compat bugfix for MSVC vectorcall
ClosedPublic

Authored by rnk on Jan 2 2020, 2:03 PM.

Details

Summary

Before this change, X86_32ABIInfo::classifyArgument would be called
twice on vector arguments to vectorcall functions. This function has
side effects to track GPR register usage, and this would lead to
incorrect GPR usage in some cases. The specific case I noticed is from
running out of XMM registers with mixed FP and vector arguments and no
aggregates of any kind. Consider this prototype:

void __vectorcall vectorcall_indirect_vec(
    double xmm0, double xmm1, double xmm2, double xmm3, double xmm4,
    __m128 xmm5,
    __m128 ecx,
    int edx,
    __m128 mem);

classifyArgument has no effects when called on a plain FP type, but when
called on a vector type, it modifies FreeRegs to model GPR consumption.
However, this should not happen during the vector call first pass.

I refactored the code to unify vectorcall HVA logic with regcall HVA
logic. The conventions pass HVAs in registers differently (expanded vs.
not expanded), but if they do not fit in registers, they both pass them
indirectly by address.

Diff Detail

Event Timeline

rnk created this revision.Jan 2 2020, 2:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 2 2020, 2:03 PM

Unit tests: pass. 61175 tests passed, 0 failed and 729 were skipped.

clang-tidy: pass.

clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

I don't see anything I have a problem with, but still want @ctopper to have a bit of time to take a look. Ping me monday on both if he doesn't respond.

craig.topper added inline comments.Jan 3 2020, 10:25 AM
clang/lib/CodeGen/TargetInfo.cpp
1648

What about ZMM?

rnk marked an inline comment as done.Jan 3 2020, 11:55 AM
rnk added inline comments.
clang/lib/CodeGen/TargetInfo.cpp
1648

This comment was pre-existing, but we can say [XYZ]MM0-5.

rnk updated this revision to Diff 236115.Jan 3 2020, 1:00 PM
  • ZYXMM

Unit tests: pass. 61177 tests passed, 0 failed and 729 were skipped.

clang-tidy: fail. Please fix clang-tidy findings.

clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

This revision is now accepted and ready to land.Jan 5 2020, 9:13 PM
This revision was automatically updated to reflect the committed changes.