[clang] [X86_64] Fix empty field error in vaarg of C++. (PR #90389)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 29 13:24:39 PDT 2024


================
@@ -3123,8 +3123,22 @@ Address X86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
 
     RegAddr = Tmp.withElementType(LTy);
   } else if (neededInt) {
-    RegAddr = Address(CGF.Builder.CreateGEP(CGF.Int8Ty, RegSaveArea, gp_offset),
-                      LTy, CharUnits::fromQuantity(8));
+    if (AI.isDirect() && AI.getDirectOffset() == 8) {
+      Address Tmp = CGF.CreateMemTemp(Ty);
+      llvm::StructType *ST = cast<llvm::StructType>(LTy);
+      Tmp = Tmp.withElementType(ST);
+      llvm::Type *TyHi = ST->getElementType(1);
----------------
efriedma-quic wrote:

The computation of TyHi is wrong.  Use `AI.getCoerceToType()`.  (Try something like `typedef struct { struct Z {} z[8]; float x, y; } X;`.)

Can we unify this code with the "Copy into a temporary if the type is more aligned" code below, so we only call CreateMemTemp() once?

Can we reuse this code for the neededSSE == 1 case?

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


More information about the cfe-commits mailing list