Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 81329c1

Browse files
author
Keegan McAllister
committedSep 27, 2014
Add intrinsics::unreachable
1 parent d64b410 commit 81329c1

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed
 

‎src/libcore/intrinsics.rs

+7
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,13 @@ extern "rust-intrinsic" {
250250
/// Abort the execution of the process.
251251
pub fn abort() -> !;
252252

253+
/// Tell LLVM that this point in the code is not reachable,
254+
/// enabling further optimizations.
255+
///
256+
/// NB: This is very different from the `unreachable!()` macro!
257+
#[cfg(not(stage0))]
258+
pub fn unreachable() -> !;
259+
253260
/// Execute a breakpoint trap, for inspection by a debugger.
254261
pub fn breakpoint();
255262

‎src/librustc/middle/trans/intrinsic.rs

+4
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::N
228228
Unreachable(bcx);
229229
v
230230
}
231+
(_, "unreachable") => {
232+
Unreachable(bcx);
233+
C_nil(ccx)
234+
}
231235
(_, "breakpoint") => {
232236
let llfn = ccx.get_intrinsic(&("llvm.debugtrap"));
233237
Call(bcx, llfn, [], None)

‎src/librustc/middle/typeck/check/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5558,6 +5558,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
55585558
} else {
55595559
match name.get() {
55605560
"abort" => (0, Vec::new(), ty::mk_bot()),
5561+
"unreachable" => (0, Vec::new(), ty::mk_bot()),
55615562
"breakpoint" => (0, Vec::new(), ty::mk_nil()),
55625563
"size_of" |
55635564
"pref_align_of" | "min_align_of" => (1u, Vec::new(), ty::mk_uint()),

0 commit comments

Comments
 (0)
Please sign in to comment.