mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-23 08:49:58 +03:00
add unreachable instruction to the mono IR
This commit is contained in:
parent
ccd302cbe9
commit
6bc0cf33a5
@ -1366,6 +1366,13 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
|
||||
value
|
||||
}
|
||||
|
||||
Unreachable => {
|
||||
// used in exception handling
|
||||
env.builder.build_unreachable();
|
||||
|
||||
env.context.i64_type().const_zero().into()
|
||||
}
|
||||
|
||||
Switch {
|
||||
branches,
|
||||
default_branch,
|
||||
|
@ -335,6 +335,7 @@ where
|
||||
Stmt::Ret(sym) => {
|
||||
self.set_last_seen(*sym, stmt);
|
||||
}
|
||||
Stmt::Unreachable => {}
|
||||
Stmt::Inc(sym, following) => {
|
||||
self.set_last_seen(*sym, stmt);
|
||||
self.scan_ast(following);
|
||||
|
@ -166,7 +166,7 @@ impl<'a> ParamMap<'a> {
|
||||
}
|
||||
Inc(_, _) | Dec(_, _) => unreachable!("these have not been introduced yet"),
|
||||
|
||||
Ret(_) | Jump(_, _) | RuntimeError(_) => {
|
||||
Ret(_) | Unreachable | Jump(_, _) | RuntimeError(_) => {
|
||||
// these are terminal, do nothing
|
||||
}
|
||||
}
|
||||
@ -470,7 +470,7 @@ impl<'a> BorrowInfState<'a> {
|
||||
}
|
||||
Inc(_, _) | Dec(_, _) => unreachable!("these have not been introduced yet"),
|
||||
|
||||
Ret(_) | RuntimeError(_) => {
|
||||
Ret(_) | RuntimeError(_) | Unreachable => {
|
||||
// these are terminal, do nothing
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,8 @@ pub fn occuring_variables(stmt: &Stmt<'_>) -> (MutSet<Symbol>, MutSet<Symbol>) {
|
||||
result.insert(*symbol);
|
||||
}
|
||||
|
||||
Unreachable => {}
|
||||
|
||||
Inc(symbol, cont) | Dec(symbol, cont) => {
|
||||
result.insert(*symbol);
|
||||
stack.push(cont);
|
||||
@ -673,6 +675,8 @@ impl<'a> Context<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
Unreachable => (stmt, MutSet::default()),
|
||||
|
||||
Jump(j, xs) => {
|
||||
let empty = MutSet::default();
|
||||
let j_live_vars = match self.jp_live_vars.get(j) {
|
||||
@ -813,6 +817,8 @@ pub fn collect_stmt(
|
||||
vars
|
||||
}
|
||||
|
||||
Unreachable => vars,
|
||||
|
||||
RuntimeError(_) => vars,
|
||||
}
|
||||
}
|
||||
|
@ -754,6 +754,7 @@ pub enum Stmt<'a> {
|
||||
ret_layout: Layout<'a>,
|
||||
},
|
||||
Ret(Symbol),
|
||||
Unreachable,
|
||||
Inc(Symbol, &'a Stmt<'a>),
|
||||
Dec(Symbol, &'a Stmt<'a>),
|
||||
Join {
|
||||
@ -1103,6 +1104,8 @@ impl<'a> Stmt<'a> {
|
||||
.append(symbol_to_doc(alloc, *symbol))
|
||||
.append(";"),
|
||||
|
||||
Unreachable => alloc.text("unreachable;"),
|
||||
|
||||
Switch {
|
||||
cond_symbol,
|
||||
branches,
|
||||
@ -4436,6 +4439,8 @@ fn substitute_in_stmt_help<'a>(
|
||||
}
|
||||
}
|
||||
|
||||
Unreachable => None,
|
||||
|
||||
RuntimeError(_) => None,
|
||||
}
|
||||
}
|
||||
|
@ -187,6 +187,7 @@ fn insert_jumps<'a>(
|
||||
None => None,
|
||||
},
|
||||
|
||||
Unreachable => None,
|
||||
Ret(_) => None,
|
||||
Jump(_, _) => None,
|
||||
RuntimeError(_) => None,
|
||||
|
Loading…
Reference in New Issue
Block a user