Skip to content

fix(warpforthc): inline user words - #130

Merged
tetsuo-cpp merged 1 commit into
canonfrom
fix/drop-dead-word-funcs
Oct 24, 2026
Merged

tetsuo-cpp merged 1 commit into
canonfrom
fix/drop-dead-word-funcs

Conversation

@tetsuo-cpp

Copy link
Copy Markdown
Owner

warpforthc emitted every user word as a dead .visible .func in the PTX. The inliner was not running at all in warpforthc. Since 8f2b838 the driver builds its own dialect registry, and that registry left out the func dialect's inliner extension, so createInlinerPass() had no func inliner interface and inlined nothing. warpforth-opt registers all extensions, so it already inlined words and erased the dead private callees. The issue's suggested symbol-dce would not have helped: after the inliner every word still had a live call.

Changes

  • warpforthc registers func::registerInlinerExtension and links MLIRFuncInlinerExtension.
  • New test/Pipeline/inlined-words.forth compiles the issue's repro with warpforthc and 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 the SUM3 function, 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):

11:.visible .entry k(
47:.visible .func  (.param .align 8 .b8 func_retval0[16]) SQ(
74:.visible .func  (.param .align 8 .b8 func_retval0[16]) SUMSQ(

After:

11:.visible .entry k(

The new test fails on the pre-fix PTX (CHECK-NOT: excluded string found in input at SQ() and passes after. check-warpforth passes 124/124 locally (LLVM 21).

Fixes #117

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.
@tetsuo-cpp
tetsuo-cpp merged commit 4eeee18 into canon Oct 24, 2026
1 check passed
@tetsuo-cpp
tetsuo-cpp deleted the fix/drop-dead-word-funcs branch October 24, 2026 10:06
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.

Inlined user words are still emitted as dead .visible .func symbols in PTX

1 participant