@@ -214,6 +214,8 @@ class PredicateInfoBuilder {
214214 // whether it returned a valid result.
215215 DenseMap<Value *, unsigned int > ValueInfoNums;
216216
217+ BumpPtrAllocator &Allocator;
218+
217219 ValueInfo &getOrCreateValueInfo (Value *);
218220 const ValueInfo &getValueInfo (Value *) const ;
219221
@@ -242,8 +244,8 @@ class PredicateInfoBuilder {
242244
243245public:
244246 PredicateInfoBuilder (PredicateInfo &PI, Function &F, DominatorTree &DT,
245- AssumptionCache &AC)
246- : PI(PI), F(F), DT(DT), AC(AC) {
247+ AssumptionCache &AC, BumpPtrAllocator &Allocator )
248+ : PI(PI), F(F), DT(DT), AC(AC), Allocator(Allocator) {
247249 // Push an empty operand info so that we can detect 0 as not finding one
248250 ValueInfos.resize (1 );
249251 }
@@ -341,7 +343,6 @@ void PredicateInfoBuilder::addInfoFor(SmallVectorImpl<Value *> &OpsToRename,
341343 auto &OperandInfo = getOrCreateValueInfo (Op);
342344 if (OperandInfo.Infos .empty ())
343345 OpsToRename.push_back (Op);
344- PI.AllInfos .push_back (PB);
345346 OperandInfo.Infos .push_back (PB);
346347}
347348
@@ -373,7 +374,7 @@ void PredicateInfoBuilder::processAssume(
373374
374375 for (Value *V : Values) {
375376 if (shouldRename (V)) {
376- auto *PA = new PredicateAssume (V, II, Cond);
377+ auto *PA = new (Allocator) PredicateAssume (V, II, Cond);
377378 addInfoFor (OpsToRename, V, PA);
378379 }
379380 }
@@ -419,8 +420,8 @@ void PredicateInfoBuilder::processBranch(
419420
420421 for (Value *V : Values) {
421422 if (shouldRename (V)) {
422- PredicateBase *PB =
423- new PredicateBranch (V, BranchBB, Succ, Cond, TakenEdge);
423+ PredicateBase *PB = new (Allocator)
424+ PredicateBranch (V, BranchBB, Succ, Cond, TakenEdge);
424425 addInfoFor (OpsToRename, V, PB);
425426 }
426427 }
@@ -445,7 +446,7 @@ void PredicateInfoBuilder::processSwitch(
445446 for (auto C : SI->cases ()) {
446447 BasicBlock *TargetBlock = C.getCaseSuccessor ();
447448 if (SwitchEdges.lookup (TargetBlock) == 1 ) {
448- PredicateSwitch *PS = new PredicateSwitch (
449+ PredicateSwitch *PS = new (Allocator) PredicateSwitch (
449450 Op, SI->getParent (), TargetBlock, C.getCaseValue (), SI);
450451 addInfoFor (OpsToRename, Op, PS);
451452 }
@@ -704,9 +705,9 @@ PredicateInfoBuilder::getValueInfo(Value *Operand) const {
704705}
705706
706707PredicateInfo::PredicateInfo (Function &F, DominatorTree &DT,
707- AssumptionCache &AC)
708+ AssumptionCache &AC, BumpPtrAllocator &Allocator )
708709 : F(F) {
709- PredicateInfoBuilder Builder (*this , F, DT, AC);
710+ PredicateInfoBuilder Builder (*this , F, DT, AC, Allocator );
710711 Builder.buildPredicateInfo ();
711712}
712713
@@ -797,7 +798,8 @@ PreservedAnalyses PredicateInfoPrinterPass::run(Function &F,
797798 auto &DT = AM.getResult <DominatorTreeAnalysis>(F);
798799 auto &AC = AM.getResult <AssumptionAnalysis>(F);
799800 OS << " PredicateInfo for function: " << F.getName () << " \n " ;
800- auto PredInfo = std::make_unique<PredicateInfo>(F, DT, AC);
801+ BumpPtrAllocator Allocator;
802+ auto PredInfo = std::make_unique<PredicateInfo>(F, DT, AC, Allocator);
801803 PredInfo->print (OS);
802804
803805 replaceCreatedSSACopys (*PredInfo, F);
@@ -859,7 +861,8 @@ PreservedAnalyses PredicateInfoVerifierPass::run(Function &F,
859861 FunctionAnalysisManager &AM) {
860862 auto &DT = AM.getResult <DominatorTreeAnalysis>(F);
861863 auto &AC = AM.getResult <AssumptionAnalysis>(F);
862- std::make_unique<PredicateInfo>(F, DT, AC)->verifyPredicateInfo ();
864+ BumpPtrAllocator Allocator;
865+ std::make_unique<PredicateInfo>(F, DT, AC, Allocator)->verifyPredicateInfo ();
863866
864867 return PreservedAnalyses::all ();
865868}
0 commit comments