@@ -171,13 +171,13 @@ pub trait ArgTypeExt<'ll, 'tcx> {
171
171
fn memory_ty ( & self , cx : & CodegenCx < ' ll , ' tcx > ) -> & ' ll Type ;
172
172
fn store (
173
173
& self ,
174
- bx : & Builder < ' _ , ' ll , ' tcx > ,
174
+ bx : & mut Builder < ' _ , ' ll , ' tcx > ,
175
175
val : & ' ll Value ,
176
176
dst : PlaceRef < ' tcx , & ' ll Value > ,
177
177
) ;
178
178
fn store_fn_arg (
179
179
& self ,
180
- bx : & Builder < ' _ , ' ll , ' tcx > ,
180
+ bx : & mut Builder < ' _ , ' ll , ' tcx > ,
181
181
idx : & mut usize ,
182
182
dst : PlaceRef < ' tcx , & ' ll Value > ,
183
183
) ;
@@ -196,14 +196,13 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
196
196
/// or results of call/invoke instructions into their destinations.
197
197
fn store (
198
198
& self ,
199
- bx : & Builder < ' _ , ' ll , ' tcx > ,
199
+ bx : & mut Builder < ' _ , ' ll , ' tcx > ,
200
200
val : & ' ll Value ,
201
201
dst : PlaceRef < ' tcx , & ' ll Value > ,
202
202
) {
203
203
if self . is_ignore ( ) {
204
204
return ;
205
205
}
206
- let cx = bx. cx ( ) ;
207
206
if self . is_sized_indirect ( ) {
208
207
OperandValue :: Ref ( val, None , self . layout . align ) . store ( bx, dst)
209
208
} else if self . is_unsized_indirect ( ) {
@@ -213,7 +212,8 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
213
212
// uses it for i16 -> {i8, i8}, but not for i24 -> {i8, i8, i8}.
214
213
let can_store_through_cast_ptr = false ;
215
214
if can_store_through_cast_ptr {
216
- let cast_dst = bx. pointercast ( dst. llval , cx. type_ptr_to ( cast. llvm_type ( cx) ) ) ;
215
+ let cast_ptr_llty = bx. cx ( ) . type_ptr_to ( cast. llvm_type ( bx. cx ( ) ) ) ;
216
+ let cast_dst = bx. pointercast ( dst. llval , cast_ptr_llty) ;
217
217
bx. store ( val, cast_dst, self . layout . align ) ;
218
218
} else {
219
219
// The actual return type is a struct, but the ABI
@@ -231,21 +231,21 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
231
231
// bitcasting to the struct type yields invalid cast errors.
232
232
233
233
// We instead thus allocate some scratch space...
234
- let scratch_size = cast. size ( cx ) ;
235
- let scratch_align = cast. align ( cx ) ;
236
- let llscratch = bx. alloca ( cast. llvm_type ( cx ) , "abi_cast" , scratch_align) ;
234
+ let scratch_size = cast. size ( bx . cx ( ) ) ;
235
+ let scratch_align = cast. align ( bx . cx ( ) ) ;
236
+ let llscratch = bx. alloca ( cast. llvm_type ( bx . cx ( ) ) , "abi_cast" , scratch_align) ;
237
237
bx. lifetime_start ( llscratch, scratch_size) ;
238
238
239
239
// ...where we first store the value...
240
240
bx. store ( val, llscratch, scratch_align) ;
241
241
242
242
// ...and then memcpy it to the intended destination.
243
243
bx. memcpy (
244
- bx . pointercast ( dst. llval , cx . type_i8p ( ) ) ,
244
+ dst. llval ,
245
245
self . layout . align ,
246
- bx . pointercast ( llscratch, cx . type_i8p ( ) ) ,
246
+ llscratch,
247
247
scratch_align,
248
- cx . const_usize ( self . layout . size . bytes ( ) ) ,
248
+ bx . cx ( ) . const_usize ( self . layout . size . bytes ( ) ) ,
249
249
MemFlags :: empty ( )
250
250
) ;
251
251
@@ -258,7 +258,7 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
258
258
259
259
fn store_fn_arg (
260
260
& self ,
261
- bx : & Builder < ' a , ' ll , ' tcx > ,
261
+ bx : & mut Builder < ' a , ' ll , ' tcx > ,
262
262
idx : & mut usize ,
263
263
dst : PlaceRef < ' tcx , & ' ll Value > ,
264
264
) {
@@ -284,14 +284,14 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
284
284
285
285
impl ArgTypeMethods < ' tcx > for Builder < ' a , ' ll , ' tcx > {
286
286
fn store_fn_arg (
287
- & self ,
287
+ & mut self ,
288
288
ty : & ArgType < ' tcx , Ty < ' tcx > > ,
289
289
idx : & mut usize , dst : PlaceRef < ' tcx , Self :: Value >
290
290
) {
291
291
ty. store_fn_arg ( self , idx, dst)
292
292
}
293
293
fn store_arg_ty (
294
- & self ,
294
+ & mut self ,
295
295
ty : & ArgType < ' tcx , Ty < ' tcx > > ,
296
296
val : & ' ll Value ,
297
297
dst : PlaceRef < ' tcx , & ' ll Value >
@@ -324,7 +324,7 @@ pub trait FnTypeExt<'tcx> {
324
324
fn ptr_to_llvm_type ( & self , cx : & CodegenCx < ' ll , ' tcx > ) -> & ' ll Type ;
325
325
fn llvm_cconv ( & self ) -> llvm:: CallConv ;
326
326
fn apply_attrs_llfn ( & self , llfn : & ' ll Value ) ;
327
- fn apply_attrs_callsite ( & self , bx : & Builder < ' a , ' ll , ' tcx > , callsite : & ' ll Value ) ;
327
+ fn apply_attrs_callsite ( & self , bx : & mut Builder < ' a , ' ll , ' tcx > , callsite : & ' ll Value ) ;
328
328
}
329
329
330
330
impl < ' tcx > FnTypeExt < ' tcx > for FnType < ' tcx , Ty < ' tcx > > {
@@ -761,7 +761,7 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
761
761
}
762
762
}
763
763
764
- fn apply_attrs_callsite ( & self , bx : & Builder < ' a , ' ll , ' tcx > , callsite : & ' ll Value ) {
764
+ fn apply_attrs_callsite ( & self , bx : & mut Builder < ' a , ' ll , ' tcx > , callsite : & ' ll Value ) {
765
765
let mut i = 0 ;
766
766
let mut apply = |attrs : & ArgAttributes | {
767
767
attrs. apply_callsite ( llvm:: AttributePlace :: Argument ( i) , callsite) ;
@@ -832,7 +832,7 @@ impl AbiMethods<'tcx> for CodegenCx<'ll, 'tcx> {
832
832
833
833
impl AbiBuilderMethods < ' tcx > for Builder < ' a , ' ll , ' tcx > {
834
834
fn apply_attrs_callsite (
835
- & self ,
835
+ & mut self ,
836
836
ty : & FnType < ' tcx , Ty < ' tcx > > ,
837
837
callsite : Self :: Value
838
838
) {
0 commit comments