[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@gmail.com>
GitOrigin-RevId: c93bad65aa654f507ea768610d003c42ba31ab7b
See https://mlir.llvm.org/ for more information.