File tree 3 files changed +21
-0
lines changed
3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -1276,6 +1276,7 @@ void CodeGenAction::executeAction() {
1276
1276
if (action == BackendActionTy::Backend_EmitLL) {
1277
1277
// When printing LLVM IR, we should convert the module to the debug info
1278
1278
// format that LLVM expects us to print.
1279
+ // See https://llvm.org/docs/RemoveDIsDebugInfo.html
1279
1280
llvm::ScopedDbgInfoFormatSetter FormatSetter (*llvmModule,
1280
1281
WriteNewDbgInfoFormat);
1281
1282
if (WriteNewDbgInfoFormat)
Original file line number Diff line number Diff line change 16
16
#include " mlir/Target/LLVMIR/Dialect/All.h"
17
17
#include " mlir/Target/LLVMIR/Export.h"
18
18
#include " mlir/Tools/mlir-translate/Translation.h"
19
+ #include " llvm/IR/DebugProgramInstruction.h"
19
20
#include " llvm/IR/LLVMContext.h"
20
21
#include " llvm/IR/Module.h"
21
22
23
+ extern llvm::cl::opt<bool > WriteNewDbgInfoFormat;
24
+
22
25
using namespace mlir ;
23
26
24
27
namespace mlir {
@@ -31,6 +34,13 @@ void registerToLLVMIRTranslation() {
31
34
if (!llvmModule)
32
35
return failure ();
33
36
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 ();
34
44
llvmModule->print (output, nullptr );
35
45
return success ();
36
46
},
Original file line number Diff line number Diff line change 22
22
#include " mlir/Tools/mlir-translate/Translation.h"
23
23
#include " llvm/ADT/StringSwitch.h"
24
24
#include " llvm/ADT/TypeSwitch.h"
25
+ #include " llvm/IR/DebugProgramInstruction.h"
26
+
27
+ extern llvm::cl::opt<bool > WriteNewDbgInfoFormat;
25
28
26
29
using namespace mlir ;
27
30
@@ -122,6 +125,13 @@ void registerTestToLLVMIR() {
122
125
if (!llvmModule)
123
126
return failure ();
124
127
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 ();
125
135
llvmModule->print (output, nullptr );
126
136
return success ();
127
137
},
You can’t perform that action at this time.
0 commit comments