@@ -3,7 +3,7 @@ use rustc_codegen_ssa::traits::{AbiBuilderMethods, BaseTypeMethods};
3
3
use rustc_data_structures:: fx:: FxHashSet ;
4
4
use rustc_middle:: bug;
5
5
use rustc_middle:: ty:: Ty ;
6
- use rustc_target:: abi:: call:: { CastTarget , FnAbi , PassMode , Reg , RegKind } ;
6
+ use rustc_target:: abi:: call:: { ArgAttributes , CastTarget , FnAbi , PassMode , Reg , RegKind } ;
7
7
8
8
use crate :: builder:: Builder ;
9
9
use crate :: context:: CodegenCx ;
@@ -120,30 +120,47 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
120
120
}
121
121
} ;
122
122
123
+ #[ cfg( feature = "master" ) ]
124
+ let apply_attrs = |ty : Type < ' gcc > , attrs : & ArgAttributes | {
125
+ if attrs. regular . contains ( rustc_target:: abi:: call:: ArgAttribute :: NoAlias ) {
126
+ ty. make_restrict ( )
127
+ } else {
128
+ ty
129
+ }
130
+ } ;
131
+ #[ cfg( not( feature = "master" ) ) ]
132
+ let apply_attrs = |ty : Type < ' gcc > , _attrs : & ArgAttributes | {
133
+ ty
134
+ } ;
135
+
123
136
for arg in self . args . iter ( ) {
124
137
let arg_ty = match arg. mode {
125
138
PassMode :: Ignore => continue ,
126
- PassMode :: Direct ( _) => arg. layout . immediate_gcc_type ( cx) ,
127
- PassMode :: Pair ( ..) => {
128
- argument_tys. push ( arg. layout . scalar_pair_element_gcc_type ( cx, 0 , true ) ) ;
129
- argument_tys. push ( arg. layout . scalar_pair_element_gcc_type ( cx, 1 , true ) ) ;
139
+ PassMode :: Pair ( a, b) => {
140
+ argument_tys. push ( apply_attrs ( arg. layout . scalar_pair_element_gcc_type ( cx, 0 , true ) , & a) ) ;
141
+ argument_tys. push ( apply_attrs ( arg. layout . scalar_pair_element_gcc_type ( cx, 1 , true ) , & b) ) ;
130
142
continue ;
131
143
}
132
- PassMode :: Indirect { extra_attrs : Some ( _) , .. } => {
133
- unimplemented ! ( ) ;
134
- }
135
144
PassMode :: Cast ( ref cast, pad_i32) => {
136
145
// add padding
137
146
if pad_i32 {
138
147
argument_tys. push ( Reg :: i32 ( ) . gcc_type ( cx) ) ;
139
148
}
140
- cast. gcc_type ( cx)
149
+ let ty = cast. gcc_type ( cx) ;
150
+ apply_attrs ( ty, & cast. attrs )
141
151
}
142
- PassMode :: Indirect { extra_attrs : None , on_stack : true , .. } => {
152
+ PassMode :: Indirect { attrs , extra_attrs : None , on_stack : true } => {
143
153
on_stack_param_indices. insert ( argument_tys. len ( ) ) ;
144
- arg. memory_ty ( cx)
154
+ apply_attrs ( arg. memory_ty ( cx) , & attrs )
145
155
} ,
146
- PassMode :: Indirect { extra_attrs : None , on_stack : false , .. } => cx. type_ptr_to ( arg. memory_ty ( cx) ) ,
156
+ PassMode :: Direct ( attrs) => apply_attrs ( arg. layout . immediate_gcc_type ( cx) , & attrs) ,
157
+ PassMode :: Indirect { attrs, extra_attrs : None , on_stack : false } => {
158
+ apply_attrs ( cx. type_ptr_to ( arg. memory_ty ( cx) ) , & attrs)
159
+ }
160
+ PassMode :: Indirect { attrs, extra_attrs : Some ( extra_attrs) , on_stack } => {
161
+ assert ! ( !on_stack) ;
162
+ apply_attrs ( apply_attrs ( cx. type_ptr_to ( arg. memory_ty ( cx) ) , & attrs) , & extra_attrs)
163
+ }
147
164
} ;
148
165
argument_tys. push ( arg_ty) ;
149
166
}
0 commit comments