@@ -1464,25 +1464,24 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const APValue &value,
14641464 case APValue::ComplexInt:
14651465 case APValue::ComplexFloat: {
14661466 mlir::Type desiredType = cgm.convertType (destType);
1467- cir::ComplexType complexType =
1468- mlir::dyn_cast<cir::ComplexType>(desiredType);
1467+ auto complexType = mlir::dyn_cast<cir::ComplexType>(desiredType);
14691468
14701469 mlir::Type complexElemTy = complexType.getElementType ();
14711470 if (isa<cir::IntType>(complexElemTy)) {
1472- llvm::APSInt real = value.getComplexIntReal ();
1473- llvm::APSInt imag = value.getComplexIntImag ();
1474- return builder. getAttr < cir::ConstComplexAttr>(
1475- complexType, cir::IntAttr::get (complexElemTy, real),
1476- cir::IntAttr::get (complexElemTy, imag));
1471+ const llvm::APSInt & real = value.getComplexIntReal ();
1472+ const llvm::APSInt & imag = value.getComplexIntImag ();
1473+ return cir::ConstComplexAttr::get (builder. getContext (), complexType,
1474+ cir::IntAttr::get (complexElemTy, real),
1475+ cir::IntAttr::get (complexElemTy, imag));
14771476 }
14781477
14791478 assert (isa<cir::FPTypeInterface>(complexElemTy) &&
14801479 " expected floating-point type" );
1481- llvm::APFloat real = value.getComplexFloatReal ();
1482- llvm::APFloat imag = value.getComplexFloatImag ();
1483- return builder. getAttr < cir::ConstComplexAttr>(
1484- complexType, cir::FPAttr::get (complexElemTy, real),
1485- cir::FPAttr::get (complexElemTy, imag));
1480+ const llvm::APFloat & real = value.getComplexFloatReal ();
1481+ const llvm::APFloat & imag = value.getComplexFloatImag ();
1482+ return cir::ConstComplexAttr::get (builder. getContext (), complexType,
1483+ cir::FPAttr::get (complexElemTy, real),
1484+ cir::FPAttr::get (complexElemTy, imag));
14861485 }
14871486 case APValue::FixedPoint:
14881487 case APValue::AddrLabelDiff:
0 commit comments