Skip to content

Commit 1a42b38

Browse files
authored
[DebugInfo][RemoveDIs] Erase ranges of instructions individually (#81007)
The BasicBlock::erase method simply removes a range of instructions from the instlist by unlinking them. However, now that we're attaching debug-info directly to instructions, some cleanup is required, so use eraseFromParent on each instruction instead. This is less efficient, but rare, and seemingly only WASM EH Prepare uses this method of BasicBlock. Detected via a memory leak check in asan. (asan is always the final boss for whatever I do).
1 parent 8f2378d commit 1a42b38

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

llvm/lib/IR/BasicBlock.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,9 @@ BasicBlock *BasicBlock::splitBasicBlockBefore(iterator I, const Twine &BBName) {
677677

678678
BasicBlock::iterator BasicBlock::erase(BasicBlock::iterator FromIt,
679679
BasicBlock::iterator ToIt) {
680-
return InstList.erase(FromIt, ToIt);
680+
for (Instruction &I : make_early_inc_range(make_range(FromIt, ToIt)))
681+
I.eraseFromParent();
682+
return ToIt;
681683
}
682684

683685
void BasicBlock::replacePhiUsesWith(BasicBlock *Old, BasicBlock *New) {

0 commit comments

Comments
 (0)