Properly legalize with empty jump tables.

This commit is contained in:
Nicolas B. Pierron
2019-07-29 14:11:40 +02:00
committed by Nicolas B. Pierron
parent 6e57e3f8f3
commit f0d7438728
2 changed files with 23 additions and 3 deletions

View File

@@ -295,9 +295,12 @@ fn expand_br_table_conds(
// This is a poor man's jump table using just a sequence of conditional branches.
let table_size = func.jump_tables[table].len();
let mut cond_failed_ebb = std::vec::Vec::with_capacity(table_size - 1);
for _ in 0..table_size - 1 {
cond_failed_ebb.push(func.dfg.make_ebb());
let mut cond_failed_ebb = vec![];
if table_size >= 1 {
cond_failed_ebb = std::vec::Vec::with_capacity(table_size - 1);
for _ in 0..table_size - 1 {
cond_failed_ebb.push(func.dfg.make_ebb());
}
}
let mut pos = FuncCursor::new(func).at_inst(inst);

View File

@@ -0,0 +1,17 @@
test legalizer
set probestack_enabled=false
set jump_tables_enabled=false
target x86_64
function u0:0(i64) {
jt0 = jump_table []
ebb0(v0: i64):
br_table v0, ebb1, jt0
; check: ebb0(v0: i64):
; nextln: jump ebb1
ebb1:
return
}
; not: jump_table