diff options
| author | River Riddle <riverriddle@google.com> | 2019-07-02 10:49:17 -0700 |
|---|---|---|
| committer | Mehdi Amini <aminim@google.com> | 2019-07-02 16:43:36 -0700 |
| commit | 206e55cc1653795166b0aebc25390bcc46f452db (patch) | |
| tree | a6872dd53892eea394b97464a520af7b139ed614 /mlir/lib/Support | |
| parent | b4a2dbc8b6dc566fa6fbb0c3d2b1e30a53e709e2 (diff) | |
| download | bcm5719-llvm-206e55cc1653795166b0aebc25390bcc46f452db.tar.gz bcm5719-llvm-206e55cc1653795166b0aebc25390bcc46f452db.zip | |
NFC: Refactor Module to be value typed.
As with Functions, Module will soon become an operation, which are value-typed. This eases the transition from Module to ModuleOp. A new class, OwningModuleRef is provided to allow for owning a reference to a Module, and will auto-delete the held module on destruction.
PiperOrigin-RevId: 256196193
Diffstat (limited to 'mlir/lib/Support')
| -rw-r--r-- | mlir/lib/Support/MlirOptMain.cpp | 4 | ||||
| -rw-r--r-- | mlir/lib/Support/TranslateClParser.cpp | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/mlir/lib/Support/MlirOptMain.cpp b/mlir/lib/Support/MlirOptMain.cpp index 15b148a31ca..d2957c17480 100644 --- a/mlir/lib/Support/MlirOptMain.cpp +++ b/mlir/lib/Support/MlirOptMain.cpp @@ -50,7 +50,7 @@ static LogicalResult performActions(raw_ostream &os, bool verifyDiagnostics, bool verifyPasses, SourceMgr &sourceMgr, MLIRContext *context, const std::vector<const mlir::PassRegistryEntry *> &passList) { - std::unique_ptr<Module> module(parseSourceFile(sourceMgr, context)); + OwningModuleRef module(parseSourceFile(sourceMgr, context)); if (!module) return failure(); @@ -63,7 +63,7 @@ performActions(raw_ostream &os, bool verifyDiagnostics, bool verifyPasses, applyPassManagerCLOptions(pm); // Run the pipeline. - if (failed(pm.run(module.get()))) + if (failed(pm.run(*module))) return failure(); // Print the output. diff --git a/mlir/lib/Support/TranslateClParser.cpp b/mlir/lib/Support/TranslateClParser.cpp index eb18acb56de..dcb55d6a15f 100644 --- a/mlir/lib/Support/TranslateClParser.cpp +++ b/mlir/lib/Support/TranslateClParser.cpp @@ -37,7 +37,7 @@ using namespace mlir; // Storage for the translation function wrappers that survive the parser. static llvm::SmallVector<TranslateFunction, 16> wrapperStorage; -static LogicalResult printMLIROutput(Module &module, +static LogicalResult printMLIROutput(Module module, llvm::StringRef outputFilename) { if (failed(module.verify())) return failure(); @@ -62,7 +62,7 @@ TranslationParser::TranslationParser(llvm::cl::Option &opt) TranslateFunction wrapper = [function](StringRef inputFilename, StringRef outputFilename, MLIRContext *context) { - std::unique_ptr<Module> module = function(inputFilename, context); + OwningModuleRef module = function(inputFilename, context); if (!module) return failure(); return printMLIROutput(*module, outputFilename); @@ -79,8 +79,8 @@ TranslationParser::TranslationParser(llvm::cl::Option &opt) MLIRContext *context) { llvm::SourceMgr sourceMgr; SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, context); - auto module = std::unique_ptr<Module>( - parseSourceFile(inputFilename, sourceMgr, context)); + auto module = + OwningModuleRef(parseSourceFile(inputFilename, sourceMgr, context)); if (!module) return failure(); return failure(function(module.get(), outputFilename)); |

