[clang] [clang][CodeGen] Return RValue from `EmitVAArg` (PR #94635)

John McCall via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 11 10:43:50 PDT 2024


================
@@ -2161,6 +2161,21 @@ static RValue EmitLoadOfMatrixLValue(LValue LV, SourceLocation Loc,
   return RValue::get(CGF.EmitLoadOfScalar(LV, Loc));
 }
 
+RValue CodeGenFunction::EmitLoadOfAnyValue(LValue LV, AggValueSlot Slot,
+                                           SourceLocation Loc) {
+  QualType Ty = LV.getType();
+  switch (getEvaluationKind(Ty)) {
+  case TEK_Scalar:
+    return EmitLoadOfLValue(LV, Loc);
+  case TEK_Complex:
+    return RValue::getComplex(EmitLoadOfComplex(LV, Loc));
+  case TEK_Aggregate:
+    EmitAggFinalDestCopy(Ty, Slot, LV, EVK_RValue);
----------------
rjmccall wrote:

I believe the EVK argument here is mean to represent the kind of value that the l-value represents.  In that case, it's an l-value — we need to preserve the underlying `va_list` storage and not treat it as something we own, because it's possible to iterate varargs twice.  I'm not sure it makes a practical difference here because variadic argumets are required to be trivial, but it's better to be accurate.

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


More information about the cfe-commits mailing list