@@ -225,7 +225,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
225
225
226
226
let mut on_stack_param_indices = FxHashSet :: default ( ) ;
227
227
if let Some ( indices) = self . on_stack_params . borrow ( ) . get ( & gcc_func) {
228
- on_stack_param_indices = indices . clone ( ) ;
228
+ on_stack_param_indices. clone_from ( indices ) ;
229
229
}
230
230
231
231
if all_args_match {
@@ -256,8 +256,8 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
256
256
actual_val. dereference ( self . location ) . to_rvalue ( )
257
257
} else {
258
258
assert ! (
259
- ! ( ( actual_ty . is_vector( ) && !expected_ty . is_vector( ) )
260
- || ( !actual_ty . is_vector( ) && expected_ty . is_vector( ) ) ) ,
259
+ ( !expected_ty . is_vector( ) || actual_ty . is_vector( ) )
260
+ && ( expected_ty . is_vector( ) || !actual_ty . is_vector( ) ) ,
261
261
"{:?} ({}) -> {:?} ({}), index: {:?}[{}]" ,
262
262
actual_ty,
263
263
actual_ty. is_vector( ) ,
@@ -277,8 +277,8 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
277
277
. collect ( ) ;
278
278
279
279
// NOTE: to take into account variadic functions.
280
- for i in casted_args . len ( ) ..args . len ( ) {
281
- casted_args. push ( args [ i ] ) ;
280
+ for arg in args . iter ( ) . skip ( casted_args . len ( ) ) {
281
+ casted_args. push ( * arg ) ;
282
282
}
283
283
284
284
Cow :: Owned ( casted_args)
@@ -353,15 +353,15 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
353
353
let function_address_names = self . function_address_names . borrow ( ) ;
354
354
let original_function_name = function_address_names. get ( & func_ptr) ;
355
355
llvm:: adjust_intrinsic_arguments (
356
- & self ,
356
+ self ,
357
357
gcc_func,
358
358
args. into ( ) ,
359
359
& func_name,
360
360
original_function_name,
361
361
)
362
362
} ;
363
363
let args_adjusted = args. len ( ) != previous_arg_count;
364
- let args = self . check_ptr_call ( "call" , func_ptr, & * args) ;
364
+ let args = self . check_ptr_call ( "call" , func_ptr, & args) ;
365
365
366
366
// gccjit requires to use the result of functions, even when it's not used.
367
367
// That's why we assign the result to a local or call add_eval().
@@ -373,7 +373,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
373
373
unsafe { RETURN_VALUE_COUNT += 1 } ;
374
374
let return_value = self . cx . context . new_call_through_ptr ( self . location , func_ptr, & args) ;
375
375
let return_value = llvm:: adjust_intrinsic_return_value (
376
- & self ,
376
+ self ,
377
377
return_value,
378
378
& func_name,
379
379
& args,
@@ -441,7 +441,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
441
441
self . block . add_assignment (
442
442
self . location ,
443
443
result,
444
- self . cx . context . new_call ( self . location , func, & args) ,
444
+ self . cx . context . new_call ( self . location , func, args) ,
445
445
) ;
446
446
result. to_rvalue ( )
447
447
}
@@ -595,7 +595,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
595
595
) -> RValue < ' gcc > {
596
596
let try_block = self . current_func ( ) . new_block ( "try" ) ;
597
597
598
- let current_block = self . block . clone ( ) ;
598
+ let current_block = self . block ;
599
599
self . block = try_block;
600
600
let call = self . call ( typ, fn_attrs, None , func, args, None ) ; // TODO(antoyo): use funclet here?
601
601
self . block = current_block;
@@ -1176,7 +1176,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
1176
1176
// NOTE: due to opaque pointers now being used, we need to cast here.
1177
1177
let ptr = self . context . new_cast ( self . location , ptr, typ. make_pointer ( ) ) ;
1178
1178
// NOTE: array indexing is always considered in bounds in GCC (TODO(antoyo): to be verified).
1179
- let mut indices = indices. into_iter ( ) ;
1179
+ let mut indices = indices. iter ( ) ;
1180
1180
let index = indices. next ( ) . expect ( "first index in inbounds_gep" ) ;
1181
1181
let mut result = self . context . new_array_access ( self . location , ptr, * index) ;
1182
1182
for index in indices {
@@ -1684,7 +1684,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
1684
1684
1685
1685
fn zext ( & mut self , value : RValue < ' gcc > , dest_typ : Type < ' gcc > ) -> RValue < ' gcc > {
1686
1686
// FIXME(antoyo): this does not zero-extend.
1687
- if value. get_type ( ) . is_bool ( ) && dest_typ. is_i8 ( & self . cx ) {
1687
+ if value. get_type ( ) . is_bool ( ) && dest_typ. is_i8 ( self . cx ) {
1688
1688
// FIXME(antoyo): hack because base::from_immediate converts i1 to i8.
1689
1689
// Fix the code in codegen_ssa::base::from_immediate.
1690
1690
return value;
@@ -2057,7 +2057,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
2057
2057
self . context . new_rvalue_from_vector ( self . location , mask_type, & vector_elements) ;
2058
2058
let shifted = self . context . new_rvalue_vector_perm ( self . location , res, res, mask) ;
2059
2059
shift *= 2 ;
2060
- res = op ( res, shifted, & self . context ) ;
2060
+ res = op ( res, shifted, self . context ) ;
2061
2061
}
2062
2062
self . context
2063
2063
. new_vector_access ( self . location , res, self . context . new_rvalue_zero ( self . int_type ) )
@@ -2073,7 +2073,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
2073
2073
}
2074
2074
2075
2075
pub fn vector_reduce_op ( & mut self , src : RValue < ' gcc > , op : BinaryOp ) -> RValue < ' gcc > {
2076
- let loc = self . location . clone ( ) ;
2076
+ let loc = self . location ;
2077
2077
self . vector_reduce ( src, |a, b, context| context. new_binary_op ( loc, op, a. get_type ( ) , a, b) )
2078
2078
}
2079
2079
@@ -2090,7 +2090,6 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
2090
2090
let vector_type = src. get_type ( ) . unqualified ( ) . dyncast_vector ( ) . expect ( "vector type" ) ;
2091
2091
let element_count = vector_type. get_num_units ( ) ;
2092
2092
( 0 ..element_count)
2093
- . into_iter ( )
2094
2093
. map ( |i| {
2095
2094
self . context
2096
2095
. new_vector_access (
@@ -2121,7 +2120,6 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
2121
2120
let vector_type = src. get_type ( ) . unqualified ( ) . dyncast_vector ( ) . expect ( "vector type" ) ;
2122
2121
let element_count = vector_type. get_num_units ( ) ;
2123
2122
( 0 ..element_count)
2124
- . into_iter ( )
2125
2123
. map ( |i| {
2126
2124
self . context
2127
2125
. new_vector_access (
@@ -2141,7 +2139,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
2141
2139
2142
2140
// Inspired by Hacker's Delight min implementation.
2143
2141
pub fn vector_reduce_min ( & mut self , src : RValue < ' gcc > ) -> RValue < ' gcc > {
2144
- let loc = self . location . clone ( ) ;
2142
+ let loc = self . location ;
2145
2143
self . vector_reduce ( src, |a, b, context| {
2146
2144
let differences_or_zeros = difference_or_zero ( loc, a, b, context) ;
2147
2145
context. new_binary_op ( loc, BinaryOp :: Plus , b. get_type ( ) , b, differences_or_zeros)
@@ -2150,7 +2148,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
2150
2148
2151
2149
// Inspired by Hacker's Delight max implementation.
2152
2150
pub fn vector_reduce_max ( & mut self , src : RValue < ' gcc > ) -> RValue < ' gcc > {
2153
- let loc = self . location . clone ( ) ;
2151
+ let loc = self . location ;
2154
2152
self . vector_reduce ( src, |a, b, context| {
2155
2153
let differences_or_zeros = difference_or_zero ( loc, a, b, context) ;
2156
2154
context. new_binary_op ( loc, BinaryOp :: Minus , a. get_type ( ) , a, differences_or_zeros)
@@ -2345,7 +2343,7 @@ impl<'tcx> HasParamEnv<'tcx> for Builder<'_, '_, 'tcx> {
2345
2343
2346
2344
impl < ' tcx > HasTargetSpec for Builder < ' _ , ' _ , ' tcx > {
2347
2345
fn target_spec ( & self ) -> & Target {
2348
- & self . cx . target_spec ( )
2346
+ self . cx . target_spec ( )
2349
2347
}
2350
2348
}
2351
2349
0 commit comments