[cfe-dev] Possible bug in Win64 ABI in Clang?

Christoffer Lernö via cfe-dev cfe-dev at lists.llvm.org
Sat Nov 14 03:36:17 PST 2020


Perusing the Clang source, I found something rather confusing:

> if ((IsVectorCall || IsRegCall) &&
>       isHomogeneousAggregate(Ty, Base, NumElts)) {
>     if (IsRegCall) {
>       if (FreeSSERegs >= NumElts) {
>         FreeSSERegs -= NumElts;
>         if (IsReturnType || Ty->isBuiltinType() || Ty->isVectorType())
>           return ABIArgInfo::getDirect();
>         return ABIArgInfo::getExpand();
>       }
>       return ABIArgInfo::getIndirect(Align, /*ByVal=*/false);
>     } else if (IsVectorCall) {
>       if (FreeSSERegs >= NumElts &&
>           (IsReturnType || Ty->isBuiltinType() || Ty->isVectorType())) {
>         FreeSSERegs -= NumElts;
>         return ABIArgInfo::getDirect();
>       } else if (IsReturnType) {
>         return ABIArgInfo::getExpand();
>       } else if (!Ty->isBuiltinType() && !Ty->isVectorType()) {
>         // HVAs are delayed and reclassified in the 2nd step.
>         return ABIArgInfo::getIndirect(Align, /*ByVal=*/false);
>       }
>     }
>   }

If we look at ”isReturnType” for IsVectorCall = true has ”ABIArgInfo::getExpand()” however, ”expand” is not a valid type of ABIArgInfo and will throw an error.

So this seems to be incorrect and should crash on vectorcall with HVA. Can someone confirm?


Christoffer
AEGIK / www.aegik.se

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20201114/934e2506/attachment.html>


More information about the cfe-dev mailing list