Skip to content

Commit de6a919

Browse files
MANGOPIE3llongint
authored andcommitted
[BOLT] Fix deadloop bug in taildup
The intent is clearly to push the tail rather than current BB. Reviewed By: maksfb Differential Revision: https://reviews.llvm.org/D159289
1 parent e8b1af9 commit de6a919

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

bolt/lib/Passes/TailDuplication.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ TailDuplication::aggressiveDuplicate(BinaryBasicBlock &BB,
303303
if (isInCacheLine(BB, Tail))
304304
return BlocksToDuplicate;
305305

306-
BinaryBasicBlock *CurrBB = &BB;
306+
BinaryBasicBlock *CurrBB = &Tail;
307307
while (CurrBB) {
308308
LLVM_DEBUG(dbgs() << "Aggressive tail duplication: adding "
309309
<< CurrBB->getName() << " to duplication list\n";);

bolt/test/X86/tail-duplication-pass.s

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,21 @@
77
# RUN: llvm-bolt %t.exe --data %t.fdata --reorder-blocks=ext-tsp \
88
# RUN: --print-finalized --tail-duplication=moderate \
99
# RUN: --tail-duplication-minimum-offset=1 -o %t.out | FileCheck %s
10+
# RUN: llvm-bolt %t.exe --data %t.fdata --print-finalized \
11+
# RUN: --tail-duplication=aggressive --tail-duplication-minimum-offset=1 \
12+
# RUN: -o %t.out | FileCheck %s --check-prefix CHECK-NOLOOP
1013

1114
# FDATA: 1 main 2 1 main #.BB2# 0 10
1215
# FDATA: 1 main 4 1 main #.BB2# 0 20
1316
# CHECK: BOLT-INFO: tail duplication modified 1 ({{.*}}%) functions; duplicated 1 blocks (1 bytes) responsible for {{.*}} dynamic executions ({{.*}}% of all block executions)
1417
# CHECK: BB Layout : .LBB00, .Ltail-dup0, .Ltmp0, .Ltmp1
1518

19+
# Check that the successor of Ltail-dup0 is .LBB00, not itself.
20+
# CHECK-NOLOOP: .Ltail-dup0 (1 instructions, align : 1)
21+
# CHECK-NOLOOP: Predecessors: .LBB00
22+
# CHECK-NOLOOP: retq
23+
# CHECK-NOLOOP: .Ltmp0 (1 instructions, align : 1)
24+
1625
.text
1726
.globl main
1827
.type main, %function

0 commit comments

Comments
 (0)