Skip to content

Commit 0309104

Browse files
dotdashalexcrichton
authored andcommitted
Mark by-value parameters that are passed on the stack as nocapture
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.
1 parent 8812e8a commit 0309104

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/librustc/middle/trans/base.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ pub fn decl_rust_fn(ccx: &CrateContext, has_env: bool,
282282
if !type_is_immediate(ccx, arg_ty) {
283283
unsafe {
284284
llvm::LLVMAddAttribute(llarg, lib::llvm::NoAliasAttribute as c_uint);
285+
llvm::LLVMAddAttribute(llarg, lib::llvm::NoCaptureAttribute as c_uint);
285286
}
286287
}
287288
}

0 commit comments

Comments
 (0)