[clang] [clang][CodeGen] Return RValue from `EmitVAArg` (PR #94635)
John McCall via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 10 16:23:18 PDT 2024
================
@@ -2161,6 +2161,19 @@ static RValue EmitLoadOfMatrixLValue(LValue LV, SourceLocation Loc,
return RValue::get(CGF.EmitLoadOfScalar(LV, Loc));
}
+RValue CodeGenFunction::EmitLoadOfAnyValue(LValue LV, 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:
+ return RValue::getAggregate(LV.getAddress());
----------------
rjmccall wrote:
I'm concerned about this laundering an l-value address into an aggregate r-value address. If someone used this as a generic routine somewhere else in CodeGen, this could pretty easily cause subtle miscompiles. Can we have the AggExprEmitter pass the `AggValueSlot` to `EmitVAArg` and so on, so that it eventually gets passed to this method? And then this method can call `EmitAggFinalDestCopy`.
It's probably okay for our existing use case here, though, where we're
That might be okay for our specific use case here — we probably never mutate the aggregate slot we get back during aggregate expression evaluation, and the slot in the `va_list` should otherwise be
https://github.com/llvm/llvm-project/pull/94635
More information about the cfe-commits
mailing list