[JumpThreading][NFCI] Reuse existing DT instead of recomputation
authorMax Kazantsev <mkazantsev@azul.com>
Mon, 30 May 2022 05:48:10 +0000 (12:48 +0700)
committerMax Kazantsev <mkazantsev@azul.com>
Mon, 30 May 2022 05:48:10 +0000 (12:48 +0700)
This whole part with recomputation of BPI and BFI looks redundant,
and we tried to get rid of it in D124439. Unfortunately, it causes
some hard-to-reproduce failures due to invalid state of analysis.
Until this is investigated and fixed, let's try to reuse at least
part of available analyzes.

DT is available at this point, and there is no need to recompute it.

Please revert if you see it causing *any* behavior changes.

llvm/lib/Transforms/Scalar/JumpThreading.cpp

index a9e5b81..b4b2b6c 100644 (file)
@@ -317,7 +317,7 @@ bool JumpThreading::runOnFunction(Function &F) {
   std::unique_ptr<BlockFrequencyInfo> BFI;
   std::unique_ptr<BranchProbabilityInfo> BPI;
   if (F.hasProfileData()) {
-    LoopInfo LI{DominatorTree(F)};
+    LoopInfo LI{*DT};
     BPI.reset(new BranchProbabilityInfo(F, LI, TLI));
     BFI.reset(new BlockFrequencyInfo(F, *BPI, LI));
   }