Skip to content

MLIR: -O1+ infers D_DoomMain as noreturn and drops the main loop #253

Closed

Description

@godofecht

doom-flow's MLIR build is currently forced to -O0 in scripts/build_wasm.sh because -O1+ makes wasm-ld/binaryen infer that D_DoomMain is noreturn and drop most of the game, including the main game loop.

Details:

  • D_DoomMain in dmain.flow ends with D_DoomLoop(), which in this port intentionally returns so the ASYNCIFY stack stays shallow.
  • doom.flow's main calls doom_bootstrap (which calls D_DoomMain) and then runs the frame loop.
  • When BACKEND=mlir is built with emcc -O1 or -O2, the resulting .wasm is missing the post-bootstrap loop, so the title screen renders but the game cannot continue.

Current workaround: scripts/build_wasm.sh line 78 sets EMCC_OPT=(-O0) for MLIR, which keeps the loop but produces an unusably slow binary.

Requested change: Flow's MLIR/LLVM lowering should not mark or infer D_DoomMain as noreturn when it has a return path, or give the user a way to suppress that attribute for a specific function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions