File tree Expand file tree Collapse file tree 2 files changed +24
-6
lines changed Expand file tree Collapse file tree 2 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -111,15 +111,14 @@ BasicBlock *
111
111
llvm::SplitKnownCriticalEdge (Instruction *TI, unsigned SuccNum,
112
112
const CriticalEdgeSplittingOptions &Options,
113
113
const Twine &BBName) {
114
- assert (!isa<IndirectBrInst>(TI) &&
115
- " Cannot split critical edge from IndirectBrInst" );
116
-
117
114
BasicBlock *TIBB = TI->getParent ();
118
115
BasicBlock *DestBB = TI->getSuccessor (SuccNum);
119
116
120
- // Splitting the critical edge to a pad block is non-trivial. Don't do
121
- // it in this generic function.
122
- if (DestBB->isEHPad ()) return nullptr ;
117
+ // Splitting the critical edge to a pad block is non-trivial.
118
+ // And we cannot split block with IndirectBr as a terminator.
119
+ // Don't do it in this generic function.
120
+ if (DestBB->isEHPad () || isa<IndirectBrInst>(TI))
121
+ return nullptr ;
123
122
124
123
if (Options.IgnoreUnreachableDests &&
125
124
isa<UnreachableInst>(DestBB->getFirstNonPHIOrDbgOrLifetime ()))
Original file line number Diff line number Diff line change @@ -53,3 +53,22 @@ if.end: ; preds = %if.else, %if.then
53
53
}
54
54
55
55
declare void @bar (i32 )
56
+
57
+ define void @indirectbr_could_not_split () {
58
+ ; CHECK-LABEL: define void @indirectbr_could_not_split() {
59
+ ; CHECK-NEXT: [[ENTRY:.*:]]
60
+ ; CHECK-NEXT: br i1 false, label %[[IBR:.*]], label %[[EXIT:.*]]
61
+ ; CHECK: [[IBR]]:
62
+ ; CHECK-NEXT: indirectbr ptr null, [label %[[EXIT]], label %exit]
63
+ ; CHECK: [[EXIT]]:
64
+ ; CHECK-NEXT: ret void
65
+ ;
66
+ entry:
67
+ br i1 false , label %ibr , label %exit
68
+
69
+ ibr:
70
+ indirectbr ptr null , [label %exit , label %exit ]
71
+
72
+ exit:
73
+ ret void
74
+ }
You can’t perform that action at this time.
0 commit comments