forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BOLT][AArch64] Remove nops in functions with defined control flow (l…
…lvm#124705) When a function has an indirect branch with unknown control flow, we preserve nops in order to keep all instruction offsets (from the start of the function) the same in case the indirect branch is used by a PC-relative jump table. However, when we know the control flow of the function, we should be able to safely remove nops.
- Loading branch information
Showing
2 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
## Verify that llvm-bolt removes nop instructions from functions with indirect | ||
## branches that have defined control flow. | ||
|
||
# REQUIRES: system-linux | ||
|
||
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o | ||
# RUN: %clang %cflags --target=aarch64-unknown-linux %t.o -o %t.exe -Wl,-q | ||
# RUN: llvm-bolt %t.exe -o %t.bolt --print-normalized 2>&1 | FileCheck %s | ||
# RUN: llvm-objdump -d --disassemble-symbols=_start %t.bolt \ | ||
# RUN: | FileCheck %s --check-prefix=CHECK-OBJDUMP | ||
|
||
# CHECK-OBJDUMP-LABEL: _start | ||
# CHECK-OBJDUMP-NOT: nop | ||
|
||
.section .text | ||
.align 4 | ||
.globl _start | ||
.type _start, %function | ||
_start: | ||
# CHECK-LABEL: Binary Function "_start" | ||
nop | ||
# CHECK-NOT: nop | ||
br x0 | ||
# CHECK: br x0 # TAILCALL | ||
.size _start, .-_start | ||
|
||
## Force relocation mode. | ||
.reloc 0, R_AARCH64_NONE |