Skip to content

Commit 7d70e24

Browse files
committed
Fix ABIInfo for UEFI
1 parent 8ab3ae8 commit 7d70e24

File tree

2 files changed

+10
-23
lines changed

2 files changed

+10
-23
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ createTargetCodeGenInfo(CodeGenModule &CGM) {
267267
: X86AVXABILevel::None);
268268

269269
switch (Triple.getOS()) {
270+
case llvm::Triple::UEFI:
270271
case llvm::Triple::Win32:
271272
return createWinX86_64TargetCodeGenInfo(CGM, AVXLevel);
272273
default:

clang/lib/CodeGen/Targets/X86.cpp

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3038,30 +3038,8 @@ static Address EmitX86_64VAArgFromMemory(CodeGenFunction &CGF,
30383038
return Address(Res, LTy, Align);
30393039
}
30403040

3041-
static RValue EmitMSABIVAArg(CodeGenFunction &CGF, Address VAListAddr,
3042-
QualType Ty, AggValueSlot Slot,
3043-
ASTContext &context) {
3044-
// MS x64 ABI requirement: "Any argument that doesn't fit in 8 bytes, or is
3045-
// not 1, 2, 4, or 8 bytes, must be passed by reference."
3046-
uint64_t Width = context.getTypeSize(Ty);
3047-
bool IsIndirect = Width > 64 || !llvm::isPowerOf2_64(Width);
3048-
3049-
return emitVoidPtrVAArg(CGF, VAListAddr, Ty, IsIndirect,
3050-
CGF.getContext().getTypeInfoInChars(Ty),
3051-
CharUnits::fromQuantity(8),
3052-
/*allowHigherAlign*/ false, Slot);
3053-
}
3054-
30553041
RValue X86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
30563042
QualType Ty, AggValueSlot Slot) const {
3057-
3058-
// Emit MS ABI compliant va_list for X86_64 targets which use Microsoft CXX
3059-
// ABI and CharPtrBuiltinVaList.
3060-
if (CGF.getTarget().getCXXABI().isMicrosoft() &&
3061-
CGF.getTarget().getBuiltinVaListKind() ==
3062-
clang::TargetInfo::CharPtrBuiltinVaList)
3063-
return EmitMSABIVAArg(CGF, VAListAddr, Ty, Slot, getContext());
3064-
30653043
// Assume that va_list type is correct; should be pointer to LLVM type:
30663044
// struct {
30673045
// i32 gp_offset;
@@ -3508,7 +3486,15 @@ void WinX86_64ABIInfo::computeInfo(CGFunctionInfo &FI) const {
35083486

35093487
RValue WinX86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
35103488
QualType Ty, AggValueSlot Slot) const {
3511-
return EmitMSABIVAArg(CGF, VAListAddr, Ty, Slot, getContext());
3489+
// MS x64 ABI requirement: "Any argument that doesn't fit in 8 bytes, or is
3490+
// not 1, 2, 4, or 8 bytes, must be passed by reference."
3491+
uint64_t Width = getContext().getTypeSize(Ty);
3492+
bool IsIndirect = Width > 64 || !llvm::isPowerOf2_64(Width);
3493+
3494+
return emitVoidPtrVAArg(CGF, VAListAddr, Ty, IsIndirect,
3495+
CGF.getContext().getTypeInfoInChars(Ty),
3496+
CharUnits::fromQuantity(8),
3497+
/*allowHigherAlign*/ false, Slot);
35123498
}
35133499

35143500
std::unique_ptr<TargetCodeGenInfo> CodeGen::createX86_32TargetCodeGenInfo(

0 commit comments

Comments
 (0)