[llvm] DAG: Fix latent verifier error in statepoint lowering (PR #222894)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 01:37:38 PDT 2026


================
@@ -931,18 +954,19 @@ SDValue SelectionDAGBuilder::LowerAsSTATEPOINT(
       Record.payload.FI = cast<FrameIndexSDNode>(Loc)->getIndex();
     } else {
       Record.type = RecordType::NoRelocate;
-      // If we didn't relocate a value, we'll essentialy end up inserting an
-      // additional use of the original value when lowering the gc.relocate.
-      // We need to make sure the value is available at the new use, which
-      // might be in another block.
-      if (Relocate->getParent() != StatepointInstr->getParent())
-        ExportFromCurrentBlock(V);
+      assert(willLowerDirectly(SDV) && "NoRelocate value must lower directly");
+
+      // A gc.relocate in another block needs the value there. Exporting it
+      // would define a vreg after the call that does not dominate a use on the
+      // unwind edge, so record the leaf and rebuild it in visitGCRelocate
+      // instead. undef re-lowers trivially and is left to the fallback path.
+      if (Relocate->getParent() != StatepointInstr->getParent() &&
+          !SDV.isUndef())
----------------
arsenm wrote:

I tried that at some point but undef already had special handling 

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


More information about the llvm-commits mailing list