On 8/19/21 2:00 PM, David Malcolm wrote:
On Thu, 2021-08-19 at 11:30 -0600, Martin Sebor via Gcc-patches wrote:
Hey Aldy & Andrew,

I introduced a leak by calling enable_ranger() without pairing it
with one to disable_ranger() on the same function (PR 101984).
I didn't realize (or look to see) that enable_ranger() dynamically
allocates memory.

The patch below adds comments to make it clear that the calls need
to be paired.  That seems obvious now but wasn't before from just
the function names.  So I'm wondering if we might want to rename
them to make it more obvious that the former involves allocating
memory that must be explicitly deallocated.

If you agree, names along the following lines would make this
clearer (to me, anyway) but I'm open to others:

    gimple_ranger *set_new_ranger (function *);
    void release_ranger (function *);

Could an RAII class help here, to make the aquire/release pairing more
automatic?

Dave

Well, we discussed making it a a pass property, among other things,  but there are also use cases we can imagine where we want to be able to have some alternate control.

I think for the moment its not overly difficult to create a ranger when your pass is ready for it, and then dispose of it when you are done.

Andrew


Reply via email to