@@ -1710,7 +1710,8 @@ pub fn new_fn_ctxt(ccx: @mut CrateContext,
1710
1710
// field of the fn_ctxt with
1711
1711
pub fn create_llargs_for_fn_args ( cx : @mut FunctionContext ,
1712
1712
self_arg : self_arg ,
1713
- args : & [ ast:: arg ] )
1713
+ args : & [ ast:: arg ] ,
1714
+ arg_tys : & [ ty:: t ] )
1714
1715
-> ~[ ValueRef ] {
1715
1716
let _icx = push_ctxt ( "create_llargs_for_fn_args" ) ;
1716
1717
@@ -1727,26 +1728,31 @@ pub fn create_llargs_for_fn_args(cx: @mut FunctionContext,
1727
1728
1728
1729
// Return an array containing the ValueRefs that we get from
1729
1730
// llvm::LLVMGetParam for each argument.
1730
- vec:: from_fn ( args. len ( ) , |i| {
1731
- unsafe {
1732
- let arg_n = cx. arg_pos ( i) ;
1733
- let arg = & args[ i] ;
1734
- let llarg = llvm:: LLVMGetParam ( cx. llfn , arg_n as c_uint ) ;
1735
-
1736
- // FIXME #7260: aliasing should be determined by monomorphized ty::t
1737
- match arg. ty . node {
1738
- // `~` pointers never alias other parameters, because ownership was transferred
1739
- ast:: ty_uniq( _) => {
1740
- 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 ) ;
1741
1745
}
1742
- // FIXME: #6785: `&mut` can only alias `&const` and `@mut`, we should check for
1743
- // those in the other parameters and then mark it as `noalias` if there aren't any
1744
- _ => { }
1745
1746
}
1746
-
1747
- 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
+ _ => { }
1748
1752
}
1749
- } )
1753
+
1754
+ llarg
1755
+ }
1750
1756
}
1751
1757
1752
1758
pub fn copy_args_to_allocas ( fcx : @mut FunctionContext ,
@@ -1881,7 +1887,6 @@ pub fn trans_closure(ccx: @mut CrateContext,
1881
1887
debug ! ( "trans_closure(..., param_substs=%s)" ,
1882
1888
param_substs. repr( ccx. tcx) ) ;
1883
1889
1884
- // Set up arguments to the function.
1885
1890
let fcx = new_fn_ctxt_w_id ( ccx,
1886
1891
path,
1887
1892
llfndecl,
@@ -1892,21 +1897,23 @@ pub fn trans_closure(ccx: @mut CrateContext,
1892
1897
body. info ( ) ,
1893
1898
Some ( body. span ) ) ;
1894
1899
1895
- let raw_llargs = create_llargs_for_fn_args ( fcx, self_arg, decl. inputs ) ;
1896
-
1897
- // Set the fixed stack segment flag if necessary.
1898
- if attr:: contains_name ( attributes, "fixed_stack_segment" ) {
1899
- set_no_inline ( fcx. llfn ) ;
1900
- set_fixed_stack_segment ( fcx. llfn ) ;
1901
- }
1902
-
1903
1900
// Create the first basic block in the function and keep a handle on it to
1904
1901
// pass to finish_fn later.
1905
1902
let bcx_top = fcx. entry_bcx . unwrap ( ) ;
1906
1903
let mut bcx = bcx_top;
1907
1904
let block_ty = node_id_type ( bcx, body. id ) ;
1908
1905
1906
+ // Set up arguments to the function.
1909
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
+
1910
1917
bcx = copy_args_to_allocas ( fcx, bcx, decl. inputs , raw_llargs, arg_tys) ;
1911
1918
1912
1919
maybe_load_env ( fcx) ;
@@ -2108,10 +2115,11 @@ pub fn trans_enum_variant_or_tuple_like_struct<A:IdAndTy>(
2108
2115
None ,
2109
2116
None ) ;
2110
2117
2111
- 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) ;
2112
2121
2113
2122
let bcx = fcx. entry_bcx . unwrap ( ) ;
2114
- let arg_tys = ty:: ty_fn_args ( ctor_ty) ;
2115
2123
2116
2124
insert_synthetic_type_entries ( bcx, fn_args, arg_tys) ;
2117
2125
let bcx = copy_args_to_allocas ( fcx, bcx, fn_args, raw_llargs, arg_tys) ;
0 commit comments