Skip to content

Mark &mut parameters as noalias #6742

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 26, 2013
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
15 changes: 14 additions & 1 deletion src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,20 @@ pub fn create_llargs_for_fn_args(cx: fn_ctxt,
vec::from_fn(args.len(), |i| {
unsafe {
let arg_n = first_real_arg + i;
llvm::LLVMGetParam(cx.llfn, arg_n as c_uint)
let arg = &args[i];
let llarg = llvm::LLVMGetParam(cx.llfn, arg_n as c_uint);

// Mark `&mut T` as no-alias, as the borrowck pass ensures it's true
match arg.ty.node {
ast::ty_rptr(_, mt) => {
if mt.mutbl == ast::m_mutbl {
llvm::LLVMAddAttribute(llarg, lib::llvm::NoAliasAttribute as c_uint);
}
}
_ => {}
}

llarg
}
})
}
Expand Down