@@ -236,13 +236,6 @@ pub(super) fn simplify_call(
236236 vector. pop_front ( ) . expect ( "There are no elements in this vector to be removed" )
237237 } ) ;
238238
239- // The popped elements are reused by `ValueId` from the source vector, so any
240- // array-typed element still aliases the source's underlying memory. Bump the
241- // reference count so a subsequent mutation through the popped value does not
242- // mutate the source in place. The same invariant is enforced for plain indexing
243- // by the `ownership` pass (see `handle_index`).
244- inc_rc_array_results ( & results, dfg, block, call_stack) ;
245-
246239 let new_vector_length =
247240 decrement_vector_length ( arguments[ 0 ] , dfg, block, call_stack) ;
248241
@@ -325,12 +318,6 @@ pub(super) fn simplify_call(
325318 results. push ( vector. remove ( index) ) ;
326319 }
327320
328- // The removed elements are reused by `ValueId` from the source vector, so any
329- // array-typed element still aliases the source's memory. Bump the RC to preserve
330- // copy-on-write semantics. See `inc_rc_array_results` for the matching invariant
331- // in `pop_front` / `pop_back`.
332- inc_rc_array_results ( & results, dfg, block, call_stack) ;
333-
334321 let new_vector = make_array ( dfg, vector, typ, block, call_stack) ;
335322 results. insert ( 0 , new_vector) ;
336323
@@ -682,27 +669,6 @@ fn decrement_vector_length(
682669 update_vector_length ( vector_len, dfg, BinaryOp :: Sub { unchecked : true } , block, call_stack)
683670}
684671
685- /// Emit `inc_rc` for each value whose type is an array or vector. Used by vector intrinsic
686- /// simplifications that hand back `ValueId`s of elements from the source vector: those elements
687- /// still alias the source's memory, so the reference count must be bumped to preserve
688- /// copy-on-write semantics. No-op under the ACIR runtime, which does not track reference counts.
689- fn inc_rc_array_results (
690- values : & [ ValueId ] ,
691- dfg : & mut DataFlowGraph ,
692- block : BasicBlockId ,
693- call_stack : CallStackId ,
694- ) {
695- if dfg. runtime ( ) . is_acir ( ) {
696- return ;
697- }
698- for value in values {
699- if dfg. type_of_value ( * value) . is_array ( ) {
700- let instruction = Instruction :: IncrementRc { value : * value } ;
701- dfg. insert_instruction_and_results ( instruction, block, None , call_stack) ;
702- }
703- }
704- }
705-
706672/// Simplify a vector push back when the length is not known to equal capacity, ie. we don't
707673/// know whether we to push new items and grow the capacity of the vector, or overwrite the
708674/// next padding item.
@@ -789,12 +755,6 @@ fn simplify_vector_pop_back(
789755 vector. pop_back ( ) ;
790756 }
791757
792- // The popped elements still alias the source vector's memory (`array_get` reads a value
793- // without bumping its reference count). Bump the RC for any array-typed element so that a
794- // subsequent mutation through the popped value triggers copy-on-write instead of mutating
795- // the source. See `inc_rc_array_results` for the matching invariant in `pop_front`.
796- inc_rc_array_results ( results. make_contiguous ( ) , dfg, block, call_stack) ;
797-
798758 let new_vector = make_array ( dfg, vector, vector_type, block, call_stack) ;
799759 results. push_front ( new_vector) ;
800760
0 commit comments