Add the correct number of locals when the same type is repeated.

This commit is contained in:
Nick Lewycky
2020-05-04 10:51:59 -07:00
parent e197afe7c9
commit 359f89878f

View File

@ -174,15 +174,17 @@ impl FuncTranslator {
let num_locals = reader.read_local_count().map_err(to_wasm_error)?;
for _ in 0..num_locals {
let mut counter = 0;
let (_count, ty) = reader
let (count, ty) = reader
.read_local_decl(&mut counter)
.map_err(to_wasm_error)?;
let ty = wptype_to_type(ty)?;
let ty = type_to_llvm(&intrinsics, ty);
// TODO: don't interleave allocas and stores.
let alloca = cache_builder.build_alloca(ty, "local");
cache_builder.build_store(alloca, const_zero(ty));
locals.push(alloca);
for _ in 0..count {
let alloca = cache_builder.build_alloca(ty, "local");
cache_builder.build_store(alloca, const_zero(ty));
locals.push(alloca);
}
}
let mut params_locals = params.clone();