[clang] [X86_64] fix empty structure vaarg in c++ (PR #77907)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 5 00:30:01 PST 2024
================
@@ -3014,6 +3014,16 @@ Address X86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
ABIArgInfo AI = classifyArgumentType(Ty, 0, neededInt, neededSSE,
/*isNamedArg*/false);
+ // Empty records are ignored for parameter passing purposes.
+ if (AI.isIgnore()) {
+ CharUnits Align = CGF.getContext().getTypeAlignInChars(Ty);
+ VAListAddr = CGF.Builder.CreateStructGEP(VAListAddr, 2);
+ llvm::Value *Load = CGF.Builder.CreateLoad(VAListAddr);
+ llvm::Value *Offset = llvm::ConstantInt::get(CGF.Int32Ty, 0);
+ Load = CGF.Builder.CreateGEP(CGF.Int8Ty, Load, Offset);
+ return Address(Load, CGF.ConvertTypeForMem(Ty), Align);
----------------
efriedma-quic wrote:
I don't think the address here is guaranteed to be appropriately aligned. It's probably better to create a temporary like I suggested before.
Also, a GEP with offset 0 does nothing.
https://github.com/llvm/llvm-project/pull/77907
More information about the cfe-commits
mailing list