1
Fork 0

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.
This commit is contained in:
Björn Steinbrink 2014-02-23 12:25:11 +01:00 committed by Alex Crichton
parent 8812e8ad49
commit 0309104cc5

View file

@ -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);
}
}
}