Skip to content

Commit

Permalink
noalias on all &mut parameters is too coarse
Browse files Browse the repository at this point in the history
it can alias `&const` and `@mut`
  • Loading branch information
thestinger committed May 28, 2013
1 parent 05735a9 commit accc527
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1694,16 +1694,13 @@ pub fn create_llargs_for_fn_args(cx: fn_ctxt,
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);
}
}
// `~` pointers never alias other parameters, because ownership was transferred
ast::ty_uniq(_) => {
llvm::LLVMAddAttribute(llarg, lib::llvm::NoAliasAttribute as c_uint);
}
// FIXME: #6785: `&mut` can only alias `&const` and `@mut`, we should check for
// those in the other parameters and then mark it as `noalias` if there aren't any
_ => {}
}

Expand Down

5 comments on commit accc527

@bors
Copy link
Contributor

@bors bors commented on accc527 May 28, 2013

Choose a reason for hiding this comment

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

@bors
Copy link
Contributor

@bors bors commented on accc527 May 28, 2013

Choose a reason for hiding this comment

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

merging thestinger/rust/revert-noalias-mut-rptr = accc527 into auto

@bors
Copy link
Contributor

@bors bors commented on accc527 May 28, 2013

Choose a reason for hiding this comment

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

thestinger/rust/revert-noalias-mut-rptr = accc527 merged ok, testing candidate = 833ed21

@bors
Copy link
Contributor

@bors bors commented on accc527 May 28, 2013

Choose a reason for hiding this comment

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

@bors
Copy link
Contributor

@bors bors commented on accc527 May 28, 2013

Choose a reason for hiding this comment

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

fast-forwarding incoming to auto = 833ed21

Please sign in to comment.