diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp index bc45caf3ec8b7..1e427b2df11cf 100644 --- a/bolt/lib/Core/BinaryFunction.cpp +++ b/bolt/lib/Core/BinaryFunction.cpp @@ -498,6 +498,11 @@ void BinaryFunction::print(raw_ostream &OS, std::string Annotation) { if (!IslandOffset) return; + // Print label if it exists at this offset. + if (const BinaryData *BD = + BC.getBinaryDataAtAddress(getAddress() + *IslandOffset)) + OS << BD->getName() << ":\n"; + const size_t IslandSize = getSizeOfDataInCodeAt(*IslandOffset); BC.printData(OS, BC.extractData(getAddress() + *IslandOffset, IslandSize), *IslandOffset); @@ -1066,7 +1071,7 @@ size_t BinaryFunction::getSizeOfDataInCodeAt(uint64_t Offset) const { auto Iter = Islands->CodeOffsets.upper_bound(Offset); if (Iter != Islands->CodeOffsets.end()) return *Iter - Offset; - return getSize() - Offset; + return getMaxSize() - Offset; } std::optional diff --git a/bolt/test/AArch64/data-in-code.s b/bolt/test/AArch64/data-in-code.s index 8d3179a0c3350..1df5d4568542f 100644 --- a/bolt/test/AArch64/data-in-code.s +++ b/bolt/test/AArch64/data-in-code.s @@ -7,7 +7,8 @@ ## Check disassembly of BOLT input. # RUN: llvm-objdump %t.exe -d | FileCheck %s -# RUN: llvm-bolt %t.exe -o %t.bolt --print-disasm | FileCheck %s +# RUN: llvm-bolt %t.exe -o %t.bolt --print-disasm \ +# RUN: | FileCheck %s --check-prefixes CHECK,CHECK-BOLT-ONLY .text .balign 4 @@ -16,16 +17,21 @@ .type _start, %function _start: mov x0, #0x0 + ldr x1, .L1 .word 0x4f82e010 ret +.size _start, .-_start +.L1: .byte 0x0, 0xff, 0x42 # CHECK-LABEL: _start # CHECK: mov x0, #0x0 +# CHECK-NEXT: ldr x1 +# CHECK-BOLT-ONLY-SAME: ISLANDat[[ADDR:]] # CHECK-NEXT: .word 0x4f82e010 # CHECK-NEXT: ret +# CHECK-BOLT-ONLY-NEXT: ISLANDat[[ADDR]] # CHECK-NEXT: .short 0xff00 # CHECK-NEXT: .byte 0x42 -.size _start, .-_start ## Force relocation mode. .reloc 0, R_AARCH64_NONE