Skip to content

[DebugInfo][RemoveDIs] Delete debug-info-format flag #143746

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

Merged
merged 4 commits into from
Jun 12, 2025
Merged
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
9 changes: 0 additions & 9 deletions llvm/include/llvm/IR/BasicBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
public:
using InstListType = SymbolTableList<Instruction, ilist_iterator_bits<true>,
ilist_parent<BasicBlock>>;
/// Flag recording whether or not this block stores debug-info in the form
/// of intrinsic instructions (false) or non-instruction records (true).
bool IsNewDbgInfoFormat;

private:
// Allow Function to renumber blocks.
Expand Down Expand Up @@ -95,12 +92,6 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
/// IsNewDbgInfoFormat = false.
LLVM_ABI void convertFromNewDbgValues();

/// Ensure the block is in "old" dbg.value format (\p NewFlag == false) or
/// in the new format (\p NewFlag == true), converting to the desired format
/// if necessary.
LLVM_ABI void setIsNewDbgInfoFormat(bool NewFlag);
LLVM_ABI void setNewDbgInfoFormatFlag(bool NewFlag);

unsigned getNumber() const {
assert(getParent() && "only basic blocks in functions have valid numbers");
return Number;
Expand Down
9 changes: 0 additions & 9 deletions llvm/include/llvm/IR/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,6 @@ class LLVM_ABI Function : public GlobalObject, public ilist_node<Function> {
friend class SymbolTableListTraits<Function>;

public:
/// Is this function using intrinsics to record the position of debugging
/// information, or non-intrinsic records? See IsNewDbgInfoFormat in
/// \ref BasicBlock.
bool IsNewDbgInfoFormat;

/// hasLazyArguments/CheckLazyArguments - The argument list of a function is
/// built on demand, so that the list isn't allocated until the first client
/// needs it. The hasLazyArguments predicate returns true if the arg list
Expand All @@ -130,9 +125,6 @@ class LLVM_ABI Function : public GlobalObject, public ilist_node<Function> {
/// \see BasicBlock::convertFromNewDbgValues.
void convertFromNewDbgValues();

void setIsNewDbgInfoFormat(bool NewVal);
void setNewDbgInfoFormatFlag(bool NewVal);

private:
friend class TargetLibraryInfoImpl;

Expand Down Expand Up @@ -760,7 +752,6 @@ class LLVM_ABI Function : public GlobalObject, public ilist_node<Function> {
/// to the newly inserted BB.
Function::iterator insert(Function::iterator Position, BasicBlock *BB) {
Function::iterator FIt = BasicBlocks.insert(Position, BB);
BB->setIsNewDbgInfoFormat(IsNewDbgInfoFormat);
return FIt;
}

Expand Down
20 changes: 0 additions & 20 deletions llvm/include/llvm/IR/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,6 @@ class LLVM_ABI Module {
/// @name Constructors
/// @{
public:
/// Is this Module using intrinsics to record the position of debugging
/// information, or non-intrinsic records? See IsNewDbgInfoFormat in
/// \ref BasicBlock.
bool IsNewDbgInfoFormat;

/// Used when printing this module in the new debug info format; removes all
/// declarations of debug intrinsics that are replaced by non-intrinsic
/// records in the new format.
Expand All @@ -230,28 +225,13 @@ class LLVM_ABI Module {
for (auto &F : *this) {
F.convertToNewDbgValues();
}
IsNewDbgInfoFormat = true;
}

/// \see BasicBlock::convertFromNewDbgValues.
void convertFromNewDbgValues() {
for (auto &F : *this) {
F.convertFromNewDbgValues();
}
IsNewDbgInfoFormat = false;
}

void setIsNewDbgInfoFormat(bool UseNewFormat) {
if (UseNewFormat && !IsNewDbgInfoFormat)
convertToNewDbgValues();
else if (!UseNewFormat && IsNewDbgInfoFormat)
convertFromNewDbgValues();
}
void setNewDbgInfoFormatFlag(bool NewFlag) {
for (auto &F : *this) {
F.setNewDbgInfoFormatFlag(NewFlag);
}
IsNewDbgInfoFormat = NewFlag;
}

/// The Module constructor. Note that there is no default constructor. You
Expand Down
4 changes: 0 additions & 4 deletions llvm/lib/AsmParser/LLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,6 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {
UpgradeNVVMAnnotations(*M);
UpgradeSectionAttributes(*M);

M->setIsNewDbgInfoFormat(true);

if (!Slots)
return false;
// Initialize the slot mapping.
Expand Down Expand Up @@ -6906,8 +6904,6 @@ bool LLParser::parseBasicBlock(PerFunctionState &PFS) {
if (SeenOldDbgInfoFormat)
return error(Lex.getLoc(), "debug record should not appear in a module "
"containing debug info intrinsics");
if (!SeenNewDbgInfoFormat)
M->setNewDbgInfoFormatFlag(true);
SeenNewDbgInfoFormat = true;
Lex.Lex();

Expand Down
8 changes: 0 additions & 8 deletions llvm/lib/Bitcode/Reader/BitcodeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4479,10 +4479,6 @@ Error BitcodeReader::parseGlobalIndirectSymbolRecord(
Error BitcodeReader::parseModule(uint64_t ResumeBit,
bool ShouldLazyLoadMetadata,
ParserCallbacks Callbacks) {
// Don't allow modules to use debug-intrinsics: autoupgrading them is now
// mandatory.
TheModule->IsNewDbgInfoFormat = true;

this->ValueTypeCallback = std::move(Callbacks.ValueType);
if (ResumeBit) {
if (Error JumpFailed = Stream.JumpToBit(ResumeBit))
Expand Down Expand Up @@ -6994,10 +6990,6 @@ Error BitcodeReader::materialize(GlobalValue *GV) {
if (Error JumpFailed = Stream.JumpToBit(DFII->second))
return JumpFailed;

// Regardless of the debug info format we want to end up in, we need
// IsNewDbgInfoFormat=true to construct any debug records seen in the bitcode.
F->IsNewDbgInfoFormat = true;

if (Error Err = parseFunctionBody(F))
return Err;
F->setIsMaterializable(false);
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/CodeGen/CodeGenPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3335,8 +3335,7 @@ class TypePromotionTransaction {

// Record where we would have to re-insert the instruction in the sequence
// of DbgRecords, if we ended up reinserting.
if (BB->IsNewDbgInfoFormat)
BeforeDbgRecord = Inst->getDbgReinsertionPosition();
BeforeDbgRecord = Inst->getDbgReinsertionPosition();

if (HasPrevInstruction) {
Point.PrevInst = std::prev(Inst->getIterator());
Expand Down
35 changes: 2 additions & 33 deletions llvm/lib/IR/BasicBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ DbgMarker *BasicBlock::createMarker(InstListType::iterator It) {
}

void BasicBlock::convertToNewDbgValues() {
IsNewDbgInfoFormat = true;

// Iterate over all instructions in the instruction list, collecting debug
// info intrinsics and converting them to DbgRecords. Once we find a "real"
// instruction, attach all those DbgRecords to a DbgMarker in that
Expand Down Expand Up @@ -91,7 +89,6 @@ void BasicBlock::convertToNewDbgValues() {

void BasicBlock::convertFromNewDbgValues() {
invalidateOrders();
IsNewDbgInfoFormat = false;

// Iterate over the block, finding instructions annotated with DbgMarkers.
// Convert any attached DbgRecords to debug intrinsics and insert ahead of the
Expand Down Expand Up @@ -126,16 +123,6 @@ void BasicBlock::dumpDbgValues() const {
}
#endif

void BasicBlock::setIsNewDbgInfoFormat(bool NewFlag) {
if (NewFlag && !IsNewDbgInfoFormat)
convertToNewDbgValues();
else if (!NewFlag && IsNewDbgInfoFormat)
convertFromNewDbgValues();
}
void BasicBlock::setNewDbgInfoFormatFlag(bool NewFlag) {
IsNewDbgInfoFormat = NewFlag;
}

ValueSymbolTable *BasicBlock::getValueSymbolTable() {
if (Function *F = getParent())
return F->getValueSymbolTable();
Expand All @@ -157,8 +144,7 @@ template class llvm::SymbolTableListTraits<

BasicBlock::BasicBlock(LLVMContext &C, const Twine &Name, Function *NewParent,
BasicBlock *InsertBefore)
: Value(Type::getLabelTy(C), Value::BasicBlockVal),
IsNewDbgInfoFormat(true), Parent(nullptr) {
: Value(Type::getLabelTy(C), Value::BasicBlockVal), Parent(nullptr) {

if (NewParent)
insertInto(NewParent, InsertBefore);
Expand All @@ -168,8 +154,6 @@ BasicBlock::BasicBlock(LLVMContext &C, const Twine &Name, Function *NewParent,

end().getNodePtr()->setParent(this);
setName(Name);
if (NewParent)
setIsNewDbgInfoFormat(NewParent->IsNewDbgInfoFormat);
}

void BasicBlock::insertInto(Function *NewParent, BasicBlock *InsertBefore) {
Expand All @@ -180,8 +164,6 @@ void BasicBlock::insertInto(Function *NewParent, BasicBlock *InsertBefore) {
NewParent->insert(InsertBefore->getIterator(), this);
else
NewParent->insert(NewParent->end(), this);

setIsNewDbgInfoFormat(NewParent->IsNewDbgInfoFormat);
}

BasicBlock::~BasicBlock() {
Expand Down Expand Up @@ -725,10 +707,6 @@ void BasicBlock::flushTerminatorDbgRecords() {
// check whether there's anything trailing at the end and move those
// DbgRecords in front of the terminator.

// Do nothing if we're not in new debug-info format.
if (!IsNewDbgInfoFormat)
return;

// If there's no terminator, there's nothing to do.
Instruction *Term = getTerminator();
if (!Term)
Expand Down Expand Up @@ -765,10 +743,6 @@ void BasicBlock::spliceDebugInfoEmptyBlock(BasicBlock::iterator Dest,
// in the iterators whether there was the intention to transfer any debug
// info.

// If we're not in "new" debug-info format, do nothing.
if (!IsNewDbgInfoFormat)
return;

assert(First == Last);
bool InsertAtHead = Dest.getHeadBit();
bool ReadFromHead = First.getHeadBit();
Expand Down Expand Up @@ -1029,8 +1003,6 @@ void BasicBlock::spliceDebugInfoImpl(BasicBlock::iterator Dest, BasicBlock *Src,

void BasicBlock::splice(iterator Dest, BasicBlock *Src, iterator First,
iterator Last) {
assert(Src->IsNewDbgInfoFormat == IsNewDbgInfoFormat);

#ifdef EXPENSIVE_CHECKS
// Check that First is before Last.
auto FromBBEnd = Src->end();
Expand All @@ -1045,9 +1017,7 @@ void BasicBlock::splice(iterator Dest, BasicBlock *Src, iterator First,
return;
}

// Handle non-instr debug-info specific juggling.
if (IsNewDbgInfoFormat)
spliceDebugInfo(Dest, Src, First, Last);
spliceDebugInfo(Dest, Src, First, Last);

// And move the instructions.
getInstList().splice(Dest, Src->getInstList(), First, Last);
Expand All @@ -1056,7 +1026,6 @@ void BasicBlock::splice(iterator Dest, BasicBlock *Src, iterator First,
}

void BasicBlock::insertDbgRecordAfter(DbgRecord *DR, Instruction *I) {
assert(IsNewDbgInfoFormat);
assert(I->getParent() == this);

iterator NextIt = std::next(I->getIterator());
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/IR/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,12 @@ void LLVMAddModuleFlag(LLVMModuleRef M, LLVMModuleFlagBehavior Behavior,
{Key, KeyLen}, unwrap(Val));
}

LLVMBool LLVMIsNewDbgInfoFormat(LLVMModuleRef M) {
return unwrap(M)->IsNewDbgInfoFormat;
}
LLVMBool LLVMIsNewDbgInfoFormat(LLVMModuleRef M) { return true; }

void LLVMSetIsNewDbgInfoFormat(LLVMModuleRef M, LLVMBool UseNewFormat) {
unwrap(M)->setIsNewDbgInfoFormat(UseNewFormat);
if (!UseNewFormat)
llvm_unreachable("LLVM no longer supports intrinsic based debug-info");
(void)M;
}

/*--.. Printing modules ....................................................--*/
Expand Down
18 changes: 1 addition & 17 deletions llvm/lib/IR/Function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,32 +87,17 @@ void Function::validateBlockNumbers() const {
}

void Function::convertToNewDbgValues() {
IsNewDbgInfoFormat = true;
for (auto &BB : *this) {
BB.convertToNewDbgValues();
}
}

void Function::convertFromNewDbgValues() {
IsNewDbgInfoFormat = false;
for (auto &BB : *this) {
BB.convertFromNewDbgValues();
}
}

void Function::setIsNewDbgInfoFormat(bool NewFlag) {
if (NewFlag && !IsNewDbgInfoFormat)
convertToNewDbgValues();
else if (!NewFlag && IsNewDbgInfoFormat)
convertFromNewDbgValues();
}
void Function::setNewDbgInfoFormatFlag(bool NewFlag) {
for (auto &BB : *this) {
BB.setNewDbgInfoFormatFlag(NewFlag);
}
IsNewDbgInfoFormat = NewFlag;
}

//===----------------------------------------------------------------------===//
// Argument Implementation
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -490,7 +475,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(true) {
NumArgs(Ty->getNumParams()) {
assert(FunctionType::isValidReturnType(getReturnType()) &&
"invalid return type");
setGlobalObjectSubClassData(0);
Expand All @@ -505,7 +490,6 @@ Function::Function(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace,

if (ParentModule) {
ParentModule->getFunctionList().push_back(this);
IsNewDbgInfoFormat = ParentModule->IsNewDbgInfoFormat;
}

HasLLVMReservedName = getName().starts_with("llvm.");
Expand Down
13 changes: 3 additions & 10 deletions llvm/lib/IR/Instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void Instruction::removeFromParent() {
}

void Instruction::handleMarkerRemoval() {
if (!getParent()->IsNewDbgInfoFormat || !DebugMarker)
if (!DebugMarker)
return;

DebugMarker->removeMarker();
Expand Down Expand Up @@ -136,9 +136,6 @@ void Instruction::insertBefore(BasicBlock &BB,

BB.getInstList().insert(InsertPos, this);

if (!BB.IsNewDbgInfoFormat)
return;

// We've inserted "this": if InsertAtHead is set then it comes before any
// DbgVariableRecords attached to InsertPos. But if it's not set, then any
// DbgRecords should now come before "this".
Expand Down Expand Up @@ -226,7 +223,7 @@ void Instruction::moveBeforeImpl(BasicBlock &BB, InstListType::iterator I,

// If we've been given the "Preserve" flag, then just move the DbgRecords with
// the instruction, no more special handling needed.
if (BB.IsNewDbgInfoFormat && DebugMarker && !Preserve) {
if (DebugMarker && !Preserve) {
if (I != this->getIterator() || InsertAtHead) {
// "this" is definitely moving in the list, or it's moving ahead of its
// attached DbgVariableRecords. Detach any existing DbgRecords.
Expand All @@ -238,7 +235,7 @@ void Instruction::moveBeforeImpl(BasicBlock &BB, InstListType::iterator I,
// the block splicer, which will do more debug-info things.
BB.getInstList().splice(I, getParent()->getInstList(), getIterator());

if (BB.IsNewDbgInfoFormat && !Preserve) {
if (!Preserve) {
DbgMarker *NextMarker = getParent()->getNextMarker(this);

// If we're inserting at point I, and not in front of the DbgRecords
Expand All @@ -258,10 +255,6 @@ iterator_range<DbgRecord::self_iterator> Instruction::cloneDebugInfoFrom(
if (!From->DebugMarker)
return DbgMarker::getEmptyDbgRecordRange();

assert(getParent()->IsNewDbgInfoFormat);
assert(getParent()->IsNewDbgInfoFormat ==
From->getParent()->IsNewDbgInfoFormat);

if (!DebugMarker)
getParent()->createMarker(this);

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 @@ -71,8 +71,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(true) {
ModuleID(std::string(MID)), SourceFileName(std::string(MID)) {
Context.addModule(this);
}

Expand All @@ -83,7 +82,6 @@ Module &Module::operator=(Module &&Other) {

ModuleID = std::move(Other.ModuleID);
SourceFileName = std::move(Other.SourceFileName);
IsNewDbgInfoFormat = std::move(Other.IsNewDbgInfoFormat);

GlobalList.clear();
GlobalList.splice(GlobalList.begin(), Other.GlobalList);
Expand Down
Loading
Loading