Skip to content

Commit

Permalink
Brilift: Use unreachable code trap
Browse files Browse the repository at this point in the history
See #343.
  • Loading branch information
sampsyo committed Oct 26, 2024
1 parent 250c1b1 commit 88e6947
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions brilift/src/translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,12 +632,11 @@ impl CompileEnv<'_> {
if return_type.is_none() {
builder.ins().return_(&[]);
} else {
// If the function has a return type
// Lets just trap since this must be dead code
builder.ins().trap(
/* Some random trap code */
cranelift_codegen::ir::TrapCode::TableOutOfBounds,
);
// An implicit return is illegal when there is a return type,
// so this code is unreachable.
builder
.ins()
.trap(cranelift_codegen::ir::TrapCode::UnreachableCodeReached);
}
}
}
Expand Down

0 comments on commit 88e6947

Please sign in to comment.