Changeset View
Changeset View
Standalone View
Standalone View
llvm/test/CodeGen/WebAssembly/switch-unreachable-default.ll
Show All 30 Lines | bb0: | ||||
ret i32 0 | ret i32 0 | ||||
bb1: | bb1: | ||||
ret i32 1 | ret i32 1 | ||||
unreachable: | unreachable: | ||||
unreachable | unreachable | ||||
} | } | ||||
; CHECK-LABEL: split: | |||||
; CHECK: .functype split (i32) -> () | |||||
; CHECK: block | |||||
; CHECK: br_if 0 | |||||
; CHECK: block | |||||
; CHECK: block | |||||
; CHECK: br_table {1, 1, 1, 1, 1, 1, 1, 0} | |||||
; CHECK: .LBB1_2 | |||||
; CHECK: end_block | |||||
; CHECK: br_table {0, 0, 0} | |||||
; CHECK: .LBB1_3 | |||||
; CHECK: end_block | |||||
; CHECK: unreachable | |||||
; CHECK: .LBB1_4 | |||||
; CHECK: end_block | |||||
; CHECK: end_function | |||||
define void @split(i8 %c) { | |||||
entry: | |||||
switch i8 %c, label %sw.default [ | |||||
i8 114, label %return | |||||
i8 103, label %sw.bb1 | |||||
i8 98, label %sw.bb2 | |||||
i8 97, label %sw.bb3 | |||||
i8 48, label %sw.bb4 | |||||
i8 49, label %sw.bb5 | |||||
] | |||||
aheejin: Unrelated question: why does this switch get split? Because it’s too big? If so, big br_tables… | |||||
tlivelyAuthorUnsubmitted Right, it's because the case indices are clustered into different groups that are far away from each other. The target-independent codegen has a lot of logic for figuring out how to best split up and group the switch cases to create only reasonably-dense jump tables. This is good for uncompressed WebAssembly as well, although a sparse br_table would still compress well. I don't know if any engines do clever lowerings of br_tables, but we want to make naively lowering them into native jump tables a reasonable option as well, so it is good to have this logic in the tools. tlively: Right, it's because the case indices are clustered into different groups that are far away from… | |||||
sw.bb1: | |||||
unreachable | |||||
sw.bb2: | |||||
unreachable | |||||
sw.bb3: | |||||
unreachable | |||||
sw.bb4: | |||||
unreachable | |||||
sw.bb5: | |||||
unreachable | |||||
sw.default: | |||||
unreachable | |||||
return: | |||||
ret void | |||||
} |
Unrelated question: why does this switch get split? Because it’s too big? If so, big br_tables are also bad for wasm too?