Skip to content

Commit decd078

Browse files
committed
Dont emit for single line functions
Signed-off-by: Peter Rong <[email protected]>
1 parent 3d9e686 commit decd078

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,18 @@ DIE &DwarfCompileUnit::updateSubprogramScopeDIE(const DISubprogram *SP,
553553
addFlag(*SPDie, dwarf::DW_AT_APPLE_omit_frame_ptr);
554554

555555
if (emitFuncLineTableOffsets() && LineTableSym) {
556-
addSectionLabel(
557-
*SPDie, dwarf::DW_AT_LLVM_stmt_sequence, LineTableSym,
558-
Asm->getObjFileLowering().getDwarfLineSection()->getBeginSymbol());
556+
// Check if we have meaningful code ranges before adding LLVM_stmt_sequence
557+
// Only add it if there are multiple basic block sections or if the single
558+
// range represents substantial code (not just a trivial function)
559+
bool hasSubstantialCode =
560+
BB_List.size() > 1 ||
561+
(BB_List.size() == 1 && BB_List[0].Begin != BB_List[0].End);
562+
563+
if (hasSubstantialCode) {
564+
addSectionLabel(
565+
*SPDie, dwarf::DW_AT_LLVM_stmt_sequence, LineTableSym,
566+
Asm->getObjFileLowering().getDwarfLineSection()->getBeginSymbol());
567+
}
559568
}
560569

561570
// Only include DW_AT_frame_base in full debug info

0 commit comments

Comments
 (0)