Skip to content

Commit 3461063

Browse files
committed
---
yaml --- r: 80865 b: refs/heads/try c: b2eb1c0 h: refs/heads/master i: 80863: 6ff3c8f v: v3
1 parent 21b89a6 commit 3461063

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cbd1eefbd350797b783df119fed7956d7e1c74ad
5-
refs/heads/try: 3c31cf25b18a1300d723e7a3b155810b23d4b472
5+
refs/heads/try: b2eb1c01a45cbb7bfc40f24073b60de61e3fad47
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/librustc/middle/trans/base.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,17 @@ pub fn decl_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t,
248248
}
249249
}
250250

251+
// The out pointer will never alias with any other pointers, as the object only exists at a
252+
// language level after the call. It can also be tagged with SRet to indicate that it is
253+
// guaranteed to point to a usable block of memory for the type.
254+
if uses_outptr {
255+
unsafe {
256+
let outptr = llvm::LLVMGetParam(llfn, 0);
257+
llvm::LLVMAddAttribute(outptr, lib::llvm::StructRetAttribute as c_uint);
258+
llvm::LLVMAddAttribute(outptr, lib::llvm::NoAliasAttribute as c_uint);
259+
}
260+
}
261+
251262
llfn
252263
}
253264

branches/try/src/librustc/middle/trans/callee.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use std::vec;
2020

2121
use back::abi;
2222
use driver::session;
23-
use lib::llvm::ValueRef;
23+
use lib::llvm::{ValueRef, NoAliasAttribute, StructRetAttribute};
2424
use lib::llvm::llvm;
2525
use metadata::csearch;
2626
use middle::trans::base;
@@ -707,7 +707,21 @@ pub fn trans_call_inner(in_cx: @mut Block,
707707
}
708708

709709
// Invoke the actual rust fn and update bcx/llresult.
710-
let (llret, b) = base::invoke(bcx, llfn, llargs, []);
710+
let mut attrs = ~[];
711+
if type_of::return_uses_outptr(in_cx.tcx(), ret_ty) {
712+
attrs.push((1, StructRetAttribute));
713+
}
714+
715+
match ty::get(ret_ty).sty {
716+
// `~` pointer return values never alias because ownership is transferred
717+
ty::ty_uniq(*) |
718+
ty::ty_evec(_, ty::vstore_uniq) => {
719+
attrs.push((0, NoAliasAttribute));
720+
}
721+
_ => ()
722+
}
723+
724+
let (llret, b) = base::invoke(bcx, llfn, llargs, attrs);
711725
bcx = b;
712726
llresult = llret;
713727

branches/try/src/librustc/middle/trans/foreign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: @mut CrateContext,
497497
// Rust expects to use an outpointer. If the foreign fn
498498
// also uses an outpointer, we can reuse it, but the types
499499
// may vary, so cast first to the Rust type. If the
500-
// foriegn fn does NOT use an outpointer, we will have to
500+
// foreign fn does NOT use an outpointer, we will have to
501501
// alloca some scratch space on the stack.
502502
match foreign_outptr {
503503
Some(llforeign_outptr) => {

0 commit comments

Comments
 (0)