Skip to content

Commit 93c0888

Browse files
committed
librustc: implement and use fixed_stack_segment attribute for intrinsics.
1 parent 4ff701b commit 93c0888

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

src/libcore/unstable/intrinsics.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,28 @@ pub extern "rust-intrinsic" {
7070
pub fn powif32(a: f32, x: i32) -> f32;
7171
pub fn powif64(a: f64, x: i32) -> f64;
7272

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

82+
#[fixed_stack_segment]
7683
pub fn cosf32(x: f32) -> f32;
84+
#[fixed_stack_segment]
7785
pub fn cosf64(x: f64) -> f64;
7886

87+
#[fixed_stack_segment]
7988
pub fn powf32(a: f32, x: f32) -> f32;
89+
#[fixed_stack_segment]
8090
pub fn powf64(a: f64, x: f64) -> f64;
8191

92+
#[fixed_stack_segment]
8293
pub fn expf32(x: f32) -> f32;
94+
#[fixed_stack_segment]
8395
pub fn expf64(x: f64) -> f64;
8496

8597
pub fn exp2f32(x: f32) -> f32;
@@ -128,4 +140,3 @@ pub extern "rust-intrinsic" {
128140
pub fn bswap32(x: i32) -> i32;
129141
pub fn bswap64(x: i64) -> i64;
130142
}
131-

src/librustc/middle/trans/foreign.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ pub fn trans_intrinsic(ccx: @CrateContext,
546546
item: @ast::foreign_item,
547547
path: ast_map::path,
548548
substs: @param_substs,
549+
attributes: &[ast::attribute],
549550
ref_id: Option<ast::node_id>) {
550551
debug!("trans_intrinsic(item.ident=%s)", *ccx.sess.str_of(item.ident));
551552

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

565+
// Set the fixed stack segment flag if necessary.
566+
if attr::attrs_contains_name(attributes, "fixed_stack_segment") {
567+
set_fixed_stack_segment(fcx.llfn);
568+
}
569+
564570
let mut bcx = top_scope_block(fcx, None), lltop = bcx.llbb;
565571
match *ccx.sess.str_of(item.ident) {
566572
~"atomic_cxchg" => {

src/librustc/middle/trans/monomorphize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ pub fn monomorphic_fn(ccx: @CrateContext,
212212
}
213213
ast_map::node_foreign_item(i, _, _, _) => {
214214
let d = mk_lldecl();
215-
foreign::trans_intrinsic(ccx, d, i, pt, psubsts.get(),
215+
foreign::trans_intrinsic(ccx, d, i, pt, psubsts.get(), i.attrs,
216216
ref_id);
217217
d
218218
}

0 commit comments

Comments
 (0)