From 0816bb32ac37b24d2f895f0c0464b7659fffd4fc Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Thu, 19 Jun 2025 17:49:33 +0100 Subject: [PATCH] [Matrix] Fix heap-use-after-free after 0fa373c77ded203eddb. We need to skip instructions in FusedInsts, as they may have been deleted. Fixes a heap-use-after-free after #141681. --- llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp b/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp index fa9e44617b7c..ccb68700747b 100644 --- a/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp +++ b/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp @@ -1140,6 +1140,9 @@ public: // Fourth, pre-process all the PHINode's. The incoming values will be // assigned later in VisitPHI. for (Instruction *Inst : MatrixInsts) { + if (FusedInsts.count(Inst)) + continue; + auto *PHI = dyn_cast(Inst); if (!PHI) continue;