Skip to content

Commit 49da766

Browse files
authored
Merge branch 'main' into hgh/libcxx/clean-up_saturation_arithmetic_tests
2 parents d7c9e34 + 9052b37 commit 49da766

File tree

231 files changed

+38735
-3794
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

231 files changed

+38735
-3794
lines changed

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,6 @@ BinaryFunction::processIndirectBranch(MCInst &Instruction, unsigned Size,
795795

796796
auto Begin = Instructions.begin();
797797
if (BC.isAArch64()) {
798-
PreserveNops = BC.HasRelocations;
799798
// Start at the last label as an approximation of the current basic block.
800799
// This is a heuristic, since the full set of labels have yet to be
801800
// determined
@@ -2300,6 +2299,10 @@ Error BinaryFunction::buildCFG(MCPlusBuilder::AllocatorIdTy AllocatorId) {
23002299
BC.errs() << "BOLT-WARNING: failed to post-process indirect branches for "
23012300
<< *this << '\n';
23022301
}
2302+
2303+
if (BC.isAArch64())
2304+
PreserveNops = BC.HasRelocations;
2305+
23032306
// In relocation mode we want to keep processing the function but avoid
23042307
// optimizing it.
23052308
setSimple(false);

bolt/test/AArch64/remove-nops.s

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## Verify that llvm-bolt removes nop instructions from functions with indirect
2+
## branches that have defined control flow.
3+
4+
# REQUIRES: system-linux
5+
6+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
7+
# RUN: %clang %cflags --target=aarch64-unknown-linux %t.o -o %t.exe -Wl,-q
8+
# RUN: llvm-bolt %t.exe -o %t.bolt --print-normalized 2>&1 | FileCheck %s
9+
# RUN: llvm-objdump -d --disassemble-symbols=_start %t.bolt \
10+
# RUN: | FileCheck %s --check-prefix=CHECK-OBJDUMP
11+
12+
# CHECK-OBJDUMP-LABEL: _start
13+
# CHECK-OBJDUMP-NOT: nop
14+
15+
.section .text
16+
.align 4
17+
.globl _start
18+
.type _start, %function
19+
_start:
20+
# CHECK-LABEL: Binary Function "_start"
21+
nop
22+
# CHECK-NOT: nop
23+
br x0
24+
# CHECK: br x0 # TAILCALL
25+
.size _start, .-_start
26+
27+
## Force relocation mode.
28+
.reloc 0, R_AARCH64_NONE

0 commit comments

Comments
 (0)