Vendor Kauri, keep line numbers straight, and lock in reproducible output - #160
Merged
Conversation
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.
Three things, all foundations rather than features.
DCE and mem2reg were lying about line numbers.
inst_lines[]is indexed by instruction position, and both passes move instructions around without moving the table with them. So after any dead code was removed, every line past the first deleted instruction was shifted. Not missing, wrong, which is worse. Four sites: the in-block compaction and the cross-function shift inbir_dce.c, and the scratch rebuild plus its own shift inbir_mem2reg.c.bir_insert.candbir_inline.cwere already doing it properly, which is probably why nobody noticed the rest.Easy to see with a kernel where lines 2, 3 and 5 are dead:
Before, that first one reported line 2.
make reprochecks the same input gives the same bytes.bir.halready claims a deterministic layout, this makes it a property instead of an intention. 309 runs, every test file across--amdgpu,--nvidia-ptxand--ir, compiled twice in separate processes so ASLR and any pointer-ordered container would show up. All reproducible today. The point is catching the commit that breaks it, because that's the only moment it's cheap to find.Kauri is vendored in.
src/kauri.hplus a one-linekauri_impl.cfor the single instantiation, included frombarracuda.hsoKA_GUARD,KA_CHKandKA_PNEWare available everywhere. Three of the style rules in CONTRIBUTING had no mechanism behind them, now they do. Added a section there showing the pattern and inviting PRs for spots that could use it, since most existing code predates the macros.It's MIT so there's no friction with Apache, and the vendored copy says so at the top. Nothing uses the arena or
KA_TRY, since allocation happens once per phase and errors areBC_ERR_*. One error idiom per compiler.Also fixed the copy in Takahe separately, which had an MPL header stamped on it and was telling people the wrong licence.
Both commits build and test standalone. 379/380 with 1 skipped,
make reproclean, no new diagnostics under the strict flags.This commit was assisted by claude code. The DCE and mem2reg were mine, claude assisted with vendoring in Kauri and adding 'make repro' as well as a draft of this PR description.