Replace OwningModuleRef with OwningOpRef<ModuleOp>

This addresses a TODO in BuiltinOps.h.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D118574
This commit is contained in:
Sanjoy Das 2022-01-29 18:41:10 -08:00
parent 73fd7d2304
commit 8f66ab1c2e
36 changed files with 122 additions and 115 deletions

View File

@ -18,7 +18,9 @@
namespace mlir { namespace mlir {
class MLIRContext; class MLIRContext;
class OwningModuleRef; template <typename OpTy>
class OwningOpRef;
class ModuleOp;
} // namespace mlir } // namespace mlir
namespace toy { namespace toy {
@ -26,7 +28,8 @@ class ModuleAST;
/// Emit IR for the given Toy moduleAST, returns a newly created MLIR module /// Emit IR for the given Toy moduleAST, returns a newly created MLIR module
/// or nullptr on failure. /// or nullptr on failure.
mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context, ModuleAST &moduleAST); mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
ModuleAST &moduleAST);
} // namespace toy } // namespace toy
#endif // TOY_MLIRGEN_H #endif // TOY_MLIRGEN_H

View File

@ -443,8 +443,8 @@ private:
namespace toy { namespace toy {
// The public API for codegen. // The public API for codegen.
mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context, mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
ModuleAST &moduleAST) { ModuleAST &moduleAST) {
return MLIRGenImpl(context).mlirGen(moduleAST); return MLIRGenImpl(context).mlirGen(moduleAST);
} }

View File

@ -78,7 +78,7 @@ int dumpMLIR() {
auto moduleAST = parseInputFile(inputFilename); auto moduleAST = parseInputFile(inputFilename);
if (!moduleAST) if (!moduleAST)
return 6; return 6;
mlir::OwningModuleRef module = mlirGen(context, *moduleAST); mlir::OwningOpRef<mlir::ModuleOp> module = mlirGen(context, *moduleAST);
if (!module) if (!module)
return 1; return 1;
@ -97,7 +97,8 @@ int dumpMLIR() {
// Parse the input mlir. // Parse the input mlir.
llvm::SourceMgr sourceMgr; llvm::SourceMgr sourceMgr;
sourceMgr.AddNewSourceBuffer(std::move(*fileOrErr), llvm::SMLoc()); sourceMgr.AddNewSourceBuffer(std::move(*fileOrErr), llvm::SMLoc());
mlir::OwningModuleRef module = mlir::parseSourceFile(sourceMgr, &context); mlir::OwningOpRef<mlir::ModuleOp> module =
mlir::parseSourceFile(sourceMgr, &context);
if (!module) { if (!module) {
llvm::errs() << "Error can't load file " << inputFilename << "\n"; llvm::errs() << "Error can't load file " << inputFilename << "\n";
return 3; return 3;

View File

@ -18,7 +18,9 @@
namespace mlir { namespace mlir {
class MLIRContext; class MLIRContext;
class OwningModuleRef; template <typename OpTy>
class OwningOpRef;
class ModuleOp;
} // namespace mlir } // namespace mlir
namespace toy { namespace toy {
@ -26,7 +28,8 @@ class ModuleAST;
/// Emit IR for the given Toy moduleAST, returns a newly created MLIR module /// Emit IR for the given Toy moduleAST, returns a newly created MLIR module
/// or nullptr on failure. /// or nullptr on failure.
mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context, ModuleAST &moduleAST); mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
ModuleAST &moduleAST);
} // namespace toy } // namespace toy
#endif // TOY_MLIRGEN_H #endif // TOY_MLIRGEN_H

View File

@ -443,8 +443,8 @@ private:
namespace toy { namespace toy {
// The public API for codegen. // The public API for codegen.
mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context, mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
ModuleAST &moduleAST) { ModuleAST &moduleAST) {
return MLIRGenImpl(context).mlirGen(moduleAST); return MLIRGenImpl(context).mlirGen(moduleAST);
} }

View File

@ -72,7 +72,7 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
} }
int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context, int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
mlir::OwningModuleRef &module) { mlir::OwningOpRef<mlir::ModuleOp> &module) {
// Handle '.toy' input to the compiler. // Handle '.toy' input to the compiler.
if (inputType != InputType::MLIR && if (inputType != InputType::MLIR &&
!llvm::StringRef(inputFilename).endswith(".mlir")) { !llvm::StringRef(inputFilename).endswith(".mlir")) {
@ -106,7 +106,7 @@ int dumpMLIR() {
// Load our Dialect in this MLIR Context. // Load our Dialect in this MLIR Context.
context.getOrLoadDialect<mlir::toy::ToyDialect>(); context.getOrLoadDialect<mlir::toy::ToyDialect>();
mlir::OwningModuleRef module; mlir::OwningOpRef<mlir::ModuleOp> module;
llvm::SourceMgr sourceMgr; llvm::SourceMgr sourceMgr;
mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context); mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context);
if (int error = loadMLIR(sourceMgr, context, module)) if (int error = loadMLIR(sourceMgr, context, module))

View File

@ -18,7 +18,9 @@
namespace mlir { namespace mlir {
class MLIRContext; class MLIRContext;
class OwningModuleRef; template <typename OpTy>
class OwningOpRef;
class ModuleOp;
} // namespace mlir } // namespace mlir
namespace toy { namespace toy {
@ -26,7 +28,8 @@ class ModuleAST;
/// Emit IR for the given Toy moduleAST, returns a newly created MLIR module /// Emit IR for the given Toy moduleAST, returns a newly created MLIR module
/// or nullptr on failure. /// or nullptr on failure.
mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context, ModuleAST &moduleAST); mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
ModuleAST &moduleAST);
} // namespace toy } // namespace toy
#endif // TOY_MLIRGEN_H #endif // TOY_MLIRGEN_H

View File

@ -447,8 +447,8 @@ private:
namespace toy { namespace toy {
// The public API for codegen. // The public API for codegen.
mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context, mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
ModuleAST &moduleAST) { ModuleAST &moduleAST) {
return MLIRGenImpl(context).mlirGen(moduleAST); return MLIRGenImpl(context).mlirGen(moduleAST);
} }

View File

@ -73,7 +73,7 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
} }
int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context, int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
mlir::OwningModuleRef &module) { mlir::OwningOpRef<mlir::ModuleOp> &module) {
// Handle '.toy' input to the compiler. // Handle '.toy' input to the compiler.
if (inputType != InputType::MLIR && if (inputType != InputType::MLIR &&
!llvm::StringRef(inputFilename).endswith(".mlir")) { !llvm::StringRef(inputFilename).endswith(".mlir")) {
@ -107,7 +107,7 @@ int dumpMLIR() {
// Load our Dialect in this MLIR Context. // Load our Dialect in this MLIR Context.
context.getOrLoadDialect<mlir::toy::ToyDialect>(); context.getOrLoadDialect<mlir::toy::ToyDialect>();
mlir::OwningModuleRef module; mlir::OwningOpRef<mlir::ModuleOp> module;
llvm::SourceMgr sourceMgr; llvm::SourceMgr sourceMgr;
mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context); mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context);
if (int error = loadMLIR(sourceMgr, context, module)) if (int error = loadMLIR(sourceMgr, context, module))

View File

@ -18,7 +18,9 @@
namespace mlir { namespace mlir {
class MLIRContext; class MLIRContext;
class OwningModuleRef; template <typename OpTy>
class OwningOpRef;
class ModuleOp;
} // namespace mlir } // namespace mlir
namespace toy { namespace toy {
@ -26,7 +28,8 @@ class ModuleAST;
/// Emit IR for the given Toy moduleAST, returns a newly created MLIR module /// Emit IR for the given Toy moduleAST, returns a newly created MLIR module
/// or nullptr on failure. /// or nullptr on failure.
mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context, ModuleAST &moduleAST); mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
ModuleAST &moduleAST);
} // namespace toy } // namespace toy
#endif // TOY_MLIRGEN_H #endif // TOY_MLIRGEN_H

View File

@ -447,8 +447,8 @@ private:
namespace toy { namespace toy {
// The public API for codegen. // The public API for codegen.
mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context, mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
ModuleAST &moduleAST) { ModuleAST &moduleAST) {
return MLIRGenImpl(context).mlirGen(moduleAST); return MLIRGenImpl(context).mlirGen(moduleAST);
} }

View File

@ -77,7 +77,7 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
} }
int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context, int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
mlir::OwningModuleRef &module) { mlir::OwningOpRef<mlir::ModuleOp> &module) {
// Handle '.toy' input to the compiler. // Handle '.toy' input to the compiler.
if (inputType != InputType::MLIR && if (inputType != InputType::MLIR &&
!llvm::StringRef(inputFilename).endswith(".mlir")) { !llvm::StringRef(inputFilename).endswith(".mlir")) {
@ -111,7 +111,7 @@ int dumpMLIR() {
// Load our Dialect in this MLIR Context. // Load our Dialect in this MLIR Context.
context.getOrLoadDialect<mlir::toy::ToyDialect>(); context.getOrLoadDialect<mlir::toy::ToyDialect>();
mlir::OwningModuleRef module; mlir::OwningOpRef<mlir::ModuleOp> module;
llvm::SourceMgr sourceMgr; llvm::SourceMgr sourceMgr;
mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context); mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context);
if (int error = loadMLIR(sourceMgr, context, module)) if (int error = loadMLIR(sourceMgr, context, module))

View File

@ -18,7 +18,9 @@
namespace mlir { namespace mlir {
class MLIRContext; class MLIRContext;
class OwningModuleRef; template <typename OpTy>
class OwningOpRef;
class ModuleOp;
} // namespace mlir } // namespace mlir
namespace toy { namespace toy {
@ -26,7 +28,8 @@ class ModuleAST;
/// Emit IR for the given Toy moduleAST, returns a newly created MLIR module /// Emit IR for the given Toy moduleAST, returns a newly created MLIR module
/// or nullptr on failure. /// or nullptr on failure.
mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context, ModuleAST &moduleAST); mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
ModuleAST &moduleAST);
} // namespace toy } // namespace toy
#endif // TOY_MLIRGEN_H #endif // TOY_MLIRGEN_H

View File

@ -447,8 +447,8 @@ private:
namespace toy { namespace toy {
// The public API for codegen. // The public API for codegen.
mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context, mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
ModuleAST &moduleAST) { ModuleAST &moduleAST) {
return MLIRGenImpl(context).mlirGen(moduleAST); return MLIRGenImpl(context).mlirGen(moduleAST);
} }

View File

@ -96,7 +96,8 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
return parser.parseModule(); return parser.parseModule();
} }
int loadMLIR(mlir::MLIRContext &context, mlir::OwningModuleRef &module) { int loadMLIR(mlir::MLIRContext &context,
mlir::OwningOpRef<mlir::ModuleOp> &module) {
// Handle '.toy' input to the compiler. // Handle '.toy' input to the compiler.
if (inputType != InputType::MLIR && if (inputType != InputType::MLIR &&
!llvm::StringRef(inputFilename).endswith(".mlir")) { !llvm::StringRef(inputFilename).endswith(".mlir")) {
@ -127,7 +128,7 @@ int loadMLIR(mlir::MLIRContext &context, mlir::OwningModuleRef &module) {
} }
int loadAndProcessMLIR(mlir::MLIRContext &context, int loadAndProcessMLIR(mlir::MLIRContext &context,
mlir::OwningModuleRef &module) { mlir::OwningOpRef<mlir::ModuleOp> &module) {
if (int error = loadMLIR(context, module)) if (int error = loadMLIR(context, module))
return error; return error;
@ -267,7 +268,7 @@ int main(int argc, char **argv) {
// Load our Dialect in this MLIR Context. // Load our Dialect in this MLIR Context.
context.getOrLoadDialect<mlir::toy::ToyDialect>(); context.getOrLoadDialect<mlir::toy::ToyDialect>();
mlir::OwningModuleRef module; mlir::OwningOpRef<mlir::ModuleOp> module;
if (int error = loadAndProcessMLIR(context, module)) if (int error = loadAndProcessMLIR(context, module))
return error; return error;

View File

@ -18,7 +18,9 @@
namespace mlir { namespace mlir {
class MLIRContext; class MLIRContext;
class OwningModuleRef; template <typename OpTy>
class OwningOpRef;
class ModuleOp;
} // namespace mlir } // namespace mlir
namespace toy { namespace toy {
@ -26,7 +28,8 @@ class ModuleAST;
/// Emit IR for the given Toy moduleAST, returns a newly created MLIR module /// Emit IR for the given Toy moduleAST, returns a newly created MLIR module
/// or nullptr on failure. /// or nullptr on failure.
mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context, ModuleAST &moduleAST); mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
ModuleAST &moduleAST);
} // namespace toy } // namespace toy
#endif // TOY_MLIRGEN_H #endif // TOY_MLIRGEN_H

View File

@ -669,8 +669,8 @@ private:
namespace toy { namespace toy {
// The public API for codegen. // The public API for codegen.
mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context, mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
ModuleAST &moduleAST) { ModuleAST &moduleAST) {
return MLIRGenImpl(context).mlirGen(moduleAST); return MLIRGenImpl(context).mlirGen(moduleAST);
} }

View File

@ -96,7 +96,8 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
return parser.parseModule(); return parser.parseModule();
} }
int loadMLIR(mlir::MLIRContext &context, mlir::OwningModuleRef &module) { int loadMLIR(mlir::MLIRContext &context,
mlir::OwningOpRef<mlir::ModuleOp> &module) {
// Handle '.toy' input to the compiler. // Handle '.toy' input to the compiler.
if (inputType != InputType::MLIR && if (inputType != InputType::MLIR &&
!llvm::StringRef(inputFilename).endswith(".mlir")) { !llvm::StringRef(inputFilename).endswith(".mlir")) {
@ -127,7 +128,7 @@ int loadMLIR(mlir::MLIRContext &context, mlir::OwningModuleRef &module) {
} }
int loadAndProcessMLIR(mlir::MLIRContext &context, int loadAndProcessMLIR(mlir::MLIRContext &context,
mlir::OwningModuleRef &module) { mlir::OwningOpRef<mlir::ModuleOp> &module) {
if (int error = loadMLIR(context, module)) if (int error = loadMLIR(context, module))
return error; return error;
@ -268,7 +269,7 @@ int main(int argc, char **argv) {
// Load our Dialect in this MLIR Context. // Load our Dialect in this MLIR Context.
context.getOrLoadDialect<mlir::toy::ToyDialect>(); context.getOrLoadDialect<mlir::toy::ToyDialect>();
mlir::OwningModuleRef module; mlir::OwningOpRef<mlir::ModuleOp> module;
if (int error = loadAndProcessMLIR(context, module)) if (int error = loadAndProcessMLIR(context, module))
return error; return error;

View File

@ -31,23 +31,6 @@
#define GET_OP_CLASSES #define GET_OP_CLASSES
#include "mlir/IR/BuiltinOps.h.inc" #include "mlir/IR/BuiltinOps.h.inc"
//===----------------------------------------------------------------------===//
// Dialect Utilities
//===----------------------------------------------------------------------===//
namespace mlir {
/// This class acts as an owning reference to a module, and will automatically
/// destroy the held module on destruction if the held module is valid.
// TODO: Remove this class in favor of using OwningOpRef directly.
class OwningModuleRef : public OwningOpRef<ModuleOp> {
public:
using OwningOpRef<ModuleOp>::OwningOpRef;
OwningModuleRef() = default;
OwningModuleRef(OwningOpRef<ModuleOp> &&other)
: OwningOpRef<ModuleOp>(std::move(other)) {}
};
} // namespace mlir
namespace llvm { namespace llvm {
/// Allow stealing the low bits of FuncOp. /// Allow stealing the low bits of FuncOp.
template <> template <>

View File

@ -612,7 +612,7 @@ public:
PDLPatternModule() = default; PDLPatternModule() = default;
/// Construct a PDL pattern with the given module. /// Construct a PDL pattern with the given module.
PDLPatternModule(OwningModuleRef pdlModule) PDLPatternModule(OwningOpRef<ModuleOp> pdlModule)
: pdlModule(std::move(pdlModule)) {} : pdlModule(std::move(pdlModule)) {}
/// Merge the state in `other` into this pattern module. /// Merge the state in `other` into this pattern module.
@ -669,7 +669,7 @@ public:
private: private:
/// The module containing the `pdl.pattern` operations. /// The module containing the `pdl.pattern` operations.
OwningModuleRef pdlModule; OwningOpRef<ModuleOp> pdlModule;
/// The external functions referenced from within the PDL module. /// The external functions referenced from within the PDL module.
llvm::StringMap<PDLConstraintFunction> constraintFunctions; llvm::StringMap<PDLConstraintFunction> constraintFunctions;

View File

@ -206,21 +206,21 @@ inline OwningOpRef<ContainerOpT> parseSourceString(llvm::StringRef sourceStr,
/// TODO: These methods are deprecated in favor of the above template versions. /// TODO: These methods are deprecated in favor of the above template versions.
/// They should be removed when usages have been updated. /// They should be removed when usages have been updated.
inline OwningModuleRef parseSourceFile(const llvm::SourceMgr &sourceMgr, inline OwningOpRef<ModuleOp> parseSourceFile(const llvm::SourceMgr &sourceMgr,
MLIRContext *context) { MLIRContext *context) {
return parseSourceFile<ModuleOp>(sourceMgr, context); return parseSourceFile<ModuleOp>(sourceMgr, context);
} }
inline OwningModuleRef parseSourceFile(llvm::StringRef filename, inline OwningOpRef<ModuleOp> parseSourceFile(llvm::StringRef filename,
MLIRContext *context) { MLIRContext *context) {
return parseSourceFile<ModuleOp>(filename, context); return parseSourceFile<ModuleOp>(filename, context);
} }
inline OwningModuleRef parseSourceFile(llvm::StringRef filename, inline OwningOpRef<ModuleOp> parseSourceFile(llvm::StringRef filename,
llvm::SourceMgr &sourceMgr, llvm::SourceMgr &sourceMgr,
MLIRContext *context) { MLIRContext *context) {
return parseSourceFile<ModuleOp>(filename, sourceMgr, context); return parseSourceFile<ModuleOp>(filename, sourceMgr, context);
} }
inline OwningModuleRef parseSourceString(llvm::StringRef moduleStr, inline OwningOpRef<ModuleOp> parseSourceString(llvm::StringRef moduleStr,
MLIRContext *context) { MLIRContext *context) {
return parseSourceString<ModuleOp>(moduleStr, context); return parseSourceString<ModuleOp>(moduleStr, context);
} }

View File

@ -25,14 +25,14 @@ class Module;
namespace mlir { namespace mlir {
class DialectRegistry; class DialectRegistry;
class OwningModuleRef;
class MLIRContext; class MLIRContext;
/// Convert the given LLVM module into MLIR's LLVM dialect. The LLVM context is /// Convert the given LLVM module into MLIR's LLVM dialect. The LLVM context is
/// extracted from the registered LLVM IR dialect. In case of error, report it /// extracted from the registered LLVM IR dialect. In case of error, report it
/// to the error handler registered with the MLIR context, if any (obtained from /// to the error handler registered with the MLIR context, if any (obtained from
/// the MLIR module), and return `{}`. /// the MLIR module), and return `{}`.
OwningModuleRef OwningOpRef<ModuleOp>
translateLLVMIRToModule(std::unique_ptr<llvm::Module> llvmModule, translateLLVMIRToModule(std::unique_ptr<llvm::Module> llvmModule,
MLIRContext *context); MLIRContext *context);

View File

@ -25,21 +25,22 @@ class DialectRegistry;
struct LogicalResult; struct LogicalResult;
class MLIRContext; class MLIRContext;
class ModuleOp; class ModuleOp;
class OwningModuleRef; template <typename OpTy>
class OwningOpRef;
/// Interface of the function that translates the sources managed by `sourceMgr` /// Interface of the function that translates the sources managed by `sourceMgr`
/// to MLIR. The source manager has at least one buffer. The implementation /// to MLIR. The source manager has at least one buffer. The implementation
/// should create a new MLIR ModuleOp in the given context and return a pointer /// should create a new MLIR ModuleOp in the given context and return a pointer
/// to it, or a nullptr in case of any error. /// to it, or a nullptr in case of any error.
using TranslateSourceMgrToMLIRFunction = using TranslateSourceMgrToMLIRFunction = std::function<OwningOpRef<ModuleOp>(
std::function<OwningModuleRef(llvm::SourceMgr &sourceMgr, MLIRContext *)>; llvm::SourceMgr &sourceMgr, MLIRContext *)>;
/// Interface of the function that translates the given string to MLIR. The /// Interface of the function that translates the given string to MLIR. The
/// implementation should create a new MLIR ModuleOp in the given context. If /// implementation should create a new MLIR ModuleOp in the given context. If
/// source-related error reporting is required from within the function, use /// source-related error reporting is required from within the function, use
/// TranslateSourceMgrToMLIRFunction instead. /// TranslateSourceMgrToMLIRFunction instead.
using TranslateStringRefToMLIRFunction = using TranslateStringRefToMLIRFunction =
std::function<OwningModuleRef(llvm::StringRef, MLIRContext *)>; std::function<OwningOpRef<ModuleOp>(llvm::StringRef, MLIRContext *)>;
/// Interface of the function that translates MLIR to a different format and /// Interface of the function that translates MLIR to a different format and
/// outputs the result to a stream. It is allowed to modify the module. /// outputs the result to a stream. It is allowed to modify the module.

View File

@ -177,7 +177,8 @@ MlirModule mlirModuleCreateEmpty(MlirLocation location) {
} }
MlirModule mlirModuleCreateParse(MlirContext context, MlirStringRef module) { MlirModule mlirModuleCreateParse(MlirContext context, MlirStringRef module) {
OwningModuleRef owning = parseSourceString(unwrap(module), unwrap(context)); OwningOpRef<ModuleOp> owning =
parseSourceString(unwrap(module), unwrap(context));
if (!owning) if (!owning)
return MlirModule{nullptr}; return MlirModule{nullptr};
return MlirModule{owning.release().getOperation()}; return MlirModule{owning.release().getOperation()};
@ -192,8 +193,9 @@ MlirBlock mlirModuleGetBody(MlirModule module) {
} }
void mlirModuleDestroy(MlirModule module) { void mlirModuleDestroy(MlirModule module) {
// Transfer ownership to an OwningModuleRef so that its destructor is called. // Transfer ownership to an OwningOpRef<ModuleOp> so that its destructor is
OwningModuleRef(unwrap(module)); // called.
OwningOpRef<ModuleOp>(unwrap(module));
} }
MlirOperation mlirModuleGetOperation(MlirModule module) { MlirOperation mlirModuleGetOperation(MlirModule module) {

View File

@ -110,8 +110,8 @@ struct CompileAndExecuteConfig {
} // namespace } // namespace
static OwningModuleRef parseMLIRInput(StringRef inputFilename, static OwningOpRef<ModuleOp> parseMLIRInput(StringRef inputFilename,
MLIRContext *context) { MLIRContext *context) {
// Set up the input file. // Set up the input file.
std::string errorMessage; std::string errorMessage;
auto file = openInputFile(inputFilename, &errorMessage); auto file = openInputFile(inputFilename, &errorMessage);
@ -122,7 +122,7 @@ static OwningModuleRef parseMLIRInput(StringRef inputFilename,
llvm::SourceMgr sourceMgr; llvm::SourceMgr sourceMgr;
sourceMgr.AddNewSourceBuffer(std::move(file), SMLoc()); sourceMgr.AddNewSourceBuffer(std::move(file), SMLoc());
return OwningModuleRef(parseSourceFile(sourceMgr, context)); return OwningOpRef<ModuleOp>(parseSourceFile(sourceMgr, context));
} }
static inline Error makeStringError(const Twine &message) { static inline Error makeStringError(const Twine &message) {

View File

@ -59,7 +59,7 @@ static LogicalResult performActions(raw_ostream &os, bool verifyDiagnostics,
// Parse the input file and reset the context threading state. // Parse the input file and reset the context threading state.
TimingScope parserTiming = timing.nest("Parser"); TimingScope parserTiming = timing.nest("Parser");
OwningModuleRef module(parseSourceFile(sourceMgr, context)); OwningOpRef<ModuleOp> module(parseSourceFile(sourceMgr, context));
context->enableMultithreading(wasThreadingEnabled); context->enableMultithreading(wasThreadingEnabled);
if (!module) if (!module)
return failure(); return failure();

View File

@ -854,11 +854,11 @@ LogicalResult Importer::processBasicBlock(llvm::BasicBlock *bb, Block *block) {
return success(); return success();
} }
OwningModuleRef OwningOpRef<ModuleOp>
mlir::translateLLVMIRToModule(std::unique_ptr<llvm::Module> llvmModule, mlir::translateLLVMIRToModule(std::unique_ptr<llvm::Module> llvmModule,
MLIRContext *context) { MLIRContext *context) {
context->loadDialect<LLVMDialect>(); context->loadDialect<LLVMDialect>();
OwningModuleRef module(ModuleOp::create( OwningOpRef<ModuleOp> module(ModuleOp::create(
FileLineColLoc::get(context, "", /*line=*/0, /*column=*/0))); FileLineColLoc::get(context, "", /*line=*/0, /*column=*/0)));
Importer deserializer(context, module.get()); Importer deserializer(context, module.get());
@ -876,8 +876,8 @@ mlir::translateLLVMIRToModule(std::unique_ptr<llvm::Module> llvmModule,
// Deserializes the LLVM bitcode stored in `input` into an MLIR module in the // Deserializes the LLVM bitcode stored in `input` into an MLIR module in the
// LLVM dialect. // LLVM dialect.
OwningModuleRef translateLLVMIRToModule(llvm::SourceMgr &sourceMgr, OwningOpRef<ModuleOp> translateLLVMIRToModule(llvm::SourceMgr &sourceMgr,
MLIRContext *context) { MLIRContext *context) {
llvm::SMDiagnostic err; llvm::SMDiagnostic err;
llvm::LLVMContext llvmContext; llvm::LLVMContext llvmContext;
std::unique_ptr<llvm::Module> llvmModule = llvm::parseIR( std::unique_ptr<llvm::Module> llvmModule = llvm::parseIR(

View File

@ -35,8 +35,8 @@ using namespace mlir;
// Deserializes the SPIR-V binary module stored in the file named as // Deserializes the SPIR-V binary module stored in the file named as
// `inputFilename` and returns a module containing the SPIR-V module. // `inputFilename` and returns a module containing the SPIR-V module.
static OwningModuleRef deserializeModule(const llvm::MemoryBuffer *input, static OwningOpRef<ModuleOp> deserializeModule(const llvm::MemoryBuffer *input,
MLIRContext *context) { MLIRContext *context) {
context->loadDialect<spirv::SPIRVDialect>(); context->loadDialect<spirv::SPIRVDialect>();
// Make sure the input stream can be treated as a stream of SPIR-V words // Make sure the input stream can be treated as a stream of SPIR-V words
@ -56,7 +56,7 @@ static OwningModuleRef deserializeModule(const llvm::MemoryBuffer *input,
if (!spirvModule) if (!spirvModule)
return {}; return {};
OwningModuleRef module(ModuleOp::create(FileLineColLoc::get( OwningOpRef<ModuleOp> module(ModuleOp::create(FileLineColLoc::get(
context, input->getBufferIdentifier(), /*line=*/0, /*column=*/0))); context, input->getBufferIdentifier(), /*line=*/0, /*column=*/0)));
module->getBody()->push_front(spirvModule.release()); module->getBody()->push_front(spirvModule.release());
@ -147,7 +147,7 @@ static LogicalResult roundTripModule(ModuleOp srcModule, bool emitDebugInfo,
return failure(); return failure();
// Wrap around in a new MLIR module. // Wrap around in a new MLIR module.
OwningModuleRef dstModule(ModuleOp::create( OwningOpRef<ModuleOp> dstModule(ModuleOp::create(
FileLineColLoc::get(&deserializationContext, FileLineColLoc::get(&deserializationContext,
/*filename=*/"", /*line=*/0, /*column=*/0))); /*filename=*/"", /*line=*/0, /*column=*/0)));
dstModule->getBody()->push_front(spirvModule.release()); dstModule->getBody()->push_front(spirvModule.release());

View File

@ -62,7 +62,7 @@ static void registerTranslateToMLIRFunction(
StringRef name, const TranslateSourceMgrToMLIRFunction &function) { StringRef name, const TranslateSourceMgrToMLIRFunction &function) {
auto wrappedFn = [function](llvm::SourceMgr &sourceMgr, raw_ostream &output, auto wrappedFn = [function](llvm::SourceMgr &sourceMgr, raw_ostream &output,
MLIRContext *context) { MLIRContext *context) {
OwningModuleRef module = function(sourceMgr, context); OwningOpRef<ModuleOp> module = function(sourceMgr, context);
if (!module || failed(verify(*module))) if (!module || failed(verify(*module)))
return failure(); return failure();
module->print(output); module->print(output);
@ -101,7 +101,7 @@ TranslateFromMLIRRegistration::TranslateFromMLIRRegistration(
DialectRegistry registry; DialectRegistry registry;
dialectRegistration(registry); dialectRegistration(registry);
context->appendDialectRegistry(registry); context->appendDialectRegistry(registry);
auto module = OwningModuleRef(parseSourceFile(sourceMgr, context)); auto module = OwningOpRef<ModuleOp>(parseSourceFile(sourceMgr, context));
if (!module || failed(verify(*module))) if (!module || failed(verify(*module)))
return failure(); return failure();
return function(module.get(), output); return function(module.get(), output);

View File

@ -63,7 +63,7 @@ TEST(MLIRExecutionEngine, AddInteger) {
registerAllDialects(registry); registerAllDialects(registry);
registerLLVMDialectTranslation(registry); registerLLVMDialectTranslation(registry);
MLIRContext context(registry); MLIRContext context(registry);
OwningModuleRef module = parseSourceString(moduleStr, &context); OwningOpRef<ModuleOp> module = parseSourceString(moduleStr, &context);
ASSERT_TRUE(!!module); ASSERT_TRUE(!!module);
ASSERT_TRUE(succeeded(lowerToLLVMDialect(*module))); ASSERT_TRUE(succeeded(lowerToLLVMDialect(*module)));
auto jitOrError = ExecutionEngine::create(*module); auto jitOrError = ExecutionEngine::create(*module);
@ -88,7 +88,7 @@ TEST(MLIRExecutionEngine, SubtractFloat) {
registerAllDialects(registry); registerAllDialects(registry);
registerLLVMDialectTranslation(registry); registerLLVMDialectTranslation(registry);
MLIRContext context(registry); MLIRContext context(registry);
OwningModuleRef module = parseSourceString(moduleStr, &context); OwningOpRef<ModuleOp> module = parseSourceString(moduleStr, &context);
ASSERT_TRUE(!!module); ASSERT_TRUE(!!module);
ASSERT_TRUE(succeeded(lowerToLLVMDialect(*module))); ASSERT_TRUE(succeeded(lowerToLLVMDialect(*module)));
auto jitOrError = ExecutionEngine::create(*module); auto jitOrError = ExecutionEngine::create(*module);
@ -207,7 +207,7 @@ TEST(NativeMemRefJit, BasicMemref) {
registerAllDialects(registry); registerAllDialects(registry);
registerLLVMDialectTranslation(registry); registerLLVMDialectTranslation(registry);
MLIRContext context(registry); MLIRContext context(registry);
OwningModuleRef module = parseSourceString(moduleStr, &context); OwningOpRef<ModuleOp> module = parseSourceString(moduleStr, &context);
ASSERT_TRUE(!!module); ASSERT_TRUE(!!module);
ASSERT_TRUE(succeeded(lowerToLLVMDialect(*module))); ASSERT_TRUE(succeeded(lowerToLLVMDialect(*module)));
auto jitOrError = ExecutionEngine::create(*module); auto jitOrError = ExecutionEngine::create(*module);

View File

@ -83,7 +83,7 @@ TEST(RegionBranchOpInterface, MutuallyExclusiveOps) {
registry.insert<CFTestDialect>(); registry.insert<CFTestDialect>();
MLIRContext ctx(registry); MLIRContext ctx(registry);
OwningModuleRef module = parseSourceString(ir, &ctx); OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
Operation *testOp = &module->getBody()->getOperations().front(); Operation *testOp = &module->getBody()->getOperations().front();
Operation *op1 = &testOp->getRegion(0).front().front(); Operation *op1 = &testOp->getRegion(0).front().front();
Operation *op2 = &testOp->getRegion(1).front().front(); Operation *op2 = &testOp->getRegion(1).front().front();
@ -104,7 +104,7 @@ TEST(RegionBranchOpInterface, NotMutuallyExclusiveOps) {
registry.insert<CFTestDialect>(); registry.insert<CFTestDialect>();
MLIRContext ctx(registry); MLIRContext ctx(registry);
OwningModuleRef module = parseSourceString(ir, &ctx); OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
Operation *testOp = &module->getBody()->getOperations().front(); Operation *testOp = &module->getBody()->getOperations().front();
Operation *op1 = &testOp->getRegion(0).front().front(); Operation *op1 = &testOp->getRegion(0).front().front();
Operation *op2 = &testOp->getRegion(1).front().front(); Operation *op2 = &testOp->getRegion(1).front().front();
@ -131,7 +131,7 @@ TEST(RegionBranchOpInterface, NestedMutuallyExclusiveOps) {
registry.insert<CFTestDialect>(); registry.insert<CFTestDialect>();
MLIRContext ctx(registry); MLIRContext ctx(registry);
OwningModuleRef module = parseSourceString(ir, &ctx); OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
Operation *testOp = &module->getBody()->getOperations().front(); Operation *testOp = &module->getBody()->getOperations().front();
Operation *op1 = Operation *op1 =
&testOp->getRegion(0).front().front().getRegion(0).front().front(); &testOp->getRegion(0).front().front().getRegion(0).front().front();

View File

@ -236,7 +236,7 @@ module {}
registry.insert<DLTIDialect, DLTestDialect>(); registry.insert<DLTIDialect, DLTestDialect>();
MLIRContext ctx(registry); MLIRContext ctx(registry);
OwningModuleRef module = parseSourceString(ir, &ctx); OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
DataLayout layout(module.get()); DataLayout layout(module.get());
EXPECT_EQ(layout.getTypeSize(IntegerType::get(&ctx, 42)), 6u); EXPECT_EQ(layout.getTypeSize(IntegerType::get(&ctx, 42)), 6u);
EXPECT_EQ(layout.getTypeSize(Float16Type::get(&ctx)), 2u); EXPECT_EQ(layout.getTypeSize(Float16Type::get(&ctx)), 2u);
@ -257,7 +257,7 @@ TEST(DataLayout, NullSpec) {
registry.insert<DLTIDialect, DLTestDialect>(); registry.insert<DLTIDialect, DLTestDialect>();
MLIRContext ctx(registry); MLIRContext ctx(registry);
OwningModuleRef module = parseSourceString(ir, &ctx); OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
auto op = auto op =
cast<DataLayoutOpInterface>(module->getBody()->getOperations().front()); cast<DataLayoutOpInterface>(module->getBody()->getOperations().front());
DataLayout layout(op); DataLayout layout(op);
@ -280,7 +280,7 @@ TEST(DataLayout, EmptySpec) {
registry.insert<DLTIDialect, DLTestDialect>(); registry.insert<DLTIDialect, DLTestDialect>();
MLIRContext ctx(registry); MLIRContext ctx(registry);
OwningModuleRef module = parseSourceString(ir, &ctx); OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
auto op = auto op =
cast<DataLayoutOpInterface>(module->getBody()->getOperations().front()); cast<DataLayoutOpInterface>(module->getBody()->getOperations().front());
DataLayout layout(op); DataLayout layout(op);
@ -306,7 +306,7 @@ TEST(DataLayout, SpecWithEntries) {
registry.insert<DLTIDialect, DLTestDialect>(); registry.insert<DLTIDialect, DLTestDialect>();
MLIRContext ctx(registry); MLIRContext ctx(registry);
OwningModuleRef module = parseSourceString(ir, &ctx); OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
auto op = auto op =
cast<DataLayoutOpInterface>(module->getBody()->getOperations().front()); cast<DataLayoutOpInterface>(module->getBody()->getOperations().front());
DataLayout layout(op); DataLayout layout(op);
@ -338,7 +338,7 @@ TEST(DataLayout, Caching) {
registry.insert<DLTIDialect, DLTestDialect>(); registry.insert<DLTIDialect, DLTestDialect>();
MLIRContext ctx(registry); MLIRContext ctx(registry);
OwningModuleRef module = parseSourceString(ir, &ctx); OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
auto op = auto op =
cast<DataLayoutOpInterface>(module->getBody()->getOperations().front()); cast<DataLayoutOpInterface>(module->getBody()->getOperations().front());
DataLayout layout(op); DataLayout layout(op);
@ -369,7 +369,7 @@ TEST(DataLayout, CacheInvalidation) {
registry.insert<DLTIDialect, DLTestDialect>(); registry.insert<DLTIDialect, DLTestDialect>();
MLIRContext ctx(registry); MLIRContext ctx(registry);
OwningModuleRef module = parseSourceString(ir, &ctx); OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
auto op = auto op =
cast<DataLayoutOpInterface>(module->getBody()->getOperations().front()); cast<DataLayoutOpInterface>(module->getBody()->getOperations().front());
DataLayout layout(op); DataLayout layout(op);
@ -395,7 +395,7 @@ TEST(DataLayout, UnimplementedTypeInterface) {
registry.insert<DLTIDialect, DLTestDialect>(); registry.insert<DLTIDialect, DLTestDialect>();
MLIRContext ctx(registry); MLIRContext ctx(registry);
OwningModuleRef module = parseSourceString(ir, &ctx); OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
auto op = auto op =
cast<DataLayoutOpInterface>(module->getBody()->getOperations().front()); cast<DataLayoutOpInterface>(module->getBody()->getOperations().front());
DataLayout layout(op); DataLayout layout(op);
@ -414,7 +414,7 @@ TEST(DataLayout, SevenBitByte) {
registry.insert<DLTIDialect, DLTestDialect>(); registry.insert<DLTIDialect, DLTestDialect>();
MLIRContext ctx(registry); MLIRContext ctx(registry);
OwningModuleRef module = parseSourceString(ir, &ctx); OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
auto op = auto op =
cast<DataLayoutOpInterface>(module->getBody()->getOperations().front()); cast<DataLayoutOpInterface>(module->getBody()->getOperations().front());
DataLayout layout(op); DataLayout layout(op);

View File

@ -47,7 +47,7 @@ protected:
DialectRegistry registry; DialectRegistry registry;
MLIRContext ctx; MLIRContext ctx;
OwningModuleRef module; OwningOpRef<ModuleOp> module;
FuncOp mapFn; FuncOp mapFn;
}; };

View File

@ -32,7 +32,7 @@ TEST(AnalysisManagerTest, FineGrainModuleAnalysisPreservation) {
MLIRContext context; MLIRContext context;
// Test fine grain invalidation of the module analysis manager. // Test fine grain invalidation of the module analysis manager.
OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context))); OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
ModuleAnalysisManager mam(*module, /*passInstrumentor=*/nullptr); ModuleAnalysisManager mam(*module, /*passInstrumentor=*/nullptr);
AnalysisManager am = mam; AnalysisManager am = mam;
@ -54,7 +54,7 @@ TEST(AnalysisManagerTest, FineGrainFunctionAnalysisPreservation) {
Builder builder(&context); Builder builder(&context);
// Create a function and a module. // Create a function and a module.
OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context))); OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
FuncOp func1 = FuncOp func1 =
FuncOp::create(builder.getUnknownLoc(), "foo", FuncOp::create(builder.getUnknownLoc(), "foo",
builder.getFunctionType(llvm::None, llvm::None)); builder.getFunctionType(llvm::None, llvm::None));
@ -84,7 +84,7 @@ TEST(AnalysisManagerTest, FineGrainChildFunctionAnalysisPreservation) {
Builder builder(&context); Builder builder(&context);
// Create a function and a module. // Create a function and a module.
OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context))); OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
FuncOp func1 = FuncOp func1 =
FuncOp::create(builder.getUnknownLoc(), "foo", FuncOp::create(builder.getUnknownLoc(), "foo",
builder.getFunctionType(llvm::None, llvm::None)); builder.getFunctionType(llvm::None, llvm::None));
@ -128,7 +128,7 @@ TEST(AnalysisManagerTest, CustomInvalidation) {
Builder builder(&context); Builder builder(&context);
// Create a function and a module. // Create a function and a module.
OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context))); OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
ModuleAnalysisManager mam(*module, /*passInstrumentor=*/nullptr); ModuleAnalysisManager mam(*module, /*passInstrumentor=*/nullptr);
AnalysisManager am = mam; AnalysisManager am = mam;
@ -150,7 +150,7 @@ TEST(AnalysisManagerTest, OpSpecificAnalysis) {
MLIRContext context; MLIRContext context;
// Create a module. // Create a module.
OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context))); OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
ModuleAnalysisManager mam(*module, /*passInstrumentor=*/nullptr); ModuleAnalysisManager mam(*module, /*passInstrumentor=*/nullptr);
AnalysisManager am = mam; AnalysisManager am = mam;
@ -174,7 +174,7 @@ TEST(AnalysisManagerTest, DependentAnalysis) {
MLIRContext context; MLIRContext context;
// Create a module. // Create a module.
OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context))); OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
ModuleAnalysisManager mam(*module, /*passInstrumentor=*/nullptr); ModuleAnalysisManager mam(*module, /*passInstrumentor=*/nullptr);
AnalysisManager am = mam; AnalysisManager am = mam;
@ -205,7 +205,7 @@ TEST(AnalysisManagerTest, NestedDependentAnalysis) {
MLIRContext context; MLIRContext context;
// Create a module. // Create a module.
OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context))); OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
ModuleAnalysisManager mam(*module, /*passInstrumentor=*/nullptr); ModuleAnalysisManager mam(*module, /*passInstrumentor=*/nullptr);
AnalysisManager am = mam; AnalysisManager am = mam;
@ -237,7 +237,7 @@ TEST(AnalysisManagerTest, DependentAnalysis2Ctors) {
MLIRContext context; MLIRContext context;
// Create a module. // Create a module.
OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context))); OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
ModuleAnalysisManager mam(*module, /*passInstrumentor=*/nullptr); ModuleAnalysisManager mam(*module, /*passInstrumentor=*/nullptr);
AnalysisManager am = mam; AnalysisManager am = mam;

View File

@ -50,7 +50,7 @@ TEST(PassManagerTest, OpSpecificAnalysis) {
Builder builder(&context); Builder builder(&context);
// Create a module with 2 functions. // Create a module with 2 functions.
OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context))); OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
for (StringRef name : {"secret", "not_secret"}) { for (StringRef name : {"secret", "not_secret"}) {
FuncOp func = FuncOp func =
FuncOp::create(builder.getUnknownLoc(), name, FuncOp::create(builder.getUnknownLoc(), name,
@ -95,7 +95,7 @@ TEST(PassManagerTest, InvalidPass) {
context.allowUnregisteredDialects(); context.allowUnregisteredDialects();
// Create a module // Create a module
OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context))); OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
// Add a single "invalid_op" operation // Add a single "invalid_op" operation
OpBuilder builder(&module->getBodyRegion()); OpBuilder builder(&module->getBodyRegion());

View File

@ -74,7 +74,7 @@ TEST(CanonicalizerTest, TestDisablePatterns) {
%1 = "test.foo"() {sym_name = "B"} : () -> (f32) %1 = "test.foo"() {sym_name = "B"} : () -> (f32)
)mlir"; )mlir";
OwningModuleRef module = mlir::parseSourceString(code, &context); OwningOpRef<ModuleOp> module = mlir::parseSourceString(code, &context);
ASSERT_TRUE(succeeded(mgr.run(*module))); ASSERT_TRUE(succeeded(mgr.run(*module)));
EXPECT_TRUE(module->lookupSymbol("B")); EXPECT_TRUE(module->lookupSymbol("B"));