Avoid dereferencing a sentinel node in splitBasicBlock while updating Phi nodes in successor basic blocks. This is needed after r279314 added an assertion to guard against that. The for loop updated in this patch can possibly deference a pointer which could be pointing to a Sentinel and hence hitting the assertion.
Details
Diff Detail
Event Timeline
In the future, please make sure you add llvm-commits as a subscriber when you create the revision, not afterwards. If you do it the wrong way around, the patch itself is never sent to llvm-commits.
LLVM language ref says: "Each basic block may optionally start with a label (giving the basic block a symbol table entry), contains a list of instructions, and ends with a terminator instruction (such as a branch or function return)." So I would expect a terminator after the last PHI instruction or is this used in some intermediate steps where that rule is temporarily broken?
What if it is a basic block that only has a terminator instruction without any Phi nodes? is that an allowed basic block in LLVM?
That is fine, but then this loop should have no problem because that terminator will return nullptr for dyn_cast<PHINode>.