Skip to content

Restore LLVM backend: fix bitrot, add tests#9292

Draft
lukewilliamboswell wants to merge 43 commits intolir-interpreterfrom
restore-llvm
Draft

Restore LLVM backend: fix bitrot, add tests#9292
lukewilliamboswell wants to merge 43 commits intolir-interpreterfrom
restore-llvm

Conversation

@lukewilliamboswell
Copy link
Copy Markdown
Collaborator

@lukewilliamboswell lukewilliamboswell commented Mar 24, 2026

Summary

  • Fix LLVM evaluator bitrot: Sync MonoLlvmCodeGen with current LIR proc_call architecture (LirProcSpec instead of LirProc), remove stale ClosureRepresentation, and wire up the real backend in LlvmEvaluator
  • Fix str_concat fold bug: Correct constant-folding for string concatenation and remove dead SortComparatorThunk code
  • Route RocEnv diagnostics through Io: Replace std.debug.print with proper Io-based output for diagnostic messages
  • Add focused LLVM backend test suite: New llvm_backend_test.zig with test helpers exercising the LLVM codegen path end-to-end, plus documented TODO for CLI integration (--opt=size/--opt=speed)

🤖 Generated with Claude Code

@lukewilliamboswell lukewilliamboswell changed the base branch from main to lir-interpreter March 25, 2026 04:48
lukewilliamboswell and others added 27 commits March 25, 2026 16:34
… up real backend

The LLVM backend fell out of sync when .call was renamed to .proc_call
and .lambda was removed in favor of LirProcSpec entries. Since
llvmEvaluatorStr aliased devEvaluatorStr, the breakage went undetected.

- Rename LirProc→LirProcSpec, getProcs→getProcSpecs throughout MonoLlvmCodeGen
- Replace .call/.lambda dispatch with .proc_call via proc_registry lookup
- Remove all lambda infrastructure (compileLambdaAsFunc, ClosureMeta,
  closure_bindings, callChainedExpr, resolveToClosureMeta, etc.)
- Rewrite list_sort_with to use ll.callable_proc instead of lambda tracing
- Add str_concat expression handler and generateEmptyString
- Add monomorphization step to llvm_evaluator (was missing after API change)
- Wire llvmEvaluatorStr to real LlvmEvaluator with fork-isolated pipeline
- Harden error handling: convert orelse unreachable to error returns

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The generateStrConcatExpr fold loop was passing (next_id, next_id) to
callStrStr2Str, concatenating each element with itself instead of with
the accumulator. Fix by loading the accumulated RocStr fields directly
from dest_ptr for arg_a and only materializing the next element for
arg_b. Also remove unused SortComparatorThunk struct.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
RocEnv callbacks (rocDbgFn, rocExpectFailedFn, rocCrashedFn) now use an
optional Io for stderr output. When Io is null, callbacks are silent.
This makes the LLVM evaluator pipeline WASM freestanding compatible.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add llvm_backend_test.zig with dev-vs-LLVM comparison tests and a
runDevAndLlvmExpectStr helper. Remove dead `builtin` import from
roc_env.zig. Document the steps needed to wire the LLVM backend into
the CLI build pipeline (--opt=size/speed).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants