Skip to content

add back noalias to &mut T pointer parameters #13935

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
May 5, 2014
Merged
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
22 changes: 11 additions & 11 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@ fn decl_fn(llmod: ModuleRef, name: &str, cc: lib::llvm::CallConv,
}
}
// `~` pointer return values never alias because ownership is transferred
// FIXME #6750 ~Trait cannot be directly marked as
// noalias because the actual object pointer is nested.
ty::ty_uniq(..) // | ty::ty_trait(_, _, ty::UniqTraitStore, _, _)
=> {
unsafe {
Expand Down Expand Up @@ -258,23 +256,25 @@ pub fn decl_rust_fn(ccx: &CrateContext, has_env: bool,
let llarg = unsafe { llvm::LLVMGetParam(llfn, (offset + i) as c_uint) };
match ty::get(arg_ty).sty {
// `~` pointer parameters never alias because ownership is transferred
// FIXME #6750 ~Trait cannot be directly marked as
// noalias because the actual object pointer is nested.
ty::ty_uniq(..) | // ty::ty_trait(_, _, ty::UniqTraitStore, _, _) |
ty::ty_closure(~ty::ClosureTy {store: ty::UniqTraitStore, ..}) => {
ty::ty_uniq(..) => {
unsafe {
llvm::LLVMAddAttribute(llarg, lib::llvm::NoAliasAttribute as c_uint);
}
},
// When a reference in an argument has no named lifetime, it's
// impossible for that reference to escape this function(ie, be
// returned).
}
// `&mut` pointer parameters never alias other parameters, or mutable global data
ty::ty_rptr(_, mt) if mt.mutbl == ast::MutMutable => {
unsafe {
llvm::LLVMAddAttribute(llarg, lib::llvm::NoAliasAttribute as c_uint);
}
}
// When a reference in an argument has no named lifetime, it's impossible for that
// reference to escape this function (returned or stored beyond the call by a closure).
ty::ty_rptr(ReLateBound(_, BrAnon(_)), _) => {
debug!("marking argument of {} as nocapture because of anonymous lifetime", name);
unsafe {
llvm::LLVMAddAttribute(llarg, lib::llvm::NoCaptureAttribute as c_uint);
}
},
}
_ => {
// For non-immediate arguments the callee gets its own copy of
// the value on the stack, so there are no aliases
Expand Down