Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit f45bea4

Browse files
committed
[IfConversion] Add missing check in IfConversion/canFallThroughTo
Summary: When trying to figure out if MBB could fallthrough to ToMBB (possibly by falling through a bunch of other MBBs) we didn't actually check if there was fallthrough between the last two blocks in the chain. Reviewers: kparzysz, iteratee, MatzeB Reviewed By: kparzysz, iteratee Subscribers: javed.absar, llvm-commits Differential Revision: https://reviews.llvm.org/D32996 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302650 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 344c4f2 commit f45bea4

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

lib/CodeGen/IfConversion.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,8 @@ static bool canFallThroughTo(MachineBasicBlock &MBB, MachineBasicBlock &ToMBB) {
13181318
return false;
13191319
PI = I++;
13201320
}
1321-
return true;
1321+
// Finally see if the last I is indeed a successor to PI.
1322+
return PI->isSuccessor(&*I);
13221323
}
13231324

13241325
/// Invalidate predecessor BB info so it would be re-analyzed to determine if it
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# RUN: llc -mtriple=arm-apple-ios -o - %s -run-pass if-converter | FileCheck %s
2+
---
3+
name: f1
4+
body: |
5+
bb.0:
6+
successors: %bb.1
7+
8+
B %bb.1
9+
10+
bb.1:
11+
successors: %bb.2, %bb.4
12+
13+
Bcc %bb.4, 1, %cpsr
14+
15+
bb.2:
16+
successors: %bb.3, %bb.5
17+
18+
Bcc %bb.5, 1, %cpsr
19+
20+
bb.3:
21+
successors: %bb.5
22+
23+
B %bb.5
24+
25+
bb.4:
26+
successors:
27+
28+
bb.5:
29+
successors: %bb.1, %bb.6
30+
31+
Bcc %bb.1, 1, %cpsr
32+
33+
bb.6:
34+
BX_RET 14, _
35+
36+
...
37+
38+
# IfConversion.cpp/canFallThroughTo thought there was a fallthrough from
39+
# bb.4 to bb5 even if the successor list was empty.
40+
# bb.4 is empty, so it surely looks like it can fallthrough, but this is what
41+
# happens for a bb just containing an "unreachable".
42+
43+
#CHECK: body: |
44+
#CHECK: bb.0:
45+
#CHECK: successors: %bb.1
46+
47+
#CHECK: bb.1:
48+
#CHECK: successors: %bb.3({{.*}}), %bb.2
49+
50+
# The original brr_cond from bb.1, jumping to the empty bb
51+
#CHECK: Bcc %bb.2
52+
#CHECK: B %bb.3
53+
54+
# Empty bb.2, originally containing "unreachable" and thus has no successors
55+
#CHECK: bb.2:
56+
#CHECK-NOT: successors
57+
58+
#CHECK: bb.3:
59+
#CHECK: successors: %bb.1
60+
61+
# Conditional BX_RET and then loop back to bb.1
62+
#CHECK: BX_RET 0
63+
#CHECK: B %bb.1
64+

0 commit comments

Comments
 (0)