@@ -22,6 +22,7 @@ use tracing::{debug, instrument};
2222
2323use crate :: builder:: matches:: util:: Range ;
2424use crate :: builder:: matches:: { Candidate , MatchPairTree , Test , TestBranch , TestCase , TestKind } ;
25+ use crate :: builder:: misc:: SpannedCallOperandsExt ;
2526use crate :: builder:: { BlockAnd , BlockAndExtension , Builder , PlaceBuilder } ;
2627
2728impl < ' a , ' tcx > Builder < ' a , ' tcx > {
@@ -311,73 +312,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
311312 }
312313 }
313314
314- fn intrinsic_offset (
315- & mut self ,
316- block : BasicBlock ,
317- ptr : Operand < ' tcx > ,
318- offset : Operand < ' tcx > ,
319- span : Span ,
320- ) -> BlockAnd < Place < ' tcx > > {
321- let tcx = self . tcx ;
322- let source_info = self . source_info ( span) ;
323- let ptr_ty = ptr. ty ( & self . local_decls , tcx) ;
324- let pointee_ty = ptr_ty. pointee ( ) ;
325- let func = Operand :: function_handle (
326- tcx,
327- tcx. require_lang_item ( LangItem :: Offset , Some ( span) ) ,
328- [ pointee_ty. into ( ) ] ,
329- span,
330- ) ;
331-
332- let out = self . temp ( ptr_ty, span) ;
333- let next_block = self . cfg . start_new_block ( ) ;
334- self . cfg . terminate ( block, source_info, TerminatorKind :: Call {
335- func,
336- args : [ Spanned { node : ptr, span } , Spanned { node : offset, span } ] . into ( ) ,
337- destination : out,
338- target : Some ( next_block) ,
339- unwind : UnwindAction :: Continue ,
340- call_source : CallSource :: Misc ,
341- fn_span : span,
342- } ) ;
343-
344- next_block. and ( out)
345- }
346-
347- fn intrinsic_aggregate_raw_ptr (
348- & mut self ,
349- block : BasicBlock ,
350- ptr : Operand < ' tcx > ,
351- data : Operand < ' tcx > ,
352- span : Span ,
353- ) -> BlockAnd < Place < ' tcx > > {
354- let tcx = self . tcx ;
355- let source_info = self . source_info ( span) ;
356- let ptr_ty = ptr. ty ( & self . local_decls , tcx) ;
357- let pointee_ty = ptr_ty. pointee ( ) ;
358- let func = Operand :: function_handle (
359- tcx,
360- tcx. require_lang_item ( LangItem :: AggregateRawPtr , Some ( span) ) ,
361- [ pointee_ty. into ( ) ] ,
362- span,
363- ) ;
364-
365- let aggregate_ptr_ty = Ty :: new_ptr ( tcx, Ty :: new_slice ( tcx, pointee_ty) , Mutability :: Not ) ;
366- let out = self . temp ( aggregate_ptr_ty, span) ;
367- let next_block = self . cfg . start_new_block ( ) ;
368- self . cfg . terminate ( block, source_info, TerminatorKind :: Call {
369- func,
370- args : [ Spanned { node : ptr, span } , Spanned { node : data, span } ] . into ( ) ,
371- destination : out,
372- target : Some ( next_block) ,
373- unwind : UnwindAction :: Continue ,
374- call_source : CallSource :: Misc ,
375- fn_span : span,
376- } ) ;
377-
378- next_block. and ( out)
379- }
380-
381315 fn subslice_sized_range (
382316 & mut self ,
383317 mut block : BasicBlock ,
@@ -431,21 +365,35 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
431365 Rvalue :: Cast ( CastKind :: PtrToPtr , Operand :: Copy ( temp_source_ptr) , elem_ptr_ty) ,
432366 ) ;
433367
434- let updated_ptr = unpack ! (
435- block = self . intrinsic_offset( block, Operand :: Copy ( temp_elem_ptr) , ptr_offset, span)
368+ let updated_ptr = self . temp ( elem_ptr_ty, span) ;
369+
370+ unpack ! (
371+ block = self . call_intrinsic(
372+ block,
373+ span,
374+ LangItem :: Offset ,
375+ & [ elem_ty] ,
376+ span. args( [ Operand :: Copy ( temp_elem_ptr) , ptr_offset] ) ,
377+ updated_ptr
378+ )
436379 ) ;
380+
437381 let slice_len = self . literal_operand ( span, slice_len) ;
382+ let slice_ptr_ty = Ty :: new_imm_ptr ( tcx, Ty :: new_slice ( tcx, elem_ty) ) ;
383+ let subslice_ptr = self . temp ( slice_ptr_ty, span) ;
438384
439- let subslice_ptr = unpack ! (
440- block = self . intrinsic_aggregate_raw_ptr (
385+ unpack ! (
386+ block = self . call_intrinsic (
441387 block,
442- Operand :: Copy ( updated_ptr) ,
443- slice_len,
444- span
388+ span,
389+ LangItem :: AggregateRawPtr ,
390+ & [ elem_ty] ,
391+ span. args( [ Operand :: Copy ( updated_ptr) , slice_len] ) ,
392+ subslice_ptr
445393 )
446394 ) ;
447- let out = PlaceBuilder :: from ( subslice_ptr) . project ( PlaceElem :: Deref ) . to_place ( self ) ;
448395
396+ let out = PlaceBuilder :: from ( subslice_ptr) . project ( PlaceElem :: Deref ) . to_place ( self ) ;
449397 block. and ( out)
450398 }
451399
0 commit comments