Skip to content

Commit f2bdc6d

Browse files
committed
---
yaml --- r: 80867 b: refs/heads/try c: 0ec4d34 h: refs/heads/master i: 80865: 3461063 80863: 6ff3c8f v: v3
1 parent f187459 commit f2bdc6d

File tree

16 files changed

+147
-197
lines changed

16 files changed

+147
-197
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: 22b6f7481f592babf2b4e230120597c47750dae1
5+
refs/heads/try: 0ec4d34b3f0fa1897ace96475a32ff0c8e15b33b
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libextra/fileinput.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,6 @@ mod test {
433433
}
434434

435435
#[test]
436-
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
437436
fn test_make_path_option_vec() {
438437
let strs = [~"some/path",
439438
~"some/other/path"];
@@ -448,7 +447,6 @@ mod test {
448447
}
449448
450449
#[test]
451-
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
452450
fn test_fileinput_read_byte() {
453451
let filenames = make_path_option_vec(vec::from_fn(
454452
3,
@@ -479,7 +477,6 @@ mod test {
479477
}
480478
481479
#[test]
482-
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
483480
fn test_fileinput_read() {
484481
let filenames = make_path_option_vec(vec::from_fn(
485482
3,
@@ -500,7 +497,6 @@ mod test {
500497
}
501498

502499
#[test]
503-
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
504500
fn test_input_vec() {
505501
let mut all_lines = ~[];
506502
let filenames = make_path_option_vec(vec::from_fn(
@@ -524,7 +520,6 @@ mod test {
524520
}
525521

526522
#[test]
527-
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
528523
fn test_input_vec_state() {
529524
let filenames = make_path_option_vec(vec::from_fn(
530525
3,
@@ -547,7 +542,6 @@ mod test {
547542
}
548543

549544
#[test]
550-
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
551545
fn test_empty_files() {
552546
let filenames = make_path_option_vec(vec::from_fn(
553547
3,
@@ -572,7 +566,6 @@ mod test {
572566
}
573567
574568
#[test]
575-
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
576569
fn test_no_trailing_newline() {
577570
let f1 =
578571
Some(Path("tmp/lib-fileinput-test-no-trailing-newline-1.tmp"));
@@ -598,7 +591,6 @@ mod test {
598591
599592
600593
#[test]
601-
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
602594
fn test_next_file() {
603595
let filenames = make_path_option_vec(vec::from_fn(
604596
3,
@@ -630,7 +622,6 @@ mod test {
630622
631623
#[test]
632624
#[should_fail]
633-
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
634625
fn test_input_vec_missing_file() {
635626
do input_vec(make_path_option_vec([~"this/file/doesnt/exist"], true)) |line| {
636627
println(line);

branches/try/src/libextra/workcache.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -496,16 +496,23 @@ fn test() {
496496
use std::io::WriterUtil;
497497
use std::{os, run};
498498

499-
let pth = Path("foo.c");
499+
// Create a path to a new file 'filename' in the directory in which
500+
// this test is running.
501+
fn make_path(filename: ~str) -> Path {
502+
let pth = os::self_exe_path().expect("workcache::test failed").pop().push(filename);
503+
if os::path_exists(&pth) {
504+
os::remove_file(&pth);
505+
}
506+
return pth;
507+
}
508+
509+
let pth = make_path(~"foo.c");
500510
{
501511
let r = io::file_writer(&pth, [io::Create]);
502512
r.unwrap().write_str("int main() { return 0; }");
503513
}
504514

505-
let db_path = os::self_exe_path().expect("workcache::test failed").pop().push("db.json");
506-
if os::path_exists(&db_path) {
507-
os::remove_file(&db_path);
508-
}
515+
let db_path = make_path(~"db.json");
509516

510517
let cx = Context::new(RWArc::new(Database::new(db_path)),
511518
RWArc::new(Logger::new()),
@@ -514,17 +521,19 @@ fn test() {
514521
let s = do cx.with_prep("test1") |prep| {
515522

516523
let subcx = cx.clone();
524+
let pth = pth.clone();
517525

518526
prep.declare_input("file", pth.to_str(), digest_file(&pth));
519527
do prep.exec |_exe| {
520-
let out = Path("foo.o");
521-
run::process_status("gcc", [~"foo.c", ~"-o", out.to_str()]);
528+
let out = make_path(~"foo.o");
529+
run::process_status("gcc", [pth.to_str(), ~"-o", out.to_str()]);
522530

523531
let _proof_of_concept = subcx.prep("subfn");
524532
// Could run sub-rules inside here.
525533

526534
out.to_str()
527535
}
528536
};
537+
529538
io::println(s);
530539
}

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

Lines changed: 61 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ impl<'self> Drop for StatRecorder<'self> {
174174
}
175175
}
176176

177-
// only use this for foreign function ABIs and glue, use `decl_rust_fn` for Rust functions
178177
pub fn decl_fn(llmod: ModuleRef, name: &str, cc: lib::llvm::CallConv, ty: Type) -> ValueRef {
179178
let llfn: ValueRef = do name.with_c_str |buf| {
180179
unsafe {
@@ -186,12 +185,18 @@ pub fn decl_fn(llmod: ModuleRef, name: &str, cc: lib::llvm::CallConv, ty: Type)
186185
return llfn;
187186
}
188187

189-
// only use this for foreign function ABIs and glue, use `decl_rust_fn` for Rust functions
190188
pub fn decl_cdecl_fn(llmod: ModuleRef, name: &str, ty: Type) -> ValueRef {
191189
return decl_fn(llmod, name, lib::llvm::CCallConv, ty);
192190
}
193191

194-
// only use this for foreign function ABIs and glue, use `get_extern_rust_fn` for Rust functions
192+
// Only use this if you are going to actually define the function. It's
193+
// not valid to simply declare a function as internal.
194+
pub fn decl_internal_cdecl_fn(llmod: ModuleRef, name: &str, ty: Type) -> ValueRef {
195+
let llfn = decl_cdecl_fn(llmod, name, ty);
196+
lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage);
197+
return llfn;
198+
}
199+
195200
pub fn get_extern_fn(externs: &mut ExternMap, llmod: ModuleRef, name: &str,
196201
cc: lib::llvm::CallConv, ty: Type) -> ValueRef {
197202
match externs.find_equiv(&name) {
@@ -200,73 +205,7 @@ pub fn get_extern_fn(externs: &mut ExternMap, llmod: ModuleRef, name: &str,
200205
}
201206
let f = decl_fn(llmod, name, cc, ty);
202207
externs.insert(name.to_owned(), f);
203-
f
204-
}
205-
206-
pub fn get_extern_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t,
207-
name: &str) -> ValueRef {
208-
match ccx.externs.find_equiv(&name) {
209-
Some(n) => return *n,
210-
None => ()
211-
}
212-
let f = decl_rust_fn(ccx, inputs, output, name);
213-
ccx.externs.insert(name.to_owned(), f);
214-
f
215-
}
216-
217-
pub fn decl_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t,
218-
name: &str) -> ValueRef {
219-
let llfty = type_of_rust_fn(ccx, inputs, output);
220-
let llfn = decl_cdecl_fn(ccx.llmod, name, llfty);
221-
222-
match ty::get(output).sty {
223-
// `~` pointer return values never alias because ownership is transferred
224-
ty::ty_uniq(*) |
225-
ty::ty_evec(_, ty::vstore_uniq) => {
226-
unsafe {
227-
llvm::LLVMAddReturnAttribute(llfn, lib::llvm::NoAliasAttribute as c_uint);
228-
}
229-
}
230-
_ => ()
231-
}
232-
233-
let uses_outptr = type_of::return_uses_outptr(ccx.tcx, output);
234-
let offset = if uses_outptr { 2 } else { 1 };
235-
236-
for (i, &arg_ty) in inputs.iter().enumerate() {
237-
let llarg = unsafe { llvm::LLVMGetParam(llfn, (offset + i) as c_uint) };
238-
match ty::get(arg_ty).sty {
239-
// `~` pointer parameters never alias because ownership is transferred
240-
ty::ty_uniq(*) |
241-
ty::ty_evec(_, ty::vstore_uniq) |
242-
ty::ty_closure(ty::ClosureTy {sigil: ast::OwnedSigil, _}) => {
243-
unsafe {
244-
llvm::LLVMAddAttribute(llarg, lib::llvm::NoAliasAttribute as c_uint);
245-
}
246-
}
247-
_ => ()
248-
}
249-
}
250-
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-
262-
llfn
263-
}
264-
265-
pub fn decl_internal_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t,
266-
name: &str) -> ValueRef {
267-
let llfn = decl_rust_fn(ccx, inputs, output, name);
268-
lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage);
269-
llfn
208+
return f;
270209
}
271210

272211
pub fn get_extern_const(externs: &mut ExternMap, llmod: ModuleRef,
@@ -870,30 +809,33 @@ pub fn null_env_ptr(ccx: &CrateContext) -> ValueRef {
870809
C_null(Type::opaque_box(ccx).ptr_to())
871810
}
872811
873-
pub fn trans_external_path(ccx: &mut CrateContext, did: ast::DefId, t: ty::t) -> ValueRef {
812+
pub fn trans_external_path(ccx: &mut CrateContext, did: ast::DefId, t: ty::t)
813+
-> ValueRef {
874814
let name = csearch::get_symbol(ccx.sess.cstore, did);
875815
match ty::get(t).sty {
876816
ty::ty_bare_fn(ref fn_ty) => {
877-
match fn_ty.abis.for_arch(ccx.sess.targ_cfg.arch) {
878-
Some(Rust) | Some(RustIntrinsic) => {
879-
get_extern_rust_fn(ccx, fn_ty.sig.inputs, fn_ty.sig.output, name)
880-
}
817+
// Currently llvm_calling_convention triggers unimpl/bug on
818+
// Rust/RustIntrinsic, so those two are handled specially here.
819+
let cconv = match fn_ty.abis.for_arch(ccx.sess.targ_cfg.arch) {
820+
Some(Rust) | Some(RustIntrinsic) => lib::llvm::CCallConv,
881821
Some(*) | None => {
882822
let c = foreign::llvm_calling_convention(ccx, fn_ty.abis);
883-
let cconv = c.unwrap_or(lib::llvm::CCallConv);
884-
let llty = type_of_fn_from_ty(ccx, t);
885-
get_extern_fn(&mut ccx.externs, ccx.llmod, name, cconv, llty)
823+
c.unwrap_or(lib::llvm::CCallConv)
886824
}
887-
}
825+
};
826+
let llty = type_of_fn_from_ty(ccx, t);
827+
return get_extern_fn(&mut ccx.externs, ccx.llmod, name, cconv, llty);
888828
}
889-
ty::ty_closure(ref f) => {
890-
get_extern_rust_fn(ccx, f.sig.inputs, f.sig.output, name)
829+
ty::ty_closure(_) => {
830+
let llty = type_of_fn_from_ty(ccx, t);
831+
return get_extern_fn(&mut ccx.externs, ccx.llmod, name,
832+
lib::llvm::CCallConv, llty);
891833
}
892834
_ => {
893835
let llty = type_of(ccx, t);
894-
get_extern_const(&mut ccx.externs, ccx.llmod, name, llty)
836+
return get_extern_const(&mut ccx.externs, ccx.llmod, name, llty);
895837
}
896-
}
838+
};
897839
}
898840
899841
pub fn invoke(bcx: @mut Block, llfn: ValueRef, llargs: ~[ValueRef],
@@ -1765,7 +1707,8 @@ pub fn new_fn_ctxt(ccx: @mut CrateContext,
17651707
// field of the fn_ctxt with
17661708
pub fn create_llargs_for_fn_args(cx: @mut FunctionContext,
17671709
self_arg: self_arg,
1768-
args: &[ast::arg])
1710+
args: &[ast::arg],
1711+
arg_tys: &[ty::t])
17691712
-> ~[ValueRef] {
17701713
let _icx = push_ctxt("create_llargs_for_fn_args");
17711714

@@ -1783,7 +1726,23 @@ pub fn create_llargs_for_fn_args(cx: @mut FunctionContext,
17831726
// Return an array containing the ValueRefs that we get from
17841727
// llvm::LLVMGetParam for each argument.
17851728
do vec::from_fn(args.len()) |i| {
1786-
unsafe { llvm::LLVMGetParam(cx.llfn, cx.arg_pos(i) as c_uint) }
1729+
let arg_n = cx.arg_pos(i);
1730+
let arg_ty = arg_tys[i];
1731+
let llarg = unsafe {llvm::LLVMGetParam(cx.llfn, arg_n as c_uint) };
1732+
1733+
match ty::get(arg_ty).sty {
1734+
// `~` pointer parameters never alias because ownership is transferred
1735+
ty::ty_uniq(*) |
1736+
ty::ty_evec(_, ty::vstore_uniq) |
1737+
ty::ty_closure(ty::ClosureTy {sigil: ast::OwnedSigil, _}) => {
1738+
unsafe {
1739+
llvm::LLVMAddAttribute(llarg, lib::llvm::NoAliasAttribute as c_uint);
1740+
}
1741+
}
1742+
_ => ()
1743+
}
1744+
1745+
llarg
17871746
}
17881747
}
17891748

@@ -1937,7 +1896,8 @@ pub fn trans_closure(ccx: @mut CrateContext,
19371896

19381897
// Set up arguments to the function.
19391898
let arg_tys = ty::ty_fn_args(node_id_type(bcx, id));
1940-
let raw_llargs = create_llargs_for_fn_args(fcx, self_arg, decl.inputs);
1899+
let raw_llargs = create_llargs_for_fn_args(fcx, self_arg,
1900+
decl.inputs, arg_tys);
19411901

19421902
// Set the fixed stack segment flag if necessary.
19431903
if attr::contains_name(attributes, "fixed_stack_segment") {
@@ -2001,6 +1961,18 @@ pub fn trans_fn(ccx: @mut CrateContext,
20011961
param_substs.repr(ccx.tcx));
20021962
let _icx = push_ctxt("trans_fn");
20031963
let output_type = ty::ty_fn_ret(ty::node_id_to_type(ccx.tcx, id));
1964+
1965+
match ty::get(output_type).sty {
1966+
// `~` pointer return values never alias because ownership is transferred
1967+
ty::ty_uniq(*) |
1968+
ty::ty_evec(_, ty::vstore_uniq) => {
1969+
unsafe {
1970+
llvm::LLVMAddReturnAttribute(llfndecl, lib::llvm::NoAliasAttribute as c_uint);
1971+
}
1972+
}
1973+
_ => ()
1974+
}
1975+
20041976
trans_closure(ccx,
20051977
path.clone(),
20061978
decl,
@@ -2148,7 +2120,7 @@ pub fn trans_enum_variant_or_tuple_like_struct<A:IdAndTy>(
21482120

21492121
let arg_tys = ty::ty_fn_args(ctor_ty);
21502122

2151-
let raw_llargs = create_llargs_for_fn_args(fcx, no_self, fn_args);
2123+
let raw_llargs = create_llargs_for_fn_args(fcx, no_self, fn_args, arg_tys);
21522124

21532125
let bcx = fcx.entry_bcx.unwrap();
21542126

@@ -2326,28 +2298,10 @@ pub fn register_fn(ccx: @mut CrateContext,
23262298
node_id: ast::NodeId,
23272299
node_type: ty::t)
23282300
-> ValueRef {
2329-
let f = match ty::get(node_type).sty {
2330-
ty::ty_bare_fn(ref f) => {
2331-
assert!(f.abis.is_rust() || f.abis.is_intrinsic());
2332-
f
2333-
}
2334-
_ => fail!("expected bare rust fn or an intrinsic")
2335-
};
2336-
2337-
let llfn = decl_rust_fn(ccx, f.sig.inputs, f.sig.output, sym);
2338-
ccx.item_symbols.insert(node_id, sym);
2339-
2340-
// FIXME #4404 android JNI hacks
2341-
let is_entry = is_entry_fn(&ccx.sess, node_id) && (!*ccx.sess.building_library ||
2342-
(*ccx.sess.building_library &&
2343-
ccx.sess.targ_cfg.os == session::OsAndroid));
2344-
if is_entry {
2345-
create_entry_wrapper(ccx, sp, llfn);
2346-
}
2347-
llfn
2301+
let llfty = type_of_fn_from_ty(ccx, node_type);
2302+
register_fn_llvmty(ccx, sp, sym, node_id, lib::llvm::CCallConv, llfty)
23482303
}
23492304

2350-
// only use this for foreign function ABIs and glue, use `register_fn` for Rust functions
23512305
pub fn register_fn_llvmty(ccx: @mut CrateContext,
23522306
sp: Span,
23532307
sym: ~str,

0 commit comments

Comments
 (0)