File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -1276,6 +1276,7 @@ void CodeGenAction::executeAction() {
12761276 if (action == BackendActionTy::Backend_EmitLL) {
12771277 // When printing LLVM IR, we should convert the module to the debug info
12781278 // format that LLVM expects us to print.
1279+ // See https://llvm.org/docs/RemoveDIsDebugInfo.html
12791280 llvm::ScopedDbgInfoFormatSetter FormatSetter (*llvmModule,
12801281 WriteNewDbgInfoFormat);
12811282 if (WriteNewDbgInfoFormat)
Original file line number Diff line number Diff line change 1616#include " mlir/Target/LLVMIR/Dialect/All.h"
1717#include " mlir/Target/LLVMIR/Export.h"
1818#include " mlir/Tools/mlir-translate/Translation.h"
19+ #include " llvm/IR/DebugProgramInstruction.h"
1920#include " llvm/IR/LLVMContext.h"
2021#include " llvm/IR/Module.h"
2122
23+ extern llvm::cl::opt<bool > WriteNewDbgInfoFormat;
24+
2225using namespace mlir ;
2326
2427namespace mlir {
@@ -31,6 +34,13 @@ void registerToLLVMIRTranslation() {
3134 if (!llvmModule)
3235 return failure ();
3336
37+ // When printing LLVM IR, we should convert the module to the debug info
38+ // format that LLVM expects us to print.
39+ // See https://llvm.org/docs/RemoveDIsDebugInfo.html
40+ llvm::ScopedDbgInfoFormatSetter FormatSetter (*llvmModule,
41+ WriteNewDbgInfoFormat);
42+ if (WriteNewDbgInfoFormat)
43+ llvmModule->removeDebugIntrinsicDeclarations ();
3444 llvmModule->print (output, nullptr );
3545 return success ();
3646 },
Original file line number Diff line number Diff line change 2222#include " mlir/Tools/mlir-translate/Translation.h"
2323#include " llvm/ADT/StringSwitch.h"
2424#include " llvm/ADT/TypeSwitch.h"
25+ #include " llvm/IR/DebugProgramInstruction.h"
26+
27+ extern llvm::cl::opt<bool > WriteNewDbgInfoFormat;
2528
2629using namespace mlir ;
2730
@@ -122,6 +125,13 @@ void registerTestToLLVMIR() {
122125 if (!llvmModule)
123126 return failure ();
124127
128+ // When printing LLVM IR, we should convert the module to the debug info
129+ // format that LLVM expects us to print.
130+ // See https://llvm.org/docs/RemoveDIsDebugInfo.html
131+ llvm::ScopedDbgInfoFormatSetter FormatSetter (*llvmModule,
132+ WriteNewDbgInfoFormat);
133+ if (WriteNewDbgInfoFormat)
134+ llvmModule->removeDebugIntrinsicDeclarations ();
125135 llvmModule->print (output, nullptr );
126136 return success ();
127137 },
You can’t perform that action at this time.
0 commit comments