Skip to content

Commit 02d1e3f

Browse files
committed
---
yaml --- r: 60752 b: refs/heads/auto c: 6c03fbf h: refs/heads/master v: v3
1 parent 49cff55 commit 02d1e3f

File tree

13 files changed

+136
-154
lines changed

13 files changed

+136
-154
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: a85993ff69d5ba9a2cf07b0d1889b3ddf2e099e5
17+
refs/heads/auto: 6c03fbfefd950f5a5d54b3b86f84657f9908f5ff
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

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

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,7 +1593,7 @@ pub fn new_fn_ctxt_w_id(ccx: @CrateContext,
15931593
impl_id: Option<ast::def_id>,
15941594
param_substs: Option<@param_substs>,
15951595
sp: Option<span>)
1596-
-> (fn_ctxt, bool) {
1596+
-> fn_ctxt {
15971597
for param_substs.each |p| { p.validate(); }
15981598

15991599
debug!("new_fn_ctxt_w_id(path=%s, id=%?, impl_id=%?, \
@@ -1611,21 +1611,19 @@ pub fn new_fn_ctxt_w_id(ccx: @CrateContext,
16111611
ty::subst_tps(ccx.tcx, substs.tys, substs.self_ty, output_type)
16121612
}
16131613
};
1614-
let imm = ty::type_is_immediate(substd_output_type);
1614+
let is_immediate = ty::type_is_immediate(substd_output_type);
16151615

16161616
let fcx = @mut fn_ctxt_ {
16171617
llfn: llfndecl,
1618-
llenv: unsafe {
1619-
llvm::LLVMGetParam(llfndecl, arg_env(imm) as c_uint)
1620-
},
1618+
llenv: unsafe { llvm::LLVMGetParam(llfndecl, 1u as c_uint) },
16211619
llretptr: None,
16221620
llstaticallocas: llbbs.sa,
16231621
llloadenv: None,
16241622
llreturn: llbbs.rt,
16251623
llself: None,
16261624
personality: None,
16271625
loop_ret: None,
1628-
has_immediate_return_value: imm,
1626+
has_immediate_return_value: is_immediate,
16291627
llargs: @mut HashMap::new(),
16301628
lllocals: @mut HashMap::new(),
16311629
llupvars: @mut HashMap::new(),
@@ -1638,15 +1636,15 @@ pub fn new_fn_ctxt_w_id(ccx: @CrateContext,
16381636
};
16391637

16401638
fcx.llretptr = Some(make_return_pointer(fcx, substd_output_type));
1641-
(fcx, imm)
1639+
fcx
16421640
}
16431641

16441642
pub fn new_fn_ctxt(ccx: @CrateContext,
16451643
path: path,
16461644
llfndecl: ValueRef,
16471645
output_type: ty::t,
16481646
sp: Option<span>)
1649-
-> (fn_ctxt, bool) {
1647+
-> fn_ctxt {
16501648
new_fn_ctxt_w_id(ccx, path, llfndecl, -1, output_type, None, None, sp)
16511649
}
16521650

@@ -1666,8 +1664,7 @@ pub fn new_fn_ctxt(ccx: @CrateContext,
16661664
// field of the fn_ctxt with
16671665
pub fn create_llargs_for_fn_args(cx: fn_ctxt,
16681666
self_arg: self_arg,
1669-
args: &[ast::arg],
1670-
ret_imm: bool)
1667+
args: &[ast::arg])
16711668
-> ~[ValueRef] {
16721669
let _icx = cx.insn_ctxt("create_llargs_for_fn_args");
16731670

@@ -1693,7 +1690,7 @@ pub fn create_llargs_for_fn_args(cx: fn_ctxt,
16931690
// llvm::LLVMGetParam for each argument.
16941691
vec::from_fn(args.len(), |i| {
16951692
unsafe {
1696-
let arg_n = arg_pos(ret_imm, i);
1693+
let arg_n = first_real_arg + i;
16971694
let arg = &args[i];
16981695
let llarg = llvm::LLVMGetParam(cx.llfn, arg_n as c_uint);
16991696

@@ -1832,15 +1829,15 @@ pub fn trans_closure(ccx: @CrateContext,
18321829
param_substs.repr(ccx.tcx));
18331830

18341831
// Set up arguments to the function.
1835-
let (fcx, imm) = new_fn_ctxt_w_id(ccx,
1836-
path,
1837-
llfndecl,
1838-
id,
1839-
output_type,
1840-
impl_id,
1841-
param_substs,
1842-
Some(body.span));
1843-
let raw_llargs = create_llargs_for_fn_args(fcx, self_arg, decl.inputs, imm);
1832+
let fcx = new_fn_ctxt_w_id(ccx,
1833+
path,
1834+
llfndecl,
1835+
id,
1836+
output_type,
1837+
impl_id,
1838+
param_substs,
1839+
Some(body.span));
1840+
let raw_llargs = create_llargs_for_fn_args(fcx, self_arg, decl.inputs);
18441841

18451842
// Set the fixed stack segment flag if necessary.
18461843
if attr::attrs_contains_name(attributes, "fixed_stack_segment") {
@@ -1965,16 +1962,16 @@ pub fn trans_enum_variant(ccx: @CrateContext,
19651962
ty_param_substs,
19661963
None,
19671964
ty::node_id_to_type(ccx.tcx, enum_id));
1968-
let (fcx, imm) = new_fn_ctxt_w_id(ccx,
1969-
~[],
1970-
llfndecl,
1971-
variant.node.id,
1972-
enum_ty,
1973-
None,
1974-
param_substs,
1975-
None);
1976-
1977-
let raw_llargs = create_llargs_for_fn_args(fcx, no_self, fn_args, imm);
1965+
let fcx = new_fn_ctxt_w_id(ccx,
1966+
~[],
1967+
llfndecl,
1968+
variant.node.id,
1969+
enum_ty,
1970+
None,
1971+
param_substs,
1972+
None);
1973+
1974+
let raw_llargs = create_llargs_for_fn_args(fcx, no_self, fn_args);
19781975
let bcx = top_scope_block(fcx, None), lltop = bcx.llbb;
19791976
let arg_tys = ty::ty_fn_args(node_id_type(bcx, variant.node.id));
19801977
let bcx = copy_args_to_allocas(fcx, bcx, fn_args, raw_llargs, arg_tys);
@@ -2044,16 +2041,16 @@ pub fn trans_tuple_struct(ccx: @CrateContext,
20442041
ty_to_str(ccx.tcx, ctor_ty)))
20452042
};
20462043
2047-
let (fcx, imm) = new_fn_ctxt_w_id(ccx,
2048-
~[],
2049-
llfndecl,
2050-
ctor_id,
2051-
tup_ty,
2052-
None,
2053-
param_substs,
2054-
None);
2044+
let fcx = new_fn_ctxt_w_id(ccx,
2045+
~[],
2046+
llfndecl,
2047+
ctor_id,
2048+
tup_ty,
2049+
None,
2050+
param_substs,
2051+
None);
20552052
2056-
let raw_llargs = create_llargs_for_fn_args(fcx, no_self, fn_args, imm);
2053+
let raw_llargs = create_llargs_for_fn_args(fcx, no_self, fn_args);
20572054
20582055
let bcx = top_scope_block(fcx, None);
20592056
let lltop = bcx.llbb;
@@ -2296,21 +2293,19 @@ pub fn create_entry_wrapper(ccx: @CrateContext,
22962293
22972294
fn create_main(ccx: @CrateContext, main_llfn: ValueRef) -> ValueRef {
22982295
let nt = ty::mk_nil();
2299-
23002296
let llfty = type_of_fn(ccx, [], nt);
23012297
let llfdecl = decl_fn(ccx.llmod, "_rust_main",
23022298
lib::llvm::CCallConv, llfty);
23032299
2304-
let (fcx, _) = new_fn_ctxt(ccx, ~[], llfdecl, nt, None);
2300+
let fcx = new_fn_ctxt(ccx, ~[], llfdecl, nt, None);
23052301
23062302
let bcx = top_scope_block(fcx, None);
23072303
let lltop = bcx.llbb;
23082304
23092305
// Call main.
2310-
let llenvarg = unsafe {
2311-
llvm::LLVMGetParam(llfdecl, arg_env(true) as c_uint)
2312-
};
2313-
let args = ~[llenvarg];
2306+
let lloutputarg = C_null(T_ptr(T_i8()));
2307+
let llenvarg = unsafe { llvm::LLVMGetParam(llfdecl, 1 as c_uint) };
2308+
let args = ~[lloutputarg, llenvarg];
23142309
let llresult = Call(bcx, main_llfn, args);
23152310
Store(bcx, llresult, fcx.llretptr.get());
23162311
@@ -2352,6 +2347,8 @@ pub fn create_entry_wrapper(ccx: @CrateContext,
23522347
trans_external_path(ccx, start_def_id, start_fn_type);
23532348
}
23542349
2350+
let retptr = llvm::LLVMBuildAlloca(bld, T_i8(), noname());
2351+
23552352
let crate_map = ccx.crate_map;
23562353
let opaque_crate_map = llvm::LLVMBuildPointerCast(bld,
23572354
crate_map,
@@ -2374,6 +2371,7 @@ pub fn create_entry_wrapper(ccx: @CrateContext,
23742371
bld, rust_main, T_ptr(T_i8()), noname());
23752372
23762373
~[
2374+
retptr,
23772375
C_null(T_opaque_box_ptr(ccx)),
23782376
opaque_rust_main,
23792377
llvm::LLVMGetParam(llfn, 0),
@@ -2386,6 +2384,7 @@ pub fn create_entry_wrapper(ccx: @CrateContext,
23862384
debug!("using user-defined start fn");
23872385
let args = {
23882386
~[
2387+
retptr,
23892388
C_null(T_opaque_box_ptr(ccx)),
23902389
llvm::LLVMGetParam(llfn, 0 as c_uint),
23912390
llvm::LLVMGetParam(llfn, 1 as c_uint),

branches/auto/src/librustc/middle/trans/cabi.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ pub impl FnType {
132132
bcx: block,
133133
ret_ty: TypeRef,
134134
llwrapfn: ValueRef,
135-
llargbundle: ValueRef,
136-
ret_imm: bool) {
135+
llargbundle: ValueRef) {
137136
let mut atys = /*bad*/copy self.arg_tys;
138137
let mut attrs = /*bad*/copy self.attrs;
139138
let mut j = 0u;

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,11 @@ pub fn trans_call_inner(in_cx: block,
510510

511511
let mut llargs = ~[];
512512

513-
if !ty::type_is_immediate(ret_ty) {
513+
if ty::type_is_immediate(ret_ty) {
514+
unsafe {
515+
llargs.push(llvm::LLVMGetUndef(T_ptr(T_i8())));
516+
}
517+
} else {
514518
llargs.push(llretslot);
515519
}
516520

branches/auto/src/librustc/middle/trans/common.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -660,26 +660,8 @@ pub fn mk_block(llbb: BasicBlockRef, parent: Option<block>, kind: block_kind,
660660
@mut block_(llbb, parent, kind, is_lpad, node_info, fcx)
661661
}
662662

663-
pub fn arg_pos(ret_imm: bool, arg: uint) -> uint {
664-
if ret_imm {
665-
arg + 1u
666-
} else {
667-
arg + 2u
668-
}
669-
}
670-
671-
pub fn arg_out(ret_imm: bool) -> uint {
672-
assert!(ret_imm);
673-
0u
674-
}
675-
676-
pub fn arg_env(ret_imm: bool) -> uint {
677-
if !ret_imm {
678-
1u
679-
} else {
680-
0u
681-
}
682-
}
663+
// First two args are retptr, env
664+
pub static first_real_arg: uint = 2u;
683665

684666
pub struct Result {
685667
bcx: block,
@@ -980,7 +962,8 @@ pub fn T_tydesc(targ_cfg: @session::config) -> TypeRef {
980962
let tydescpp = T_ptr(T_ptr(tydesc));
981963
let pvoid = T_ptr(T_i8());
982964
let glue_fn_ty =
983-
T_ptr(T_fn([T_ptr(T_nil()), tydescpp, pvoid], T_void()));
965+
T_ptr(T_fn([T_ptr(T_nil()), T_ptr(T_nil()), tydescpp,
966+
pvoid], T_void()));
984967

985968
let int_type = T_int(targ_cfg);
986969
let elems =

0 commit comments

Comments
 (0)