Repository navigation
fix(mlir): doom #230 MLIR→wasm playable path - #250
Merged
Merged
Conversation
Bare llvm.mlir.global for struct / struct-array statics lowered to LLVM undef, so doom tables (iwads, menus, animdefs, …) were garbage and W_ReadLump failed with incomplete reads. Emit LLVM-dialect-only init regions (arith is illegal there): fold constant field exprs, addressof string literals, insertvalue structs, and llvm.mlir.zero for missing/aggregate defaults. Co-authored-by: Abhishek Shivakumar <[email protected]>
Two MLIR bugs blocked doom-flow on wasm: 1. Struct / struct-array module statics lowered to LLVM undef (iwads, menus, animdefs, …). Emit LLVM-dialect init regions. 2. u32 `%` / `/` used signed srem/sdiv when unsigned-ness was not tracked on call results / global loads. W_LumpNameHash % n then produced negative GEP indices, corrupted the heap (FILE*), and W_ReadLump failed with incomplete reads after W_GenerateHashTable. Co-authored-by: Abhishek Shivakumar <[email protected]>
ptr<u8>[i] as i32 was using arith.extsi (255→-1), breaking Doom WAD SHORT/LONG assembly and R_InitTextures patch lookup. Mark unsigned loads/casts and use extui; same for u8 struct fields. Co-authored-by: Abhishek Shivakumar <[email protected]>
&thinkercap spilled the global address into a fresh alloca and returned the alloca pointer (pointer-to-pointer). Thinker list init wrote through stack temps; P_Ticker then call_indirect'd heap addresses → wasm table index OOB / frozen title screen. Co-authored-by: Abhishek Shivakumar <[email protected]>
Symbol(const) stuffed the ConstDecl into is_mutable (positional arg bug), so definition was always None and `let mut x = SOME_CONST` failed strict tier-2 (examples/wasm/parallel_scaling.flow). Pass definition= explicitly; accept const bindings in _is_const_scalar. Co-authored-by: Abhishek Shivakumar <[email protected]>
godofecht
marked this pull request as ready for review
August 9, 2026 19:41
Contributor
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
2 tasks done
cursor Bot
pushed a commit
that referenced
this pull request
Aug 9, 2026
) Confirm #253/#254 against Flow tip: addressof for module globals (from #250) stops -O1+ turning drawshim getters into unreachable/noreturn, and static string arrays initialize via _emit_static_llvm_array_global. Size ptr/string to 4 bytes under --wasm32 in memref layouts (#255). Refresh doom_mlir -O2 preview and document status. Co-authored-by: Cursor Agent <[email protected]>
godofecht
added a commit
that referenced
this pull request
Aug 9, 2026
* fix(mlir): initialize struct module statics (doom #230) Bare llvm.mlir.global for struct / struct-array statics lowered to LLVM undef, so doom tables (iwads, menus, animdefs, …) were garbage and W_ReadLump failed with incomplete reads. Emit LLVM-dialect-only init regions (arith is illegal there): fold constant field exprs, addressof string literals, insertvalue structs, and llvm.mlir.zero for missing/aggregate defaults. Co-authored-by: Abhishek Shivakumar <[email protected]> * fix(mlir): struct static inits + unsigned rem/div (#230) Two MLIR bugs blocked doom-flow on wasm: 1. Struct / struct-array module statics lowered to LLVM undef (iwads, menus, animdefs, …). Emit LLVM-dialect init regions. 2. u32 `%` / `/` used signed srem/sdiv when unsigned-ness was not tracked on call results / global loads. W_LumpNameHash % n then produced negative GEP indices, corrupted the heap (FILE*), and W_ReadLump failed with incomplete reads after W_GenerateHashTable. Co-authored-by: Abhishek Shivakumar <[email protected]> * fix(mlir): zero-extend u8 loads on widen (#230) ptr<u8>[i] as i32 was using arith.extsi (255→-1), breaking Doom WAD SHORT/LONG assembly and R_InitTextures patch lookup. Mark unsigned loads/casts and use extui; same for u8 struct fields. Co-authored-by: Abhishek Shivakumar <[email protected]> * fix(mlir): &module_global is addressof, not alloca spill (#230) &thinkercap spilled the global address into a fresh alloca and returned the alloca pointer (pointer-to-pointer). Thinker list init wrote through stack temps; P_Ticker then call_indirect'd heap addresses → wasm table index OOB / frozen title screen. Co-authored-by: Abhishek Shivakumar <[email protected]> * fix(types): const refs are valid module-static initializers Symbol(const) stuffed the ConstDecl into is_mutable (positional arg bug), so definition was always None and `let mut x = SOME_CONST` failed strict tier-2 (examples/wasm/parallel_scaling.flow). Pass definition= explicitly; accept const bindings in _is_const_scalar. Co-authored-by: Abhishek Shivakumar <[email protected]> --------- Co-authored-by: Cursor Agent <[email protected]>
godofecht
added a commit
that referenced
this pull request
Aug 9, 2026
Record that BACKEND=mlir doom boots in-browser after the generator fixes on main, and document the dual C|MLIR→emcc near-term path. Co-authored-by: Abhishek Shivakumar <[email protected]>
godofecht
added a commit
that referenced
this pull request
Aug 9, 2026
) Confirm #253/#254 against Flow tip: addressof for module globals (from #250) stops -O1+ turning drawshim getters into unreachable/noreturn, and static string arrays initialize via _emit_static_llvm_array_global. Size ptr/string to 4 bytes under --wasm32 in memref layouts (#255). Refresh doom_mlir -O2 preview and document status. Co-authored-by: Cursor Agent <[email protected]>
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
Closes the Flow side of #230: doom-flow MLIR→wasm boots and is interactive in-browser (title / menu via Enter).
MLIR fixes (doom)
undef)%//—remui/divuiwhen operands areuNu8widen —extuinotextsi(255→255)&module_global—addressof, not alloca spill (thinker list / wasm table OOB)CI (this follow-up)
Tier-2 failed on pre-existing
examples/wasm/parallel_scaling.flow(let mut cur_shards = SHARDS_MAX). Root cause:Symbol(..., const, exported, decl)putdeclinis_mutablesodefinitionwas alwaysNone. Fixed construction +_is_const_scalaraccepts moduleconstrefs.Verification
parallel_scaling.flow --stricttranspiles