[PATCH] D108251: [llvm-profgen] Use shared pointer to fix memory leak issue from asan

Hongtao Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 17 15:39:16 PDT 2021


hoy added inline comments.


================
Comment at: llvm/tools/llvm-profgen/PerfReader.cpp:299
   // Call to load the binary in the ctor of ProfiledBinary.
-  Binary = new ProfiledBinary(BinaryPath);
+  Binary = std::make_shared<ProfiledBinary>(BinaryPath);
   // Initialize the base address to preferred address.
----------------
I think you can use `unique_ptr` here. Everywhere else consuming the binary can use the raw pointer, until `PerfReaderBase` is deleted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108251



More information about the llvm-commits mailing list