From d83f37f039dbd96918feb94c441882f71d772e55 Mon Sep 17 00:00:00 2001 From: Stephen Tozer Date: Tue, 11 Jun 2024 15:14:21 +0100 Subject: [PATCH] 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: 3cc2710e0dd53bb82742904fa13014018a1137ed. 460408f78b30720950040e336f7b566aa7203269. --- flang/lib/Frontend/FrontendActions.cpp | 10 ---------- mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp | 10 ---------- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | 10 ---------- mlir/test/lib/Dialect/Test/TestToLLVMIRTranslation.cpp | 10 ---------- 4 files changed, 40 deletions(-) diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp index a74d2be9be3b..b1b6391f1439 100644 --- a/flang/lib/Frontend/FrontendActions.cpp +++ b/flang/lib/Frontend/FrontendActions.cpp @@ -50,7 +50,6 @@ #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/Bitcode/BitcodeWriterPass.h" #include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h" -#include "llvm/IR/DebugProgramInstruction.h" #include "llvm/IR/LLVMRemarkStreamer.h" #include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/Verifier.h" @@ -82,8 +81,6 @@ using namespace Fortran::frontend; llvm::PassPluginLibraryInfo get##Ext##PluginInfo(); #include "llvm/Support/Extension.def" -extern llvm::cl::opt WriteNewDbgInfoFormat; - /// Save the given \c mlirModule to a temporary .mlir file, in a location /// decided by the -save-temps flag. No files are produced if the flag is not /// specified. @@ -1274,13 +1271,6 @@ void CodeGenAction::executeAction() { runOptimizationPipeline(ci.isOutputStreamNull() ? *os : ci.getOutputStream()); if (action == BackendActionTy::Backend_EmitLL) { - // 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(ci.isOutputStreamNull() ? *os : ci.getOutputStream(), /*AssemblyAnnotationWriter=*/nullptr); return; diff --git a/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp index be3b36c76205..455889377953 100644 --- a/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp @@ -16,12 +16,9 @@ #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 WriteNewDbgInfoFormat; - using namespace mlir; namespace mlir { @@ -34,13 +31,6 @@ 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(); }, diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp index e1a60f195fe8..7b86b250c294 100644 --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -64,8 +64,6 @@ using namespace mlir; using namespace mlir::LLVM; using namespace mlir::LLVM::detail; -extern llvm::cl::opt UseNewDbgInfoFormat; - #include "mlir/Dialect/LLVMIR/LLVMConversionEnumsToLLVM.inc" namespace { @@ -1791,9 +1789,6 @@ prepareLLVMModule(Operation *m, llvm::LLVMContext &llvmContext, StringRef name) { m->getContext()->getOrLoadDialect(); auto llvmModule = std::make_unique(name, llvmContext); - // ModuleTranslation can currently only construct modules in the old debug - // info format, so set the flag accordingly. - llvmModule->setNewDbgInfoFormatFlag(false); if (auto dataLayoutAttr = m->getDiscardableAttr(LLVM::LLVMDialect::getDataLayoutAttrName())) { llvmModule->setDataLayout(cast(dataLayoutAttr).getValue()); @@ -1872,11 +1867,6 @@ mlir::translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext, if (failed(translator.convertFunctions())) return nullptr; - // Once we've finished constructing elements in the module, we should convert - // it to use the debug info format desired by LLVM. - // See https://llvm.org/docs/RemoveDIsDebugInfo.html - translator.llvmModule->setIsNewDbgInfoFormat(UseNewDbgInfoFormat); - if (!disableVerification && llvm::verifyModule(*translator.llvmModule, &llvm::errs())) return nullptr; diff --git a/mlir/test/lib/Dialect/Test/TestToLLVMIRTranslation.cpp b/mlir/test/lib/Dialect/Test/TestToLLVMIRTranslation.cpp index 813b4960faa9..57e7d658fb50 100644 --- a/mlir/test/lib/Dialect/Test/TestToLLVMIRTranslation.cpp +++ b/mlir/test/lib/Dialect/Test/TestToLLVMIRTranslation.cpp @@ -22,9 +22,6 @@ #include "mlir/Tools/mlir-translate/Translation.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/TypeSwitch.h" -#include "llvm/IR/DebugProgramInstruction.h" - -extern llvm::cl::opt WriteNewDbgInfoFormat; using namespace mlir; @@ -125,13 +122,6 @@ void registerTestToLLVMIR() { 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(); },