Skip to content

clang generates incorrect wasm object code from .s input #56935

@TerrorJack

Description

@TerrorJack

Minimal repro:

foo:
.functype foo () -> (i32)
i32.const 420
if i32
  i32.const 421
  return
else
  i32.const 423
end_if
end_function

Compile it with clang --target=wasm32-wasi -c test.s -o test.o, then disassemble with wasm-objdump -d test.o:

test.o:	file format wasm 0x1

Code Disassembly:

000041 func[0] <foo>:
 000042: 41 a4 03                   | i32.const 420
 000045: 04 7f                      | if i32
 000047: 41 a5 03                   |   i32.const 421
 00004a: 0f                         |   return
 00004b: 41 a7 03                   |   i32.const 423
 00004e: 0b                         | end
 00004f: 0b                         | end

else has been incorrectly dropped.

This is confirmed against both 14.0.6 and trunk.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions