Check frontend and native CorePrep lowerings for parity in the source fuzz harness - #29
Merged
Merged
Conversation
… 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
marked this pull request as ready for review
October 2, 2026 12:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 secondpayload 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 indepth-first preorder, generated symbols renamed in first-use order. Everything else is compared exactly.
source_llvm_fuzzer,differential_fuzzerand
source_fuzz_smoke; the smoke gains four sources that must be accepted.Compiler/Fuzzing/Tests/coreprep_parity_testsjoins 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.block and source, before any generated code runs.
source_llvm_fuzzerwith the check enabled: 200 seconds, 277,753 inputs, no divergence (no sanitizer in that run).Limits