diff options
Diffstat (limited to 'mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp')
| -rw-r--r-- | mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp index 455889377953..92e786b130ab 100644 --- a/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp @@ -16,9 +16,12 @@ #include "mlir/Target/LLVMIR/Dialect/All.h" #include "mlir/Target/LLVMIR/Export.h" #include "mlir/Tools/mlir-translate/Translation.h" +#include "llvm/IR/DebugProgramInstruction.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" +extern llvm::cl::opt<bool> WriteNewDbgInfoFormat; + using namespace mlir; namespace mlir { @@ -31,6 +34,13 @@ void registerToLLVMIRTranslation() { if (!llvmModule) return failure(); + // When printing LLVM IR, we should convert the module to the debug info + // format that LLVM expects us to print. + // See https://llvm.org/docs/RemoveDIsDebugInfo.html + llvm::ScopedDbgInfoFormatSetter formatSetter(*llvmModule, + WriteNewDbgInfoFormat); + if (WriteNewDbgInfoFormat) + llvmModule->removeDebugIntrinsicDeclarations(); llvmModule->print(output, nullptr); return success(); }, |
