Skip to content

Commit 0e4b8b8

Browse files
authored
[DebugInfo][RemoveDIs] Rip out the UseNewDbgInfoFormat flag (#143207)
Start removing debug intrinsics support -- starting with the flag that controls production of their replacement, debug records. This patch removes the command-line-flag and with it the ability to switch back to intrinsics. The module / function / block level "IsNewDbgInfoFormat" flags get hardcoded to true, I'll to incrementally remove things that depend on those flags.
1 parent 7f08503 commit 0e4b8b8

File tree

27 files changed

+69
-263
lines changed

27 files changed

+69
-263
lines changed

clang/test/CodeGenCXX/tmp-md-nodes2.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// REQUIRES: asserts
22
// RUN: %clang_cc1 -O0 -triple %itanium_abi_triple -debug-info-kind=limited -emit-llvm %s -o - | \
33
// RUN: FileCheck %s
4-
// RUN: %clang_cc1 -O0 -triple %itanium_abi_triple -debug-info-kind=limited -emit-llvm -mllvm --experimental-debuginfo-iterators=true %s -o - | \
5-
// RUN: FileCheck %s
64

75
// This test simply checks that the varargs thunk is created. The failing test
86
// case asserts.

flang/test/Integration/debug-local-var-2.f90

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
! RUN: %flang_fc1 -emit-llvm -debug-info-kind=standalone %s -mllvm --experimental-debuginfo-iterators=true -o - | FileCheck %s --check-prefixes=BOTH,RECORDS
2-
! RUN: %flang_fc1 -emit-llvm -debug-info-kind=line-tables-only %s -mllvm --experimental-debuginfo-iterators=false -o - | FileCheck --check-prefix=LINEONLY %s
3-
! RUN: %flang_fc1 -emit-llvm -debug-info-kind=line-tables-only %s -mllvm --experimental-debuginfo-iterators=true -o - | FileCheck --check-prefix=LINEONLY %s
1+
! RUN: %flang_fc1 -emit-llvm -debug-info-kind=standalone %s -o - | FileCheck %s --check-prefixes=BOTH,RECORDS
2+
! RUN: %flang_fc1 -emit-llvm -debug-info-kind=line-tables-only %s -o - | FileCheck --check-prefix=LINEONLY %s
43

54
! This tests checks the debug information for local variables in llvm IR.
65

llvm/include/llvm/IR/BasicBlock.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
8787

8888
/// Convert variable location debugging information stored in dbg.value
8989
/// intrinsics into DbgMarkers / DbgRecords. Deletes all dbg.values in
90-
/// the process and sets IsNewDbgInfoFormat = true. Only takes effect if
91-
/// the UseNewDbgInfoFormat LLVM command line option is given.
90+
/// the process and sets IsNewDbgInfoFormat = true.
9291
LLVM_ABI void convertToNewDbgValues();
9392

9493
/// Convert variable location debugging information stored in DbgMarkers and

llvm/include/llvm/IR/PassManagerImpl.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include "llvm/Support/Compiler.h"
2323
#include "llvm/Support/PrettyStackTrace.h"
2424

25-
LLVM_ABI extern llvm::cl::opt<bool> UseNewDbgInfoFormat;
26-
2725
namespace llvm {
2826

2927
template <typename IRUnitT, typename AnalysisManagerT, typename... ExtraArgTs>
@@ -67,7 +65,7 @@ PreservedAnalyses PassManager<IRUnitT, AnalysisManagerT, ExtraArgTs...>::run(
6765

6866
// RemoveDIs: if requested, convert debug-info to DbgRecord representation
6967
// for duration of these passes.
70-
ScopedDbgInfoFormatSetter FormatSetter(IR, UseNewDbgInfoFormat);
68+
ScopedDbgInfoFormatSetter FormatSetter(IR, true);
7169

7270
StackTraceEntry Entry(PI, IR);
7371
for (auto &Pass : Passes) {

llvm/lib/AsmParser/LLParser.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ static cl::opt<bool> AllowIncompleteIR(
6464
"Allow incomplete IR on a best effort basis (references to unknown "
6565
"metadata will be dropped)"));
6666

67-
LLVM_ABI extern llvm::cl::opt<bool> UseNewDbgInfoFormat;
68-
6967
static std::string getTypeString(Type *T) {
7068
std::string Result;
7169
raw_string_ostream Tmp(Result);
@@ -443,7 +441,7 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {
443441
UpgradeNVVMAnnotations(*M);
444442
UpgradeSectionAttributes(*M);
445443

446-
M->setIsNewDbgInfoFormat(UseNewDbgInfoFormat);
444+
M->setIsNewDbgInfoFormat(true);
447445

448446
if (!Slots)
449447
return false;

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ static cl::opt<bool> ExpandConstantExprs(
101101
cl::desc(
102102
"Expand constant expressions to instructions for testing purposes"));
103103

104-
LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat;
105-
106104
namespace {
107105

108106
enum {
@@ -4481,9 +4479,9 @@ Error BitcodeReader::parseGlobalIndirectSymbolRecord(
44814479
Error BitcodeReader::parseModule(uint64_t ResumeBit,
44824480
bool ShouldLazyLoadMetadata,
44834481
ParserCallbacks Callbacks) {
4484-
// In preparation for the deletion of debug-intrinsics, don't allow module
4485-
// loading to escape intrinsics being autoupgraded to debug records.
4486-
TheModule->IsNewDbgInfoFormat = UseNewDbgInfoFormat;
4482+
// Don't allow modules to use debug-intrinsics: autoupgrading them is now
4483+
// mandatory.
4484+
TheModule->IsNewDbgInfoFormat = true;
44874485

44884486
this->ValueTypeCallback = std::move(Callbacks.ValueType);
44894487
if (ResumeBit) {

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ namespace llvm {
122122
extern FunctionSummary::ForceSummaryHotnessType ForceSummaryEdgesCold;
123123
}
124124

125-
LLVM_ABI extern llvm::cl::opt<bool> UseNewDbgInfoFormat;
126-
127125
namespace {
128126

129127
/// These are manifest constants used by the bitcode writer. They do not need to

llvm/lib/CodeGen/MIRPrinter.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ static cl::opt<bool> SimplifyMIR(
7070
static cl::opt<bool> PrintLocations("mir-debug-loc", cl::Hidden, cl::init(true),
7171
cl::desc("Print MIR debug-locations"));
7272

73-
extern cl::opt<bool> UseNewDbgInfoFormat;
74-
7573
namespace {
7674

7775
/// This structure describes how to print out stack object references.
@@ -967,8 +965,7 @@ void MIRFormatter::printIRValue(raw_ostream &OS, const Value &V,
967965
}
968966

969967
void llvm::printMIR(raw_ostream &OS, const Module &M) {
970-
ScopedDbgInfoFormatSetter FormatSetter(const_cast<Module &>(M),
971-
UseNewDbgInfoFormat);
968+
ScopedDbgInfoFormatSetter FormatSetter(const_cast<Module &>(M), true);
972969

973970
yaml::Output Out(OS);
974971
Out << const_cast<Module &>(M);
@@ -979,6 +976,6 @@ void llvm::printMIR(raw_ostream &OS, const MachineModuleInfo &MMI,
979976
// RemoveDIs: as there's no textual form for DbgRecords yet, print debug-info
980977
// in dbg.value format.
981978
ScopedDbgInfoFormatSetter FormatSetter(
982-
const_cast<Function &>(MF.getFunction()), UseNewDbgInfoFormat);
979+
const_cast<Function &>(MF.getFunction()), true);
983980
printMF(OS, MMI, MF);
984981
}

llvm/lib/IR/BasicBlock.cpp

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,6 @@ using namespace llvm;
3131
#define DEBUG_TYPE "ir"
3232
STATISTIC(NumInstrRenumberings, "Number of renumberings across all blocks");
3333

34-
// This cl-opt exists to control whether variable-location information is
35-
// produced using intrinsics, or whether DbgRecords are produced. However,
36-
// it's imminently being phased out, so give it a flag-name that is very
37-
// unlikely to be used anywhere.
38-
//
39-
// If you find yourself needing to use this flag for any period longer than
40-
// five minutes, please revert the patch making this change, and make contact
41-
// in this discourse post, where we can discuss any further transition work
42-
// that might be needed to remove debug intrinsics.
43-
//
44-
// https://discourse.llvm.org/t/psa-ir-output-changing-from-debug-intrinsics-to-debug-records/79578
45-
LLVM_ABI cl::opt<bool>
46-
UseNewDbgInfoFormat("dont-pass-this-flag-please-experimental-debuginfo",
47-
cl::Hidden, cl::init(true));
48-
49-
// This cl-opt collects the --experimental-debuginfo-iterators flag and then
50-
// does nothing with it (because the it gets stored into an otherwise unused
51-
// cl-opt), so that we can disable debug-intrinsic production without
52-
// immediately modifying lots of tests. If your tests break because of this
53-
// change, please see the next comment up.
54-
static cl::opt<bool> DeliberatelyUnseenDbgInfoFlag(
55-
"experimental-debuginfo-iterators", cl::Hidden,
56-
cl::init(true));
57-
5834
DbgMarker *BasicBlock::createMarker(Instruction *I) {
5935
assert(IsNewDbgInfoFormat &&
6036
"Tried to create a marker in a non new debug-info block!");
@@ -187,7 +163,7 @@ template class llvm::SymbolTableListTraits<
187163
BasicBlock::BasicBlock(LLVMContext &C, const Twine &Name, Function *NewParent,
188164
BasicBlock *InsertBefore)
189165
: Value(Type::getLabelTy(C), Value::BasicBlockVal),
190-
IsNewDbgInfoFormat(UseNewDbgInfoFormat), Parent(nullptr) {
166+
IsNewDbgInfoFormat(true), Parent(nullptr) {
191167

192168
if (NewParent)
193169
insertInto(NewParent, InsertBefore);

llvm/lib/IR/Function.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ static cl::opt<int> NonGlobalValueMaxNameSize(
6565
"non-global-value-max-name-size", cl::Hidden, cl::init(1024),
6666
cl::desc("Maximum size for the name of non-global values."));
6767

68-
LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat;
69-
7068
void Function::renumberBlocks() {
7169
validateBlockNumbers();
7270

@@ -492,7 +490,7 @@ Function::Function(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace,
492490
const Twine &name, Module *ParentModule)
493491
: GlobalObject(Ty, Value::FunctionVal, AllocMarker, Linkage, name,
494492
computeAddrSpace(AddrSpace, ParentModule)),
495-
NumArgs(Ty->getNumParams()), IsNewDbgInfoFormat(UseNewDbgInfoFormat) {
493+
NumArgs(Ty->getNumParams()), IsNewDbgInfoFormat(true) {
496494
assert(FunctionType::isValidReturnType(getReturnType()) &&
497495
"invalid return type");
498496
setGlobalObjectSubClassData(0);

llvm/lib/IR/IRPrintingPasses.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424

2525
using namespace llvm;
2626

27-
LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat;
28-
2927
namespace {
3028

3129
class PrintModulePassWrapper : public ModulePass {
@@ -42,12 +40,10 @@ class PrintModulePassWrapper : public ModulePass {
4240
ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {}
4341

4442
bool runOnModule(Module &M) override {
45-
ScopedDbgInfoFormatSetter FormatSetter(M, UseNewDbgInfoFormat);
43+
ScopedDbgInfoFormatSetter FormatSetter(M, true);
4644
// Remove intrinsic declarations when printing in the new format.
47-
// TODO: Move this into Module::setIsNewDbgInfoFormat when we're ready to
48-
// update test output.
49-
if (UseNewDbgInfoFormat)
50-
M.removeDebugIntrinsicDeclarations();
45+
// TODO: consider removing this as debug-intrinsics are gone.
46+
M.removeDebugIntrinsicDeclarations();
5147

5248
if (llvm::isFunctionInPrintList("*")) {
5349
if (!Banner.empty())
@@ -88,7 +84,7 @@ class PrintFunctionPassWrapper : public FunctionPass {
8884

8985
// This pass just prints a banner followed by the function as it's processed.
9086
bool runOnFunction(Function &F) override {
91-
ScopedDbgInfoFormatSetter FormatSetter(F, UseNewDbgInfoFormat);
87+
ScopedDbgInfoFormatSetter FormatSetter(F, true);
9288

9389
if (isFunctionInPrintList(F.getName())) {
9490
if (forcePrintModuleIR())

llvm/lib/IR/Instruction.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ BasicBlock::iterator Instruction::insertInto(BasicBlock *ParentBB,
130130
return getIterator();
131131
}
132132

133-
LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat;
134-
135133
void Instruction::insertBefore(BasicBlock &BB,
136134
InstListType::iterator InsertPos) {
137135
assert(!DebugMarker);

llvm/lib/IR/LegacyPassManager.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
using namespace llvm;
3434

35-
LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat;
3635
// See PassManagers.h for Pass Manager infrastructure overview.
3736

3837
//===----------------------------------------------------------------------===//
@@ -530,7 +529,7 @@ bool PassManagerImpl::run(Module &M) {
530529
// RemoveDIs: if a command line flag is given, convert to the
531530
// DbgVariableRecord representation of debug-info for the duration of these
532531
// passes.
533-
ScopedDbgInfoFormatSetter FormatSetter(M, UseNewDbgInfoFormat);
532+
ScopedDbgInfoFormatSetter FormatSetter(M, true);
534533

535534
for (ImmutablePass *ImPass : getImmutablePasses())
536535
Changed |= ImPass->doInitialization(M);

llvm/lib/IR/Module.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@
5454

5555
using namespace llvm;
5656

57-
LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat;
58-
5957
//===----------------------------------------------------------------------===//
6058
// Methods to implement the globals and functions lists.
6159
//
@@ -74,7 +72,7 @@ template class LLVM_EXPORT_TEMPLATE llvm::SymbolTableListTraits<GlobalIFunc>;
7472
Module::Module(StringRef MID, LLVMContext &C)
7573
: Context(C), ValSymTab(std::make_unique<ValueSymbolTable>(-1)),
7674
ModuleID(std::string(MID)), SourceFileName(std::string(MID)),
77-
IsNewDbgInfoFormat(UseNewDbgInfoFormat) {
75+
IsNewDbgInfoFormat(true) {
7876
Context.addModule(this);
7977
}
8078

llvm/lib/IRPrinter/IRPrintingPasses.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323

2424
using namespace llvm;
2525

26-
LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat;
27-
2826
PrintModulePass::PrintModulePass() : OS(dbgs()) {}
2927
PrintModulePass::PrintModulePass(raw_ostream &OS, const std::string &Banner,
3028
bool ShouldPreserveUseListOrder,
@@ -34,12 +32,10 @@ PrintModulePass::PrintModulePass(raw_ostream &OS, const std::string &Banner,
3432
EmitSummaryIndex(EmitSummaryIndex) {}
3533

3634
PreservedAnalyses PrintModulePass::run(Module &M, ModuleAnalysisManager &AM) {
37-
ScopedDbgInfoFormatSetter FormatSetter(M, UseNewDbgInfoFormat);
35+
ScopedDbgInfoFormatSetter FormatSetter(M, true);
3836
// Remove intrinsic declarations when printing in the new format.
39-
// TODO: Move this into Module::setIsNewDbgInfoFormat when we're ready to
40-
// update test output.
41-
if (UseNewDbgInfoFormat)
42-
M.removeDebugIntrinsicDeclarations();
37+
// TODO: consider removing this now that debug intrinsics are gone.
38+
M.removeDebugIntrinsicDeclarations();
4339

4440
if (llvm::isFunctionInPrintList("*")) {
4541
if (!Banner.empty())
@@ -76,7 +72,7 @@ PrintFunctionPass::PrintFunctionPass(raw_ostream &OS, const std::string &Banner)
7672

7773
PreservedAnalyses PrintFunctionPass::run(Function &F,
7874
FunctionAnalysisManager &) {
79-
ScopedDbgInfoFormatSetter FormatSetter(F, UseNewDbgInfoFormat);
75+
ScopedDbgInfoFormatSetter FormatSetter(F, true);
8076

8177
if (isFunctionInPrintList(F.getName())) {
8278
if (forcePrintModuleIR())

llvm/lib/LTO/LTO.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ using namespace object;
7070

7171
#define DEBUG_TYPE "lto"
7272

73-
LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat;
74-
7573
static cl::opt<bool>
7674
DumpThinCGSCCs("dump-thin-cg-sccs", cl::init(false), cl::Hidden,
7775
cl::desc("Dump the SCCs in the ThinLTO index's callgraph"));
@@ -602,7 +600,7 @@ LTO::RegularLTOState::RegularLTOState(unsigned ParallelCodeGenParallelismLevel,
602600
: ParallelCodeGenParallelismLevel(ParallelCodeGenParallelismLevel),
603601
Ctx(Conf), CombinedModule(std::make_unique<Module>("ld-temp.o", Ctx)),
604602
Mover(std::make_unique<IRMover>(*CombinedModule)) {
605-
CombinedModule->IsNewDbgInfoFormat = UseNewDbgInfoFormat;
603+
CombinedModule->IsNewDbgInfoFormat = true;
606604
}
607605

608606
LTO::ThinLTOState::ThinLTOState(ThinBackend BackendParam)

llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141

4242
using namespace llvm;
4343

44-
extern cl::opt<bool> UseNewDbgInfoFormat;
45-
4644
#define DEBUG_TYPE "coro-frame"
4745

4846
namespace {
@@ -842,18 +840,12 @@ static void buildFrameDebugInfo(Function &F, coro::Shape &Shape,
842840
DILocation::get(DIS->getContext(), LineNum, /*Column=*/1, DIS);
843841
assert(FrameDIVar->isValidLocationForIntrinsic(DILoc));
844842

845-
if (UseNewDbgInfoFormat) {
846-
DbgVariableRecord *NewDVR =
847-
new DbgVariableRecord(ValueAsMetadata::get(Shape.FramePtr), FrameDIVar,
848-
DBuilder.createExpression(), DILoc,
849-
DbgVariableRecord::LocationType::Declare);
850-
BasicBlock::iterator It = Shape.getInsertPtAfterFramePtr();
851-
It->getParent()->insertDbgRecordBefore(NewDVR, It);
852-
} else {
853-
DBuilder.insertDeclare(Shape.FramePtr, FrameDIVar,
854-
DBuilder.createExpression(), DILoc,
855-
Shape.getInsertPtAfterFramePtr());
856-
}
843+
DbgVariableRecord *NewDVR =
844+
new DbgVariableRecord(ValueAsMetadata::get(Shape.FramePtr), FrameDIVar,
845+
DBuilder.createExpression(), DILoc,
846+
DbgVariableRecord::LocationType::Declare);
847+
BasicBlock::iterator It = Shape.getInsertPtAfterFramePtr();
848+
It->getParent()->insertDbgRecordBefore(NewDVR, It);
857849
}
858850

859851
// Build a struct that will keep state for an active coroutine.
@@ -1136,19 +1128,12 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
11361128
// This dbg.declare is preserved for all coro-split function
11371129
// fragments. It will be unreachable in the main function, and
11381130
// processed by coro::salvageDebugInfo() by the Cloner.
1139-
if (UseNewDbgInfoFormat) {
1140-
DbgVariableRecord *NewDVR = new DbgVariableRecord(
1141-
ValueAsMetadata::get(CurrentReload), DDI->getVariable(),
1142-
DDI->getExpression(), DDI->getDebugLoc(),
1143-
DbgVariableRecord::LocationType::Declare);
1144-
Builder.GetInsertPoint()->getParent()->insertDbgRecordBefore(
1145-
NewDVR, Builder.GetInsertPoint());
1146-
} else {
1147-
DIBuilder(*CurrentBlock->getParent()->getParent(), AllowUnresolved)
1148-
.insertDeclare(CurrentReload, DDI->getVariable(),
1149-
DDI->getExpression(), DDI->getDebugLoc(),
1150-
Builder.GetInsertPoint());
1151-
}
1131+
DbgVariableRecord *NewDVR = new DbgVariableRecord(
1132+
ValueAsMetadata::get(CurrentReload), DDI->getVariable(),
1133+
DDI->getExpression(), DDI->getDebugLoc(),
1134+
DbgVariableRecord::LocationType::Declare);
1135+
Builder.GetInsertPoint()->getParent()->insertDbgRecordBefore(
1136+
NewDVR, Builder.GetInsertPoint());
11521137
// This dbg.declare is for the main function entry point. It
11531138
// will be deleted in all coro-split functions.
11541139
coro::salvageDebugInfo(ArgToAllocaMap, *DDI, false /*UseEntryValue*/);

0 commit comments

Comments
 (0)