Skip to content

[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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mlir/include/mlir/Target/LLVMIR/Export.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document

Copy link
Contributor Author

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

} // namespace mlir

#endif // MLIR_TARGET_LLVMIR_EXPORT_H
3 changes: 2 additions & 1 deletion mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Loading