Repository navigation
fix(warpforthc): inline user words - #130
Merged
Merged
Conversation
warpforthc builds its own dialect registry, and since 8f2b838 it no longer pulls in the func dialect's inliner extension. Without it the inliner pass inlines nothing, so every user word reached PTX as a .visible .func. warpforth-opt was unaffected because it registers all extensions. i64-memory-alignment.forth checked loads and stores inside the SUM3 function, which no longer exists once words are inlined. Its kernel checks still cover 64-bit global accesses.
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.
warpforthcemitted every user word as a dead.visible .funcin the PTX. The inliner was not running at all inwarpforthc. Since 8f2b838 the driver builds its own dialect registry, and that registry left out the func dialect's inliner extension, socreateInlinerPass()had no func inliner interface and inlined nothing.warpforth-optregisters all extensions, so it already inlined words and erased the dead private callees. The issue's suggestedsymbol-dcewould not have helped: after the inliner every word still had a live call.Changes
warpforthcregistersfunc::registerInlinerExtensionand linksMLIRFuncInlinerExtension.test/Pipeline/inlined-words.forthcompiles the issue's repro withwarpforthcand checks the PTX has.entry k(and no.func.test/Pipeline/i64-memory-alignment.forth(from fix(conversion): attach the NVPTX data layout to the GPU module #124) checked loads and stores inside theSUM3function, which only existed because of this bug. I removed that section. The kernel-side 64-bit checks and the implicit no-32-bit-access check remain.Recursion can't keep a word out of line. A word is registered only after its body is parsed, so it can't call itself, and the call graph is acyclic. Every word gets fully inlined, so no linkage change is needed.
Repro
Issue program,
warpforthc repro.forth -o out.ptx; grep -n '\.entry\|\.func' out.ptx.Before (canon):
After:
The new test fails on the pre-fix PTX (
CHECK-NOT: excluded string found in inputatSQ() and passes after.check-warpforthpasses 124/124 locally (LLVM 21).Fixes #117