Skip to content

Commit 3e04bc4

Browse files
committed
---
yaml --- r: 80582 b: refs/heads/auto c: b2eb1c0 h: refs/heads/master v: v3
1 parent 2cec316 commit 3e04bc4

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
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 3c31cf25b18a1300d723e7a3b155810b23d4b472
16+
refs/heads/auto: b2eb1c01a45cbb7bfc40f24073b60de61e3fad47
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/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/auto/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/auto/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)