Skip to content

Commit 9cb7b4f

Browse files
committed
Correctly implement SILBasicBlock::erase().
LLVM ilist::erase does not return the following iterator the way an STL list would. Compensate by computing the next iterator and ignoring LLVM's result. I expect this to fix the ASAN bots: <rdar://problem/31550303> OSS Swift CI ASAN bot fails on AccessMarker tests.
1 parent e26c08f commit 9cb7b4f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/SIL/SILBasicBlock.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,16 @@ void SILBasicBlock::remove(SILInstruction *I) {
9090
InstList.remove(I);
9191
}
9292

93+
/// Returns the iterator following the erased instruction, STL-style.
9394
SILBasicBlock::iterator SILBasicBlock::erase(SILInstruction *I) {
9495
// Notify the delete handlers that this instruction is going away.
9596
getModule().notifyDeleteHandlers(&*I);
9697
auto *F = getParent();
97-
auto II = InstList.erase(I);
98+
// LLVM does not currently implement ilist::erase correctly. Compensate.
99+
iterator next = std::next(SILBasicBlock::iterator(I));
100+
InstList.erase(I);
98101
F->getModule().deallocateInst(I);
99-
return II;
102+
return next;
100103
}
101104

102105
/// This method unlinks 'self' from the containing SILFunction and deletes it.

0 commit comments

Comments
 (0)