Skip to content

Commit 2e51a32

Browse files
committed
[BOLT] Check for !isTailCall in isUnconditionalBranch
Add !isTailCall in isUnconditionalBranch check in order to sync the x86 and aarch64 and fix the fixDoubleJumps pass on aarch64. Vladislav Khmelevsky, Advanced Software Technology Lab, Huawei Differential Revision: https://reviews.llvm.org/D122929
1 parent 04b42c9 commit 2e51a32

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ class MCPlusBuilder {
353353
}
354354

355355
virtual bool isUnconditionalBranch(const MCInst &Inst) const {
356-
return Analysis->isUnconditionalBranch(Inst);
356+
return Analysis->isUnconditionalBranch(Inst) && !isTailCall(Inst);
357357
}
358358

359359
virtual bool isIndirectBranch(const MCInst &Inst) const {

bolt/lib/Target/X86/X86MCPlusBuilder.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ class X86MCPlusBuilder : public MCPlusBuilder {
7878
return Analysis->isBranch(Inst) && !isTailCall(Inst);
7979
}
8080

81-
bool isUnconditionalBranch(const MCInst &Inst) const override {
82-
return Analysis->isUnconditionalBranch(Inst) && !isTailCall(Inst);
83-
}
84-
8581
bool isNoop(const MCInst &Inst) const override {
8682
return X86::isNOP(Inst.getOpcode());
8783
}

bolt/test/AArch64/ext-double-jump.s

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This test checks that remove double jumps pass works properly with
2+
# non-local branches.
3+
4+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
5+
# RUN: %clang %cflags -nostartfiles -nodefaultlibs %t.o -o %t.exe -Wl,-q
6+
# RUN: llvm-bolt %t.exe -o %t.bolt -peepholes=double-jumps
7+
8+
.text
9+
.align 4
10+
.global dummy1
11+
.type dummy1, %function
12+
dummy1:
13+
mov x2, x0
14+
ret
15+
.size dummy1, .-dummy1
16+
17+
.global dummy2
18+
.type dummy2, %function
19+
dummy2:
20+
mov x1, x0
21+
ret
22+
.size dummy2, .-dummy2
23+
24+
.global _start
25+
.type _start, %function
26+
_start:
27+
cbz x10, 1f
28+
b dummy1
29+
1:
30+
b dummy2
31+
.size _start, .-_start

0 commit comments

Comments
 (0)