@@ -214,6 +214,8 @@ class PredicateInfoBuilder {
214
214
// whether it returned a valid result.
215
215
DenseMap<Value *, unsigned int > ValueInfoNums;
216
216
217
+ BumpPtrAllocator &Allocator;
218
+
217
219
ValueInfo &getOrCreateValueInfo (Value *);
218
220
const ValueInfo &getValueInfo (Value *) const ;
219
221
@@ -242,8 +244,8 @@ class PredicateInfoBuilder {
242
244
243
245
public:
244
246
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) {
247
249
// Push an empty operand info so that we can detect 0 as not finding one
248
250
ValueInfos.resize (1 );
249
251
}
@@ -341,7 +343,6 @@ void PredicateInfoBuilder::addInfoFor(SmallVectorImpl<Value *> &OpsToRename,
341
343
auto &OperandInfo = getOrCreateValueInfo (Op);
342
344
if (OperandInfo.Infos .empty ())
343
345
OpsToRename.push_back (Op);
344
- PI.AllInfos .push_back (PB);
345
346
OperandInfo.Infos .push_back (PB);
346
347
}
347
348
@@ -373,7 +374,7 @@ void PredicateInfoBuilder::processAssume(
373
374
374
375
for (Value *V : Values) {
375
376
if (shouldRename (V)) {
376
- auto *PA = new PredicateAssume (V, II, Cond);
377
+ auto *PA = new (Allocator) PredicateAssume (V, II, Cond);
377
378
addInfoFor (OpsToRename, V, PA);
378
379
}
379
380
}
@@ -419,8 +420,8 @@ void PredicateInfoBuilder::processBranch(
419
420
420
421
for (Value *V : Values) {
421
422
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);
424
425
addInfoFor (OpsToRename, V, PB);
425
426
}
426
427
}
@@ -445,7 +446,7 @@ void PredicateInfoBuilder::processSwitch(
445
446
for (auto C : SI->cases ()) {
446
447
BasicBlock *TargetBlock = C.getCaseSuccessor ();
447
448
if (SwitchEdges.lookup (TargetBlock) == 1 ) {
448
- PredicateSwitch *PS = new PredicateSwitch (
449
+ PredicateSwitch *PS = new (Allocator) PredicateSwitch (
449
450
Op, SI->getParent (), TargetBlock, C.getCaseValue (), SI);
450
451
addInfoFor (OpsToRename, Op, PS);
451
452
}
@@ -704,9 +705,9 @@ PredicateInfoBuilder::getValueInfo(Value *Operand) const {
704
705
}
705
706
706
707
PredicateInfo::PredicateInfo (Function &F, DominatorTree &DT,
707
- AssumptionCache &AC)
708
+ AssumptionCache &AC, BumpPtrAllocator &Allocator )
708
709
: F(F) {
709
- PredicateInfoBuilder Builder (*this , F, DT, AC);
710
+ PredicateInfoBuilder Builder (*this , F, DT, AC, Allocator );
710
711
Builder.buildPredicateInfo ();
711
712
}
712
713
@@ -797,7 +798,8 @@ PreservedAnalyses PredicateInfoPrinterPass::run(Function &F,
797
798
auto &DT = AM.getResult <DominatorTreeAnalysis>(F);
798
799
auto &AC = AM.getResult <AssumptionAnalysis>(F);
799
800
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);
801
803
PredInfo->print (OS);
802
804
803
805
replaceCreatedSSACopys (*PredInfo, F);
@@ -859,7 +861,8 @@ PreservedAnalyses PredicateInfoVerifierPass::run(Function &F,
859
861
FunctionAnalysisManager &AM) {
860
862
auto &DT = AM.getResult <DominatorTreeAnalysis>(F);
861
863
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 ();
863
866
864
867
return PreservedAnalyses::all ();
865
868
}
0 commit comments