| 1 |
;; RUN: wast --assert default --snapshot tests/snapshots % |
| 2 |
|
| 3 |
(module |
| 4 |
(func $main (result i32) |
| 5 |
(local i32 i32 i32 i32) |
| 6 |
i32.const 0 |
| 7 |
local.tee 2 |
| 8 |
local.set 3 |
| 9 |
loop ;; label = @1 |
| 10 |
local.get 2 |
| 11 |
i32.const 50000 |
| 12 |
i32.eq |
| 13 |
(@metadata.code.branch_hint "\00") if ;; label = @2 |
| 14 |
i32.const 1 |
| 15 |
local.set 3 |
| 16 |
end |
| 17 |
local.get 2 |
| 18 |
i32.const 1 |
| 19 |
i32.add |
| 20 |
local.tee 2 |
| 21 |
i32.const 100000 |
| 22 |
i32.ne |
| 23 |
(@metadata.code.branch_hint "\01") br_if 0 (;@1;) |
| 24 |
end |
| 25 |
local.get 3) |
| 26 |
) |
| 27 |
|
| 28 |
(module |
| 29 |
(import "" "" (func)) |
| 30 |
|
| 31 |
(func |
| 32 |
i32.const 0 |
| 33 |
(@metadata.code.branch_hint "\00") |
| 34 |
if |
| 35 |
end |
| 36 |
) |
| 37 |
) |
| 38 |
|
| 39 |
(module |
| 40 |
(import "" "" (func)) |
| 41 |
|
| 42 |
(func |
| 43 |
i32.const 0 |
| 44 |
(@metadata.code.branch_hint "\00") |
| 45 |
if |
| 46 |
i32.const 0 |
| 47 |
(@metadata.code.branch_hint "\01") |
| 48 |
br_if 0 |
| 49 |
end |
| 50 |
) |
| 51 |
|
| 52 |
(func |
| 53 |
i32.const 0 |
| 54 |
(@metadata.code.branch_hint "\01") |
| 55 |
if |
| 56 |
i32.const 0 |
| 57 |
(@metadata.code.branch_hint "\00") |
| 58 |
br_if 0 |
| 59 |
end |
| 60 |
) |
| 61 |
) |
| 62 |
|
| 63 |
(assert_malformed |
| 64 |
(module quote "(@metadata.code.branch_hint)") |
| 65 |
"expected valid module field") |
| 66 |
(assert_malformed |
| 67 |
(module quote "(func (@metadata.code.branch_hint))") |
| 68 |
"expected a string") |
| 69 |
(assert_malformed |
| 70 |
(module quote "(func (@metadata.code.branch_hint \"a\"))") |
| 71 |
"invalid value for branch hint") |
| 72 |
|
| 73 |
;; make sure this at least doesn't crash. Should perhaps be an error? |
| 74 |
(module |
| 75 |
(func (@metadata.code.branch_hint "\00")) |
| 76 |
(func |
| 77 |
(@metadata.code.branch_hint "\00") |
| 78 |
(@metadata.code.branch_hint "\01") |
| 79 |
) |
| 80 |
(func |
| 81 |
(@metadata.code.branch_hint "\00") |
| 82 |
(@metadata.code.branch_hint "\00") |
| 83 |
(@metadata.code.branch_hint "\00") |
| 84 |
i32.const 0 |
| 85 |
(@metadata.code.branch_hint "\00") |
| 86 |
(@metadata.code.branch_hint "\00") |
| 87 |
(@metadata.code.branch_hint "\00") |
| 88 |
if |
| 89 |
(@metadata.code.branch_hint "\00") |
| 90 |
(@metadata.code.branch_hint "\00") |
| 91 |
(@metadata.code.branch_hint "\00") |
| 92 |
end |
| 93 |
(@metadata.code.branch_hint "\00") |
| 94 |
(@metadata.code.branch_hint "\00") |
| 95 |
(@metadata.code.branch_hint "\00") |
| 96 |
) |
| 97 |
) |