diff options
| author | Chris Lattner <clattner@google.com> | 2018-10-25 16:58:08 -0700 |
|---|---|---|
| committer | jpienaar <jpienaar@google.com> | 2019-03-29 13:40:05 -0700 |
| commit | adbba70d8215007e2519fce8933f7259e64b991d (patch) | |
| tree | 7218b65debde9d275f0e99a62583261a05ac386c /mlir/lib/Transforms/Utils/Pass.cpp | |
| parent | 7de0da9594e5411aa555ee1a09e6c7f7bace0012 (diff) | |
| download | bcm5719-llvm-adbba70d8215007e2519fce8933f7259e64b991d.tar.gz bcm5719-llvm-adbba70d8215007e2519fce8933f7259e64b991d.zip | |
Simplify FunctionPass to eliminate the CFGFunctionPass/MLFunctionPass
distinction. FunctionPasses can now choose to get called on all functions, or
have the driver split CFG/ML Functions up for them. NFC.
PiperOrigin-RevId: 218775885
Diffstat (limited to 'mlir/lib/Transforms/Utils/Pass.cpp')
| -rw-r--r-- | mlir/lib/Transforms/Utils/Pass.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/mlir/lib/Transforms/Utils/Pass.cpp b/mlir/lib/Transforms/Utils/Pass.cpp index 8b1110798bd..e4edee31900 100644 --- a/mlir/lib/Transforms/Utils/Pass.cpp +++ b/mlir/lib/Transforms/Utils/Pass.cpp @@ -23,19 +23,31 @@ #include "mlir/IR/CFGFunction.h" #include "mlir/IR/MLFunction.h" #include "mlir/IR/Module.h" - using namespace mlir; +/// Out of line virtual method to ensure vtables and metadata are emitted to a +/// single .o file. +void Pass::anchor() {} + +/// Out of line virtual method to ensure vtables and metadata are emitted to a +/// single .o file. +void ModulePass::anchor() {} + /// Function passes walk a module and look at each function with their /// corresponding hooks and terminates upon error encountered. PassResult FunctionPass::runOnModule(Module *m) { for (auto &fn : *m) { - if (auto *mlFunc = dyn_cast<MLFunction>(&fn)) - if (runOnMLFunction(mlFunc)) - return failure(); - if (auto *cfgFunc = dyn_cast<CFGFunction>(&fn)) - if (runOnCFGFunction(cfgFunc)) - return failure(); + if (runOnFunction(&fn)) + return failure(); } return success(); } + +PassResult FunctionPass::runOnFunction(Function *fn) { + if (auto *mlFunc = dyn_cast<MLFunction>(fn)) + return runOnMLFunction(mlFunc); + if (auto *cfgFunc = dyn_cast<CFGFunction>(fn)) + return runOnCFGFunction(cfgFunc); + + return success(); +} |

