[all-commits] [llvm/llvm-project] c93bad: [mlir][wasmssa] Fix if/else round-trip and verify ...

Saqib Khan via All-commits all-commits at lists.llvm.org
Sat Oct 3 20:23:45 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c93bad65aa654f507ea768610d003c42ba31ab7b
      https://github.com/llvm/llvm-project/commit/c93bad65aa654f507ea768610d003c42ba31ab7b
  Author: Saqib Khan <saqibkhan at utexas.edu>
  Date:   2026-10-04 (Sun, 04 Oct 2026)

  Changed paths:
    M mlir/include/mlir/Dialect/WasmSSA/IR/WasmSSAOps.td
    M mlir/lib/Dialect/WasmSSA/IR/WasmSSAOps.cpp
    M mlir/test/Dialect/WasmSSA/custom_parser/if.mlir
    A mlir/test/Dialect/WasmSSA/return-invalid.mlir
    M mlir/test/Target/Wasm/if.mlir

  Log Message:
  -----------
  [mlir][wasmssa] Fix if/else round-trip and verify return types (#227828)

Fixes two WasmSSA dialect bugs:

**#226072: `wasmssa.if` does not round-trip.** The else region was
printed with `printKeywordOrString("else ")`. Because of the trailing
space, `"else "` is not a valid bare keyword, so it was printed as a
quoted string (`} "else "{`), which `parseElseRegion` does not accept.
The else keyword is now printed directly, giving `} else {`.

**#226073: `wasmssa.return` is not checked against the function's
results.** `wasmssa.return` had no verifier, so a function could return
a different number or type of values than its signature declares. This
adds a `ReturnOp` verifier that checks the operands against the
enclosing `wasmssa.func`. Checking in the return op rather than in
`FuncOp::verifyBody` also covers returns nested inside
`block`/`loop`/`if` regions.

Tests:
- `custom_parser/if.mlir` expected the broken `"else "` output; it now
expects `} else {` and gains a second RUN line piping through `mlir-opt`
again to check the round trip. Its `@func_0` returned `f32` from an
`i32` function, which the new verifier rejects, so the signature is now
`-> f32`.
- `Target/Wasm/if.mlir` also expected the quoted `"else "` and is
updated. The Wasm importer's output passes the new verifier.
- New `return-invalid.mlir` covers type mismatch, too few / too many
operands, and a mismatched return inside a nested `if` region.

`llvm-lit mlir/test/Dialect/WasmSSA mlir/test/Target/Wasm
mlir/test/Conversion/RaiseWasm`: 112/112 pass. The new and updated
dialect tests fail without the fix.

Assisted-by: Claude Code (Claude Opus 5.5)

Co-authored-by: Ferdinand Lemaire <flscminecraft at gmail.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list