Skip to content

Commit

Permalink
Mark by-value parameters that are passed on the stack as nocapture
Browse files Browse the repository at this point in the history
The by-value argument is a copy that is only valid for the duration of
the function call, therefore keeping any pointer to it that outlives the
call is illegal.
  • Loading branch information
dotdash authored and alexcrichton committed Feb 25, 2014
1 parent 8812e8a commit 0309104
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ pub fn decl_rust_fn(ccx: &CrateContext, has_env: bool,
if !type_is_immediate(ccx, arg_ty) {
unsafe {
llvm::LLVMAddAttribute(llarg, lib::llvm::NoAliasAttribute as c_uint);
llvm::LLVMAddAttribute(llarg, lib::llvm::NoCaptureAttribute as c_uint);
}
}
}
Expand Down

0 comments on commit 0309104

Please sign in to comment.