@@ -137,6 +137,13 @@ fn fcx_has_nonzero_span(fcx: &FunctionContext) -> bool {
137
137
}
138
138
}
139
139
140
+ fn span_is_empty ( opt_span : & Option < span > ) -> bool {
141
+ match * opt_span {
142
+ None => true ,
143
+ Some ( span) => * span. lo == 0 && * span. hi == 0
144
+ }
145
+ }
146
+
140
147
struct StatRecorder < ' self > {
141
148
ccx : @mut CrateContext ,
142
149
name : & ' self str ,
@@ -1624,6 +1631,13 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
1624
1631
}
1625
1632
} ;
1626
1633
let uses_outptr = type_of:: return_uses_outptr ( ccx. tcx , substd_output_type) ;
1634
+
1635
+ let debug_context = if id != -1 && ccx. sess . opts . debuginfo && !span_is_empty ( & sp) {
1636
+ Some ( debuginfo:: create_function_debug_context ( ccx, id, param_substs, llfndecl) )
1637
+ } else {
1638
+ None
1639
+ } ;
1640
+
1627
1641
let fcx = @mut FunctionContext {
1628
1642
llfn : llfndecl,
1629
1643
llenv : unsafe {
@@ -1644,7 +1658,7 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
1644
1658
span : sp,
1645
1659
path : path,
1646
1660
ccx : ccx,
1647
- debug_context : None ,
1661
+ debug_context : debug_context ,
1648
1662
} ;
1649
1663
fcx. llenv = unsafe {
1650
1664
llvm:: LLVMGetParam ( llfndecl, fcx. env_arg_pos ( ) as c_uint )
@@ -1696,7 +1710,8 @@ pub fn new_fn_ctxt(ccx: @mut CrateContext,
1696
1710
// field of the fn_ctxt with
1697
1711
pub fn create_llargs_for_fn_args ( cx : @mut FunctionContext ,
1698
1712
self_arg : self_arg ,
1699
- args : & [ ast:: arg ] )
1713
+ args : & [ ast:: arg ] ,
1714
+ arg_tys : & [ ty:: t ] )
1700
1715
-> ~[ ValueRef ] {
1701
1716
let _icx = push_ctxt ( "create_llargs_for_fn_args" ) ;
1702
1717
@@ -1713,26 +1728,31 @@ pub fn create_llargs_for_fn_args(cx: @mut FunctionContext,
1713
1728
1714
1729
// Return an array containing the ValueRefs that we get from
1715
1730
// llvm::LLVMGetParam for each argument.
1716
- vec:: from_fn ( args. len ( ) , |i| {
1717
- unsafe {
1718
- let arg_n = cx. arg_pos ( i) ;
1719
- let arg = & args[ i] ;
1720
- let llarg = llvm:: LLVMGetParam ( cx. llfn , arg_n as c_uint ) ;
1721
-
1722
- // FIXME #7260: aliasing should be determined by monomorphized ty::t
1723
- match arg. ty . node {
1724
- // `~` pointers never alias other parameters, because ownership was transferred
1725
- ast:: ty_uniq( _) => {
1726
- llvm:: LLVMAddAttribute ( llarg, lib:: llvm:: NoAliasAttribute as c_uint ) ;
1731
+ do vec:: from_fn ( args. len ( ) ) |i| {
1732
+ let arg_n = cx. arg_pos ( i) ;
1733
+ let arg_ty = arg_tys[ i] ;
1734
+ let llarg = unsafe { llvm:: LLVMGetParam ( cx. llfn , arg_n as c_uint ) } ;
1735
+
1736
+ match ty:: get ( arg_ty) . sty {
1737
+ // `~` pointers never alias other parameters, because
1738
+ // ownership was transferred
1739
+ ty:: ty_uniq( * ) |
1740
+ ty:: ty_evec( _, ty:: vstore_uniq) |
1741
+ ty:: ty_closure( ty:: ClosureTy { sigil : ast:: OwnedSigil , _} ) => {
1742
+ unsafe {
1743
+ llvm:: LLVMAddAttribute (
1744
+ llarg, lib:: llvm:: NoAliasAttribute as c_uint ) ;
1727
1745
}
1728
- // FIXME: #6785: `&mut` can only alias `&const` and `@mut`, we should check for
1729
- // those in the other parameters and then mark it as `noalias` if there aren't any
1730
- _ => { }
1731
1746
}
1732
-
1733
- llarg
1747
+ // FIXME: #6785: `&mut` can only alias `&const` and
1748
+ // `@mut`, we should check for those in the other
1749
+ // parameters and then mark it as `noalias` if there
1750
+ // aren't any
1751
+ _ => { }
1734
1752
}
1735
- } )
1753
+
1754
+ llarg
1755
+ }
1736
1756
}
1737
1757
1738
1758
pub fn copy_args_to_allocas ( fcx : @mut FunctionContext ,
@@ -1867,7 +1887,6 @@ pub fn trans_closure(ccx: @mut CrateContext,
1867
1887
debug ! ( "trans_closure(..., param_substs=%s)" ,
1868
1888
param_substs. repr( ccx. tcx) ) ;
1869
1889
1870
- // Set up arguments to the function.
1871
1890
let fcx = new_fn_ctxt_w_id ( ccx,
1872
1891
path,
1873
1892
llfndecl,
@@ -1877,29 +1896,33 @@ pub fn trans_closure(ccx: @mut CrateContext,
1877
1896
param_substs,
1878
1897
body. info ( ) ,
1879
1898
Some ( body. span ) ) ;
1880
- let raw_llargs = create_llargs_for_fn_args ( fcx, self_arg, decl. inputs ) ;
1881
-
1882
- // Set the fixed stack segment flag if necessary.
1883
- if attr:: contains_name ( attributes, "fixed_stack_segment" ) {
1884
- set_no_inline ( fcx. llfn ) ;
1885
- set_fixed_stack_segment ( fcx. llfn ) ;
1886
- }
1887
-
1888
- if ccx. sess . opts . debuginfo && fcx_has_nonzero_span ( fcx) {
1889
- debuginfo:: create_function_metadata ( fcx) ;
1890
- }
1891
1899
1892
1900
// Create the first basic block in the function and keep a handle on it to
1893
1901
// pass to finish_fn later.
1894
1902
let bcx_top = fcx. entry_bcx . unwrap ( ) ;
1895
1903
let mut bcx = bcx_top;
1896
1904
let block_ty = node_id_type ( bcx, body. id ) ;
1897
1905
1906
+ // Set up arguments to the function.
1898
1907
let arg_tys = ty:: ty_fn_args ( node_id_type ( bcx, id) ) ;
1908
+ let raw_llargs = create_llargs_for_fn_args ( fcx, self_arg,
1909
+ decl. inputs , arg_tys) ;
1910
+
1911
+ // Set the fixed stack segment flag if necessary.
1912
+ if attr:: contains_name ( attributes, "fixed_stack_segment" ) {
1913
+ set_no_inline ( fcx. llfn ) ;
1914
+ set_fixed_stack_segment ( fcx. llfn ) ;
1915
+ }
1916
+
1899
1917
bcx = copy_args_to_allocas ( fcx, bcx, decl. inputs , raw_llargs, arg_tys) ;
1900
1918
1901
1919
maybe_load_env ( fcx) ;
1902
1920
1921
+ // Up until here, IR instructions for this function have explicitly not been annotated with
1922
+ // source code location, so we don't step into call setup code. From here on, source location
1923
+ // emitting should be enabled.
1924
+ debuginfo:: start_emitting_source_locations ( fcx) ;
1925
+
1903
1926
// This call to trans_block is the place where we bridge between
1904
1927
// translation calls that don't have a return value (trans_crate,
1905
1928
// trans_mod, trans_item, et cetera) and those that do
@@ -2092,10 +2115,11 @@ pub fn trans_enum_variant_or_tuple_like_struct<A:IdAndTy>(
2092
2115
None ,
2093
2116
None ) ;
2094
2117
2095
- let raw_llargs = create_llargs_for_fn_args ( fcx, no_self, fn_args) ;
2118
+ let arg_tys = ty:: ty_fn_args ( ctor_ty) ;
2119
+
2120
+ let raw_llargs = create_llargs_for_fn_args ( fcx, no_self, fn_args, arg_tys) ;
2096
2121
2097
2122
let bcx = fcx. entry_bcx . unwrap ( ) ;
2098
- let arg_tys = ty:: ty_fn_args ( ctor_ty) ;
2099
2123
2100
2124
insert_synthetic_type_entries ( bcx, fn_args, arg_tys) ;
2101
2125
let bcx = copy_args_to_allocas ( fcx, bcx, fn_args, raw_llargs, arg_tys) ;
0 commit comments