Skip to content

Commit 014943e

Browse files
committed
---
yaml --- r: 60759 b: refs/heads/auto c: 3c4ce79 h: refs/heads/master i: 60757: 5149b40 60755: 8594ffe 60751: 49cff55 v: v3
1 parent 1afd2b5 commit 014943e

File tree

13 files changed

+58
-110
lines changed

13 files changed

+58
-110
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: b7f71e1ee661ea0d5d9731fcf4779a452bbee486
17+
refs/heads/auto: 3c4ce7951868efb17ab02dcd452d969f8eb1bb12
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/configure

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,11 +555,11 @@ then
555555
CFG_CLANG_VERSION=$("$CFG_CLANG" \
556556
--version \
557557
| grep version \
558-
| sed 's/.*\(version .*\)/\1/' \
558+
| sed 's/.*\(version .*\)/\1/; s/.*based on \(LLVM .*\))/\1/' \
559559
| cut -d ' ' -f 2)
560560

561561
case $CFG_CLANG_VERSION in
562-
(3.0svn | 3.0 | 3.1* | 3.2* | 3.3* | 4.0* | 4.1* | 4.2*)
562+
(3.0svn | 3.0 | 3.1* | 3.2* | 3.3*)
563563
step_msg "found ok version of CLANG: $CFG_CLANG_VERSION"
564564
CFG_C_COMPILER="clang"
565565
;;

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

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,11 +1612,10 @@ pub fn new_fn_ctxt_w_id(ccx: @CrateContext,
16121612
}
16131613
};
16141614
let is_immediate = ty::type_is_immediate(substd_output_type);
1615+
16151616
let fcx = @mut fn_ctxt_ {
16161617
llfn: llfndecl,
1617-
llenv: unsafe {
1618-
llvm::LLVMGetUndef(T_ptr(T_i8()))
1619-
},
1618+
llenv: unsafe { llvm::LLVMGetParam(llfndecl, 1u as c_uint) },
16201619
llretptr: None,
16211620
llstaticallocas: llbbs.sa,
16221621
llloadenv: None,
@@ -1635,9 +1634,7 @@ pub fn new_fn_ctxt_w_id(ccx: @CrateContext,
16351634
path: path,
16361635
ccx: @ccx
16371636
};
1638-
fcx.llenv = unsafe {
1639-
llvm::LLVMGetParam(llfndecl, fcx.env_arg_pos() as c_uint)
1640-
};
1637+
16411638
fcx.llretptr = Some(make_return_pointer(fcx, substd_output_type));
16421639
fcx
16431640
}
@@ -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 = cx.arg_pos(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

@@ -2296,26 +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
23042300
let fcx = new_fn_ctxt(ccx, ~[], llfdecl, nt, None);
23052301
2306-
// the args vector built in create_entry_fn will need
2307-
// be updated if this assertion starts to fail.
2308-
assert!(fcx.has_immediate_return_value);
2309-
23102302
let bcx = top_scope_block(fcx, None);
23112303
let lltop = bcx.llbb;
23122304
23132305
// Call main.
2314-
let llenvarg = unsafe {
2315-
let env_arg = fcx.env_arg_pos();
2316-
llvm::LLVMGetParam(llfdecl, env_arg as c_uint)
2317-
};
2318-
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];
23192309
let llresult = Call(bcx, main_llfn, args);
23202310
Store(bcx, llresult, fcx.llretptr.get());
23212311
@@ -2349,14 +2339,14 @@ pub fn create_entry_wrapper(ccx: @CrateContext,
23492339
llvm::LLVMPositionBuilderAtEnd(bld, llbb);
23502340
23512341
let start_def_id = ccx.tcx.lang_items.start_fn();
2352-
if start_def_id.crate == ast::local_crate {
2353-
ccx.sess.bug("start lang item is never in the local crate")
2354-
} else {
2342+
if start_def_id.crate != ast::local_crate {
23552343
let start_fn_type = csearch::get_type(ccx.tcx,
23562344
start_def_id).ty;
23572345
trans_external_path(ccx, start_def_id, start_fn_type);
23582346
}
23592347
2348+
let retptr = llvm::LLVMBuildAlloca(bld, T_i8(), noname());
2349+
23602350
let crate_map = ccx.crate_map;
23612351
let opaque_crate_map = llvm::LLVMBuildPointerCast(bld,
23622352
crate_map,
@@ -2366,8 +2356,7 @@ pub fn create_entry_wrapper(ccx: @CrateContext,
23662356
let (start_fn, args) = if use_start_lang_item {
23672357
let start_def_id = ccx.tcx.lang_items.start_fn();
23682358
let start_fn = if start_def_id.crate == ast::local_crate {
2369-
ccx.sess.bug("start lang item is never in the local \
2370-
crate")
2359+
get_item_val(ccx, start_def_id.node)
23712360
} else {
23722361
let start_fn_type = csearch::get_type(ccx.tcx,
23732362
start_def_id).ty;
@@ -2379,6 +2368,7 @@ pub fn create_entry_wrapper(ccx: @CrateContext,
23792368
bld, rust_main, T_ptr(T_i8()), noname());
23802369
23812370
~[
2371+
retptr,
23822372
C_null(T_opaque_box_ptr(ccx)),
23832373
opaque_rust_main,
23842374
llvm::LLVMGetParam(llfn, 0),
@@ -2391,6 +2381,7 @@ pub fn create_entry_wrapper(ccx: @CrateContext,
23912381
debug!("using user-defined start fn");
23922382
let args = {
23932383
~[
2384+
retptr,
23942385
C_null(T_opaque_box_ptr(ccx)),
23952386
llvm::LLVMGetParam(llfn, 0 as c_uint),
23962387
llvm::LLVMGetParam(llfn, 1 as c_uint),

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: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -351,30 +351,6 @@ pub struct fn_ctxt_ {
351351
ccx: @@CrateContext
352352
}
353353

354-
pub impl fn_ctxt_ {
355-
pub fn arg_pos(&self, arg: uint) -> uint {
356-
if self.has_immediate_return_value {
357-
arg + 1u
358-
} else {
359-
arg + 2u
360-
}
361-
}
362-
363-
pub fn out_arg_pos(&self) -> uint {
364-
assert!(self.has_immediate_return_value);
365-
0u
366-
}
367-
368-
pub fn env_arg_pos(&self) -> uint {
369-
if !self.has_immediate_return_value {
370-
1u
371-
} else {
372-
0u
373-
}
374-
}
375-
376-
}
377-
378354
pub type fn_ctxt = @mut fn_ctxt_;
379355

380356
pub fn warn_not_to_commit(ccx: @CrateContext, msg: &str) {
@@ -684,6 +660,9 @@ pub fn mk_block(llbb: BasicBlockRef, parent: Option<block>, kind: block_kind,
684660
@mut block_(llbb, parent, kind, is_lpad, node_info, fcx)
685661
}
686662

663+
// First two args are retptr, env
664+
pub static first_real_arg: uint = 2u;
665+
687666
pub struct Result {
688667
bcx: block,
689668
val: ValueRef
@@ -983,7 +962,8 @@ pub fn T_tydesc(targ_cfg: @session::config) -> TypeRef {
983962
let tydescpp = T_ptr(T_ptr(tydesc));
984963
let pvoid = T_ptr(T_i8());
985964
let glue_fn_ty =
986-
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()));
987967

988968
let int_type = T_int(targ_cfg);
989969
let elems =

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ fn build_shim_fn_(ccx: @CrateContext,
153153
let fcx = new_fn_ctxt(ccx, ~[], llshimfn, tys.fn_sig.output, None);
154154
let bcx = top_scope_block(fcx, None);
155155
let lltop = bcx.llbb;
156-
157156
let llargbundle = get_param(llshimfn, 0u);
158157
let llargvals = arg_builder(bcx, tys, llargbundle);
159158

@@ -438,11 +437,11 @@ pub fn trans_foreign_mod(ccx: @CrateContext,
438437
let llbasefn = base_fn(ccx, *link_name(ccx, item), tys, cc);
439438
let ty = ty::lookup_item_type(ccx.tcx,
440439
ast_util::local_def(item.id)).ty;
441-
let ret_ty = ty::ty_fn_ret(ty);
442440
let args = vec::from_fn(ty::ty_fn_args(ty).len(), |i| {
443-
get_param(decl, fcx.arg_pos(i))
441+
get_param(decl, i + first_real_arg)
444442
});
445443
let retval = Call(bcx, llbasefn, args);
444+
let ret_ty = ty::ty_fn_ret(ty);
446445
if !ty::type_is_nil(ret_ty) && !ty::type_is_bot(ret_ty) {
447446
Store(bcx, retval, fcx.llretptr.get());
448447
}
@@ -466,11 +465,11 @@ pub fn trans_foreign_mod(ccx: @CrateContext,
466465
set_fixed_stack_segment(fcx.llfn);
467466
let ty = ty::lookup_item_type(ccx.tcx,
468467
ast_util::local_def(item.id)).ty;
469-
let ret_ty = ty::ty_fn_ret(ty);
470468
let args = vec::from_fn(ty::ty_fn_args(ty).len(), |i| {
471-
get_param(decl, fcx.arg_pos(i))
469+
get_param(decl, i + first_real_arg)
472470
});
473471
let retval = Call(bcx, llbasefn, args);
472+
let ret_ty = ty::ty_fn_ret(ty);
474473
if !ty::type_is_nil(ret_ty) && !ty::type_is_bot(ret_ty) {
475474
Store(bcx, retval, fcx.llretptr.get());
476475
}
@@ -513,9 +512,9 @@ pub fn trans_foreign_mod(ccx: @CrateContext,
513512
let _icx = bcx.insn_ctxt("foreign::wrap::build_args");
514513
let ccx = bcx.ccx();
515514
let n = tys.llsig.llarg_tys.len();
515+
let implicit_args = first_real_arg; // return + env
516516
for uint::range(0, n) |i| {
517-
let arg_i = bcx.fcx.arg_pos(i);
518-
let mut llargval = get_param(llwrapfn, arg_i);
517+
let mut llargval = get_param(llwrapfn, i + implicit_args);
519518

520519
// In some cases, Rust will pass a pointer which the
521520
// native C type doesn't have. In that case, just
@@ -569,7 +568,6 @@ pub fn trans_intrinsic(ccx: @CrateContext,
569568

570569
let mut bcx = top_scope_block(fcx, None);
571570
let lltop = bcx.llbb;
572-
let first_real_arg = fcx.arg_pos(0u);
573571
match *ccx.sess.str_of(item.ident) {
574572
~"atomic_cxchg" => {
575573
let old = AtomicCmpXchg(bcx,
@@ -1271,6 +1269,8 @@ pub fn trans_foreign_fn(ccx: @CrateContext,
12711269
if !ty::type_is_immediate(tys.fn_sig.output) {
12721270
let llretptr = load_inbounds(bcx, llargbundle, [0u, n]);
12731271
llargvals.push(llretptr);
1272+
} else {
1273+
llargvals.push(C_null(T_ptr(T_i8())));
12741274
}
12751275

12761276
let llenvptr = C_null(T_opaque_box_ptr(bcx.ccx()));

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use back::link::*;
1919
use driver::session;
2020
use lib;
2121
use lib::llvm::{llvm, ValueRef, TypeRef, True};
22-
use lib::llvm::type_to_str;
2322
use middle::trans::adt;
2423
use middle::trans::base::*;
2524
use middle::trans::callee;
@@ -382,9 +381,8 @@ pub fn call_tydesc_glue_full(bcx: block,
382381
}
383382
};
384383

385-
Call(bcx, llfn, [C_null(T_ptr(T_nil())),
386-
C_null(T_ptr(T_ptr(bcx.ccx().tydesc_type))),
387-
llrawptr]);
384+
Call(bcx, llfn, [C_null(T_ptr(T_nil())), C_null(T_ptr(T_nil())),
385+
C_null(T_ptr(T_ptr(bcx.ccx().tydesc_type))), llrawptr]);
388386
}
389387

390388
// See [Note-arg-mode]
@@ -485,16 +483,17 @@ pub fn trans_struct_drop(bcx: block,
485483
};
486484

487485
// Class dtors have no explicit args, so the params should
488-
// just consist of the environment (self)
489-
assert_eq!(params.len(), 1);
486+
// just consist of the output pointer and the environment
487+
// (self)
488+
assert_eq!(params.len(), 2);
490489

491490
// Take a reference to the class (because it's using the Drop trait),
492491
// do so now.
493492
let llval = alloca(bcx, val_ty(v0));
494493
Store(bcx, v0, llval);
495494

496-
let self_arg = PointerCast(bcx, llval, params[0]);
497-
let args = ~[self_arg];
495+
let self_arg = PointerCast(bcx, llval, params[1]);
496+
let args = ~[C_null(T_ptr(T_i8())), self_arg];
498497

499498
Call(bcx, dtor_addr, args);
500499

@@ -740,8 +739,7 @@ pub fn make_generic_glue_inner(ccx: @CrateContext,
740739

741740
let bcx = top_scope_block(fcx, None);
742741
let lltop = bcx.llbb;
743-
let rawptr0_arg = fcx.arg_pos(1u);
744-
let llrawptr0 = unsafe { llvm::LLVMGetParam(llfn, rawptr0_arg as c_uint) };
742+
let llrawptr0 = unsafe { llvm::LLVMGetParam(llfn, 3u as c_uint) };
745743
helper(bcx, llrawptr0, t);
746744
finish_fn(fcx, lltop);
747745
return llfn;

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,19 +286,14 @@ pub impl Reflector {
286286

287287
let llfty = type_of_fn(ccx, [opaqueptrty], ty::mk_int());
288288
let llfdecl = decl_internal_cdecl_fn(ccx.llmod, sym, llfty);
289+
let arg = unsafe {
290+
llvm::LLVMGetParam(llfdecl, first_real_arg as c_uint)
291+
};
289292
let fcx = new_fn_ctxt(ccx,
290293
~[],
291294
llfdecl,
292295
ty::mk_uint(),
293296
None);
294-
let arg = unsafe {
295-
//
296-
// we know the return type of llfdecl is an int here, so
297-
// no need for a special check to see if the return type
298-
// is immediate.
299-
//
300-
llvm::LLVMGetParam(llfdecl, fcx.arg_pos(0u) as c_uint)
301-
};
302297
let bcx = top_scope_block(fcx, None);
303298
let arg = BitCast(bcx, arg, llptrty);
304299
let ret = adt::trans_get_discr(bcx, repr, arg);

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ pub fn type_of_fn(cx: @CrateContext, inputs: &[ty::t], output: ty::t)
4646
let lloutputtype = type_of(cx, output);
4747
if !output_is_immediate {
4848
atys.push(T_ptr(lloutputtype));
49+
} else {
50+
// FIXME #6575: Eliminate this.
51+
atys.push(T_ptr(T_i8()));
4952
}
5053

5154
// Arg 1: Environment
@@ -331,7 +334,9 @@ pub fn llvm_type_name(cx: @CrateContext,
331334
}
332335

333336
pub fn type_of_dtor(ccx: @CrateContext, self_ty: ty::t) -> TypeRef {
334-
T_fn([T_ptr(type_of(ccx, self_ty))] /* self */, T_nil())
337+
T_fn([T_ptr(T_i8()), // output pointer
338+
T_ptr(type_of(ccx, self_ty))], // self arg
339+
T_nil())
335340
}
336341

337342
pub fn type_of_rooted(ccx: @CrateContext, t: ty::t) -> TypeRef {
@@ -344,5 +349,5 @@ pub fn type_of_rooted(ccx: @CrateContext, t: ty::t) -> TypeRef {
344349
pub fn type_of_glue_fn(ccx: @CrateContext, t: ty::t) -> TypeRef {
345350
let tydescpp = T_ptr(T_ptr(ccx.tydesc_type));
346351
let llty = T_ptr(type_of(ccx, t));
347-
return T_fn([T_ptr(T_nil()), tydescpp, llty], T_nil());
352+
return T_fn([T_ptr(T_nil()), T_ptr(T_nil()), tydescpp, llty], T_nil());
348353
}

branches/auto/src/librustc/middle/ty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ type type_cache = @mut HashMap<ast::def_id, ty_param_bounds_and_ty>;
907907

908908
type constness_cache = @mut HashMap<ast::def_id, const_eval::constness>;
909909

910-
pub type node_type_table = @mut SmallIntMap<t>;
910+
pub type node_type_table = @mut HashMap<uint,t>;
911911

912912
fn mk_rcache() -> creader_cache {
913913
return @mut HashMap::new();
@@ -934,7 +934,7 @@ pub fn mk_ctxt(s: session::Session,
934934
def_map: dm,
935935
region_maps: region_maps,
936936
region_paramd_items: region_paramd_items,
937-
node_types: @mut SmallIntMap::new(),
937+
node_types: @mut HashMap::new(),
938938
node_type_substs: @mut HashMap::new(),
939939
trait_refs: @mut HashMap::new(),
940940
trait_defs: @mut HashMap::new(),

0 commit comments

Comments
 (0)