2JXKNG3VODYXLJ3TINRQH3H7OG3XFV3HYWDTNJTIZNFOVIV6FGKAC
FJZWJHLW5B2JGYHKSHIYBRG2IVTLCPKT3SR2PWKDPCLRATYEXEQQC
Q4OZZTLAP6RD35RZGN2SZRXPGNBDAK6OYHMYIIZVHYRCZWFUGWRAC
64WSQVMQZ4U4VHDNNO2HIYUB5WQT7U6E2463CSVBCZ7EDGTYUEDAC
JITJ6VHLW7JJAQUFG4LBZOMEXORKSBKJYQZ4DALCVLYAWM4BDISQC
EFKQM5UNVCK623Y6L2OBSBD4W3E6DHMDPMXORFLCSJGOXHKPAFHQC
O2DTNJ3ZOJJKDHGPNE2DZSZF7CFU4G5D65RIDOYZHYYBH3JZAAIAC
FVAVNSGB7J3BNE4ON22YS6DHW3B3XHCRBDB53LJSRCKFTELCVNAQC
: 1_int_identity.c |> clang -cc1 -Ofast -emit-llvm-bc -triple=wasm32-unknown-unknown-wasm -std=c17 -o %o %f |> %B.bc
: 1_int_identity.bc |> llc -O3 -filetype=obj %f -o %o |> %B.o
: 1_int_identity.o |> wasm-ld --lto-O3 --no-entry %f -o %o --initial-memory=0 |> %B.wasm
: 1_int_identity.wasm |> wasm-opt -Oz -o %o %f |> %B.opt.wasm
int identity(int a) {
return a;
}
]
end
test "1_int_identity" do
assert parse_file("test_data/1_int_identity.opt.wasm")
|> Enum.filter(fn {k, _} -> k == :section_type or k == :section_body end) ==
[
{:section_type, :type},
{:section_body, [{[:i32], [:i32]}]},
{:section_type, :function},
{:section_body, [0]},
{:section_type, :memory},
{:section_body, [{2, nil}]},
{:section_type, :global},
{:section_body,
[{{:i32, :const}, ["i32.const": 66560]}, {{:i32, :const}, ["i32.const": 1024]}]},
{:section_type, :export},
{:section_body,
[
{"memory", {:mem, 0}},
{"__heap_base", {:global, 0}},
{"__data_end", {:global, 1}},
{"identity", {:func, 0}}
]},
{:section_type, :code},
{:section_body, [%{code: %{expr: ["local.get": 0], locals: []}, size: 4}]}