Skip to content

Commit

Permalink
librustc: implement and use fixed_stack_segment attribute for intri…
Browse files Browse the repository at this point in the history
…nsics.
  • Loading branch information
huonw committed Apr 20, 2013
1 parent 4ff701b commit 93c0888
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/libcore/unstable/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,28 @@ pub extern "rust-intrinsic" {
pub fn powif32(a: f32, x: i32) -> f32;
pub fn powif64(a: f64, x: i32) -> f64;

// the following kill the stack canary without
// `fixed_stack_segment`. This possibly only affects the f64
// variants, but it's hard to be sure since it seems to only
// occur with fairly specific arguments.
#[fixed_stack_segment]
pub fn sinf32(x: f32) -> f32;
#[fixed_stack_segment]
pub fn sinf64(x: f64) -> f64;

#[fixed_stack_segment]
pub fn cosf32(x: f32) -> f32;
#[fixed_stack_segment]
pub fn cosf64(x: f64) -> f64;

#[fixed_stack_segment]
pub fn powf32(a: f32, x: f32) -> f32;
#[fixed_stack_segment]
pub fn powf64(a: f64, x: f64) -> f64;

#[fixed_stack_segment]
pub fn expf32(x: f32) -> f32;
#[fixed_stack_segment]
pub fn expf64(x: f64) -> f64;

pub fn exp2f32(x: f32) -> f32;
Expand Down Expand Up @@ -128,4 +140,3 @@ pub extern "rust-intrinsic" {
pub fn bswap32(x: i32) -> i32;
pub fn bswap64(x: i64) -> i64;
}

6 changes: 6 additions & 0 deletions src/librustc/middle/trans/foreign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ pub fn trans_intrinsic(ccx: @CrateContext,
item: @ast::foreign_item,
path: ast_map::path,
substs: @param_substs,
attributes: &[ast::attribute],
ref_id: Option<ast::node_id>) {
debug!("trans_intrinsic(item.ident=%s)", *ccx.sess.str_of(item.ident));

Expand All @@ -561,6 +562,11 @@ pub fn trans_intrinsic(ccx: @CrateContext,
Some(copy substs),
Some(item.span));

// Set the fixed stack segment flag if necessary.
if attr::attrs_contains_name(attributes, "fixed_stack_segment") {
set_fixed_stack_segment(fcx.llfn);
}

let mut bcx = top_scope_block(fcx, None), lltop = bcx.llbb;
match *ccx.sess.str_of(item.ident) {
~"atomic_cxchg" => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/monomorphize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ pub fn monomorphic_fn(ccx: @CrateContext,
}
ast_map::node_foreign_item(i, _, _, _) => {
let d = mk_lldecl();
foreign::trans_intrinsic(ccx, d, i, pt, psubsts.get(),
foreign::trans_intrinsic(ccx, d, i, pt, psubsts.get(), i.attrs,
ref_id);
d
}
Expand Down

0 comments on commit 93c0888

Please sign in to comment.