Skip to content

Commit

Permalink
Brilift: Use unreachable code trap
Browse files Browse the repository at this point in the history
  • Loading branch information
sampsyo authored and Pat-Lafon committed Nov 4, 2024
1 parent 6b9390d commit fd19001
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 fd19001

Please sign in to comment.