@@ -155,6 +155,8 @@ namespace {
155
155
AU.addRequired <TargetLibraryInfoWrapperPass>();
156
156
AU.addRequired <TargetTransformInfoWrapperPass>();
157
157
}
158
+
159
+ void releaseMemory () override { Impl.releaseMemory (); }
158
160
};
159
161
160
162
} // end anonymous namespace
@@ -328,7 +330,7 @@ bool JumpThreading::runOnFunction(Function &F) {
328
330
}
329
331
330
332
bool Changed = Impl.runImpl (F, TLI, TTI, LVI, AA, &DTU, F.hasProfileData (),
331
- BFI. get ( ), BPI. get ( ));
333
+ std::move (BFI ), std::move (BPI ));
332
334
if (PrintLVIAfterJumpThreading) {
333
335
dbgs () << " LVI for function '" << F.getName () << " ':\n " ;
334
336
LVI->printLVI (F, DTU.getDomTree (), dbgs ());
@@ -348,15 +350,16 @@ PreservedAnalyses JumpThreadingPass::run(Function &F,
348
350
auto &AA = AM.getResult <AAManager>(F);
349
351
DomTreeUpdater DTU (DT, DomTreeUpdater::UpdateStrategy::Lazy);
350
352
351
- BlockFrequencyInfo * BFI = nullptr ;
352
- BranchProbabilityInfo * BPI = nullptr ;
353
+ std::unique_ptr< BlockFrequencyInfo> BFI;
354
+ std::unique_ptr< BranchProbabilityInfo> BPI;
353
355
if (F.hasProfileData ()) {
354
- BFI = &AM.getResult <BlockFrequencyAnalysis>(F);
355
- BPI = &AM.getResult <BranchProbabilityAnalysis>(F);
356
+ LoopInfo LI{DominatorTree (F)};
357
+ BPI.reset (new BranchProbabilityInfo (F, LI, &TLI));
358
+ BFI.reset (new BlockFrequencyInfo (F, *BPI, LI));
356
359
}
357
360
358
- bool Changed =
359
- runImpl (F, &TLI, &TTI, &LVI, &AA, &DTU, F. hasProfileData ( ), BFI, BPI);
361
+ bool Changed = runImpl (F, &TLI, &TTI, &LVI, &AA, &DTU, F. hasProfileData (),
362
+ std::move (BFI ), std::move ( BPI) );
360
363
361
364
if (PrintLVIAfterJumpThreading) {
362
365
dbgs () << " LVI for function '" << F.getName () << " ':\n " ;
@@ -374,28 +377,26 @@ PreservedAnalyses JumpThreadingPass::run(Function &F,
374
377
bool JumpThreadingPass::runImpl (Function &F, TargetLibraryInfo *TLI_,
375
378
TargetTransformInfo *TTI_, LazyValueInfo *LVI_,
376
379
AliasAnalysis *AA_, DomTreeUpdater *DTU_,
377
- bool HasProfileData_, BlockFrequencyInfo *BFI_,
378
- BranchProbabilityInfo *BPI_) {
380
+ bool HasProfileData_,
381
+ std::unique_ptr<BlockFrequencyInfo> BFI_,
382
+ std::unique_ptr<BranchProbabilityInfo> BPI_) {
379
383
LLVM_DEBUG (dbgs () << " Jump threading on function '" << F.getName () << " '\n " );
380
384
TLI = TLI_;
381
385
TTI = TTI_;
382
386
LVI = LVI_;
383
387
AA = AA_;
384
388
DTU = DTU_;
385
- BFI = BFI_ ;
386
- BPI = BPI_ ;
389
+ BFI. reset () ;
390
+ BPI. reset () ;
387
391
// When profile data is available, we need to update edge weights after
388
392
// successful jump threading, which requires both BPI and BFI being available.
389
393
HasProfileData = HasProfileData_;
390
394
auto *GuardDecl = F.getParent ()->getFunction (
391
395
Intrinsic::getName (Intrinsic::experimental_guard));
392
396
HasGuards = GuardDecl && !GuardDecl->use_empty ();
393
397
if (HasProfileData) {
394
- assert (BFI && " BFI not provided?" );
395
- assert (BPI && " BPI not provided?" );
396
- } else {
397
- assert (!BFI && " BFI should not be provided?" );
398
- assert (!BPI && " BPI should not be provided?" );
398
+ BPI = std::move (BPI_);
399
+ BFI = std::move (BFI_);
399
400
}
400
401
401
402
// Reduce the number of instructions duplicated when optimizing strictly for
0 commit comments