-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[MLIR][ModuleTranslation] Add disableVerification parameter (NFC) #94445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MLIR][ModuleTranslation] Add disableVerification parameter (NFC) #94445
Conversation
This commit adds a boolean parameter that allows downstream users to disable the verification when translating an MLIR module to LLVM IR. This is helpful for debugging broken LLVM IR modules post translation.
@llvm/pr-subscribers-mlir Author: Christian Ulmann (Dinistro) ChangesThis commit adds a boolean parameter that allows downstream users to disable the verification when translating an MLIR module to LLVM IR. This is helpful for debugging broken LLVM IR modules post translation. Full diff: https://github.com/llvm/llvm-project/pull/94445.diff 3 Files Affected:
diff --git a/mlir/include/mlir/Target/LLVMIR/Export.h b/mlir/include/mlir/Target/LLVMIR/Export.h
index f9a6db0fc94d5..2244968655138 100644
--- a/mlir/include/mlir/Target/LLVMIR/Export.h
+++ b/mlir/include/mlir/Target/LLVMIR/Export.h
@@ -26,7 +26,8 @@ class Operation;
/// LLVMTranslationDialectInterface.
std::unique_ptr<llvm::Module>
translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext,
- llvm::StringRef name = "LLVMDialectModule");
+ llvm::StringRef name = "LLVMDialectModule",
+ bool disableVerification = false);
} // namespace mlir
#endif // MLIR_TARGET_LLVMIR_EXPORT_H
diff --git a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
index 310a43e0de96b..85fdfed3bdbeb 100644
--- a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
+++ b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
@@ -57,7 +57,8 @@ class ComdatSelectorOp;
/// needs to look up block and function mappings.
class ModuleTranslation {
friend std::unique_ptr<llvm::Module>
- mlir::translateModuleToLLVMIR(Operation *, llvm::LLVMContext &, StringRef);
+ mlir::translateModuleToLLVMIR(Operation *, llvm::LLVMContext &, StringRef,
+ bool);
public:
/// Stores the mapping between a function name and its LLVM IR representation.
diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index 1ec0736ec08bf..9d3666ec20f34 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -1783,7 +1783,7 @@ prepareLLVMModule(Operation *m, llvm::LLVMContext &llvmContext,
std::unique_ptr<llvm::Module>
mlir::translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext,
- StringRef name) {
+ StringRef name, bool disableVerification) {
if (!satisfiesLLVMModule(module)) {
module->emitOpError("can not be translated to an LLVMIR module");
return nullptr;
@@ -1832,7 +1832,8 @@ mlir::translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext,
if (failed(translator.convertFunctions()))
return nullptr;
- if (llvm::verifyModule(*translator.llvmModule, &llvm::errs()))
+ if (!disableVerification &&
+ llvm::verifyModule(*translator.llvmModule, &llvm::errs()))
return nullptr;
return std::move(translator.llvmModule);
|
@llvm/pr-subscribers-mlir-llvm Author: Christian Ulmann (Dinistro) ChangesThis commit adds a boolean parameter that allows downstream users to disable the verification when translating an MLIR module to LLVM IR. This is helpful for debugging broken LLVM IR modules post translation. Full diff: https://github.com/llvm/llvm-project/pull/94445.diff 3 Files Affected:
diff --git a/mlir/include/mlir/Target/LLVMIR/Export.h b/mlir/include/mlir/Target/LLVMIR/Export.h
index f9a6db0fc94d5..2244968655138 100644
--- a/mlir/include/mlir/Target/LLVMIR/Export.h
+++ b/mlir/include/mlir/Target/LLVMIR/Export.h
@@ -26,7 +26,8 @@ class Operation;
/// LLVMTranslationDialectInterface.
std::unique_ptr<llvm::Module>
translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext,
- llvm::StringRef name = "LLVMDialectModule");
+ llvm::StringRef name = "LLVMDialectModule",
+ bool disableVerification = false);
} // namespace mlir
#endif // MLIR_TARGET_LLVMIR_EXPORT_H
diff --git a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
index 310a43e0de96b..85fdfed3bdbeb 100644
--- a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
+++ b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
@@ -57,7 +57,8 @@ class ComdatSelectorOp;
/// needs to look up block and function mappings.
class ModuleTranslation {
friend std::unique_ptr<llvm::Module>
- mlir::translateModuleToLLVMIR(Operation *, llvm::LLVMContext &, StringRef);
+ mlir::translateModuleToLLVMIR(Operation *, llvm::LLVMContext &, StringRef,
+ bool);
public:
/// Stores the mapping between a function name and its LLVM IR representation.
diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index 1ec0736ec08bf..9d3666ec20f34 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -1783,7 +1783,7 @@ prepareLLVMModule(Operation *m, llvm::LLVMContext &llvmContext,
std::unique_ptr<llvm::Module>
mlir::translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext,
- StringRef name) {
+ StringRef name, bool disableVerification) {
if (!satisfiesLLVMModule(module)) {
module->emitOpError("can not be translated to an LLVMIR module");
return nullptr;
@@ -1832,7 +1832,8 @@ mlir::translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext,
if (failed(translator.convertFunctions()))
return nullptr;
- if (llvm::verifyModule(*translator.llvmModule, &llvm::errs()))
+ if (!disableVerification &&
+ llvm::verifyModule(*translator.llvmModule, &llvm::errs()))
return nullptr;
return std::move(translator.llvmModule);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -26,7 +26,8 @@ class Operation; | |||
/// LLVMTranslationDialectInterface. | |||
std::unique_ptr<llvm::Module> | |||
translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext, | |||
llvm::StringRef name = "LLVMDialectModule"); | |||
llvm::StringRef name = "LLVMDialectModule", | |||
bool disableVerification = false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, improved here: #94577
This commit enhances the docsting of `translateModuleToLLVMIR` as a followup to #94445
This commit enhances the docsting of `translateModuleToLLVMIR` as a followup to #94445
This commit adds a boolean parameter that allows downstream users to disable the verification when translating an MLIR module to LLVM IR. This is helpful for debugging broken LLVM IR modules post translation.