[clang] [X86_64] fix empty structure vaarg in c++ (PR #77907)

Longsheng Mou via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 5 00:34:47 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);
----------------
CoTinker wrote:

how to create a temporary?

https://github.com/llvm/llvm-project/pull/77907


More information about the cfe-commits mailing list