From 95877e7b379ee14d36e27b632b7d2e8d504cc8b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Sun, 23 Feb 2014 12:25:11 +0100 Subject: [PATCH] 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. --- src/librustc/middle/trans/base.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index d920378f5089d..ee21e1e49d022 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -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); } } }