diff options
| -rw-r--r-- | src/librustc/middle/trans/callee.rs | 6 | ||||
| -rw-r--r-- | src/librustc/middle/trans/foreign.rs | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index d55589cb7e8..54c905a4c16 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -706,12 +706,15 @@ pub fn trans_call_inner(in_cx: @mut Block, _ => {} } - // Invoke the actual rust fn and update bcx/llresult. + // A function pointer is called without the declaration available, so we have to apply + // any attributes with ABI implications directly to the call instruction. Right now, the + // only attribute we need to worry about is `sret`. let mut attrs = ~[]; if type_of::return_uses_outptr(in_cx.tcx(), ret_ty) { attrs.push((1, StructRetAttribute)); } + // The `noalias` attribute on the return value is useful to a function ptr caller. match ty::get(ret_ty).sty { // `~` pointer return values never alias because ownership is transferred ty::ty_uniq(*) | @@ -721,6 +724,7 @@ pub fn trans_call_inner(in_cx: @mut Block, _ => () } + // Invoke the actual rust fn and update bcx/llresult. let (llret, b) = base::invoke(bcx, llfn, llargs, attrs); bcx = b; llresult = llret; diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index 3836bd5c47c..b00d77d72dd 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -264,6 +264,9 @@ pub fn trans_native_call(bcx: @mut Block, } }; + // A function pointer is called without the declaration available, so we have to apply + // any attributes with ABI implications directly to the call instruction. Right now, the + // only attribute we need to worry about is `sret`. let attrs; if fn_type.sret { attrs = &[(1, StructRetAttribute)]; |
