Skip to content

Commit 82ca752

Browse files
authored
[BOLT][DWARF] Add test for DW_AT_ranges input without function output (#81794)
Added a test that relies on -fbasic-block-sections=all and --gc-sections that exercises a code path that previously printed a warning.
1 parent 7249692 commit 82ca752

4 files changed

+544
-15
lines changed

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -919,15 +919,10 @@ void DWARFRewriter::updateUnitDebugInfo(
919919
DIEValue LowPCVal = Die->findAttribute(dwarf::DW_AT_low_pc);
920920
DIEValue HighPCVal = Die->findAttribute(dwarf::DW_AT_high_pc);
921921
if (FunctionRanges.empty()) {
922-
if (LowPCVal && HighPCVal) {
922+
if (LowPCVal && HighPCVal)
923923
FunctionRanges.push_back({0, HighPCVal.getDIEInteger().getValue()});
924-
} else {
925-
// I haven't seen this case, but who knows what other compilers
926-
// generate.
924+
else
927925
FunctionRanges.push_back({0, 1});
928-
errs() << "BOLT-WARNING: [internal-dwarf-error]: subprogram got GCed "
929-
"by the linker, DW_AT_ranges is used\n";
930-
}
931926
}
932927

933928
if (FunctionRanges.size() == 1 && !opts::AlwaysConvertToRanges) {

bolt/test/X86/dwarf4-subprogram-single-gc-ranges.test

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-subprogram-single-gc-ranges-main.s -o %t1.o
44
# RUN: %clang %cflags %t1.o -o %t.exe -Wl,-q
5-
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections &> %t1.txt
6-
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t1.txt
5+
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
6+
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt > %t1.txt
77
# RUN: cat %t1.txt | FileCheck --check-prefix=POSTCHECK %s
88

99
# This test checks BOLT correctly handles DW_TAG_subprogram with Ranges with single entry, when function was GCed.
1010

11-
# POSTCHECK: BOLT-WARNING: [internal-dwarf-error]: subprogram got GCed by the linker, DW_AT_ranges is used
12-
1311
# POSTCHECK: DW_TAG_subprogram
1412
# POSTCHECK-NEXT: DW_AT_frame_base
1513
# POSTCHECK-NEXT: DW_AT_linkage_name

0 commit comments

Comments
 (0)