[PATCH] D122929: [BOLT] Fix remove double jumps peephole pass
Vladislav Khmelevsky via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 1 12:00:36 PDT 2022
yota9 created this revision.
yota9 added reviewers: maksfb, rafauler, Amir.
Herald added a subscriber: ayermolo.
Herald added a project: All.
yota9 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Remove the assert statement and change the if condition since it does
not cover non-local branch cases.
Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D122929
Files:
bolt/lib/Passes/BinaryPasses.cpp
bolt/test/AArch64/ext-double-jump.s
Index: bolt/test/AArch64/ext-double-jump.s
===================================================================
--- /dev/null
+++ bolt/test/AArch64/ext-double-jump.s
@@ -0,0 +1,26 @@
+# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown \
+# RUN: %s -o %t.o
+# RUN: %clang %cflags -nostartfiles -nodefaultlibs %t.o -o %t.exe -Wl,-q
+# RUN: llvm-bolt %t.exe -o %t.bolt -peepholes=double-jumps
+
+ .text
+ .align 4
+ .global dummy1
+ .type dummy1, %function
+dummy1:
+ mov x2, x0
+ ret
+
+ .global dummy2
+ .type dummy2, %function
+dummy2:
+ mov x1, x0
+ ret
+
+ .global _start
+ .type _start, %function
+_start:
+ cbz x10, 1f
+ b dummy1
+1:
+ b dummy2
Index: bolt/lib/Passes/BinaryPasses.cpp
===================================================================
--- bolt/lib/Passes/BinaryPasses.cpp
+++ bolt/lib/Passes/BinaryPasses.cpp
@@ -697,8 +697,8 @@
// Succ will be null in the tail call case. In this case we
// need to explicitly add a tail call instruction.
MCInst *Branch = Pred->getLastNonPseudoInstr();
- if (Branch && MIB->isUnconditionalBranch(*Branch)) {
- assert(MIB->getTargetSymbol(*Branch) == BB.getLabel());
+ if (Branch && MIB->isUnconditionalBranch(*Branch) &&
+ MIB->getTargetSymbol(*Branch) == BB.getLabel()) {
Pred->removeSuccessor(&BB);
Pred->eraseInstruction(Pred->findInstruction(Branch));
Pred->addTailCallInstruction(SuccSym);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122929.419825.patch
Type: text/x-patch
Size: 1474 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220401/cc184af1/attachment.bin>
More information about the llvm-commits
mailing list