[llvm] [BOLT][AArch64] Check Last Element Instead of Returning `nullptr` in `lookupStubFromGroup` (PR #114015)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 2 02:56:44 PDT 2024
================
@@ -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);
----------------
liusy58 wrote:
The following example can verify this
```asm
# REQUIRES: system-linux, asserts
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
# RUN: %clang %cflags -O0 -fPIC -pie %t.o -o %t.exe -nostdlib -Wl,-q
# RUN: link_fdata %s %t.o %t.fdata
# RUN: llvm-bolt %t.exe -o %t.bolt --use-old-text=0 --lite=0 --split-all-cold \
# RUN: --align-functions-max-bytes=1 --split-functions \
# RUN: --data %t.fdata --reorder-functions=exec-count | FileCheck %s
# CHECK: BOLT-INFO: Inserted 1 stubs in the hot area and 0 stubs in the cold area. Shared 0 times, iterated 3 times.
.section .text
.global _start
.global dummy
.global func
.align 4
.global _start
.type _start, %function
_start:
# FDATA: 0 [unknown] 0 1 _start 0 0 100
bl func
bl func
ret
.global func
.type func, %function
func:
add x0, x0, #1
ret
.global dummy
.type dummy, %function
dummy:
# FDATA: 0 [unknown] 0 1 dummy 0 0 42
.rept 33554432 // Insert enough NOPs to exceed the branch range (adjust as necessary)
add x0, x0, #1
.endr
ret
.reloc 0, R_AARCH64_NONE
```
But, this example should take a lot of time to finish...
https://github.com/llvm/llvm-project/pull/114015
More information about the llvm-commits
mailing list