Repository navigation
fix(mlir): uN/null/memref + MLIR wasm preload (#222–#225) - #229
Merged
Merged
Conversation
MLIR has no unsigned integer types, so flow_gfx_* externs with u8
parameters failed mlir-opt ("expected non-function type"). Lower uN to
iN of the same width and track unsigned SSA origins so widen casts still
use arith.extui.
Co-authored-by: Cursor <[email protected]>
`let p: ptr<T> = arr` was reusing the memref SSA and retagging it as !llvm.ptr, so later arr[i] emitted llvm.getelementptr on a memref (snake_gfx). Emit extract_aligned_pointer_as_index → inttoptr into a fresh SSA, prefer declared memref types for indexing, and ensure void functions terminate CF while/for exit blocks with func.return. Co-authored-by: Cursor <[email protected]>
Ship scripts/wasm_build.py --backend=mlir (Flow→MLIR→LLVM→emcc) needed to validate gfx games, and add a unit test that array→ptr decay keeps memref indexing on the alloc SSA. With #222+#224, snake_gfx builds under ./flow wasm --backend=mlir. Co-authored-by: Cursor <[email protected]>
Covers resolve_backend and builds hello_wasm with both backends when emcc is available — guards the MLIR WASM path landed for epic #221. Co-authored-by: Cursor <[email protected]>
6 tasks
arith.constant null and (null : !llvm.ptr) globals are invalid MLIR. Lower null literals and pointer module statics to llvm.mlir.zero / zero-init globals, use llvm.icmp for ptr equality, and ptrtoint for ptr→int casts so null checks type-check under mlir-opt. Co-authored-by: Cursor <[email protected]>
Stop silently dropping --preload when used without --fs. wasm_build.py now passes --preload-file + FORCE_FILESYSTEM, accepts --link (skipping Cocoa .m), and exposes INITIAL_MEMORY / ASYNCIFY_STACK_SIZE knobs. ./flow wasm forwards those flags and errors clearly if --fs/--threads are combined with --backend=mlir. Co-authored-by: Cursor <[email protected]>
This was referenced Aug 7, 2026
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.
Summary
uN→ MLIRiN(+extuion widen)extract_aligned_pointer_as_index/inttoptr(snake_gfx)null→llvm.mlir.zero; ptr globals zero-init;llvm.icmp/ptrtointwasm_build.py+./flow wasmhonor--preload/--linkon both backends (no silent drop); clear refuse for--fs/--threads+ MLIRTest plan
pytest tests/unit/test_mlir_generator.py(null + array decay)pytest tests/integration/test_wasm_backends.py(both backends + preload.data)./flow wasm examples/wasm/hello_wasm.flow --backend=mlir --preload … --link runtime/flow_rt_support.c./flow wasm … --backend=mlir --fs memfserrors clearlyParent: #221