Skip to content

Commit 0ba391a

Browse files
authored
[BOLT] Improve constant island disassembly (#127971)
* Add label that identifies constant island. * Support cases where the island is located after the function.
1 parent 78d82d3 commit 0ba391a

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,11 @@ void BinaryFunction::print(raw_ostream &OS, std::string Annotation) {
498498
if (!IslandOffset)
499499
return;
500500

501+
// Print label if it exists at this offset.
502+
if (const BinaryData *BD =
503+
BC.getBinaryDataAtAddress(getAddress() + *IslandOffset))
504+
OS << BD->getName() << ":\n";
505+
501506
const size_t IslandSize = getSizeOfDataInCodeAt(*IslandOffset);
502507
BC.printData(OS, BC.extractData(getAddress() + *IslandOffset, IslandSize),
503508
*IslandOffset);
@@ -1066,7 +1071,7 @@ size_t BinaryFunction::getSizeOfDataInCodeAt(uint64_t Offset) const {
10661071
auto Iter = Islands->CodeOffsets.upper_bound(Offset);
10671072
if (Iter != Islands->CodeOffsets.end())
10681073
return *Iter - Offset;
1069-
return getSize() - Offset;
1074+
return getMaxSize() - Offset;
10701075
}
10711076

10721077
std::optional<uint64_t>

bolt/test/AArch64/data-in-code.s

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
## Check disassembly of BOLT input.
88
# RUN: llvm-objdump %t.exe -d | FileCheck %s
99

10-
# RUN: llvm-bolt %t.exe -o %t.bolt --print-disasm | FileCheck %s
10+
# RUN: llvm-bolt %t.exe -o %t.bolt --print-disasm \
11+
# RUN: | FileCheck %s --check-prefixes CHECK,CHECK-BOLT-ONLY
1112

1213
.text
1314
.balign 4
@@ -16,16 +17,21 @@
1617
.type _start, %function
1718
_start:
1819
mov x0, #0x0
20+
ldr x1, .L1
1921
.word 0x4f82e010
2022
ret
23+
.size _start, .-_start
24+
.L1:
2125
.byte 0x0, 0xff, 0x42
2226
# CHECK-LABEL: _start
2327
# CHECK: mov x0, #0x0
28+
# CHECK-NEXT: ldr x1
29+
# CHECK-BOLT-ONLY-SAME: ISLANDat[[ADDR:]]
2430
# CHECK-NEXT: .word 0x4f82e010
2531
# CHECK-NEXT: ret
32+
# CHECK-BOLT-ONLY-NEXT: ISLANDat[[ADDR]]
2633
# CHECK-NEXT: .short 0xff00
2734
# CHECK-NEXT: .byte 0x42
28-
.size _start, .-_start
2935

3036
## Force relocation mode.
3137
.reloc 0, R_AARCH64_NONE

0 commit comments

Comments
 (0)