[PATCH] D156618: [IR] Fix a memory leak in Function::dropAllReferences()

Duncan P. N. Exon Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 31 11:51:34 PDT 2023


dexonsmith added a comment.

In D156618#4632179 <https://reviews.llvm.org/D156618#4632179>, @dexonsmith wrote:

> Seems unfortunate to add calls to `ConstantPointerNull::get()` when all of the callers are about to call `delete`.
>
> Can we instead somehow enforce that `delete` is always called right after? Perhaps add an assertion that this is so?

Or, looking back at the motivation (calling `deleteBody()`), can we have two entry points?

- One prepares for deletion (99% of callers), skips `CPN::get()`
- One makes it a prototype (deleteBody), calls `CPN::get()`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156618



More information about the llvm-commits mailing list