Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bolt/lib/Passes/LongJmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ BinaryBasicBlock *LongJmpPass::lookupStubFromGroup(
const std::pair<uint64_t, BinaryBasicBlock *> &RHS) {
return LHS.first < RHS.first;
});
if (Cand == Candidates.end())
return nullptr;
if (Cand != Candidates.begin()) {
if (Cand == Candidates.end()) {
Cand = std::prev(Cand);
} else if (Cand != Candidates.begin()) {
const StubTy *LeftCand = std::prev(Cand);
if (Cand->first - DotAddress > DotAddress - LeftCand->first)
Cand = LeftCand;
Expand Down
32 changes: 32 additions & 0 deletions bolt/test/AArch64/one-stub.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This test verifies that no unnecessary stubs are inserted when each DotAddress increases during a lookup.

# REQUIRES: system-linux, asserts

# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
# RUN: %clang %cflags -O0 %t.o -o %t.exe -nostdlib -Wl,-q
# RUN: link_fdata %s %t.o %t.fdata
# RUN: llvm-bolt %t.exe -o %t.bolt \
# RUN: --data %t.fdata | FileCheck %s

# CHECK: BOLT-INFO: Inserted 1 stubs in the hot area and 0 stubs in the cold area.

.section .text
.global _start
.global far_away_func

.align 4
.global _start
.type _start, %function
_start:
# FDATA: 0 [unknown] 0 1 _start 0 0 100
bl far_away_func
bl far_away_func
ret
.space 0x8000000
.global far_away_func
.type far_away_func, %function
far_away_func:
add x0, x0, #1
ret

.reloc 0, R_AARCH64_NONE
Loading