[PATCH] D140237: [IR][NFC] Add BasicBlock::erase(Instruction *I) for erasing a single Instruction.

Sergei Barannikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 16 12:32:20 PST 2022


barannikov88 added a comment.

In D140237#4002292 <https://reviews.llvm.org/D140237#4002292>, @vporpo wrote:

> The main reason is that the  BB behaves like a list as it implements begin(), end(), size(), splice() etc. so not having an erase(I) function looks strange.
> Up until now one could simply do BB->getInstList().erase(I), instead of I->eraseFromParent(), so this function is covering this case.

If the intention is to make it behave like a container, then the `erase` method should take an iterator.
But who would possibly use it if it requires a BB reference to call the method? It is kind of easier and //safer// to just `I->eraseFromParent()`.
I don't mind adding this, just don't see how it can be useful.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140237/new/

https://reviews.llvm.org/D140237



More information about the llvm-commits mailing list