Skip to content

Commit

Permalink
Add noalias to safe shared reference parameters
Browse files Browse the repository at this point in the history
This add the LLVM noalias attribute to parameters of a
shared reference type (&) which have a safe interior.
  • Loading branch information
Zoxc committed Jul 25, 2014
1 parent a455345 commit 4c2d4cd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/librustc/middle/trans/base.rs
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

5 comments on commit 4c2d4cd

@bors
Copy link
Contributor

@bors bors commented on 4c2d4cd Jul 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from cmr
at Zoxc@4c2d4cd

@bors
Copy link
Contributor

@bors bors commented on 4c2d4cd Jul 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging Zoxc/rust/noalias-ref = 4c2d4cd into auto

@bors
Copy link
Contributor

@bors bors commented on 4c2d4cd Jul 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zoxc/rust/noalias-ref = 4c2d4cd merged ok, testing candidate = 44019c7

@bors
Copy link
Contributor

@bors bors commented on 4c2d4cd Jul 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 44019c7

Please sign in to comment.