File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed
Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change 1010#include " QueryParser.h"
1111#include " mlir/Dialect/Func/IR/FuncOps.h"
1212#include " mlir/IR/IRMapping.h"
13+ #include " mlir/IR/Verifier.h"
1314#include " mlir/Query/Matcher/MatchFinder.h"
1415#include " mlir/Query/QuerySession.h"
1516#include " llvm/ADT/SetVector.h"
@@ -68,6 +69,7 @@ static Operation *extractFunction(std::vector<Operation *> &ops,
6869 // Clone operations and build function body
6970 std::vector<Operation *> clonedOps;
7071 std::vector<Value> clonedVals;
72+ // TODO: Handle extraction of operations containing block arguments.
7173 for (Operation *slicedOp : slice) {
7274 Operation *clonedOp =
7375 clonedOps.emplace_back (builder.clone (*slicedOp, mapper));
@@ -129,6 +131,8 @@ LogicalResult MatchQuery::run(llvm::raw_ostream &os, QuerySession &qs) const {
129131 finder.flattenMatchedOps (matches);
130132 Operation *function =
131133 extractFunction (flattenedMatches, rootOp->getContext (), functionName);
134+ if (failed (verify (function)))
135+ return mlir::failure ();
132136 os << " \n " << *function << " \n\n " ;
133137 function->erase ();
134138 return mlir::success ();
You can’t perform that action at this time.
0 commit comments