diff options
| author | Keegan McAllister <kmcallister@mozilla.com> | 2014-09-03 12:00:08 -0700 |
|---|---|---|
| committer | Keegan McAllister <kmcallister@mozilla.com> | 2014-10-04 20:09:09 -0700 |
| commit | 401aeaf6d3a6ec712ee46151faf574adaa5ff3c6 (patch) | |
| tree | d8f456d0fa5868f969d868ce0eaf7c62d9a327ef /src | |
| parent | 1f3cda8bd8496c3b3771b0201d1073ed575321d0 (diff) | |
| download | rust-401aeaf6d3a6ec712ee46151faf574adaa5ff3c6.tar.gz rust-401aeaf6d3a6ec712ee46151faf574adaa5ff3c6.zip | |
Add intrinsics::unreachable
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcore/intrinsics.rs | 7 | ||||
| -rw-r--r-- | src/librustc/middle/trans/intrinsic.rs | 4 | ||||
| -rw-r--r-- | src/librustc/middle/typeck/check/mod.rs | 1 |
3 files changed, 12 insertions, 0 deletions
diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index a3d63bbe06c..7d86b65168f 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -250,6 +250,13 @@ extern "rust-intrinsic" { /// Abort the execution of the process. pub fn abort() -> !; + /// Tell LLVM that this point in the code is not reachable, + /// enabling further optimizations. + /// + /// NB: This is very different from the `unreachable!()` macro! + #[cfg(not(stage0))] + pub fn unreachable() -> !; + /// Execute a breakpoint trap, for inspection by a debugger. pub fn breakpoint(); diff --git a/src/librustc/middle/trans/intrinsic.rs b/src/librustc/middle/trans/intrinsic.rs index 628971775ae..f9d55143c84 100644 --- a/src/librustc/middle/trans/intrinsic.rs +++ b/src/librustc/middle/trans/intrinsic.rs @@ -228,6 +228,10 @@ pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::N Unreachable(bcx); v } + (_, "unreachable") => { + Unreachable(bcx); + C_nil(ccx) + } (_, "breakpoint") => { let llfn = ccx.get_intrinsic(&("llvm.debugtrap")); Call(bcx, llfn, [], None) diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index d4c38d48a8c..197fd236727 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -5589,6 +5589,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) { } else { match name.get() { "abort" => (0, Vec::new(), ty::mk_bot()), + "unreachable" => (0, Vec::new(), ty::mk_bot()), "breakpoint" => (0, Vec::new(), ty::mk_nil()), "size_of" | "pref_align_of" | "min_align_of" => (1u, Vec::new(), ty::mk_uint()), |
