[WebAssembly] Read global index in init expression as LEB

Subscribers: jfb, dschuff

Differential Revision: https://reviews.llvm.org/D32462

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301330 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sam Clegg 2017-04-25 17:11:56 +00:00
parent b3518390c1
commit 2854ea835f
3 changed files with 8 additions and 5 deletions

View File

@ -144,7 +144,7 @@ static Error readInitExpr(wasm::WasmInitExpr &Expr, const uint8_t *&Ptr) {
Expr.Value.Float64 = readFloat64(Ptr);
break;
case wasm::WASM_OPCODE_GET_GLOBAL:
Expr.Value.Global = readUint32(Ptr);
Expr.Value.Global = readULEB128(Ptr);
break;
default:
return make_error<GenericBinaryError>("Invalid opcode in init_expr",

View File

@ -294,6 +294,9 @@ void MappingTraits<wasm::WasmInitExpr>::mapping(IO &IO,
case wasm::WASM_OPCODE_F64_CONST:
IO.mapRequired("Value", Expr.Value.Float64);
break;
case wasm::WASM_OPCODE_GET_GLOBAL:
IO.mapRequired("Index", Expr.Value.Global);
break;
}
}

View File

@ -18,8 +18,8 @@ Sections:
Functions:
- 1
- Offset:
Opcode: I32_CONST
Value: 5
Opcode: GET_GLOBAL
Index: 1
Functions:
- 4
...
@ -34,7 +34,7 @@ Sections:
# CHECK: Value: 3
# CHECK: Functions: [ 1 ]
# CHECK: - Offset:
# CHECK: Opcode: I32_CONST
# CHECK: Value: 5
# CHECK: Opcode: GET_GLOBAL
# CHECK: Index: 1
# CHECK: Functions: [ 4 ]
# CHECK: ...