63 lines · plain
1## Check that llvm-bolt will not unnecessarily relax ADR instruction.2 3# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o4# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -static5# RUN: llvm-bolt %t.exe -o %t.bolt --split-functions --split-strategy=random26# RUN: llvm-objdump -d -j .text %t.bolt | FileCheck %s7# RUN: llvm-objdump -d --disassemble-symbols=foo.cold.0 %t.bolt \8# RUN: | FileCheck --check-prefix=CHECK-FOO %s9 10## ADR below references its containing function that is split. But ADR is always11## in the main fragment, thus there is no need to relax it.12 .text13 .globl _start14 .type _start, %function15_start:16 .cfi_startproc17# CHECK: <_start>:18# CHECK-NEXT: adr19 adr x1, _start20 cmp x1, x1121 b.hi .L122 mov x0, #0x023.L1:24 ret x3025 .cfi_endproc26.size _start, .-_start27 28 29## In foo, ADR is in the split fragment but references the main one. Thus, it30## needs to be relaxed into ADRP + ADD.31 .globl foo32 .type foo, %function33foo:34 .cfi_startproc35 cmp x1, x1136 b.hi .L237.L2:38# CHECK-FOO: <foo.cold.0>:39# CHECK-FOO-NEXT: adrp40# CHECK-FOO-NEXT: add41 adr x1, foo42 ret x3043 .cfi_endproc44.size foo, .-foo45 46## bar is a non-simple function. We can still relax ADR, because it has a47## preceding NOP.48 .globl bar49 .type bar, %function50bar:51 .cfi_startproc52# CHECK-LABEL: <bar>:53# CHECK-NEXT: adrp54# CHECK-NEXT: add55 nop56 adr x0, foo57 adr x1, .L358 br x159.L3:60 ret x061 .cfi_endproc62 .size bar, .-bar63