From bd57a54906e8940833b072c512cb494cab270811 Mon Sep 17 00:00:00 2001 From: Francesco Bertolaccini Date: Tue, 17 Dec 2024 19:39:58 +0100 Subject: [PATCH] pr: Remove `noparse` arguments from `noparse` when folding. --- lib/vast/Dialect/Parser/Ops.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/vast/Dialect/Parser/Ops.cpp b/lib/vast/Dialect/Parser/Ops.cpp index 89a6c35a57..f9b5ef7639 100644 --- a/lib/vast/Dialect/Parser/Ops.cpp +++ b/lib/vast/Dialect/Parser/Ops.cpp @@ -18,7 +18,17 @@ namespace vast::pr { using fold_result_t = ::llvm::SmallVectorImpl< ::mlir::OpFoldResult >; logical_result NoParse::fold(FoldAdaptor adaptor, fold_result_t &results) { - return mlir::failure(); + auto change = mlir::failure(); + auto op = getOperation(); + + for (auto [idx, operand] : llvm::reverse(llvm::enumerate(getOperands()))) { + if (auto noparse = mlir::dyn_cast< NoParse >(operand.getDefiningOp())) { + op->eraseOperand(idx); + change = mlir::success(); + } + } + + return change; } } // namespace vast::pr