extern {}
extern {
+ #[allocator]
fn je_mallocx(size: size_t, flags: c_int) -> *mut c_void;
fn je_rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void;
fn je_xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t;
#![feature(no_std)]
#![no_std]
+#![feature(allocator)]
#![feature(lang_items, unsafe_destructor)]
#![feature(box_syntax)]
#![feature(optin_builtin_traits)]
use back::link::{mangle_exported_name};
use back::{link, abi};
use lint;
-use llvm::{BasicBlockRef, Linkage, ValueRef, Vector, get_param};
+use llvm::{AttrHelper, BasicBlockRef, Linkage, ValueRef, Vector, get_param};
use llvm;
use metadata::{csearch, encoder, loader};
use middle::astencode;
llvm::FunctionIndex as c_uint,
llvm::ColdAttribute as uint64_t)
},
+ "allocator" => {
+ llvm::NoAliasAttribute.apply_llfn(llvm::ReturnIndex as c_uint, llfn);
+ }
_ => used = false,
}
if used {
ccx.sess().bug("unexpected intrinsic in trans_external_path")
}
_ => {
- foreign::register_foreign_item_fn(ccx, fn_ty.abi, t,
- &name[..])
+ let llfn = foreign::register_foreign_item_fn(ccx, fn_ty.abi, t, &name[..]);
+ let attrs = csearch::get_item_attrs(&ccx.sess().cstore, did);
+ set_llvm_fn_attrs(ccx, &attrs, llfn);
+ llfn
}
}
}
let abi = ccx.tcx().map.get_foreign_abi(id);
let ty = ty::node_id_to_type(ccx.tcx(), ni.id);
let name = foreign::link_name(&*ni);
- foreign::register_foreign_item_fn(ccx, abi, ty, &name)
+ let llfn = foreign::register_foreign_item_fn(ccx, abi, ty, &name);
+ set_llvm_fn_attrs(ccx, &ni.attrs, llfn);
+ llfn
}
ast::ForeignItemStatic(..) => {
foreign::register_static(ccx, &*ni)
"foreign fn's sty isn't a bare_fn_ty?")
}
- register_foreign_item_fn(ccx, abi, ty,
- &lname);
+ let llfn = register_foreign_item_fn(ccx, abi, ty, &lname);
+ base::set_llvm_fn_attrs(ccx, &foreign_item.attrs, llfn);
// Unlike for other items, we shouldn't call
// `base::update_linkage` here. Foreign items have
// special linkage requirements, which are handled
("box_syntax", "1.0.0", Active),
("on_unimplemented", "1.0.0", Active),
("simd_ffi", "1.0.0", Active),
+ ("allocator", "1.0.0", Active),
("if_let", "1.0.0", Accepted),
("while_let", "1.0.0", Accepted),
("rustc_on_unimplemented", Gated("on_unimplemented",
"the `#[rustc_on_unimplemented]` attribute \
is an experimental feature")),
+ ("allocator", Gated("allocator",
+ "the `#[allocator]` attribute is an experimental feature")),
("rustc_variance", Gated("rustc_attrs",
"the `#[rustc_variance]` attribute \
is an experimental feature")),