[clang] [clang] Fix UEFI Target info (PR #127290)
Petr Hosek via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 21 23:11:29 PDT 2025
================
@@ -3038,8 +3038,30 @@ static Address EmitX86_64VAArgFromMemory(CodeGenFunction &CGF,
return Address(Res, LTy, Align);
}
+static RValue EmitMSABIVAArg(CodeGenFunction &CGF, Address VAListAddr,
+ QualType Ty, AggValueSlot Slot,
+ ASTContext &context) {
+ // MS x64 ABI requirement: "Any argument that doesn't fit in 8 bytes, or is
+ // not 1, 2, 4, or 8 bytes, must be passed by reference."
+ uint64_t Width = context.getTypeSize(Ty);
+ bool IsIndirect = Width > 64 || !llvm::isPowerOf2_64(Width);
+
+ return emitVoidPtrVAArg(CGF, VAListAddr, Ty, IsIndirect,
+ CGF.getContext().getTypeInfoInChars(Ty),
+ CharUnits::fromQuantity(8),
+ /*allowHigherAlign*/ false, Slot);
+}
+
RValue X86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
QualType Ty, AggValueSlot Slot) const {
+
+ // Emit MS ABI compliant va_list for X86_64 targets which use Microsoft CXX
+ // ABI and CharPtrBuiltinVaList.
+ if (CGF.getTarget().getCXXABI().isMicrosoft() &&
+ CGF.getTarget().getBuiltinVaListKind() ==
+ clang::TargetInfo::CharPtrBuiltinVaList)
+ return EmitMSABIVAArg(CGF, VAListAddr, Ty, Slot, getContext());
----------------
petrhosek wrote:
Wouldn't it be cleaner and safer to use `WinX86_64ABIInfo` (and `WinX86_64TargetCodeGenInfo`) for UEFI?
https://github.com/llvm/llvm-project/pull/127290
More information about the cfe-commits
mailing list