diff options
author | Amara Emerson <amara@apple.com> | 2023-10-06 14:54:27 -0700 |
---|---|---|
committer | Amara Emerson <amara@apple.com> | 2023-10-06 15:02:39 -0700 |
commit | 7510f32f906ab4e583542eae2611b020f88629af (patch) | |
tree | 47df9b2adbe46707b9a288d0b4138a605fac176e /llvm/lib/CodeGen/MachineSink.cpp | |
parent | 531233d4b099835a3b384456c2c22453010f9780 (diff) | |
download | llvm-7510f32f906ab4e583542eae2611b020f88629af.zip llvm-7510f32f906ab4e583542eae2611b020f88629af.tar.gz llvm-7510f32f906ab4e583542eae2611b020f88629af.tar.bz2 |
[MachineSink] Fix crash due to use-after-free in a MachineInstr* cache.
After the SinkAndFold optimization was enabled, we saw some crashes with
GISel due to SinkAndFold erasing an MI while a reference was being held in a
cache.
Diffstat (limited to 'llvm/lib/CodeGen/MachineSink.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineSink.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineSink.cpp b/llvm/lib/CodeGen/MachineSink.cpp index 2d9ff33..40f33d6 100644 --- a/llvm/lib/CodeGen/MachineSink.cpp +++ b/llvm/lib/CodeGen/MachineSink.cpp @@ -540,6 +540,8 @@ bool MachineSinking::PerformSinkAndFold(MachineInstr &MI, } LLVM_DEBUG(dbgs() << "yielding"; New->dump()); SinkDst->eraseFromParent(); + // Clear the StoreInstrCache, since we may have invalidated it by erasing. + StoreInstrCache.clear(); } // Collect operands that need to be cleaned up because the registers no longer |