[llvm] [GVN] Invalidate ICF cache when clearing the instructions (PR #68145)

Shivam Gupta via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 3 11:51:53 PDT 2023


https://github.com/xgupta created https://github.com/llvm/llvm-project/pull/68145

This fixes #48805

/home/user/llvm-project/llvm/lib/Analysis/InstructionPrecedenceTracking.cpp:93: void llvm::InstructionPrecedenceTracking::validate(const llvm::BasicBlock *) const: Assertion `It->second == &Insn && "Cached first special instruction is wrong!"' failed.

>From 882a60121671c411d4c6777590becdf374de0a4b Mon Sep 17 00:00:00 2001
From: Shivam Gupta <shivam98.tkg at gmail.com>
Date: Wed, 4 Oct 2023 00:20:29 +0530
Subject: [PATCH] [GVN] Invalidate ICF cache when clearing the instructions

This fixes #48805

/home/user/llvm-project/llvm/lib/Analysis/InstructionPrecedenceTracking.cpp:93:
void llvm::InstructionPrecedenceTracking::validate(const llvm::BasicBlock *) const:
Assertion `It->second == &Insn && "Cached first special instruction is wrong!"' failed.
---
 llvm/lib/Transforms/Scalar/GVN.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index bc54846ccf0ad2d..f7a905c2e13c4d4 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -2799,6 +2799,7 @@ bool GVNPass::processBlock(BasicBlock *BB) {
       salvageDebugInfo(*I);
       removeInstruction(I);
     }
+    ICF->clear();
     InstrsToErase.clear();
 
     if (AtStart)



More information about the llvm-commits mailing list