Skip to content

Add noalias to safe shared reference parameters #15970

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
Jul 25, 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
5 changes: 4 additions & 1 deletion src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2140,7 +2140,10 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t)
attrs.push((idx, llvm::NonNullAttribute as u64));
}
// `&mut` pointer parameters never alias other parameters, or mutable global data
ty::ty_rptr(b, mt) if mt.mutbl == ast::MutMutable => {
// `&` pointer parameters never alias either (for LLVM's purposes) as long as the
// interior is safe
ty::ty_rptr(b, mt) if mt.mutbl == ast::MutMutable ||
!ty::type_contents(ccx.tcx(), mt.ty).interior_unsafe() => {
attrs.push((idx, llvm::NoAliasAttribute as u64));
attrs.push((idx, llvm::NonNullAttribute as u64));
match b {
Expand Down