@@ -51,7 +51,7 @@ namespace psr {
5151
5252LLVMPointsToSet::LLVMPointsToSet (ProjectIRDB &IRDB, bool UseLazyEvaluation,
5353 PointerAnalysisType PATy)
54- : PTA(IRDB, UseLazyEvaluation, PATy) {
54+ : PTA(IRDB, UseLazyEvaluation, PATy), Owner(IRDB.getNumGlobals()) {
5555 for (llvm::Module *M : IRDB.getAllModules ()) {
5656 // compute points-to information for all globals
5757
@@ -122,7 +122,8 @@ auto LLVMPointsToSet::addSingletonPointsToSet(const llvm::Value *V)
122122 auto &PTS = PointsToSets[V];
123123
124124 if (!PTS) {
125- PTS = std::make_shared<PointsToSetTy>(PointsToSetTy{V});
125+ PTS = Owner.acquire ();
126+ PTS->insert (V);
126127 }
127128
128129 assert (PTS->count (V));
@@ -144,9 +145,9 @@ void LLVMPointsToSet::mergePointsToSets(const llvm::Value *V1,
144145 mergePointsToSets (SearchV1->second , SearchV2->second );
145146}
146147
147- auto LLVMPointsToSet::mergePointsToSets (const PointsToSetPtrTy & PTS1,
148- const PointsToSetPtrTy & PTS2)
149- -> PointsToSetPtrTy {
148+ auto LLVMPointsToSet::mergePointsToSets (PointsToSetTy * PTS1,
149+ PointsToSetTy * PTS2)
150+ -> PointsToSetTy * {
150151 if (PTS1 == PTS2) {
151152 return PTS1;
152153 }
@@ -167,12 +168,11 @@ auto LLVMPointsToSet::mergePointsToSets(const PointsToSetPtrTy &PTS1,
167168 }
168169
169170 // add smaller set to larger one and get rid of the smaller set
170- // LargerSet->merge(*SmallerSet);
171171 LargerSet->reserve (LargerSet->size () + SmallerSet->size ());
172172 LargerSet->insert (SmallerSet->begin (), SmallerSet->end ());
173- SmallerSet->clear ();
174173
175- // assert(SmallerSet->empty() && "Expect the points-to-sets to be disjoint");
174+ SmallerSet->clear ();
175+ Owner.release (SmallerSet);
176176
177177 return LargerSet;
178178}
@@ -474,8 +474,8 @@ LLVMPointsToSet::alias(const llvm::Value *V1, const llvm::Value *V2,
474474}
475475
476476auto LLVMPointsToSet::getEmptyPointsToSet () -> PointsToSetPtrTy {
477- static auto EmptySet = std::make_shared<PointsToSetTy>() ;
478- return EmptySet;
477+ static PointsToSetTy EmptySet{} ;
478+ return & EmptySet;
479479}
480480
481481auto LLVMPointsToSet::getPointsToSet (
@@ -497,13 +497,16 @@ auto LLVMPointsToSet::getPointsToSet(
497497
498498auto LLVMPointsToSet::getReachableAllocationSites (
499499 const llvm::Value *V, bool IntraProcOnly,
500- [[maybe_unused]] const llvm::Instruction *I) -> PointsToSetPtrTy {
500+ [[maybe_unused]] const llvm::Instruction *I) -> AllocationSiteSetPtrTy {
501+
502+ auto AllocSites = std::make_unique<PointsToSetTy>();
503+
501504 // if V is not a (interesting) pointer we can return an empty set
502505 if (!isInterestingPointer (V)) {
503- return getEmptyPointsToSet () ;
506+ return AllocSites ;
504507 }
505508 computeValuesPointsToSet (V);
506- auto AllocSites = std::make_shared<PointsToSetTy>();
509+
507510 const auto PTS = PointsToSets[V];
508511 // consider the full inter-procedural points-to/alias information
509512 if (!IntraProcOnly) {
@@ -587,7 +590,9 @@ void LLVMPointsToSet::mergeWith(const PointsToInfo &PTI) {
587590 // if none of the pointers of a set of other is known in this, we need to
588591 // perform a copy
589592 if (!FoundElemPtr) {
590- PointsToSets.insert ({KeyPtr, std::make_shared<PointsToSetTy>(*Set)});
593+ auto *PTS = Owner.acquire ();
594+ *PTS = *Set;
595+ PointsToSets.try_emplace (KeyPtr, PTS);
591596 }
592597 }
593598}
0 commit comments