Skip to content

Commit 22b6f74

Browse files
committed
document why attributes are set on CallInst
1 parent b2eb1c0 commit 22b6f74

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/librustc/middle/trans/callee.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,12 +706,15 @@ pub fn trans_call_inner(in_cx: @mut Block,
706706
_ => {}
707707
}
708708

709-
// Invoke the actual rust fn and update bcx/llresult.
709+
// A function pointer is called without the declaration available, so we have to apply
710+
// any attributes with ABI implications directly to the call instruction. Right now, the
711+
// only attribute we need to worry about is `sret`.
710712
let mut attrs = ~[];
711713
if type_of::return_uses_outptr(in_cx.tcx(), ret_ty) {
712714
attrs.push((1, StructRetAttribute));
713715
}
714716

717+
// The `noalias` attribute on the return value is useful to a function ptr caller.
715718
match ty::get(ret_ty).sty {
716719
// `~` pointer return values never alias because ownership is transferred
717720
ty::ty_uniq(*) |
@@ -721,6 +724,7 @@ pub fn trans_call_inner(in_cx: @mut Block,
721724
_ => ()
722725
}
723726

727+
// Invoke the actual rust fn and update bcx/llresult.
724728
let (llret, b) = base::invoke(bcx, llfn, llargs, attrs);
725729
bcx = b;
726730
llresult = llret;

src/librustc/middle/trans/foreign.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ pub fn trans_native_call(bcx: @mut Block,
264264
}
265265
};
266266

267+
// A function pointer is called without the declaration available, so we have to apply
268+
// any attributes with ABI implications directly to the call instruction. Right now, the
269+
// only attribute we need to worry about is `sret`.
267270
let attrs;
268271
if fn_type.sret {
269272
attrs = &[(1, StructRetAttribute)];

0 commit comments

Comments
 (0)