OSDN Git Service

[Utils] Use WeakTrackingVH in vector used as scratch storage.
authorAlina Sbirlea <asbirlea@google.com>
Thu, 23 Jan 2020 22:21:08 +0000 (14:21 -0800)
committerAlina Sbirlea <asbirlea@google.com>
Fri, 24 Jan 2020 00:04:57 +0000 (16:04 -0800)
commit9e66c4ec127ef6e73f1bafe06fe3fba45d59feee
tree680cddd0ef06a249261dbd39c67b932b6b2765a3
parent2af74e27ed7d0832cbdde9cb969aaca7a42e99f9
[Utils] Use WeakTrackingVH in vector used as scratch storage.

The utility method RecursivelyDeleteTriviallyDeadInstructions receives
as input a vector of Instructions, where all inputs are valid
instructions. This same vector is used as a scratch storage (per the
header comment) to recursively delete instructions. If an instruction is
added as an operand of multiple other instructions, it may be added twice,
then deleted once, then the second reference in the vector is invalid.
Switch to using a Vector<WeakTrackingVH>.
This change facilitates a clean-up in LoopStrengthReduction.
llvm/include/llvm/Transforms/Utils/Local.h
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/Scalar/InstSimplifyPass.cpp
llvm/lib/Transforms/Scalar/LoopInstSimplify.cpp
llvm/lib/Transforms/Utils/Local.cpp