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

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 23:01:48 PDT 2026


kazutakahirata wrote:

May I suggest a commit message like this? IMHO, the verifier is just reporting the problem for us. The most important thing here is that this patch fixes a wrong-code bug:

```text
DAG: Fix cross-block gc.relocate of constants and allocas

When constants and static allocas are relocated in an invoke statepoint's
landing pad, LowerAsSTATEPOINT places the virtual register definition
after the STATEPOINT call:

  bb.0.entry:
    STATEPOINT ...          ; unwinds to bb.2 before %0 is defined
    %0:gr64 = MOV64ri 1

  bb.2.lpad (landing-pad):
    $rax = COPY %0:gr64     ; reads uninitialized %0 (folded to undef)

This happens because LowerAsSTATEPOINT calls ExportFromCurrentBlock(V) for
cross-block NoRelocate values, queuing a CopyToReg in PendingExports that
is chained after the STATEPOINT call node.

This patch fixes the problem by recording the directly-lowered leaf in
StatepointRelocationRecord and rematerializing it in visitGCRelocate,
resolving both the wrong-code miscompile on the unwind path and the
machine verifier error with -early-live-intervals.
```

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


More information about the llvm-commits mailing list