@@ -90,80 +90,49 @@ class DeadEndBlocks {
9090 const SILFunction *getFunction () const { return f; }
9191};
9292
93- // / A struct that contains the intermediate state used in computing
94- // / joint-dominance sets. Enables a pass to easily reuse the same small data
95- // / structures with clearing (noting that clearing our internal state does not
96- // / cause us to shrink meaning that once we malloc, we keep the malloced
97- // / memory).
98- struct JointPostDominanceSetComputer {
99- // / The worklist that drives the algorithm.
100- SmallVector<SILBasicBlock *, 32 > worklist;
101-
102- // / A subset of our initial blocks that we found as a predecessor of another
103- // / block along our walk.
104- SmallVector<SILBasicBlock *, 8 > reachableInputBlocks;
105-
106- // / As we process the worklist, any successors that we see that have not been
107- // / visited yet are placed in here. At the end of our worklist, any blocks
108- // / that remain here are "leaking blocks" that together with our initial set
109- // / would provide a jointly-postdominating set of our dominating value.
110- SmallVector<SILBasicBlock *, 32 > blocksThatLeakIfNeverVisited;
111-
112- DeadEndBlocks &deadEndBlocks;
113-
114- JointPostDominanceSetComputer (DeadEndBlocks &deadEndBlocks)
115- : deadEndBlocks(deadEndBlocks) {}
116-
117- void clear () {
118- worklist.clear ();
119- reachableInputBlocks.clear ();
120- blocksThatLeakIfNeverVisited.clear ();
121- }
122-
123- // / Compute joint-postdominating set for \p dominatingBlock and \p
124- // / dominatedBlockSet found by walking up the CFG from the latter to the
125- // / former.
126- // /
127- // / We pass back the following information via callbacks so our callers can
128- // / use whatever container they need to:
129- // /
130- // / * inputBlocksFoundDuringWalk: Any blocks from the "dominated
131- // / block set" that was found as a predecessor block during our traversal is
132- // / passed to this callback. These can occur for two reasons:
133- // /
134- // / 1. We actually had a block in \p dominatedBlockSet that was reachable
135- // / from another block in said set. This is a valid usage of the API
136- // / since it could be that the user does not care about such uses and
137- // / leave this callback empty.
138- // /
139- // / 2. We had a block in \p dominatedBlockSet that is in a sub-loop in the
140- // / loop-nest relative to \p dominatingBlock causing us to go around a
141- // / backedge and hit the block during our traversal. In this case, we
142- // / have already during the traversal passed the exiting blocks of the
143- // / sub-loop as joint postdominace completion set blocks. This is useful
144- // / if one is using this API for lifetime extension purposes of lifetime
145- // / ending uses and one needs to insert compensating copy_value at these
146- // / locations due to the lack of strong control-equivalence in between
147- // / the block and \p dominatingBlock.
148- // /
149- // /
150- // / * foundJointPostDomSetCompletionBlocks: The set of blocks not in \p
151- // / dominatedBlockSet that together with \p dominatedBlockSet
152- // / jointly-postdominate \p dominatedBlock. This is "completing" the joint
153- // / post-dominance set.
154- // /
155- // / * inputBlocksInJointPostDomSet: Any of our input blocks that were never
156- // / found as a predecessor is passed to this callback. This block is in the
157- // / final minimal joint-postdominance set and is passed to this
158- // / callback. This is optional and we will avoid doing work if it is not
159- // / set.
160- void findJointPostDominatingSet (
161- SILBasicBlock *dominatingBlock,
162- ArrayRef<SILBasicBlock *> dominatedBlockSet,
163- function_ref<void (SILBasicBlock *)> inputBlocksFoundDuringWalk,
164- function_ref<void(SILBasicBlock *)> foundJointPostDomSetCompletionBlocks,
165- function_ref<void(SILBasicBlock *)> inputBlocksInJointPostDomSet = {});
166- };
93+ // / Compute joint-postdominating set for \p dominatingBlock and \p
94+ // / dominatedBlockSet found by walking up the CFG from the latter to the
95+ // / former.
96+ // /
97+ // / We pass back the following information via callbacks so our callers can
98+ // / use whatever container they need to:
99+ // /
100+ // / * inputBlocksFoundDuringWalk: Any blocks from the "dominated
101+ // / block set" that was found as a predecessor block during our traversal is
102+ // / passed to this callback. These can occur for two reasons:
103+ // /
104+ // / 1. We actually had a block in \p dominatedBlockSet that was reachable
105+ // / from another block in said set. This is a valid usage of the API
106+ // / since it could be that the user does not care about such uses and
107+ // / leave this callback empty.
108+ // /
109+ // / 2. We had a block in \p dominatedBlockSet that is in a sub-loop in the
110+ // / loop-nest relative to \p dominatingBlock causing us to go around a
111+ // / backedge and hit the block during our traversal. In this case, we
112+ // / have already during the traversal passed the exiting blocks of the
113+ // / sub-loop as joint postdominace completion set blocks. This is useful
114+ // / if one is using this API for lifetime extension purposes of lifetime
115+ // / ending uses and one needs to insert compensating copy_value at these
116+ // / locations due to the lack of strong control-equivalence in between
117+ // / the block and \p dominatingBlock.
118+ // /
119+ // /
120+ // / * foundJointPostDomSetCompletionBlocks: The set of blocks not in \p
121+ // / dominatedBlockSet that together with \p dominatedBlockSet
122+ // / jointly-postdominate \p dominatedBlock. This is "completing" the joint
123+ // / post-dominance set.
124+ // /
125+ // / * inputBlocksInJointPostDomSet: Any of our input blocks that were never
126+ // / found as a predecessor is passed to this callback. This block is in the
127+ // / final minimal joint-postdominance set and is passed to this
128+ // / callback. This is optional and we will avoid doing work if it is not
129+ // / set.
130+ void findJointPostDominatingSet (
131+ SILBasicBlock *dominatingBlock,
132+ ArrayRef<SILBasicBlock *> dominatedBlockSet,
133+ function_ref<void (SILBasicBlock *)> inputBlocksFoundDuringWalk,
134+ function_ref<void(SILBasicBlock *)> foundJointPostDomSetCompletionBlocks,
135+ function_ref<void(SILBasicBlock *)> inputBlocksInJointPostDomSet = {});
167136
168137} // namespace swift
169138
0 commit comments