Rename the no_split_stack attribute to no_stack_check

The old name is misleading as we haven't had segmented stacks in quite some
time. But we still recognize it, with a deprecation warning.
This commit is contained in:
Keegan McAllister 2014-09-05 17:28:24 -07:00
parent 79d056f94b
commit db3bd23467
8 changed files with 54 additions and 31 deletions

View file

@ -571,6 +571,7 @@ impl LintPass for UnusedAttribute {
"no_builtins",
"no_mangle",
"no_split_stack",
"no_stack_check",
"packed",
"static_assert",
"thread_local",

View file

@ -245,7 +245,7 @@ fn get_extern_rust_fn(ccx: &CrateContext, fn_ty: ty::t, name: &str, did: ast::De
let f = decl_rust_fn(ccx, fn_ty, name);
csearch::get_item_attrs(&ccx.sess().cstore, did, |attrs| {
set_llvm_fn_attrs(attrs.as_slice(), f)
set_llvm_fn_attrs(ccx, attrs.as_slice(), f)
});
ccx.externs().borrow_mut().insert(name.to_string(), f);
@ -436,7 +436,7 @@ pub fn set_inline_hint(f: ValueRef) {
llvm::SetFunctionAttribute(f, llvm::InlineHintAttribute)
}
pub fn set_llvm_fn_attrs(attrs: &[ast::Attribute], llfn: ValueRef) {
pub fn set_llvm_fn_attrs(ccx: &CrateContext, attrs: &[ast::Attribute], llfn: ValueRef) {
use syntax::attr::*;
// Set the inline hint if there is one
match find_inline_attr(attrs) {
@ -446,16 +446,24 @@ pub fn set_llvm_fn_attrs(attrs: &[ast::Attribute], llfn: ValueRef) {
InlineNone => { /* fallthrough */ }
}
// Add the no-split-stack attribute if requested
if contains_name(attrs, "no_split_stack") {
unset_split_stack(llfn);
}
if contains_name(attrs, "cold") {
unsafe {
llvm::LLVMAddFunctionAttribute(llfn,
llvm::FunctionIndex as c_uint,
llvm::ColdAttribute as uint64_t)
for attr in attrs.iter() {
let mut used = true;
match attr.name().get() {
"no_stack_check" => unset_split_stack(llfn),
"no_split_stack" => {
unset_split_stack(llfn);
ccx.sess().span_warn(attr.span,
"no_split_stack is a deprecated synonym for no_stack_check");
}
"cold" => unsafe {
llvm::LLVMAddFunctionAttribute(llfn,
llvm::FunctionIndex as c_uint,
llvm::ColdAttribute as uint64_t)
},
_ => used = false,
}
if used {
attr::mark_used(attr);
}
}
}
@ -2751,7 +2759,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
sym,
i.id)
};
set_llvm_fn_attrs(i.attrs.as_slice(), llfn);
set_llvm_fn_attrs(ccx, i.attrs.as_slice(), llfn);
llfn
}
@ -2893,7 +2901,7 @@ fn register_method(ccx: &CrateContext, id: ast::NodeId,
let sym = exported_name(ccx, id, mty, m.attrs.as_slice());
let llfn = register_fn(ccx, m.span, sym, id, mty);
set_llvm_fn_attrs(m.attrs.as_slice(), llfn);
set_llvm_fn_attrs(ccx, m.attrs.as_slice(), llfn);
llfn
}

View file

@ -640,7 +640,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
id, t.repr(tcx));
let llfn = base::decl_internal_rust_fn(ccx, t, ps.as_slice());
base::set_llvm_fn_attrs(attrs, llfn);
base::set_llvm_fn_attrs(ccx, attrs, llfn);
base::trans_fn(ccx, decl, body, llfn, param_substs, id, []);
llfn
}

View file

@ -149,7 +149,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
};
let setup_lldecl = |lldecl, attrs: &[ast::Attribute]| {
base::update_linkage(ccx, lldecl, None, base::OriginalTranslation);
set_llvm_fn_attrs(attrs, lldecl);
set_llvm_fn_attrs(ccx, attrs, lldecl);
let is_first = !ccx.available_monomorphizations().borrow().contains(&s);
if is_first {

View file

@ -39,9 +39,9 @@ static DEFAULT_STACK_SIZE: uint = 1024 * 1024;
// This is the starting point of rust os threads. The first thing we do
// is make sure that we don't trigger __morestack (also why this has a
// no_split_stack annotation), and then we extract the main function
// no_stack_check annotation), and then we extract the main function
// and invoke it.
#[no_split_stack]
#[no_stack_check]
extern fn thread_start(main: *mut libc::c_void) -> imp::rust_thread_return {
unsafe {
stack::record_os_managed_stack_bounds(0, uint::MAX);

View file

@ -11,7 +11,7 @@
// ignore-android: FIXME(#10381)
// This test case checks if function arguments already have the correct value when breaking at the
// beginning of a function. Functions with the #[no_split_stack] attribute have the same prologue as
// beginning of a function. Functions with the #[no_stack_check] attribute have the same prologue as
// regular C functions compiled with GCC or Clang and therefore are better handled by GDB. As a
// consequence, and as opposed to regular Rust functions, we can set the breakpoints via the
// function name (and don't have to fall back on using line numbers). For LLDB this shouldn't make
@ -246,7 +246,7 @@
#![allow(unused_variable)]
#[no_split_stack]
#[no_stack_check]
fn immediate_args(a: int, b: bool, c: f64) {
()
}
@ -262,42 +262,42 @@ struct BigStruct {
h: u64
}
#[no_split_stack]
#[no_stack_check]
fn non_immediate_args(a: BigStruct, b: BigStruct) {
()
}
#[no_split_stack]
#[no_stack_check]
fn binding(a: i64, b: u64, c: f64) {
let x = 0i;
}
#[no_split_stack]
#[no_stack_check]
fn assignment(mut a: u64, b: u64, c: f64) {
a = b;
}
#[no_split_stack]
#[no_stack_check]
fn function_call(x: u64, y: u64, z: f64) {
std::io::stdio::print("Hi!")
}
#[no_split_stack]
#[no_stack_check]
fn identifier(x: u64, y: u64, z: f64) -> u64 {
x
}
#[no_split_stack]
#[no_stack_check]
fn return_expr(x: u64, y: u64, z: f64) -> u64 {
return x;
}
#[no_split_stack]
#[no_stack_check]
fn arithmetic_expr(x: u64, y: u64, z: f64) -> u64 {
x + y
}
#[no_split_stack]
#[no_stack_check]
fn if_expr(x: u64, y: u64, z: f64) -> u64 {
if x + y < 1000 {
x
@ -306,7 +306,7 @@ fn if_expr(x: u64, y: u64, z: f64) -> u64 {
}
}
#[no_split_stack]
#[no_stack_check]
fn while_expr(mut x: u64, y: u64, z: u64) -> u64 {
while x + y < 1000 {
x += z
@ -314,7 +314,7 @@ fn while_expr(mut x: u64, y: u64, z: u64) -> u64 {
return x;
}
#[no_split_stack]
#[no_stack_check]
fn loop_expr(mut x: u64, y: u64, z: u64) -> u64 {
loop {
x += z;

View file

@ -0,0 +1,14 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//~ WARNING no_split_stack is a deprecated synonym for no_stack_check
#[no_split_stack]
fn main() {
}

View file

@ -25,7 +25,7 @@ extern "rust-intrinsic" { fn transmute<T, U>(t: T) -> U; }
#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} }
#[start]
#[no_split_stack]
#[no_stack_check]
fn main(_: int, _: *const *const u8) -> int {
unsafe {
let (ptr, _): (*const u8, uint) = transmute("Hello!\0");