@@ -759,20 +759,8 @@ extension InteriorUseWalker {
759
759
if let inst = operand. instruction as? ForwardingInstruction {
760
760
return inst. forwardedResults. walk { walkDownUses ( of: $0) }
761
761
}
762
- if let phi = Phi ( using: operand) {
763
- if phi. value. ownership == . guaranteed {
764
- return walkDown ( guaranteedPhi: phi)
765
- }
766
- // This is a phi of a dependent value. partial_apply [on_stack]
767
- // and mark_dependence [nonescaping] cannot be cloned, so all
768
- // dependent phis must be dominated.
769
- assert ( definingValue. parentBlock. dominates ( phi. successor,
770
- functionContext. dominatorTree) ,
771
- " on-stack partial apply cannot be cloned " )
772
- return walkDownUses ( of: phi. value)
773
- }
774
- // TODO: verify that ForwardInstruction handles all .forward
775
- // operand ownership and change this to a fatalError.
762
+ // TODO: verify that ForwardInstruction handles all .forward operand ownership and assert that only phis can be
763
+ // reached: assert(Phi(using: operand) != nil)
776
764
return . continueWalk
777
765
}
778
766
@@ -796,79 +784,6 @@ extension InteriorUseWalker {
796
784
fatalError ( " ownership requires a lifetime " )
797
785
}
798
786
}
799
-
800
- // Dominating definingValue example: walkDown must continue visiting
801
- // uses of a reborrow in the inner borrow scope:
802
- //
803
- // bb0:
804
- // d1 = ...
805
- // cond_br bb1, bb2
806
- // bb1:
807
- // b1 = borrow d1
808
- // br bb3(b1)
809
- // bb2:
810
- // b2 = borrow d1
811
- // br bb3(b2)
812
- // bb3(reborrow):
813
- // u1 = d1
814
- // u2 = reborrow
815
- // // can't move destroy above u2
816
- // destroy_value d1
817
- //
818
- // Dominating definingValue example: walkDown must continue visiting
819
- // uses of a guaranteed phi in the outer lifetime:
820
- //
821
- // bb0:
822
- // b1 = borrow d1
823
- // cond_br bb1, bb2
824
- // bb1:
825
- // p1 = projection b1
826
- // br bb3(p1)
827
- // bb2:
828
- // p1 = projection b1
829
- // br bb3(p2)
830
- // bb3(forwardingPhi):
831
- // u1 = b1
832
- // u2 = forwardingPhi
833
- // // can't move end_borrow above u2
834
- // end_borrow b1
835
- private mutating func walkDown( guaranteedPhi: Phi ) -> WalkResult {
836
- guard visited. insert ( guaranteedPhi. value) else {
837
- return . continueWalk
838
- }
839
- let phiValue = guaranteedPhi. value. lookThroughBorrowedFromUser
840
- guard phiValue. getEnclosingValues ( functionContext) . contains ( definingValue) else {
841
- // Since definingValue is not an enclosing value, it must be
842
- // consumed or reborrowed by some outer adjacent phi in this
843
- // block. An outer adjacent phi's uses do not contribute to the
844
- // outer liveness. Instead, guaranteedPhi will be recorded as a
845
- // regular lifetime-ending use by the visitor.
846
- return . continueWalk
847
- }
848
- // definingValue is not consumed or reborrowed by an outer
849
- // adjacent phi in guaranteedPhi's block. Therefore this
850
- // guaranteedPhi's uses contribute to the liveness of
851
- // definingValue.
852
- //
853
- // TODO: instead of relying on Dominance, we can reformulate
854
- // this algorithm to detect redundant phis, similar to the
855
- // SSAUpdater.
856
- if !definingValue. parentBlock. dominates ( guaranteedPhi. successor,
857
- functionContext. dominatorTree) {
858
- // definingValue does not dominate guaranteedPhi. Record this
859
- // unenclosed phi so the liveness client can insert the missing
860
- // outer adjacent phi.
861
- unenclosedPhis. append ( guaranteedPhi) ;
862
- return . continueWalk
863
- }
864
- // Since definingValue dominates guaranteedPhi, this is a well-formed linear
865
- // lifetime, and liveness can proceed.
866
- if guaranteedPhi. isReborrow {
867
- return visitInnerScopeUses ( of: guaranteedPhi. value)
868
- } else {
869
- return visitAllUses ( of: guaranteedPhi. value)
870
- }
871
- }
872
787
}
873
788
874
789
/// Cache the liveness boundary by taking a snapshot of its InstructionRange.
@@ -954,9 +869,6 @@ let interiorLivenessTest = FunctionTest("interior_liveness_swift") {
954
869
print ( " Incomplete liveness " )
955
870
}
956
871
print ( range)
957
- print ( " Unenclosed phis { " )
958
- visitor. unenclosedPhis. forEach { print ( " \( $0) " ) }
959
- print ( " } " )
960
872
961
873
var boundary = LivenessBoundary ( value: value, range: range, context)
962
874
defer { boundary. deinitialize ( ) }
0 commit comments