Skip to content

Commit f3cbd76

Browse files
committed
DebugInfo: Avoid some MMI::hasDebugInfo checks
I assume getSubprogram will do the correct thing in hasDebugInfo, and this is redundant with the debug_compile_units distance check. This is in preparation for removing the field.
1 parent 0df69b8 commit f3cbd76

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,7 @@ bool DebugHandlerBase::isUnsignedDIType(const DIType *Ty) {
241241
Ty->getTag() == dwarf::DW_TAG_unspecified_type;
242242
}
243243

244-
static bool hasDebugInfo(const MachineModuleInfo *MMI,
245-
const MachineFunction *MF) {
246-
if (!MMI->hasDebugInfo())
247-
return false;
244+
static bool hasDebugInfo(const MachineFunction *MF) {
248245
auto *SP = MF->getFunction().getSubprogram();
249246
if (!SP)
250247
return false;
@@ -258,7 +255,7 @@ static bool hasDebugInfo(const MachineModuleInfo *MMI,
258255
void DebugHandlerBase::beginFunction(const MachineFunction *MF) {
259256
PrevInstBB = nullptr;
260257

261-
if (!Asm || !hasDebugInfo(MMI, MF)) {
258+
if (!Asm || !hasDebugInfo(MF)) {
262259
skippedNonDebugFunction();
263260
return;
264261
}
@@ -415,7 +412,7 @@ void DebugHandlerBase::endInstruction() {
415412
}
416413

417414
void DebugHandlerBase::endFunction(const MachineFunction *MF) {
418-
if (Asm && hasDebugInfo(MMI, MF))
415+
if (Asm && hasDebugInfo(MF))
419416
endFunctionImpl(MF);
420417
DbgValues.clear();
421418
DbgLabels.clear();

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,14 +1148,15 @@ sortGlobalExprs(SmallVectorImpl<DwarfCompileUnit::GlobalExpr> &GVEs) {
11481148
void DwarfDebug::beginModule(Module *M) {
11491149
DebugHandlerBase::beginModule(M);
11501150

1151-
if (!Asm || !MMI->hasDebugInfo())
1151+
if (!Asm)
11521152
return;
11531153

11541154
unsigned NumDebugCUs = std::distance(M->debug_compile_units_begin(),
11551155
M->debug_compile_units_end());
1156+
if (NumDebugCUs == 0)
1157+
return;
1158+
11561159
assert(NumDebugCUs > 0 && "Asm unexpectedly initialized");
1157-
assert(MMI->hasDebugInfo() &&
1158-
"DebugInfoAvailabilty unexpectedly not initialized");
11591160
SingleCU = NumDebugCUs == 1;
11601161
DenseMap<DIGlobalVariable *, SmallVector<DwarfCompileUnit::GlobalExpr, 1>>
11611162
GVMap;

llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ void NVPTXAsmPrinter::emitFunctionEntryLabel() {
493493
// Emit initial .loc debug directive for correct relocation symbol data.
494494
if (const DISubprogram *SP = MF->getFunction().getSubprogram()) {
495495
assert(SP->getUnit());
496-
if (!SP->getUnit()->isDebugDirectivesOnly() && MMI && MMI->hasDebugInfo())
496+
if (!SP->getUnit()->isDebugDirectivesOnly())
497497
emitInitialRawDwarfLocDirective(*MF);
498498
}
499499
}
@@ -912,7 +912,7 @@ void NVPTXAsmPrinter::emitHeader(Module &M, raw_ostream &O,
912912
if (HasFullDebugInfo)
913913
break;
914914
}
915-
if (MMI && MMI->hasDebugInfo() && HasFullDebugInfo)
915+
if (HasFullDebugInfo)
916916
O << ", debug";
917917

918918
O << "\n";

0 commit comments

Comments
 (0)