@@ -136,7 +136,7 @@ class ElementUseCollector {
136136 SILModule &Module;
137137 const PMOMemoryObjectInfo &TheMemory;
138138 SmallVectorImpl<PMOMemoryUse> &Uses;
139- SmallVectorImpl<SILInstruction *> & Releases;
139+ SmallVectorImpl<SILInstruction *> * Releases = nullptr ;
140140
141141 // / When walking the use list, if we index into a struct element, keep track
142142 // / of this, so that any indexes into tuple subelements don't affect the
@@ -146,7 +146,7 @@ class ElementUseCollector {
146146public:
147147 ElementUseCollector (const PMOMemoryObjectInfo &TheMemory,
148148 SmallVectorImpl<PMOMemoryUse> &Uses,
149- SmallVectorImpl<SILInstruction *> & Releases)
149+ SmallVectorImpl<SILInstruction *> * Releases)
150150 : Module(TheMemory.MemoryInst->getModule ()), TheMemory(TheMemory),
151151 Uses(Uses), Releases(Releases) {}
152152
@@ -212,7 +212,9 @@ bool ElementUseCollector::collectContainerUses(SILValue boxValue) {
212212 // eliminated. That should be implemented and fixed.
213213 if (isa<StrongReleaseInst>(user) || isa<ReleaseValueInst>(user) ||
214214 isa<DestroyValueInst>(user)) {
215- Releases.push_back (user);
215+ if (Releases) {
216+ Releases->push_back (user);
217+ }
216218 continue ;
217219 }
218220
@@ -436,7 +438,9 @@ bool ElementUseCollector::collectUses(SILValue Pointer) {
436438
437439 // We model destroy_addr as a release of the entire value.
438440 if (isa<DestroyAddrInst>(User)) {
439- Releases.push_back (User);
441+ if (Releases) {
442+ Releases->push_back (User);
443+ }
440444 continue ;
441445 }
442446
@@ -539,9 +543,16 @@ bool ElementUseCollector::collectUses(SILValue Pointer) {
539543
540544// / collectPMOElementUsesFrom - Analyze all uses of the specified allocation
541545// / instruction (alloc_box, alloc_stack or mark_uninitialized), classifying them
542- // / and storing the information found into the Uses and Releases lists.
546+ // / and storing the information found into the Uses lists.
543547bool swift::collectPMOElementUsesFrom (
548+ const PMOMemoryObjectInfo &MemoryInfo, SmallVectorImpl<PMOMemoryUse> &Uses)
549+ {
550+ return
551+ ElementUseCollector (MemoryInfo, Uses, /* Releases*/ nullptr ).collectFrom ();
552+ }
553+
554+ bool swift::collectPMOElementUsesAndDestroysFrom (
544555 const PMOMemoryObjectInfo &MemoryInfo, SmallVectorImpl<PMOMemoryUse> &Uses,
545556 SmallVectorImpl<SILInstruction *> &Releases) {
546- return ElementUseCollector (MemoryInfo, Uses, Releases).collectFrom ();
557+ return ElementUseCollector (MemoryInfo, Uses, & Releases).collectFrom ();
547558}
0 commit comments