@@ -109,6 +109,43 @@ static bool endLifetimeAtLivenessBoundary(SILValue value,
109109 return changed;
110110}
111111
112+ static void visitUsersOutsideLinearLivenessBoundary (
113+ SILValue value, const SSAPrunedLiveness &liveness,
114+ llvm::function_ref<void (SILInstruction *)> visitor) {
115+ if (value->getOwnershipKind () == OwnershipKind::None) {
116+ return ;
117+ }
118+ LinearLiveness linearLiveness (value);
119+ linearLiveness.compute ();
120+ for (auto pair : liveness.getAllUsers ()) {
121+ if (pair.second .isEnding () || isa<ExtendLifetimeInst>(pair.first )) {
122+ continue ;
123+ }
124+ auto *user = pair.first ;
125+ if (linearLiveness.getLiveness ().isWithinBoundary (user)) {
126+ continue ;
127+ }
128+ visitor (user);
129+ }
130+ }
131+
132+ namespace swift ::test {
133+ // Arguments:
134+ // - SILValue: value
135+ // Dumps:
136+ // - the instructions outside the liveness boundary
137+ static FunctionTest LivenessPartialBoundaryOutsideUsersTest (
138+ " liveness_partial_boundary_outside_users" ,
139+ [](auto &function, auto &arguments, auto &test) {
140+ SILValue value = arguments.takeValue ();
141+ InteriorLiveness liveness (value);
142+ liveness.compute (test.getDominanceInfo ());
143+ visitUsersOutsideLinearLivenessBoundary (
144+ value, liveness.getLiveness (),
145+ [](auto *inst) { inst->print (llvm::outs ()); });
146+ });
147+ } // end namespace swift::test
148+
112149namespace {
113150// / Implements OSSALifetimeCompletion::visitAvailabilityBoundary. Finds
114151// / positions as near as possible to unreachables at which `value`'s lifetime
0 commit comments