summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Target
diff options
context:
space:
mode:
authorAlex Zinenko <zinenko@google.com>2019-11-07 11:42:11 -0800
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-11-07 11:42:46 -0800
commit09e8e7107aafcdc61632ed0aabfa63255859e87a (patch)
treef959bddf1f25131141c029205983d1233441efb1 /mlir/lib/Target
parenteb47d5ee66e2e3dc4d9f2fc7768c41f6b037f3db (diff)
downloadbcm5719-llvm-09e8e7107aafcdc61632ed0aabfa63255859e87a.tar.gz
bcm5719-llvm-09e8e7107aafcdc61632ed0aabfa63255859e87a.zip
mlir-translate: support -verify-diagnostics
MLIR translation tools can emit diagnostics and we want to be able to check if it is indeed the case in tests. Reuse the source manager error handlers provided for mlir-opt to support the verification in mlir-translate. This requires us to change the signature of the functions that are registered to translate sources to MLIR: it now takes a source manager instead of a memory buffer. PiperOrigin-RevId: 279132972
Diffstat (limited to 'mlir/lib/Target')
-rw-r--r--mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
index 47b92b9e884..fd4e4134d8b 100644
--- a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
+++ b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
@@ -571,15 +571,15 @@ mlir::translateLLVMIRToModule(std::unique_ptr<llvm::Module> llvmModule,
// Deserializes the LLVM bitcode stored in `input` into an MLIR module in the
// LLVM dialect.
-OwningModuleRef
-translateLLVMIRToModule(std::unique_ptr<llvm::MemoryBuffer> input,
- MLIRContext *context) {
+OwningModuleRef translateLLVMIRToModule(llvm::SourceMgr &sourceMgr,
+ MLIRContext *context) {
LLVMDialect *dialect = context->getRegisteredDialect<LLVMDialect>();
assert(dialect && "Could not find LLVMDialect?");
llvm::SMDiagnostic err;
std::unique_ptr<llvm::Module> llvmModule =
- llvm::parseIR(*input, err, dialect->getLLVMContext(),
+ llvm::parseIR(*sourceMgr.getMemoryBuffer(sourceMgr.getMainFileID()), err,
+ dialect->getLLVMContext(),
/*UpgradeDebugInfo=*/true,
/*DataLayoutString=*/"");
if (!llvmModule) {
@@ -593,7 +593,7 @@ translateLLVMIRToModule(std::unique_ptr<llvm::MemoryBuffer> input,
}
static TranslateToMLIRRegistration
- fromLLVM("import-llvm", [](std::unique_ptr<llvm::MemoryBuffer> input,
- MLIRContext *context) {
- return translateLLVMIRToModule(std::move(input), context);
- });
+ fromLLVM("import-llvm",
+ [](llvm::SourceMgr &sourceMgr, MLIRContext *context) {
+ return translateLLVMIRToModule(sourceMgr, context);
+ });
OpenPOWER on IntegriCloud