@@ -1780,16 +1780,20 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t) -> Vec<(uint, u6
1780
1780
1781
1781
for ( idx, & t) in fn_sig. inputs. iter( ) . enumerate( ) . map( |( i, v) | ( i + first_arg_offset, v) ) {
1782
1782
match ty:: get( t) . sty {
1783
+ // this needs to be first to prevent fat pointers from falling through
1784
+ _ if !type_is_immediate( ccx, t) => {
1785
+ // For non-immediate arguments the callee gets its own copy of
1786
+ // the value on the stack, so there are no aliases. It's also
1787
+ // program-invisible so can't possibly capture
1788
+ attrs. push( ( idx, lib:: llvm:: NoAliasAttribute as u64 ) ) ;
1789
+ attrs. push( ( idx, lib:: llvm:: NoCaptureAttribute as u64 ) ) ;
1790
+ attrs. push( ( idx, lib:: llvm:: NonNullAttribute as u64 ) ) ;
1791
+ }
1783
1792
// `~` pointer parameters never alias because ownership is transferred
1784
1793
ty:: ty_uniq( _) => {
1785
1794
attrs. push( ( idx, lib:: llvm:: NoAliasAttribute as u64 ) ) ;
1786
1795
attrs. push( ( idx, lib:: llvm:: NonNullAttribute as u64 ) ) ;
1787
1796
}
1788
- // These are not really pointers but pairs, (pointer, len)
1789
- ty:: ty_rptr( _, ty:: mt { ty: it, .. } ) |
1790
- ty:: ty_rptr( _, ty:: mt { ty: it, .. } ) if match ty:: get( it) . sty {
1791
- ty:: ty_str | ty:: ty_vec( ..) => true , _ => false
1792
- } => { }
1793
1797
// `&mut` pointer parameters never alias other parameters, or mutable global data
1794
1798
ty:: ty_rptr( b, mt) if mt. mutbl == ast:: MutMutable => {
1795
1799
attrs. push( ( idx, lib:: llvm:: NoAliasAttribute as u64 ) ) ;
@@ -1811,15 +1815,7 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t) -> Vec<(uint, u6
1811
1815
ty:: ty_rptr( _, _) => {
1812
1816
attrs. push( ( idx, lib:: llvm:: NonNullAttribute as u64 ) ) ;
1813
1817
}
1814
- _ => {
1815
- // For non-immediate arguments the callee gets its own copy of
1816
- // the value on the stack, so there are no aliases. It's also
1817
- // program-invisible so can't possibly capture
1818
- if !type_is_immediate( ccx, t) {
1819
- attrs. push( ( idx, lib:: llvm:: NoAliasAttribute as u64 ) ) ;
1820
- attrs. push( ( idx, lib:: llvm:: NoCaptureAttribute as u64 ) ) ;
1821
- }
1822
- }
1818
+ _ => ( )
1823
1819
}
1824
1820
}
1825
1821
0 commit comments