[llvm] InstCombine: Fix a crash in `PointerReplacer` when constructing a new PHI (PR #130256)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 8 19:10:05 PST 2025


================
@@ -360,7 +360,10 @@ void PointerReplacer::replace(Instruction *I) {
 
     IC.InsertNewInstWith(NewI, LT->getIterator());
     IC.replaceInstUsesWith(*LT, NewI);
-    WorkMap[LT] = NewI;
+    // LT has actually been replaced by NewI. It is useless to insert LT into
+    // the map. Instead, we insert NewI into the map to indicate this is the
+    // replacement (new value).
+    WorkMap[NewI] = NewI;
----------------
arsenm wrote:

Can you just not add it to the map? I'm not sure what the point of the identity mapping would be 

https://github.com/llvm/llvm-project/pull/130256


More information about the llvm-commits mailing list