[PATCH] D118677: [llvm-profgen] Clean up unnecessary memory reservations between phases.
Hongtao Yu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 1 09:40:26 PST 2022
hoy added inline comments.
================
Comment at: llvm/tools/llvm-profgen/llvm-profgen.cpp:161
Generator->generateProfile();
+ Reader.release();
Generator->write();
----------------
wenlei wrote:
> nit: using a lexical scope for this purpose might be better.
Lexical scope is nice, but in this case `Reader` and `Generator` have overlapping lifetimes, i.e, we need `Reader` to be released before `Generator->write();` but after `Generator->generateProfile();`. So one lexical scope including both objects may not work.
Actually maybe we can define `Reader->getSampleCounters()` as a `unique_ptr` too, so that when it is transferred to `Generator`, `Generator` will take its ownership and release it when appropriate.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118677/new/
https://reviews.llvm.org/D118677
More information about the llvm-commits
mailing list