Skip to content

Upgrade rewrite gate clang-cl to 21.1.8; re-enable calc_fib and calc_sum_array#96

Merged
NaC-L merged 1 commit intomainfrom
fix/calc-fib-codegen
Apr 7, 2026
Merged

Upgrade rewrite gate clang-cl to 21.1.8; re-enable calc_fib and calc_sum_array#96
NaC-L merged 1 commit intomainfrom
fix/calc-fib-codegen

Conversation

@NaC-L
Copy link
Copy Markdown
Owner

@NaC-L NaC-L commented Apr 7, 2026

Summary

The windows-latest preinstalled clang-cl (currently 20.1.8 at C:\Program Files\LLVM\bin\clang-cl.exe) produces a lifter binary that segfaults on calc_fib before emitting any IR (ACCESS_VIOLATION 0xC0000005), causing the rewrite gates to fail whenever calc_fib or calc_sum_array is un-skipped. Clang 21.1.8 is verified locally to compile the lifter into a binary that lifts both samples to their expected constant returns.

Why not downgrade to clang 18?

The runner image's MSVC STL (14.44.35207+) hard-requires clang 19.0.0 or newer via a static_assert in yvals_core.h:

error STL1000: Unexpected compiler version, expected Clang 19.0.0 or newer.

Clang 18.1.8 cannot build any C++ TU that includes the STL on the current windows-latest image, so pinning to the same LLVM 18 version the lifter links against is not an option. Clang 21.1.8 is the lowest tested version that both satisfies the STL requirement and avoids the clang-20 miscompile.

Changes

  • .github/workflows/rewrite-strict-gate.yml: add an Upgrade clang-cl to 21.1.8 step before Resolve LLVM_DIR that runs choco upgrade llvm --version=21.1.8 and pins CMAKE_{C,CXX}_COMPILER to the upgraded binary.
  • scripts/rewrite/instruction_microtests.json: drop the ci_skip entries on calc_fib and calc_sum_array.
  • docs/SCOPE.md: bump the corpus counts to 33 samples / 177 runtime semantic cases.

Verification

All CI checks pass on this branch (run 24089530699): rewrite-quick-gate, rewrite-strict-gate, build (iced), build (zydis), windows-iced, windows-zydis.

Follow-up

Investigating the underlying clang 20.1.8 miscompile in the lifter is still worth doing \u2014 it is almost certainly UB somewhere in the structured-loop recovery path that clang 21 happens to tolerate. Tracked separately.

@NaC-L NaC-L force-pushed the fix/calc-fib-codegen branch 3 times, most recently from 5310ae0 to 9d7e5cf Compare April 7, 2026 14:57
@NaC-L NaC-L marked this pull request as ready for review April 7, 2026 14:57
@NaC-L NaC-L changed the title [diagnostic] capture calc_fib codegen on windows-latest Pin rewrite gate to LLVM 18.1.8 clang-cl; re-enable calc_fib and calc_sum_array Apr 7, 2026
@NaC-L NaC-L force-pushed the fix/calc-fib-codegen branch 5 times, most recently from 30ea050 to 68c3cde Compare April 7, 2026 15:24
…array

The windows-latest preinstalled clang-cl (currently 20.1.8 at
`C:\Program Files\LLVM\bin\clang-cl.exe`) produces a lifter binary
that segfaults on calc_fib before emitting any IR, causing the rewrite
gate to fail. Clang 21.1.8 has been verified locally to compile the
lifter into a binary that lifts both calc_fib and calc_sum_array to
their expected constant returns (`ret i64 13` and `ret i64 150`).

Rolling back to clang 18.x is not an option: the runner image's MSVC STL
(14.44+) hard-requires clang 19.0.0 or newer via a static_assert in
yvals_core.h. Clang 21 satisfies that bound and dodges the clang 20.1.8
miscompile.

Upgrading via `choco upgrade llvm --version=21.1.8` keeps the existing
`C:\Program Files\LLVM\bin\clang-cl.exe` path valid, so the rest of
the pipeline (Resolve LLVM_DIR, Resolve clang-cl, Configure, Build) is
unchanged.

## Changes
- `.github/workflows/rewrite-strict-gate.yml`: add an "Upgrade clang-cl
  to 21.1.8" step before `Resolve LLVM_DIR` that runs `choco upgrade
  llvm` and pins `CMAKE_{C,CXX}_COMPILER` to the upgraded binary.
- `scripts/rewrite/instruction_microtests.json`: drop the `ci_skip`
  entries on `calc_fib` and `calc_sum_array`.
- `docs/SCOPE.md`: bump the corpus counts to 33 samples / 177 runtime
  semantic cases.

## Follow-up
Investigating the underlying clang 20.1.8 miscompile in the lifter is
still worth doing \u2014 it's almost certainly UB somewhere in the
structured-loop recovery path that clang 21 happens to tolerate. Tracked
separately.
@NaC-L NaC-L force-pushed the fix/calc-fib-codegen branch from 68c3cde to 91020b7 Compare April 7, 2026 15:24
@NaC-L NaC-L changed the title Pin rewrite gate to LLVM 18.1.8 clang-cl; re-enable calc_fib and calc_sum_array Upgrade rewrite gate clang-cl to 21.1.8; re-enable calc_fib and calc_sum_array Apr 7, 2026
@NaC-L NaC-L merged commit 0fbc2e9 into main Apr 7, 2026
7 checks passed
@NaC-L NaC-L deleted the fix/calc-fib-codegen branch April 7, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant