Skip to content

Commit cdc7ef3

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 df45fdf commit cdc7ef3

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
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;

0 commit comments

Comments
 (0)