// Make sure the LiveIns are still sorted and unique.
MBB->sortUniqueLiveIns();
// Replace the edges to PrologueMBB by edges to the sequences
- // we are about to add.
- MBB->ReplaceUsesOfBlockWith(&PrologueMBB, AddedBlocks[0]);
+ // we are about to add, but only update for immediate predecessors.
+ if (MBB->isSuccessor(&PrologueMBB))
+ MBB->ReplaceUsesOfBlockWith(&PrologueMBB, AddedBlocks[0]);
}
// The required stack size that is aligned to ARM constant criterion.
}
+
+declare void @panic() unnamed_addr
+
+; We used to crash while compiling the following function.
+; ARM-linux-LABEL: build_should_not_segfault:
+; ARM-android-LABEL: build_should_not_segfault:
+define void @build_should_not_segfault(i8 %x) unnamed_addr #0 {
+start:
+ %_0 = icmp ult i8 %x, 16
+ %or.cond = select i1 undef, i1 true, i1 %_0
+ br i1 %or.cond, label %bb1, label %bb2
+
+bb1:
+ ret void
+
+bb2:
+ call void @panic()
+ unreachable
+}
+
attributes #0 = { "split-stack" }
; Thumb-linux-NOT: bl __morestack
}
+
+declare void @panic() unnamed_addr
+
+; We used to crash while compiling the following function.
+; Thumb-linux-LABEL: build_should_not_segfault:
+; Thumb-android-LABEL: build_should_not_segfault:
+define void @build_should_not_segfault(i8 %x) unnamed_addr #0 {
+start:
+ %_0 = icmp ult i8 %x, 16
+ %or.cond = select i1 undef, i1 true, i1 %_0
+ br i1 %or.cond, label %bb1, label %bb2
+
+bb1:
+ ret void
+
+bb2:
+ call void @panic()
+ unreachable
+}
+
attributes #0 = { "split-stack" }
; ARM-NEXT: .long 40192
}
+
+declare void @panic() unnamed_addr
+
+; We used to crash while compiling the following function.
+; THUMB-LABEL: build_should_not_segfault:
+; ARM-LABEL: build_should_not_segfault:
+define void @build_should_not_segfault(i8 %x) unnamed_addr #0 {
+start:
+ %_0 = icmp ult i8 %x, 16
+ %or.cond = select i1 undef, i1 true, i1 %_0
+ br i1 %or.cond, label %bb1, label %bb2
+
+bb1:
+ ret void
+
+bb2:
+ call void @panic()
+ unreachable
+}
+
attributes #0 = { "split-stack" }