[llvm] [SelectionDAG] Fix the assertion failure in Release build after #91747 (PR #93416)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Sun May 26 11:17:39 PDT 2024


================
@@ -11293,10 +11293,12 @@ void SelectionDAG::ReplaceAllUsesWith(SDNode *From, const SDValue *To) {
     return ReplaceAllUsesWith(SDValue(From, 0), To[0]);
 
   for (unsigned i = 0, e = From->getNumValues(); i != e; ++i) {
-    // Preserve Debug Info.
-    transferDbgValues(SDValue(From, i), To[i]);
-    // Preserve extra info.
-    copyExtraInfo(From, To[i].getNode());
+    if (From->hasAnyUseOfValue(i)) {
+      // Preserve Debug Info.
+      transferDbgValues(SDValue(From, i), To[i]);
+      // Preserve extra info.
+      copyExtraInfo(From, To[i].getNode());
----------------
s-barannikov wrote:

It looks like you're reading uninitialized memory here. The number of results must match exactly, which is not true when you're replacing (i8, i32) with just (i32).


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


More information about the llvm-commits mailing list