Skip to content

Commit d83f37f

Browse files
committed
Revert#2 "[MLIR][Flang][DebugInfo] Set debug info format in MLIR->IR translation (#95098)"
Also reverts "[MLIR][Flang][DebugInfo] Convert debug format in MLIR translators" The patch above introduces behaviour controlled by an LLVM flag into the Flang driver, which is incorrect behaviour. This reverts commits: 3cc2710. 460408f.
1 parent 2eb60e2 commit d83f37f

File tree

4 files changed

+0
-40
lines changed

4 files changed

+0
-40
lines changed

flang/lib/Frontend/FrontendActions.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
#include "llvm/Analysis/TargetTransformInfo.h"
5151
#include "llvm/Bitcode/BitcodeWriterPass.h"
5252
#include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h"
53-
#include "llvm/IR/DebugProgramInstruction.h"
5453
#include "llvm/IR/LLVMRemarkStreamer.h"
5554
#include "llvm/IR/LegacyPassManager.h"
5655
#include "llvm/IR/Verifier.h"
@@ -82,8 +81,6 @@ using namespace Fortran::frontend;
8281
llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
8382
#include "llvm/Support/Extension.def"
8483

85-
extern llvm::cl::opt<bool> WriteNewDbgInfoFormat;
86-
8784
/// Save the given \c mlirModule to a temporary .mlir file, in a location
8885
/// decided by the -save-temps flag. No files are produced if the flag is not
8986
/// specified.
@@ -1274,13 +1271,6 @@ void CodeGenAction::executeAction() {
12741271
runOptimizationPipeline(ci.isOutputStreamNull() ? *os : ci.getOutputStream());
12751272

12761273
if (action == BackendActionTy::Backend_EmitLL) {
1277-
// When printing LLVM IR, we should convert the module to the debug info
1278-
// format that LLVM expects us to print.
1279-
// See https://llvm.org/docs/RemoveDIsDebugInfo.html
1280-
llvm::ScopedDbgInfoFormatSetter FormatSetter(*llvmModule,
1281-
WriteNewDbgInfoFormat);
1282-
if (WriteNewDbgInfoFormat)
1283-
llvmModule->removeDebugIntrinsicDeclarations();
12841274
llvmModule->print(ci.isOutputStreamNull() ? *os : ci.getOutputStream(),
12851275
/*AssemblyAnnotationWriter=*/nullptr);
12861276
return;

mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@
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"
2019
#include "llvm/IR/LLVMContext.h"
2120
#include "llvm/IR/Module.h"
2221

23-
extern llvm::cl::opt<bool> WriteNewDbgInfoFormat;
24-
2522
using namespace mlir;
2623

2724
namespace mlir {
@@ -34,13 +31,6 @@ void registerToLLVMIRTranslation() {
3431
if (!llvmModule)
3532
return failure();
3633

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();
4434
llvmModule->print(output, nullptr);
4535
return success();
4636
},

mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ using namespace mlir;
6464
using namespace mlir::LLVM;
6565
using namespace mlir::LLVM::detail;
6666

67-
extern llvm::cl::opt<bool> UseNewDbgInfoFormat;
68-
6967
#include "mlir/Dialect/LLVMIR/LLVMConversionEnumsToLLVM.inc"
7068

7169
namespace {
@@ -1791,9 +1789,6 @@ prepareLLVMModule(Operation *m, llvm::LLVMContext &llvmContext,
17911789
StringRef name) {
17921790
m->getContext()->getOrLoadDialect<LLVM::LLVMDialect>();
17931791
auto llvmModule = std::make_unique<llvm::Module>(name, llvmContext);
1794-
// ModuleTranslation can currently only construct modules in the old debug
1795-
// info format, so set the flag accordingly.
1796-
llvmModule->setNewDbgInfoFormatFlag(false);
17971792
if (auto dataLayoutAttr =
17981793
m->getDiscardableAttr(LLVM::LLVMDialect::getDataLayoutAttrName())) {
17991794
llvmModule->setDataLayout(cast<StringAttr>(dataLayoutAttr).getValue());
@@ -1872,11 +1867,6 @@ mlir::translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext,
18721867
if (failed(translator.convertFunctions()))
18731868
return nullptr;
18741869

1875-
// Once we've finished constructing elements in the module, we should convert
1876-
// it to use the debug info format desired by LLVM.
1877-
// See https://llvm.org/docs/RemoveDIsDebugInfo.html
1878-
translator.llvmModule->setIsNewDbgInfoFormat(UseNewDbgInfoFormat);
1879-
18801870
if (!disableVerification &&
18811871
llvm::verifyModule(*translator.llvmModule, &llvm::errs()))
18821872
return nullptr;

mlir/test/lib/Dialect/Test/TestToLLVMIRTranslation.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
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;
2825

2926
using namespace mlir;
3027

@@ -125,13 +122,6 @@ void registerTestToLLVMIR() {
125122
if (!llvmModule)
126123
return failure();
127124

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();
135125
llvmModule->print(output, nullptr);
136126
return success();
137127
},

0 commit comments

Comments
 (0)