Skip to content

Check frontend and native CorePrep lowerings for parity in the source fuzz harness - #29

Merged
Leitwolf11 merged 2 commits into
mainfrom
test/coreprep-parity
Oct 2, 2026
Merged

Leitwolf11 merged 2 commits into
mainfrom
test/coreprep-parity

Conversation

@Leitwolf11

@Leitwolf11 Leitwolf11 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

What changed

The Haskell frontend and the native Core-to-CorePrep adapter both lower Core to CorePrep, and only the native result
reaches Xpp. Five divergences between them were found by hand or by chance and fixed in #28. This makes the comparison automatic.

  • vxs_frontend_fuzz_compile (testing-only entry) delivers the CorePrep wire of the same compilation as a second
    payload after Core. Production entries are unchanged; the native receiver accepts CorePrep once, only after Core,
    and only on the testing route.
  • Compiler/Fuzzing/CorePrepParity.{hpp,cpp} compares two CorePrep modules in a canonical form: reachable blocks in
    depth-first preorder, generated symbols renamed in first-use order. Everything else is compared exactly.
  • The source fuzz harness requires parity for every accepted source in source_llvm_fuzzer, differential_fuzzer
    and source_fuzz_smoke; the smoke gains four sources that must be accepted.
  • Compiler/Fuzzing/Tests/coreprep_parity_tests joins the native suite list (22 suites).

Verification

  • go run ./helpers/cmd/develop test: all 22 native suites passed (Windows).
  • cabal test visual-xsharp-compiler-tests fuzz-feedback-tests: PASS.
  • verify-helpers, verify-docs, clang-format: PASS.
  • Mutation check: restoring the for-loop update defect makes the smoke fail in the parity check with the offending
    block and source, before any generated code runs.
  • source_llvm_fuzzer with the check enabled: 200 seconds, 277,753 inputs, no divergence (no sanitizer in that run).

Limits

  • Parity shows that the two lowerings agree, not that either is correct.
  • Closures and templates have no deterministic parity source yet.
  • macOS and Linux were not run locally.

… fuzz harness

The Haskell frontend lowers optimized Core to CorePrep, and the native
pipeline lowers the same Core again with its own adapter. Only the native
result reaches Xpp and both lowerings are well formed, so a divergence is a
miscompile no later verifier can see. Five such divergences were found by
hand or by chance; this makes the comparison automatic.

The testing-only frontend entry vxs_frontend_fuzz_compile now delivers the
CorePrep wire of the same compilation as a second payload after Core.
Production entries are unchanged and still deliver exactly one buffer, and
the native receiver accepts CorePrep once, only after Core, and only on the
testing route.

CompareCorePrep brings both modules to a canonical form, reachable blocks in
depth-first preorder with the true edge first and generated symbols renamed
in first-use order while keeping their kind, and then compares source
symbols, types, literals, operations, operand and instruction order and edge
roles exactly. Its own test suite pins what the comparison may and may not
ignore and joins the native suite list.

Every accepted source in the source and differential fuzzers and in the
deterministic smoke is checked, and the smoke gains four sources that must
be accepted. Reintroducing the for-loop update defect fails the smoke in
this check before any generated code runs. The fuzzing, Core IR and testing
documents describe the check and its limits: it shows that the lowerings
agree, not that either is correct.
@Leitwolf11
Leitwolf11 changed the base branch from fix/deep-fuzz-campaigns to main October 2, 2026 00:51
@Leitwolf11
Leitwolf11 marked this pull request as ready for review October 2, 2026 12:53
@Leitwolf11
Leitwolf11 merged commit 8ef0ca0 into main Oct 2, 2026
73 checks passed
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