@@ -1557,7 +1557,7 @@ pub fn alloca_maybe_zeroed(cx: block, ty: Type, name: &str, zero: bool) -> Value
1557
1557
return llvm:: LLVMGetUndef ( ty. to_ref( ) ) ;
1558
1558
}
1559
1559
}
1560
- let initcx = base:: raw_block( cx. fcx, false , cx. fcx. llstaticallocas ) ;
1560
+ let initcx = base:: raw_block( cx. fcx, false , cx. fcx. get_llstaticallocas ( ) ) ;
1561
1561
let p = Alloca ( initcx, ty, name) ;
1562
1562
if zero { memzero( initcx, p, ty) ; }
1563
1563
p
@@ -1570,21 +1570,18 @@ pub fn arrayalloca(cx: block, ty: Type, v: ValueRef) -> ValueRef {
1570
1570
return llvm:: LLVMGetUndef ( ty. to_ref( ) ) ;
1571
1571
}
1572
1572
}
1573
- return ArrayAlloca ( base:: raw_block( cx. fcx, false , cx. fcx. llstaticallocas ) , ty, v) ;
1573
+ return ArrayAlloca ( base:: raw_block( cx. fcx, false , cx. fcx. get_llstaticallocas ( ) ) , ty, v) ;
1574
1574
}
1575
1575
1576
1576
pub struct BasicBlocks {
1577
1577
sa: BasicBlockRef ,
1578
1578
}
1579
1579
1580
- // Creates the standard set of basic blocks for a function
1581
- pub fn mk_standard_basic_blocks( llfn: ValueRef ) -> BasicBlocks {
1580
+ pub fn mk_staticallocas_basic_block( llfn: ValueRef ) -> BasicBlockRef {
1582
1581
unsafe {
1583
1582
let cx = task_llcx( ) ;
1584
- BasicBlocks {
1585
- sa: str :: as_c_str( "static_allocas" ,
1586
- |buf| llvm:: LLVMAppendBasicBlockInContext ( cx, llfn, buf) ) ,
1587
- }
1583
+ str :: as_c_str( "static_allocas" ,
1584
+ |buf| llvm:: LLVMAppendBasicBlockInContext ( cx, llfn, buf) )
1588
1585
}
1589
1586
}
1590
1587
@@ -1604,7 +1601,7 @@ pub fn make_return_pointer(fcx: fn_ctxt, output_type: ty::t) -> ValueRef {
1604
1601
llvm:: LLVMGetParam ( fcx. llfn, 0 )
1605
1602
} else {
1606
1603
let lloutputtype = type_of:: type_of( fcx. ccx, output_type) ;
1607
- alloca( raw_block( fcx, false , fcx. llstaticallocas ) , lloutputtype,
1604
+ alloca( raw_block( fcx, false , fcx. get_llstaticallocas ( ) ) , lloutputtype,
1608
1605
"__make_return_pointer" )
1609
1606
}
1610
1607
}
@@ -1632,8 +1629,6 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
1632
1629
id,
1633
1630
param_substs. repr( ccx. tcx) ) ;
1634
1631
1635
- let llbbs = mk_standard_basic_blocks( llfndecl) ;
1636
-
1637
1632
let substd_output_type = match param_substs {
1638
1633
None => output_type,
1639
1634
Some ( substs) => {
@@ -1647,7 +1642,7 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
1647
1642
llvm:: LLVMGetUndef ( Type :: i8p( ) . to_ref( ) )
1648
1643
} ,
1649
1644
llretptr: None ,
1650
- llstaticallocas: llbbs . sa ,
1645
+ llstaticallocas: None ,
1651
1646
llloadenv: None ,
1652
1647
llreturn: None ,
1653
1648
llself: None ,
@@ -1821,14 +1816,24 @@ pub fn build_return_block(fcx: fn_ctxt, ret_cx: block) {
1821
1816
1822
1817
pub fn tie_up_header_blocks( fcx: fn_ctxt, lltop: BasicBlockRef ) {
1823
1818
let _icx = push_ctxt( "tie_up_header_blocks" ) ;
1824
- match fcx. llloadenv {
1819
+ let llnext = match fcx. llloadenv {
1825
1820
Some ( ll) => {
1826
- Br ( raw_block( fcx, false , fcx. llstaticallocas) , ll) ;
1821
+ unsafe {
1822
+ llvm:: LLVMMoveBasicBlockBefore ( ll, lltop) ;
1823
+ }
1827
1824
Br ( raw_block( fcx, false , ll) , lltop) ;
1825
+ ll
1828
1826
}
1829
- None => {
1830
- Br ( raw_block( fcx, false , fcx. llstaticallocas) , lltop) ;
1827
+ None => lltop
1828
+ } ;
1829
+ match fcx. llstaticallocas {
1830
+ Some ( ll) => {
1831
+ unsafe {
1832
+ llvm:: LLVMMoveBasicBlockBefore ( ll, llnext) ;
1833
+ }
1834
+ Br ( raw_block( fcx, false , ll) , llnext) ;
1831
1835
}
1836
+ None => ( )
1832
1837
}
1833
1838
}
1834
1839
0 commit comments