@@ -225,8 +225,9 @@ class LowerMalloc: public mlir::OpConversionPattern<mlir::rlc::MallocOp>
225225
226226 const auto & dl = mlir::DataLayout::closest (op);
227227
228- auto baseType = typeConverter->convertType (mlir::rlc::ProxyType::get (
229- op.getType ().cast <mlir::rlc::OwningPtrType>().getUnderlying ()));
228+ auto baseType = typeConverter->convertType (
229+ mlir::rlc::ProxyType::get (
230+ op.getType ().cast <mlir::rlc::OwningPtrType>().getUnderlying ()));
230231
231232 auto baseSize = rewriter.getI64IntegerAttr (dl.getTypeSize (baseType));
232233 auto count = rewriter.create <mlir::LLVM::ConstantOp>(
@@ -377,10 +378,13 @@ class ExplicitConstructRewriter
377378 typeConverter->convertType (mlir::rlc::ProxyType::get (op.getType ()));
378379 auto alloca = makeAlloca (rewriter, mapped, op.getLoc ());
379380
380- rewriter.create <mlir::LLVM::CallOp>(
381+ auto callOp = rewriter.create <mlir::LLVM::CallOp>(
381382 op.getLoc (),
382- mlir::TypeRange (),
383+ mlir::LLVM::LLVMFunctionType::get (
384+ mlir::LLVM::LLVMVoidType::get (op.getContext ()),
385+ { alloca.getType () }),
383386 mlir::ValueRange ({ adaptor.getInitializer (), alloca }));
387+
384388 rewriter.replaceOp (op, alloca);
385389 return mlir::LogicalResult::success ();
386390 }
@@ -528,10 +532,11 @@ class IsOpRewriter: public mlir::OpConversionPattern<mlir::rlc::IsOp>
528532 return mlir::success ();
529533 }
530534
531- auto convertedUnionType = typeConverter
532- ->convertType (mlir::rlc::ProxyType::get (
533- op.getExpression ().getType ()))
534- .cast <mlir::LLVM::LLVMStructType>();
535+ auto convertedUnionType =
536+ typeConverter
537+ ->convertType (
538+ mlir::rlc::ProxyType::get (op.getExpression ().getType ()))
539+ .cast <mlir::LLVM::LLVMStructType>();
535540 auto lastElementIndex = convertedUnionType.getBody ().size () - 1 ;
536541
537542 auto zero = rewriter.getZeroAttr (rewriter.getI64Type ());
@@ -629,8 +634,9 @@ class ValueUpcastRewriter
629634 if (op.getInput ().getType () != op.getResult ().getType () and
630635 not op.getInput ().getType ().isa <mlir::rlc::AlternativeType>())
631636 {
632- op.emitError (" internal error somehow a template upcast did not had the "
633- " same input and output type at lowering time" );
637+ op.emitError (
638+ " internal error somehow a template upcast did not had the "
639+ " same input and output type at lowering time" );
634640 return mlir::failure ();
635641 }
636642 rewriter.replaceOp (op, op.getInput ());
@@ -1278,6 +1284,7 @@ class CallRewriter: public mlir::OpConversionPattern<mlir::rlc::CallOp>
12781284 {
12791285 rewriter.setInsertionPoint (op);
12801286 llvm::SmallVector<mlir::Value, 2 > args;
1287+ llvm::SmallVector<mlir::Type, 2 > argTypes;
12811288 assert (op.getNumResults () <= 1 );
12821289 args.push_back (adaptor.getCallee ());
12831290 auto loc = op.getLoc ();
@@ -1296,10 +1303,16 @@ class CallRewriter: public mlir::OpConversionPattern<mlir::rlc::CallOp>
12961303 }
12971304
12981305 for (auto arg : adaptor.getArgs ())
1306+ {
12991307 args.push_back (arg);
1308+ argTypes.push_back (arg.getType ());
1309+ }
13001310
13011311 auto newOp = rewriter.create <mlir::LLVM::CallOp>(
1302- op.getLoc (), mlir::ValueRange (), args);
1312+ op.getLoc (),
1313+ mlir::LLVM::LLVMFunctionType::get (
1314+ mlir::LLVM::LLVMVoidType::get (op.getContext ()), argTypes),
1315+ args);
13031316
13041317 if (type.isa <mlir::rlc::ReferenceType>())
13051318 result = makeAlignedLoad (
@@ -1839,8 +1852,9 @@ class FunctionRewriter
18391852 {
18401853 auto subprogramAttr = diGenerator.getFunctionAttr (
18411854 newF, op.getUnmangledName (), op.getType ());
1842- newF->setLoc (mlir::FusedLoc::get (
1843- op.getContext (), { newF.getLoc () }, subprogramAttr));
1855+ newF->setLoc (
1856+ mlir::FusedLoc::get (
1857+ op.getContext (), { newF.getLoc () }, subprogramAttr));
18441858
18451859 rewriter.setInsertionPointToStart (&newF.getBody ().front ());
18461860 for (auto [argument, value, newValue] : llvm::zip (
0 commit comments