@@ -1728,16 +1728,20 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t) -> Vec<(uint, u6
1728
1728
1729
1729
for ( idx, & t) in fn_sig. inputs. iter( ) . enumerate( ) . map( |( i, v) | ( i + first_arg_offset, v) ) {
1730
1730
match ty:: get( t) . sty {
1731
+ // this needs to be first to prevent fat pointers from falling through
1732
+ _ if !type_is_immediate( ccx, t) => {
1733
+ // For non-immediate arguments the callee gets its own copy of
1734
+ // the value on the stack, so there are no aliases. It's also
1735
+ // program-invisible so can't possibly capture
1736
+ attrs. push( ( idx, lib:: llvm:: NoAliasAttribute as u64 ) ) ;
1737
+ attrs. push( ( idx, lib:: llvm:: NoCaptureAttribute as u64 ) ) ;
1738
+ attrs. push( ( idx, lib:: llvm:: NonNullAttribute as u64 ) ) ;
1739
+ }
1731
1740
// `~` pointer parameters never alias because ownership is transferred
1732
1741
ty:: ty_uniq( _) => {
1733
1742
attrs. push( ( idx, lib:: llvm:: NoAliasAttribute as u64 ) ) ;
1734
1743
attrs. push( ( idx, lib:: llvm:: NonNullAttribute as u64 ) ) ;
1735
1744
}
1736
- // These are not really pointers but pairs, (pointer, len)
1737
- ty:: ty_rptr( _, ty:: mt { ty: it, .. } ) |
1738
- ty:: ty_rptr( _, ty:: mt { ty: it, .. } ) if match ty:: get( it) . sty {
1739
- ty:: ty_str | ty:: ty_vec( ..) => true , _ => false
1740
- } => { }
1741
1745
// `&mut` pointer parameters never alias other parameters, or mutable global data
1742
1746
ty:: ty_rptr( b, mt) if mt. mutbl == ast:: MutMutable => {
1743
1747
attrs. push( ( idx, lib:: llvm:: NoAliasAttribute as u64 ) ) ;
@@ -1759,16 +1763,7 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t) -> Vec<(uint, u6
1759
1763
ty:: ty_rptr( _, _) => {
1760
1764
attrs. push( ( idx, lib:: llvm:: NonNullAttribute as u64 ) ) ;
1761
1765
}
1762
- _ => {
1763
- // For non-immediate arguments the callee gets its own copy of
1764
- // the value on the stack, so there are no aliases. It's also
1765
- // program-invisible so can't possibly capture
1766
- if !type_is_immediate( ccx, t) {
1767
- attrs. push( ( idx, lib:: llvm:: NoAliasAttribute as u64 ) ) ;
1768
- attrs. push( ( idx, lib:: llvm:: NoCaptureAttribute as u64 ) ) ;
1769
- attrs. push( ( idx, lib:: llvm:: NonNullAttribute as u64 ) ) ;
1770
- }
1771
- }
1766
+ _ => ( )
1772
1767
}
1773
1768
}
1774
1769
0 commit comments