[Mlir-commits] [mlir] 2af37cf - Check for nullptr before dereferencing in translateModuleToLLVMIR()
Mehdi Amini
llvmlistbot at llvm.org
Thu Nov 5 20:09:32 PST 2020
Author: Mehdi Amini
Date: 2020-11-06T04:09:18Z
New Revision: 2af37cf7ffc43daa9523f209050761039c29964b
URL: https://github.com/llvm/llvm-project/commit/2af37cf7ffc43daa9523f209050761039c29964b
DIFF: https://github.com/llvm/llvm-project/commit/2af37cf7ffc43daa9523f209050761039c29964b.diff
LOG: Check for nullptr before dereferencing in translateModuleToLLVMIR()
This is defensive with respect to invocations of this API with an IR
that isn't ready to be converted to LLVM IR.
Added:
Modified:
mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp
index 8f22b734538e..476f3658f304 100644
--- a/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp
+++ b/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp
@@ -28,7 +28,9 @@ mlir::translateModuleToLLVMIR(ModuleOp m, llvm::LLVMContext &llvmContext,
StringRef name) {
auto llvmModule =
LLVM::ModuleTranslation::translateModule<>(m, llvmContext, name);
- if (verifyModule(*llvmModule))
+ if (!llvmModule)
+ emitError(m.getLoc(), "Fail to convert MLIR to LLVM IR");
+ else if (verifyModule(*llvmModule))
emitError(m.getLoc(), "LLVM IR fails to verify");
return llvmModule;
}
More information about the Mlir-commits
mailing list