Skip to content

Commit 354cfba

Browse files
authored
[DebugInfo][RemoveDIs] Remove scoped-dbg-format-setter (#143450)
This was a utility for flipping between intrinsic and debug record mode -- we don't need it any more. The "IsNewDbgInfoFormat" should be true everywhere.
1 parent ddef9ce commit 354cfba

File tree

10 files changed

+3
-56
lines changed

10 files changed

+3
-56
lines changed

llvm/include/llvm/IR/DebugProgramInstruction.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -692,25 +692,6 @@ getDbgRecordRange(DbgMarker *DebugMarker) {
692692

693693
DEFINE_ISA_CONVERSION_FUNCTIONS(DbgRecord, LLVMDbgRecordRef)
694694

695-
/// Used to temporarily set the debug info format of a function, module, or
696-
/// basic block for the duration of this object's lifetime, after which the
697-
/// prior state will be restored.
698-
template <typename T> class ScopedDbgInfoFormatSetter {
699-
T &Obj;
700-
bool OldState;
701-
702-
public:
703-
ScopedDbgInfoFormatSetter(T &Obj, bool NewState)
704-
: Obj(Obj), OldState(Obj.IsNewDbgInfoFormat) {
705-
Obj.setIsNewDbgInfoFormat(NewState);
706-
}
707-
~ScopedDbgInfoFormatSetter() { Obj.setIsNewDbgInfoFormat(OldState); }
708-
};
709-
710-
template <typename T>
711-
ScopedDbgInfoFormatSetter(T &Obj,
712-
bool NewState) -> ScopedDbgInfoFormatSetter<T>;
713-
714695
} // namespace llvm
715696

716697
#endif // LLVM_IR_DEBUGPROGRAMINSTRUCTION_H

llvm/include/llvm/IR/PassManagerImpl.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ PreservedAnalyses PassManager<IRUnitT, AnalysisManagerT, ExtraArgTs...>::run(
6363
detail::getAnalysisResult<PassInstrumentationAnalysis>(
6464
AM, IR, std::tuple<ExtraArgTs...>(ExtraArgs...));
6565

66-
// RemoveDIs: if requested, convert debug-info to DbgRecord representation
67-
// for duration of these passes.
68-
ScopedDbgInfoFormatSetter FormatSetter(IR, true);
69-
7066
StackTraceEntry Entry(PI, IR);
7167
for (auto &Pass : Passes) {
7268
Entry.setPass(&*Pass);

llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
using namespace llvm;
2020

2121
PreservedAnalyses BitcodeWriterPass::run(Module &M, ModuleAnalysisManager &AM) {
22-
ScopedDbgInfoFormatSetter FormatSetter(M, M.IsNewDbgInfoFormat);
23-
if (M.IsNewDbgInfoFormat)
24-
M.removeDebugIntrinsicDeclarations();
22+
M.removeDebugIntrinsicDeclarations();
2523

2624
const ModuleSummaryIndex *Index =
2725
EmitSummaryIndex ? &(AM.getResult<ModuleSummaryIndexAnalysis>(M))
@@ -51,9 +49,7 @@ namespace {
5149
StringRef getPassName() const override { return "Bitcode Writer"; }
5250

5351
bool runOnModule(Module &M) override {
54-
ScopedDbgInfoFormatSetter FormatSetter(M, M.IsNewDbgInfoFormat);
55-
if (M.IsNewDbgInfoFormat)
56-
M.removeDebugIntrinsicDeclarations();
52+
M.removeDebugIntrinsicDeclarations();
5753

5854
WriteBitcodeToFile(M, OS, ShouldPreserveUseListOrder, /*Index=*/nullptr,
5955
/*EmitModuleHash=*/false);

llvm/lib/CodeGen/MIRPrinter.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -965,17 +965,11 @@ void MIRFormatter::printIRValue(raw_ostream &OS, const Value &V,
965965
}
966966

967967
void llvm::printMIR(raw_ostream &OS, const Module &M) {
968-
ScopedDbgInfoFormatSetter FormatSetter(const_cast<Module &>(M), true);
969-
970968
yaml::Output Out(OS);
971969
Out << const_cast<Module &>(M);
972970
}
973971

974972
void llvm::printMIR(raw_ostream &OS, const MachineModuleInfo &MMI,
975973
const MachineFunction &MF) {
976-
// RemoveDIs: as there's no textual form for DbgRecords yet, print debug-info
977-
// in dbg.value format.
978-
ScopedDbgInfoFormatSetter FormatSetter(
979-
const_cast<Function &>(MF.getFunction()), true);
980974
printMF(OS, MMI, MF);
981975
}

llvm/lib/IR/IRPrintingPasses.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class PrintModulePassWrapper : public ModulePass {
4040
ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {}
4141

4242
bool runOnModule(Module &M) override {
43-
ScopedDbgInfoFormatSetter FormatSetter(M, true);
4443
// Remove intrinsic declarations when printing in the new format.
4544
// TODO: consider removing this as debug-intrinsics are gone.
4645
M.removeDebugIntrinsicDeclarations();
@@ -84,8 +83,6 @@ class PrintFunctionPassWrapper : public FunctionPass {
8483

8584
// This pass just prints a banner followed by the function as it's processed.
8685
bool runOnFunction(Function &F) override {
87-
ScopedDbgInfoFormatSetter FormatSetter(F, true);
88-
8986
if (isFunctionInPrintList(F.getName())) {
9087
if (forcePrintModuleIR())
9188
OS << Banner << " (function: " << F.getName() << ")\n"

llvm/lib/IR/LegacyPassManager.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -526,11 +526,6 @@ bool PassManagerImpl::run(Module &M) {
526526
dumpArguments();
527527
dumpPasses();
528528

529-
// RemoveDIs: if a command line flag is given, convert to the
530-
// DbgVariableRecord representation of debug-info for the duration of these
531-
// passes.
532-
ScopedDbgInfoFormatSetter FormatSetter(M, true);
533-
534529
for (ImmutablePass *ImPass : getImmutablePasses())
535530
Changed |= ImPass->doInitialization(M);
536531

llvm/lib/IRPrinter/IRPrintingPasses.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ PrintModulePass::PrintModulePass(raw_ostream &OS, const std::string &Banner,
3232
EmitSummaryIndex(EmitSummaryIndex) {}
3333

3434
PreservedAnalyses PrintModulePass::run(Module &M, ModuleAnalysisManager &AM) {
35-
ScopedDbgInfoFormatSetter FormatSetter(M, true);
3635
// Remove intrinsic declarations when printing in the new format.
3736
// TODO: consider removing this now that debug intrinsics are gone.
3837
M.removeDebugIntrinsicDeclarations();
@@ -72,8 +71,6 @@ PrintFunctionPass::PrintFunctionPass(raw_ostream &OS, const std::string &Banner)
7271

7372
PreservedAnalyses PrintFunctionPass::run(Function &F,
7473
FunctionAnalysisManager &) {
75-
ScopedDbgInfoFormatSetter FormatSetter(F, true);
76-
7774
if (isFunctionInPrintList(F.getName())) {
7875
if (forcePrintModuleIR())
7976
OS << Banner << " (function: " << F.getName() << ")\n" << *F.getParent();

llvm/lib/Linker/IRMover.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,9 +1444,6 @@ Error IRLinker::run() {
14441444
if (Error Err = SrcM->getMaterializer()->materializeMetadata())
14451445
return Err;
14461446

1447-
// Convert source module to match dest for the duration of the link.
1448-
ScopedDbgInfoFormatSetter FormatSetter(*SrcM, DstM.IsNewDbgInfoFormat);
1449-
14501447
// Inherit the target data from the source module if the destination
14511448
// module doesn't have one already.
14521449
if (DstM.getDataLayout().isDefault())

llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,7 @@ llvm::ThinLTOBitcodeWriterPass::run(Module &M, ModuleAnalysisManager &AM) {
584584
FunctionAnalysisManager &FAM =
585585
AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
586586

587-
ScopedDbgInfoFormatSetter FormatSetter(M, M.IsNewDbgInfoFormat);
588-
if (M.IsNewDbgInfoFormat)
589-
M.removeDebugIntrinsicDeclarations();
587+
M.removeDebugIntrinsicDeclarations();
590588

591589
bool Changed = writeThinLTOBitcode(
592590
OS, ThinLinkOS,

mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ void registerToLLVMIRTranslation() {
3232
if (!llvmModule)
3333
return failure();
3434

35-
// When printing LLVM IR, we should convert the module to the debug info
36-
// format that LLVM expects us to print.
37-
// See https://llvm.org/docs/RemoveDIsDebugInfo.html
38-
llvm::ScopedDbgInfoFormatSetter formatSetter(*llvmModule, true);
3935
llvmModule->removeDebugIntrinsicDeclarations();
4036
llvmModule->print(output, nullptr);
4137
return success();

0 commit comments

Comments
 (0)