[llvm-mca][RISCV] Fix llvm-mca RISCVInstrument memory leak
authorMichael Maitland <michaeltmaitland@gmail.com>
Wed, 17 May 2023 20:48:18 +0000 (13:48 -0700)
committerMichael Maitland <michaeltmaitland@gmail.com>
Mon, 22 May 2023 17:36:41 +0000 (10:36 -0700)
commit56674e8e4a4bb086a03857ec28739b1ecbd05374
tree4768ab1994a1a581ea79c6f7dc1e402e6c441089
parent9f992cc9350a7f7072a6dbf018ea07142ea7a7ed
[llvm-mca][RISCV] Fix llvm-mca RISCVInstrument memory leak

There was a memory leak that presented itself once the llvm-mca
tests were committed. This leak was not checked for by the pre-commit
tests. This change changes the shared_ptr to a unique_ptr to avoid
this problem.

We will know that this fix works once committed since I don't know
whether it is possible to force a lit test to use LSan. I spent the
day trying to build llvm with LSan enabled without much luck. If
anyone knows how to build llvm with LSan for the lit-tests, I am
happy to give it another try locally.

Differential Revision: https://reviews.llvm.org/D150816
12 files changed:
llvm/include/llvm/MCA/CustomBehaviour.h
llvm/include/llvm/MCA/InstrBuilder.h
llvm/lib/MCA/CustomBehaviour.cpp
llvm/lib/MCA/InstrBuilder.cpp
llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp
llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.h
llvm/tools/llvm-mca/CodeRegion.cpp
llvm/tools/llvm-mca/CodeRegion.h
llvm/tools/llvm-mca/CodeRegionGenerator.cpp
llvm/tools/llvm-mca/llvm-mca.cpp
llvm/unittests/tools/llvm-mca/MCATestBase.cpp
llvm/unittests/tools/llvm-mca/X86/TestIncrementalMCA.cpp