diff options
| author | River Riddle <riverriddle@google.com> | 2020-01-13 15:46:40 -0800 |
|---|---|---|
| committer | River Riddle <riverriddle@google.com> | 2020-01-13 15:51:28 -0800 |
| commit | c7748404920b3674e79059cbbe73b6041a214444 (patch) | |
| tree | e7dc6a063e4f67e6b7b79f6d2fc71b067a315fa2 /mlir/lib/Transforms/Inliner.cpp | |
| parent | 6fca03f0cae77c275870c4569bfeeb7ca0f561a6 (diff) | |
| download | bcm5719-llvm-c7748404920b3674e79059cbbe73b6041a214444.tar.gz bcm5719-llvm-c7748404920b3674e79059cbbe73b6041a214444.zip | |
[mlir] Update the CallGraph for nested symbol references, and simplify CallableOpInterface
Summary:
This enables tracking calls that cross symbol table boundaries. It also simplifies some of the implementation details of CallableOpInterface, i.e. there can only be one region within the callable operation.
Depends On D72042
Reviewed By: jpienaar
Differential Revision: https://reviews.llvm.org/D72043
Diffstat (limited to 'mlir/lib/Transforms/Inliner.cpp')
| -rw-r--r-- | mlir/lib/Transforms/Inliner.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/mlir/lib/Transforms/Inliner.cpp b/mlir/lib/Transforms/Inliner.cpp index b2cee7da083..d310316994f 100644 --- a/mlir/lib/Transforms/Inliner.cpp +++ b/mlir/lib/Transforms/Inliner.cpp @@ -86,8 +86,15 @@ static void collectCallOps(iterator_range<Region::iterator> blocks, while (!worklist.empty()) { for (Operation &op : *worklist.pop_back_val()) { if (auto call = dyn_cast<CallOpInterface>(op)) { - CallGraphNode *node = - cg.resolveCallable(call.getCallableForCallee(), &op); + CallInterfaceCallable callable = call.getCallableForCallee(); + + // TODO(riverriddle) Support inlining nested call references. + if (SymbolRefAttr symRef = callable.dyn_cast<SymbolRefAttr>()) { + if (!symRef.isa<FlatSymbolRefAttr>()) + continue; + } + + CallGraphNode *node = cg.resolveCallable(callable, &op); if (!node->isExternal()) calls.emplace_back(call, node); continue; @@ -274,6 +281,15 @@ struct InlinerPass : public OperationPass<InlinerPass> { CallGraph &cg = getAnalysis<CallGraph>(); auto *context = &getContext(); + // The inliner should only be run on operations that define a symbol table, + // as the callgraph will need to resolve references. + Operation *op = getOperation(); + if (!op->hasTrait<OpTrait::SymbolTable>()) { + op->emitOpError() << " was scheduled to run under the inliner, but does " + "not define a symbol table"; + return signalPassFailure(); + } + // Collect a set of canonicalization patterns to use when simplifying // callable regions within an SCC. OwningRewritePatternList canonPatterns; |

