Skip to content

Commit a2b0244

Browse files
committed
Only do the if-else chain for type switch on wasm targets
1 parent c9f69aa commit a2b0244

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/llvm_backend_stmt.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,11 +1982,13 @@ gb_internal void lb_build_type_switch_stmt(lbProcedure *p, AstTypeSwitchStmt *ss
19821982
if (type_size_of(parent_base_type) == 0) {
19831983
GB_ASSERT(tag.value == nullptr);
19841984
switch_instr = LLVMBuildSwitch(p->builder, lb_const_bool(p->module, t_llvm_bool, false).value, else_block->block, cast(unsigned)num_cases);
1985-
} else if (switch_kind == TypeSwitch_Union) {
1985+
} else {
19861986
GB_ASSERT(tag.value != nullptr);
1987-
switch_instr = LLVMBuildSwitch(p->builder, tag.value, else_block->block, cast(unsigned)num_cases);
1988-
} else if (switch_kind == TypeSwitch_Any) {
1989-
// gb_printf_err("HERE!\n");
1987+
if (switch_kind == TypeSwitch_Any && is_arch_wasm()) {
1988+
// Only do the if-else chain on wasm targets
1989+
} else {
1990+
switch_instr = LLVMBuildSwitch(p->builder, tag.value, else_block->block, cast(unsigned)num_cases);
1991+
}
19901992
}
19911993

19921994
bool all_by_reference = false;

0 commit comments

Comments
 (0)