Skip to content

Commit d97cf08

Browse files
author
blake2-ppc
committed
---
yaml --- r: 64560 b: refs/heads/snap-stage3 c: 60cb9c0 h: refs/heads/master v: v3
1 parent 6321232 commit d97cf08

File tree

15 files changed

+702
-1247
lines changed

15 files changed

+702
-1247
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 205baa6ca2272e21032f8fb5477edefe4120bcbc
4+
refs/heads/snap-stage3: 60cb9c003c48f29396470611e0caa544f3acea89
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libextra/serialize.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,19 @@ impl<
662662
}
663663
}
664664

665+
impl<
666+
S: Encoder,
667+
T: Encodable<S>
668+
> Encodable<S> for DList<T> {
669+
fn encode(&self, s: &mut S) {
670+
do s.emit_seq(self.len()) |s| {
671+
for self.iter().enumerate().advance |(i, e)| {
672+
s.emit_seq_elt(i, |s| e.encode(s));
673+
}
674+
}
675+
}
676+
}
677+
665678
impl<D:Decoder,T:Decodable<D>> Decodable<D> for DList<T> {
666679
fn decode(d: &mut D) -> DList<T> {
667680
let mut list = DList::new();

branches/snap-stage3/src/librustc/lib/llvm.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,8 +984,6 @@ pub mod llvm {
984984
pub unsafe fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
985985
#[fast_ffi]
986986
pub unsafe fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
987-
#[fast_ffi]
988-
pub unsafe fn LLVMInstructionEraseFromParent(Inst: ValueRef);
989987

990988
/* Operations on call sites */
991989
#[fast_ffi]

branches/snap-stage3/src/librustc/middle/trans/base.rs

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ use middle::trans::_match;
4141
use middle::trans::adt;
4242
use middle::trans::base;
4343
use middle::trans::build::*;
44-
use middle::trans::builder::{Builder, noname};
4544
use middle::trans::callee;
4645
use middle::trans::common::*;
4746
use middle::trans::consts;
@@ -1503,35 +1502,34 @@ pub fn memcpy_ty(bcx: block, dst: ValueRef, src: ValueRef, t: ty::t) {
15031502
}
15041503

15051504
pub fn zero_mem(cx: block, llptr: ValueRef, t: ty::t) {
1506-
if cx.unreachable { return; }
15071505
let _icx = push_ctxt("zero_mem");
15081506
let bcx = cx;
15091507
let ccx = cx.ccx();
15101508
let llty = type_of::type_of(ccx, t);
1511-
memzero(&B(bcx), llptr, llty);
1509+
memzero(bcx, llptr, llty);
15121510
}
15131511

15141512
// Always use this function instead of storing a zero constant to the memory
15151513
// in question. If you store a zero constant, LLVM will drown in vreg
15161514
// allocation for large data structures, and the generated code will be
15171515
// awful. (A telltale sign of this is large quantities of
15181516
// `mov [byte ptr foo],0` in the generated code.)
1519-
pub fn memzero(b: &Builder, llptr: ValueRef, ty: Type) {
1517+
pub fn memzero(cx: block, llptr: ValueRef, ty: Type) {
15201518
let _icx = push_ctxt("memzero");
1521-
let ccx = b.ccx;
1519+
let ccx = cx.ccx();
15221520

15231521
let intrinsic_key = match ccx.sess.targ_cfg.arch {
15241522
X86 | Arm | Mips => "llvm.memset.p0i8.i32",
15251523
X86_64 => "llvm.memset.p0i8.i64"
15261524
};
15271525

15281526
let llintrinsicfn = ccx.intrinsics.get_copy(&intrinsic_key);
1529-
let llptr = b.pointercast(llptr, Type::i8().ptr_to());
1527+
let llptr = PointerCast(cx, llptr, Type::i8().ptr_to());
15301528
let llzeroval = C_u8(0);
1531-
let size = machine::llsize_of(ccx, ty);
1529+
let size = IntCast(cx, machine::llsize_of(ccx, ty), ccx.int_type);
15321530
let align = C_i32(llalign_of_min(ccx, ty) as i32);
15331531
let volatile = C_i1(false);
1534-
b.call(llintrinsicfn, [llptr, llzeroval, size, align, volatile]);
1532+
Call(cx, llintrinsicfn, [llptr, llzeroval, size, align, volatile]);
15351533
}
15361534

15371535
pub fn alloc_ty(bcx: block, t: ty::t, name: &str) -> ValueRef {
@@ -1554,12 +1552,9 @@ pub fn alloca_maybe_zeroed(cx: block, ty: Type, name: &str, zero: bool) -> Value
15541552
return llvm::LLVMGetUndef(ty.ptr_to().to_ref());
15551553
}
15561554
}
1557-
let p = Alloca(cx, ty, name);
1558-
if zero {
1559-
let b = cx.fcx.ccx.builder();
1560-
b.position_before(cx.fcx.alloca_insert_pt.get());
1561-
memzero(&b, p, ty);
1562-
}
1555+
let initcx = base::raw_block(cx.fcx, false, cx.fcx.get_llstaticallocas());
1556+
let p = Alloca(initcx, ty, name);
1557+
if zero { memzero(initcx, p, ty); }
15631558
p
15641559
}
15651560

@@ -1570,7 +1565,7 @@ pub fn arrayalloca(cx: block, ty: Type, v: ValueRef) -> ValueRef {
15701565
return llvm::LLVMGetUndef(ty.to_ref());
15711566
}
15721567
}
1573-
return ArrayAlloca(cx, ty, v);
1568+
return ArrayAlloca(base::raw_block(cx.fcx, false, cx.fcx.get_llstaticallocas()), ty, v);
15741569
}
15751570

15761571
pub struct BasicBlocks {
@@ -1601,8 +1596,8 @@ pub fn make_return_pointer(fcx: fn_ctxt, output_type: ty::t) -> ValueRef {
16011596
llvm::LLVMGetParam(fcx.llfn, 0)
16021597
} else {
16031598
let lloutputtype = type_of::type_of(fcx.ccx, output_type);
1604-
let bcx = fcx.entry_bcx.get();
1605-
Alloca(bcx, lloutputtype, "__make_return_pointer")
1599+
alloca(raw_block(fcx, false, fcx.get_llstaticallocas()), lloutputtype,
1600+
"__make_return_pointer")
16061601
}
16071602
}
16081603
}
@@ -1620,7 +1615,6 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
16201615
output_type: ty::t,
16211616
skip_retptr: bool,
16221617
param_substs: Option<@param_substs>,
1623-
opt_node_info: Option<NodeInfo>,
16241618
sp: Option<span>)
16251619
-> fn_ctxt {
16261620
for param_substs.iter().advance |p| { p.validate(); }
@@ -1644,8 +1638,8 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
16441638
llvm::LLVMGetUndef(Type::i8p().to_ref())
16451639
},
16461640
llretptr: None,
1647-
entry_bcx: None,
1648-
alloca_insert_pt: None,
1641+
llstaticallocas: None,
1642+
llloadenv: None,
16491643
llreturn: None,
16501644
llself: None,
16511645
personality: None,
@@ -1663,15 +1657,6 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
16631657
fcx.llenv = unsafe {
16641658
llvm::LLVMGetParam(llfndecl, fcx.env_arg_pos() as c_uint)
16651659
};
1666-
1667-
unsafe {
1668-
let entry_bcx = top_scope_block(fcx, opt_node_info);
1669-
Load(entry_bcx, C_null(Type::i8p()));
1670-
1671-
fcx.entry_bcx = Some(entry_bcx);
1672-
fcx.alloca_insert_pt = Some(llvm::LLVMGetFirstInstruction(entry_bcx.llbb));
1673-
}
1674-
16751660
if !ty::type_is_nil(substd_output_type) && !(is_immediate && skip_retptr) {
16761661
fcx.llretptr = Some(make_return_pointer(fcx, substd_output_type));
16771662
}
@@ -1684,7 +1669,7 @@ pub fn new_fn_ctxt(ccx: @mut CrateContext,
16841669
output_type: ty::t,
16851670
sp: Option<span>)
16861671
-> fn_ctxt {
1687-
new_fn_ctxt_w_id(ccx, path, llfndecl, -1, output_type, false, None, None, sp)
1672+
new_fn_ctxt_w_id(ccx, path, llfndecl, -1, output_type, false, None, sp)
16881673
}
16891674

16901675
// NB: must keep 4 fns in sync:
@@ -1799,8 +1784,9 @@ pub fn copy_args_to_allocas(fcx: fn_ctxt,
17991784

18001785
// Ties up the llstaticallocas -> llloadenv -> lltop edges,
18011786
// and builds the return block.
1802-
pub fn finish_fn(fcx: fn_ctxt, last_bcx: block) {
1787+
pub fn finish_fn(fcx: fn_ctxt, lltop: BasicBlockRef, last_bcx: block) {
18031788
let _icx = push_ctxt("finish_fn");
1789+
tie_up_header_blocks(fcx, lltop);
18041790

18051791
let ret_cx = match fcx.llreturn {
18061792
Some(llreturn) => {
@@ -1812,7 +1798,6 @@ pub fn finish_fn(fcx: fn_ctxt, last_bcx: block) {
18121798
None => last_bcx
18131799
};
18141800
build_return_block(fcx, ret_cx);
1815-
fcx.cleanup();
18161801
}
18171802

18181803
// Builds the return block for a function.
@@ -1825,6 +1810,29 @@ pub fn build_return_block(fcx: fn_ctxt, ret_cx: block) {
18251810
}
18261811
}
18271812

1813+
pub fn tie_up_header_blocks(fcx: fn_ctxt, lltop: BasicBlockRef) {
1814+
let _icx = push_ctxt("tie_up_header_blocks");
1815+
let llnext = match fcx.llloadenv {
1816+
Some(ll) => {
1817+
unsafe {
1818+
llvm::LLVMMoveBasicBlockBefore(ll, lltop);
1819+
}
1820+
Br(raw_block(fcx, false, ll), lltop);
1821+
ll
1822+
}
1823+
None => lltop
1824+
};
1825+
match fcx.llstaticallocas {
1826+
Some(ll) => {
1827+
unsafe {
1828+
llvm::LLVMMoveBasicBlockBefore(ll, llnext);
1829+
}
1830+
Br(raw_block(fcx, false, ll), llnext);
1831+
}
1832+
None => ()
1833+
}
1834+
}
1835+
18281836
pub enum self_arg { impl_self(ty::t, ty::SelfMode), no_self, }
18291837

18301838
// trans_closure: Builds an LLVM function out of a source function.
@@ -1857,7 +1865,6 @@ pub fn trans_closure(ccx: @mut CrateContext,
18571865
output_type,
18581866
false,
18591867
param_substs,
1860-
body.info(),
18611868
Some(body.span));
18621869
let raw_llargs = create_llargs_for_fn_args(fcx, self_arg, decl.inputs);
18631870

@@ -1869,8 +1876,9 @@ pub fn trans_closure(ccx: @mut CrateContext,
18691876

18701877
// Create the first basic block in the function and keep a handle on it to
18711878
// pass to finish_fn later.
1872-
let bcx_top = fcx.entry_bcx.get();
1879+
let bcx_top = top_scope_block(fcx, body.info());
18731880
let mut bcx = bcx_top;
1881+
let lltop = bcx.llbb;
18741882
let block_ty = node_id_type(bcx, body.id);
18751883

18761884
let arg_tys = ty::ty_fn_args(node_id_type(bcx, id));
@@ -1906,7 +1914,7 @@ pub fn trans_closure(ccx: @mut CrateContext,
19061914
}
19071915

19081916
// Insert the mandatory first few basic blocks before lltop.
1909-
finish_fn(fcx, bcx);
1917+
finish_fn(fcx, lltop, bcx);
19101918
}
19111919

19121920
// trans_fn: creates an LLVM function corresponding to a source language
@@ -2076,12 +2084,12 @@ pub fn trans_enum_variant_or_tuple_like_struct<A:IdAndTy>(
20762084
result_ty,
20772085
false,
20782086
param_substs,
2079-
None,
20802087
None);
20812088

20822089
let raw_llargs = create_llargs_for_fn_args(fcx, no_self, fn_args);
20832090

2084-
let bcx = fcx.entry_bcx.get();
2091+
let bcx = top_scope_block(fcx, None);
2092+
let lltop = bcx.llbb;
20852093
let arg_tys = ty::ty_fn_args(ctor_ty);
20862094

20872095
insert_synthetic_type_entries(bcx, fn_args, arg_tys);
@@ -2099,7 +2107,7 @@ pub fn trans_enum_variant_or_tuple_like_struct<A:IdAndTy>(
20992107
let arg_ty = arg_tys[i];
21002108
memcpy_ty(bcx, lldestptr, llarg, arg_ty);
21012109
}
2102-
finish_fn(fcx, bcx);
2110+
finish_fn(fcx, lltop, bcx);
21032111
}
21042112

21052113
pub fn trans_enum_def(ccx: @mut CrateContext, enum_definition: &ast::enum_def,
@@ -2327,7 +2335,9 @@ pub fn create_entry_wrapper(ccx: @mut CrateContext,
23272335
// be updated if this assertion starts to fail.
23282336
assert!(fcx.has_immediate_return_value);
23292337

2330-
let bcx = fcx.entry_bcx.get();
2338+
let bcx = top_scope_block(fcx, None);
2339+
let lltop = bcx.llbb;
2340+
23312341
// Call main.
23322342
let llenvarg = unsafe {
23332343
let env_arg = fcx.env_arg_pos();
@@ -2336,7 +2346,7 @@ pub fn create_entry_wrapper(ccx: @mut CrateContext,
23362346
let args = ~[llenvarg];
23372347
Call(bcx, main_llfn, args);
23382348

2339-
finish_fn(fcx, bcx);
2349+
finish_fn(fcx, lltop, bcx);
23402350
return llfdecl;
23412351
}
23422352

0 commit comments

Comments
 (0)