Skip to content

add an abort intrinsic #9860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 15, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/librustc/middle/trans/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ pub fn trans_intrinsic(ccx: @mut CrateContext,
}

match name {
"abort" => {
let llfn = bcx.ccx().intrinsics.get_copy(&("llvm.trap"));
Call(bcx, llfn, [], []);
RetVoid(bcx);
}
"size_of" => {
let tp_ty = substs.tys[0];
let lltp_ty = type_of::type_of(ccx, tp_ty);
Expand Down
1 change: 1 addition & 0 deletions src/librustc/middle/typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3585,6 +3585,7 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) {

} else {
match name {
"abort" => (0, ~[], ty::mk_bot()),
"size_of" |
"pref_align_of" | "min_align_of" => (1u, ~[], ty::mk_uint()),
"init" => (1u, ~[], param(ccx, 0u)),
Expand Down
3 changes: 3 additions & 0 deletions src/libstd/unstable/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ pub trait TyVisitor {
}

extern "rust-intrinsic" {
/// Abort the execution of the process.
#[cfg(not(stage0))]
pub fn abort() -> !;

/// Atomic compare and exchange, sequentially consistent.
pub fn atomic_cxchg(dst: &mut int, old: int, src: int) -> int;
Expand Down