|
| 1 | +;;; TOOL: run-objdump |
| 2 | +;;; ARGS0: --enable-annotations --enable-code-metadata |
| 3 | +;;; ARGS1: -x -j "metadata.code.branch_hint" |
| 4 | +;; combined from https://github.com/bytecodealliance/wasm-tools/tree/6ed178840fae8599312ab14c2cad6faea9f80bf1/tests/cli/branch-hinting |
| 5 | +(module |
| 6 | + (func $main (result i32) |
| 7 | + (local i32 i32 i32 i32) |
| 8 | + i32.const 0 |
| 9 | + local.tee 2 |
| 10 | + local.set 3 |
| 11 | + loop ;; label = @1 |
| 12 | + local.get 2 |
| 13 | + i32.const 50000 |
| 14 | + i32.eq |
| 15 | + (@metadata.code.branch_hint "\00") if ;; label = @2 |
| 16 | + i32.const 1 |
| 17 | + local.set 3 |
| 18 | + end |
| 19 | + local.get 2 |
| 20 | + i32.const 1 |
| 21 | + i32.add |
| 22 | + local.tee 2 |
| 23 | + i32.const 100000 |
| 24 | + i32.ne |
| 25 | + (@metadata.code.branch_hint "\01") br_if 0 (;@1;) |
| 26 | + end |
| 27 | + local.get 3) |
| 28 | + |
| 29 | + (func |
| 30 | + i32.const 0 |
| 31 | + (@metadata.code.branch_hint "\00") |
| 32 | + if |
| 33 | + end) |
| 34 | + |
| 35 | + |
| 36 | + (func |
| 37 | + i32.const 0 |
| 38 | + (@metadata.code.branch_hint "\00") |
| 39 | + if |
| 40 | + i32.const 0 |
| 41 | + (@metadata.code.branch_hint "\01") |
| 42 | + br_if 0 |
| 43 | + end) |
| 44 | + |
| 45 | + (func |
| 46 | + i32.const 0 |
| 47 | + (@metadata.code.branch_hint "\01") |
| 48 | + if |
| 49 | + i32.const 0 |
| 50 | + (@metadata.code.branch_hint "\00") |
| 51 | + br_if 0 |
| 52 | + end) |
| 53 | +) |
| 54 | + |
| 55 | +(;; STDOUT ;;; |
| 56 | +branch-hints.wasm: file format wasm 0x1 |
| 57 | +Section Details: |
| 58 | +Custom: |
| 59 | + - name: "metadata.code.branch_hint" |
| 60 | + - func[0]: |
| 61 | + - meta[12]: |
| 62 | + - 0000000: 00 . |
| 63 | + - meta[25]: |
| 64 | + - 0000000: 01 . |
| 65 | + - func[1]: |
| 66 | + - meta[3]: |
| 67 | + - 0000000: 00 . |
| 68 | + - func[2]: |
| 69 | + - meta[3]: |
| 70 | + - 0000000: 00 . |
| 71 | + - meta[7]: |
| 72 | + - 0000000: 01 . |
| 73 | + - func[3]: |
| 74 | + - meta[3]: |
| 75 | + - 0000000: 01 . |
| 76 | + - meta[7]: |
| 77 | + - 0000000: 00 . |
| 78 | +Code Disassembly: |
| 79 | +000057 func[0]: |
| 80 | + 000058: 04 7f | local[0..3] type=i32 |
| 81 | + 00005a: 41 00 | i32.const 0 |
| 82 | + 00005c: 22 02 | local.tee 2 |
| 83 | + 00005e: 21 03 | local.set 3 |
| 84 | + 000060: 03 40 | loop |
| 85 | + 000062: 20 02 | local.get 2 |
| 86 | + 000064: 41 d0 86 03 | i32.const 50000 |
| 87 | + 000068: 46 | i32.eq |
| 88 | + 000069: 04 40 | if |
| 89 | + 00006b: 41 01 | i32.const 1 |
| 90 | + 00006d: 21 03 | local.set 3 |
| 91 | + 00006f: 0b | end |
| 92 | + 000070: 20 02 | local.get 2 |
| 93 | + 000072: 41 01 | i32.const 1 |
| 94 | + 000074: 6a | i32.add |
| 95 | + 000075: 22 02 | local.tee 2 |
| 96 | + 000077: 41 a0 8d 06 | i32.const 100000 |
| 97 | + 00007b: 47 | i32.ne |
| 98 | + 00007c: 0d 00 | br_if 0 |
| 99 | + 00007e: 0b | end |
| 100 | + 00007f: 20 03 | local.get 3 |
| 101 | + 000081: 0b | end |
| 102 | +000083 func[1]: |
| 103 | + 000084: 41 00 | i32.const 0 |
| 104 | + 000086: 04 40 | if |
| 105 | + 000088: 0b | end |
| 106 | + 000089: 0b | end |
| 107 | +00008b func[2]: |
| 108 | + 00008c: 41 00 | i32.const 0 |
| 109 | + 00008e: 04 40 | if |
| 110 | + 000090: 41 00 | i32.const 0 |
| 111 | + 000092: 0d 00 | br_if 0 |
| 112 | + 000094: 0b | end |
| 113 | + 000095: 0b | end |
| 114 | +000097 func[3]: |
| 115 | + 000098: 41 00 | i32.const 0 |
| 116 | + 00009a: 04 40 | if |
| 117 | + 00009c: 41 00 | i32.const 0 |
| 118 | + 00009e: 0d 00 | br_if 0 |
| 119 | + 0000a0: 0b | end |
| 120 | + 0000a1: 0b | end |
| 121 | +;;; STDOUT ;;) |
0 commit comments