[all-commits] [llvm/llvm-project] b217a7: [unittests/CodeGen] Remove unique_ptr from the res...
weiguozhi via All-commits
all-commits at lists.llvm.org
Tue Aug 16 15:09:07 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: b217a78720f10ed739c39a2d74a54ef492a4cd29
https://github.com/llvm/llvm-project/commit/b217a78720f10ed739c39a2d74a54ef492a4cd29
Author: Guozhi Wei <carrot at google.com>
Date: 2022-08-16 (Tue, 16 Aug 2022)
Changed paths:
M llvm/unittests/CodeGen/MFCommon.inc
M llvm/unittests/CodeGen/MachineOperandTest.cpp
Log Message:
-----------
[unittests/CodeGen] Remove unique_ptr from the result of createTargetMachine
The object contained in unique_ptr will be automatically deleted at the end of
the current scope. In createMachineFunction,
auto TM = createTargetMachine();
creates a TM contained in unique_ptr, a reference of the TM is stored in a
MachineFunction object, but at the end of the function, the TM is deleted, so
later access to the TM(and contained STI, TRI ...) through MachineFunction
object is invalid.
So we should not use unique_ptr<BogusTargetMachine> in functions
createMachineFunction and createTargetMachine.
Differential Revision: https://reviews.llvm.org/D131790
More information about the All-commits
mailing list