From a0f638b1efa2aa65d9450a198eece04a84267f48 Mon Sep 17 00:00:00 2001 From: Robert Konicar Date: Tue, 8 Oct 2024 15:22:05 +0200 Subject: [PATCH] conv:tollvm: Fix assert triggered by lowering a call with void return value. --- lib/vast/Conversion/ToLLVM/IRsToLLVM.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/vast/Conversion/ToLLVM/IRsToLLVM.cpp b/lib/vast/Conversion/ToLLVM/IRsToLLVM.cpp index 4f267260bc..7b48fcd068 100644 --- a/lib/vast/Conversion/ToLLVM/IRsToLLVM.cpp +++ b/lib/vast/Conversion/ToLLVM/IRsToLLVM.cpp @@ -1012,7 +1012,14 @@ namespace vast::conv::irstollvm auto call = rewriter.create< mlir::LLVM::CallOp >( op.getLoc(), mk_fty(), op.getCallee(), ops.getOperands() ); - rewriter.replaceOp(op, call.getResults()); + + // the result gets removed when return type is void + // because the number of results is mismatched, we can't use replace (triggers assert) + // removing the op is ok, since in llvm dialect a void value can't be used anyway + if (call.getResult()) + rewriter.replaceOp(op, call.getResults()); + else + rewriter.eraseOp(op); return logical_result::success(); }