Skip to content

[DebugInfo][RemoveDIs] Rip out the UseNewDbgInfoFormat flag #143207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions llvm/include/llvm/IR/BasicBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ class BasicBlock final : public Value, // Basic blocks are data objects also

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

/// Convert variable location debugging information stored in DbgMarkers and
Expand Down
4 changes: 1 addition & 3 deletions llvm/include/llvm/IR/PassManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/PrettyStackTrace.h"

LLVM_ABI extern llvm::cl::opt<bool> UseNewDbgInfoFormat;

namespace llvm {

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

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

StackTraceEntry Entry(PI, IR);
for (auto &Pass : Passes) {
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/AsmParser/LLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ static cl::opt<bool> AllowIncompleteIR(
"Allow incomplete IR on a best effort basis (references to unknown "
"metadata will be dropped)"));

LLVM_ABI extern llvm::cl::opt<bool> UseNewDbgInfoFormat;

static std::string getTypeString(Type *T) {
std::string Result;
raw_string_ostream Tmp(Result);
Expand Down Expand Up @@ -443,7 +441,7 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {
UpgradeNVVMAnnotations(*M);
UpgradeSectionAttributes(*M);

M->setIsNewDbgInfoFormat(UseNewDbgInfoFormat);
M->setIsNewDbgInfoFormat(true);

if (!Slots)
return false;
Expand Down
8 changes: 3 additions & 5 deletions llvm/lib/Bitcode/Reader/BitcodeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ static cl::opt<bool> ExpandConstantExprs(
cl::desc(
"Expand constant expressions to instructions for testing purposes"));

LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat;

namespace {

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

this->ValueTypeCallback = std::move(Callbacks.ValueType);
if (ResumeBit) {
Expand Down
2 changes: 0 additions & 2 deletions llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ namespace llvm {
extern FunctionSummary::ForceSummaryHotnessType ForceSummaryEdgesCold;
}

LLVM_ABI extern llvm::cl::opt<bool> UseNewDbgInfoFormat;

namespace {

/// These are manifest constants used by the bitcode writer. They do not need to
Expand Down
7 changes: 2 additions & 5 deletions llvm/lib/CodeGen/MIRPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ static cl::opt<bool> SimplifyMIR(
static cl::opt<bool> PrintLocations("mir-debug-loc", cl::Hidden, cl::init(true),
cl::desc("Print MIR debug-locations"));

extern cl::opt<bool> UseNewDbgInfoFormat;

namespace {

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

void llvm::printMIR(raw_ostream &OS, const Module &M) {
ScopedDbgInfoFormatSetter FormatSetter(const_cast<Module &>(M),
UseNewDbgInfoFormat);
ScopedDbgInfoFormatSetter FormatSetter(const_cast<Module &>(M), true);

yaml::Output Out(OS);
Out << const_cast<Module &>(M);
Expand All @@ -979,6 +976,6 @@ void llvm::printMIR(raw_ostream &OS, const MachineModuleInfo &MMI,
// RemoveDIs: as there's no textual form for DbgRecords yet, print debug-info
// in dbg.value format.
ScopedDbgInfoFormatSetter FormatSetter(
const_cast<Function &>(MF.getFunction()), UseNewDbgInfoFormat);
const_cast<Function &>(MF.getFunction()), true);
printMF(OS, MMI, MF);
}
26 changes: 1 addition & 25 deletions llvm/lib/IR/BasicBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,6 @@ using namespace llvm;
#define DEBUG_TYPE "ir"
STATISTIC(NumInstrRenumberings, "Number of renumberings across all blocks");

// This cl-opt exists to control whether variable-location information is
// produced using intrinsics, or whether DbgRecords are produced. However,
// it's imminently being phased out, so give it a flag-name that is very
// unlikely to be used anywhere.
//
// If you find yourself needing to use this flag for any period longer than
// five minutes, please revert the patch making this change, and make contact
// in this discourse post, where we can discuss any further transition work
// that might be needed to remove debug intrinsics.
//
// https://discourse.llvm.org/t/psa-ir-output-changing-from-debug-intrinsics-to-debug-records/79578
LLVM_ABI cl::opt<bool>
UseNewDbgInfoFormat("dont-pass-this-flag-please-experimental-debuginfo",
cl::Hidden, cl::init(true));

// This cl-opt collects the --experimental-debuginfo-iterators flag and then
// does nothing with it (because the it gets stored into an otherwise unused
// cl-opt), so that we can disable debug-intrinsic production without
// immediately modifying lots of tests. If your tests break because of this
// change, please see the next comment up.
static cl::opt<bool> DeliberatelyUnseenDbgInfoFlag(
"experimental-debuginfo-iterators", cl::Hidden,
cl::init(true));

DbgMarker *BasicBlock::createMarker(Instruction *I) {
assert(IsNewDbgInfoFormat &&
"Tried to create a marker in a non new debug-info block!");
Expand Down Expand Up @@ -187,7 +163,7 @@ template class llvm::SymbolTableListTraits<
BasicBlock::BasicBlock(LLVMContext &C, const Twine &Name, Function *NewParent,
BasicBlock *InsertBefore)
: Value(Type::getLabelTy(C), Value::BasicBlockVal),
IsNewDbgInfoFormat(UseNewDbgInfoFormat), Parent(nullptr) {
IsNewDbgInfoFormat(true), Parent(nullptr) {

if (NewParent)
insertInto(NewParent, InsertBefore);
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/IR/Function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ static cl::opt<int> NonGlobalValueMaxNameSize(
"non-global-value-max-name-size", cl::Hidden, cl::init(1024),
cl::desc("Maximum size for the name of non-global values."));

LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat;

void Function::renumberBlocks() {
validateBlockNumbers();

Expand Down Expand Up @@ -492,7 +490,7 @@ Function::Function(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace,
const Twine &name, Module *ParentModule)
: GlobalObject(Ty, Value::FunctionVal, AllocMarker, Linkage, name,
computeAddrSpace(AddrSpace, ParentModule)),
NumArgs(Ty->getNumParams()), IsNewDbgInfoFormat(UseNewDbgInfoFormat) {
NumArgs(Ty->getNumParams()), IsNewDbgInfoFormat(true) {
assert(FunctionType::isValidReturnType(getReturnType()) &&
"invalid return type");
setGlobalObjectSubClassData(0);
Expand Down
12 changes: 4 additions & 8 deletions llvm/lib/IR/IRPrintingPasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

using namespace llvm;

LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat;

namespace {

class PrintModulePassWrapper : public ModulePass {
Expand All @@ -42,12 +40,10 @@ class PrintModulePassWrapper : public ModulePass {
ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {}

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

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

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

if (isFunctionInPrintList(F.getName())) {
if (forcePrintModuleIR())
Expand Down
2 changes: 0 additions & 2 deletions llvm/lib/IR/Instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ BasicBlock::iterator Instruction::insertInto(BasicBlock *ParentBB,
return getIterator();
}

LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat;

void Instruction::insertBefore(BasicBlock &BB,
InstListType::iterator InsertPos) {
assert(!DebugMarker);
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/IR/LegacyPassManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

using namespace llvm;

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

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

for (ImmutablePass *ImPass : getImmutablePasses())
Changed |= ImPass->doInitialization(M);
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/IR/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@

using namespace llvm;

LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat;

//===----------------------------------------------------------------------===//
// Methods to implement the globals and functions lists.
//
Expand All @@ -74,7 +72,7 @@ template class LLVM_EXPORT_TEMPLATE llvm::SymbolTableListTraits<GlobalIFunc>;
Module::Module(StringRef MID, LLVMContext &C)
: Context(C), ValSymTab(std::make_unique<ValueSymbolTable>(-1)),
ModuleID(std::string(MID)), SourceFileName(std::string(MID)),
IsNewDbgInfoFormat(UseNewDbgInfoFormat) {
IsNewDbgInfoFormat(true) {
Context.addModule(this);
}

Expand Down
12 changes: 4 additions & 8 deletions llvm/lib/IRPrinter/IRPrintingPasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

using namespace llvm;

LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat;

PrintModulePass::PrintModulePass() : OS(dbgs()) {}
PrintModulePass::PrintModulePass(raw_ostream &OS, const std::string &Banner,
bool ShouldPreserveUseListOrder,
Expand All @@ -34,12 +32,10 @@ PrintModulePass::PrintModulePass(raw_ostream &OS, const std::string &Banner,
EmitSummaryIndex(EmitSummaryIndex) {}

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

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

PreservedAnalyses PrintFunctionPass::run(Function &F,
FunctionAnalysisManager &) {
ScopedDbgInfoFormatSetter FormatSetter(F, UseNewDbgInfoFormat);
ScopedDbgInfoFormatSetter FormatSetter(F, true);

if (isFunctionInPrintList(F.getName())) {
if (forcePrintModuleIR())
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/LTO/LTO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ using namespace object;

#define DEBUG_TYPE "lto"

LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat;

static cl::opt<bool>
DumpThinCGSCCs("dump-thin-cg-sccs", cl::init(false), cl::Hidden,
cl::desc("Dump the SCCs in the ThinLTO index's callgraph"));
Expand Down Expand Up @@ -602,7 +600,7 @@ LTO::RegularLTOState::RegularLTOState(unsigned ParallelCodeGenParallelismLevel,
: ParallelCodeGenParallelismLevel(ParallelCodeGenParallelismLevel),
Ctx(Conf), CombinedModule(std::make_unique<Module>("ld-temp.o", Ctx)),
Mover(std::make_unique<IRMover>(*CombinedModule)) {
CombinedModule->IsNewDbgInfoFormat = UseNewDbgInfoFormat;
CombinedModule->IsNewDbgInfoFormat = true;
}

LTO::ThinLTOState::ThinLTOState(ThinBackend BackendParam)
Expand Down
39 changes: 12 additions & 27 deletions llvm/lib/Transforms/Coroutines/CoroFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@

using namespace llvm;

extern cl::opt<bool> UseNewDbgInfoFormat;

#define DEBUG_TYPE "coro-frame"

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

if (UseNewDbgInfoFormat) {
DbgVariableRecord *NewDVR =
new DbgVariableRecord(ValueAsMetadata::get(Shape.FramePtr), FrameDIVar,
DBuilder.createExpression(), DILoc,
DbgVariableRecord::LocationType::Declare);
BasicBlock::iterator It = Shape.getInsertPtAfterFramePtr();
It->getParent()->insertDbgRecordBefore(NewDVR, It);
} else {
DBuilder.insertDeclare(Shape.FramePtr, FrameDIVar,
DBuilder.createExpression(), DILoc,
Shape.getInsertPtAfterFramePtr());
}
DbgVariableRecord *NewDVR =
new DbgVariableRecord(ValueAsMetadata::get(Shape.FramePtr), FrameDIVar,
DBuilder.createExpression(), DILoc,
DbgVariableRecord::LocationType::Declare);
BasicBlock::iterator It = Shape.getInsertPtAfterFramePtr();
It->getParent()->insertDbgRecordBefore(NewDVR, It);
}

// Build a struct that will keep state for an active coroutine.
Expand Down Expand Up @@ -1136,19 +1128,12 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
// This dbg.declare is preserved for all coro-split function
// fragments. It will be unreachable in the main function, and
// processed by coro::salvageDebugInfo() by the Cloner.
if (UseNewDbgInfoFormat) {
DbgVariableRecord *NewDVR = new DbgVariableRecord(
ValueAsMetadata::get(CurrentReload), DDI->getVariable(),
DDI->getExpression(), DDI->getDebugLoc(),
DbgVariableRecord::LocationType::Declare);
Builder.GetInsertPoint()->getParent()->insertDbgRecordBefore(
NewDVR, Builder.GetInsertPoint());
} else {
DIBuilder(*CurrentBlock->getParent()->getParent(), AllowUnresolved)
.insertDeclare(CurrentReload, DDI->getVariable(),
DDI->getExpression(), DDI->getDebugLoc(),
Builder.GetInsertPoint());
}
DbgVariableRecord *NewDVR = new DbgVariableRecord(
ValueAsMetadata::get(CurrentReload), DDI->getVariable(),
DDI->getExpression(), DDI->getDebugLoc(),
DbgVariableRecord::LocationType::Declare);
Builder.GetInsertPoint()->getParent()->insertDbgRecordBefore(
NewDVR, Builder.GetInsertPoint());
// This dbg.declare is for the main function entry point. It
// will be deleted in all coro-split functions.
coro::salvageDebugInfo(ArgToAllocaMap, *DDI, false /*UseEntryValue*/);
Expand Down
18 changes: 4 additions & 14 deletions llvm/lib/Transforms/Utils/Local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@
using namespace llvm;
using namespace llvm::PatternMatch;

extern cl::opt<bool> UseNewDbgInfoFormat;

#define DEBUG_TYPE "local"

STATISTIC(NumRemoved, "Number of unreachable basic blocks removed");
Expand Down Expand Up @@ -1691,16 +1689,10 @@ static void insertDbgValueOrDbgVariableRecord(DIBuilder &Builder, Value *DV,
DIExpression *DIExpr,
const DebugLoc &NewLoc,
BasicBlock::iterator Instr) {
if (!UseNewDbgInfoFormat) {
Builder.insertDbgValueIntrinsic(DV, DIVar, DIExpr, NewLoc, Instr);
} else {
// RemoveDIs: if we're using the new debug-info format, allocate a
// DbgVariableRecord directly instead of a dbg.value intrinsic.
ValueAsMetadata *DVAM = ValueAsMetadata::get(DV);
DbgVariableRecord *DV =
new DbgVariableRecord(DVAM, DIVar, DIExpr, NewLoc.get());
Instr->getParent()->insertDbgRecordBefore(DV, Instr);
}
ValueAsMetadata *DVAM = ValueAsMetadata::get(DV);
DbgVariableRecord *DVRec =
new DbgVariableRecord(DVAM, DIVar, DIExpr, NewLoc.get());
Instr->getParent()->insertDbgRecordBefore(DVRec, Instr);
}

static void insertDbgValueOrDbgVariableRecordAfter(
Expand Down Expand Up @@ -1838,7 +1830,6 @@ void llvm::ConvertDebugDeclareToDebugValue(DbgVariableRecord *DVR,
// then we want to insert a dbg.value for the corresponding fragment.
LLVM_DEBUG(dbgs() << "Failed to convert dbg.declare to dbg.value: " << *DVR
<< '\n');
assert(UseNewDbgInfoFormat);

// For now, when there is a store to parts of the variable (but we do not
// know which part) we insert an dbg.value intrinsic to indicate that we
Expand Down Expand Up @@ -1919,7 +1910,6 @@ void llvm::ConvertDebugDeclareToDebugValue(DbgVariableRecord *DVR, LoadInst *LI,
// future if multi-location support is added to the IR, it might be
// preferable to keep tracking both the loaded value and the original
// address in case the alloca can not be elided.
assert(UseNewDbgInfoFormat);

// Create a DbgVariableRecord directly and insert.
ValueAsMetadata *LIVAM = ValueAsMetadata::get(LI);
Expand Down
Loading
Loading