We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e2f8b51 commit 2c2346eCopy full SHA for 2c2346e
src/librustc/middle/trans/base.rs
@@ -1694,7 +1694,20 @@ pub fn create_llargs_for_fn_args(cx: fn_ctxt,
1694
vec::from_fn(args.len(), |i| {
1695
unsafe {
1696
let arg_n = first_real_arg + i;
1697
- llvm::LLVMGetParam(cx.llfn, arg_n as c_uint)
+ let arg = &args[i];
1698
+ let llarg = llvm::LLVMGetParam(cx.llfn, arg_n as c_uint);
1699
+
1700
+ // Mark `&mut T` as no-alias, as the borrowck pass ensures it's true
1701
+ match arg.ty.node {
1702
+ ast::ty_rptr(_, mt) => {
1703
+ if mt.mutbl == ast::m_mutbl {
1704
+ llvm::LLVMAddAttribute(llarg, lib::llvm::NoAliasAttribute as c_uint);
1705
+ }
1706
1707
+ _ => {}
1708
1709
1710
+ llarg
1711
}
1712
})
1713
0 commit comments