[clang] [clang][CodeGen] Return RValue from `EmitVAArg` (PR #94635)
John McCall via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 6 10:38:57 PDT 2024
================
@@ -5988,12 +5988,29 @@ CGCallee CGCallee::prepareConcreteCallee(CodeGenFunction &CGF) const {
/* VarArg handling */
-Address CodeGenFunction::EmitVAArg(VAArgExpr *VE, Address &VAListAddr) {
- VAListAddr = VE->isMicrosoftABI()
- ? EmitMSVAListRef(VE->getSubExpr())
- : EmitVAListRef(VE->getSubExpr());
+RValue CodeGenFunction::EmitVAArg(VAArgExpr *VE, Address &VAListAddr) {
+ VAListAddr = VE->isMicrosoftABI() ? EmitMSVAListRef(VE->getSubExpr())
+ : EmitVAListRef(VE->getSubExpr());
QualType Ty = VE->getType();
+ Address ResAddr = Address::invalid();
if (VE->isMicrosoftABI())
- return CGM.getTypes().getABIInfo().EmitMSVAArg(*this, VAListAddr, Ty);
- return CGM.getTypes().getABIInfo().EmitVAArg(*this, VAListAddr, Ty);
+ ResAddr = CGM.getTypes().getABIInfo().EmitMSVAArg(*this, VAListAddr, Ty);
+ else
+ ResAddr = CGM.getTypes().getABIInfo().EmitVAArg(*this, VAListAddr, Ty);
+
+ switch (getEvaluationKind(VE->getType())) {
+ case TEK_Scalar: {
+ llvm::Value *Load = Builder.CreateLoad(ResAddr);
+ return RValue::get(Load);
+ }
+ case TEK_Complex: {
+ llvm::Value *Load = Builder.CreateLoad(ResAddr);
+ llvm::Value *Real = Builder.CreateExtractValue(Load, 0);
+ llvm::Value *Imag = Builder.CreateExtractValue(Load, 1);
+ return RValue::getComplex(std::make_pair(Real, Imag));
----------------
rjmccall wrote:
There's an `EmitLoadOfComplex` you can use here. You'll just need to `MakeAddrLValue` first.
https://github.com/llvm/llvm-project/pull/94635
More information about the cfe-commits
mailing list