diff options
Diffstat (limited to 'clang/lib/CIR/CodeGen/CIRGenCall.cpp')
-rw-r--r-- | clang/lib/CIR/CodeGen/CIRGenCall.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/clang/lib/CIR/CodeGen/CIRGenCall.cpp b/clang/lib/CIR/CodeGen/CIRGenCall.cpp index 2970b36..61072f0 100644 --- a/clang/lib/CIR/CodeGen/CIRGenCall.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenCall.cpp @@ -522,7 +522,8 @@ RValue CIRGenFunction::emitCall(const CIRGenFunctionInfo &funcInfo, assert(!cir::MissingFeatures::opCallPaddingArgs()); mlir::Type argType = convertType(canQualArgType); - if (!mlir::isa<cir::RecordType>(argType)) { + if (!mlir::isa<cir::RecordType>(argType) && + !mlir::isa<cir::ComplexType>(argType)) { mlir::Value v; if (arg.isAggregate()) cgm.errorNYI(loc, "emitCall: aggregate call argument"); @@ -540,15 +541,16 @@ RValue CIRGenFunction::emitCall(const CIRGenFunctionInfo &funcInfo, cirCallArgs[argNo] = v; } else { Address src = Address::invalid(); - if (!arg.isAggregate()) - cgm.errorNYI(loc, "emitCall: non-aggregate call argument"); - else + if (!arg.isAggregate()) { + src = createMemTemp(arg.ty, loc, "coerce"); + arg.copyInto(*this, src, loc); + } else { src = arg.hasLValue() ? arg.getKnownLValue().getAddress() : arg.getKnownRValue().getAggregateAddress(); + } // Fast-isel and the optimizer generally like scalar values better than // FCAs, so we flatten them if this is safe to do for this argument. - auto argRecordTy = cast<cir::RecordType>(argType); mlir::Type srcTy = src.getElementType(); // FIXME(cir): get proper location for each argument. mlir::Location argLoc = loc; @@ -564,7 +566,7 @@ RValue CIRGenFunction::emitCall(const CIRGenFunctionInfo &funcInfo, // uint64_t DstSize = CGM.getDataLayout().getTypeAllocSize(STy); // if (SrcSize < DstSize) { assert(!cir::MissingFeatures::dataLayoutTypeAllocSize()); - if (srcTy != argRecordTy) { + if (srcTy != argType) { cgm.errorNYI(loc, "emitCall: source type does not match argument type"); } else { // FIXME(cir): this currently only runs when the types are exactly the @@ -676,6 +678,18 @@ RValue CIRGenFunction::emitCall(const CIRGenFunctionInfo &funcInfo, llvm_unreachable("Invalid evaluation kind"); } +void CallArg::copyInto(CIRGenFunction &cgf, Address addr, + mlir::Location loc) const { + LValue dst = cgf.makeAddrLValue(addr, ty); + if (!hasLV && rv.isScalar()) + cgf.cgm.errorNYI(loc, "copyInto scalar value"); + else if (!hasLV && rv.isComplex()) + cgf.emitStoreOfComplex(loc, rv.getComplexValue(), dst, /*isInit=*/true); + else + cgf.cgm.errorNYI(loc, "copyInto hasLV"); + isUsed = true; +} + void CIRGenFunction::emitCallArg(CallArgList &args, const clang::Expr *e, clang::QualType argType) { assert(argType->isReferenceType() == e->isGLValue() && |