diff options
author | Nikita Popov <npopov@redhat.com> | 2023-01-06 17:33:53 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2023-01-06 17:36:01 +0100 |
commit | c60149b49e18a4cedc4c57d3bcb42d95061245f1 (patch) | |
tree | 2d88fed55d87904452602c00a4df252fc6b40fd6 /llvm/lib/Analysis/CaptureTracking.cpp | |
parent | 1aa9862df3634d1d526e5bfd0431408a24ac435a (diff) | |
download | llvm-c60149b49e18a4cedc4c57d3bcb42d95061245f1.zip llvm-c60149b49e18a4cedc4c57d3bcb42d95061245f1.tar.gz llvm-c60149b49e18a4cedc4c57d3bcb42d95061245f1.tar.bz2 |
Revert "[Dominator] Add findNearestCommonDominator() for Instructions (NFC)"
This reverts commit 7f0de9573f758f5f9108795850337a5acbd17eef.
This is missing handling for !isReachableFromEntry() blocks, which
may be relevant for some callers. Revert for now.
Diffstat (limited to 'llvm/lib/Analysis/CaptureTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/CaptureTracking.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/CaptureTracking.cpp b/llvm/lib/Analysis/CaptureTracking.cpp index 7f3a2b4..f4fd660 100644 --- a/llvm/lib/Analysis/CaptureTracking.cpp +++ b/llvm/lib/Analysis/CaptureTracking.cpp @@ -179,10 +179,25 @@ namespace { if (EphValues.contains(I)) return false; - if (!EarliestCapture) + if (!EarliestCapture) { EarliestCapture = I; - else - EarliestCapture = DT.findNearestCommonDominator(EarliestCapture, I); + } else if (EarliestCapture->getParent() == I->getParent()) { + if (I->comesBefore(EarliestCapture)) + EarliestCapture = I; + } else { + BasicBlock *CurrentBB = I->getParent(); + BasicBlock *EarliestBB = EarliestCapture->getParent(); + if (DT.dominates(EarliestBB, CurrentBB)) { + // EarliestCapture already comes before the current use. + } else if (DT.dominates(CurrentBB, EarliestBB)) { + EarliestCapture = I; + } else { + // Otherwise find the nearest common dominator and use its terminator. + auto *NearestCommonDom = + DT.findNearestCommonDominator(CurrentBB, EarliestBB); + EarliestCapture = NearestCommonDom->getTerminator(); + } + } Captured = true; // Return false to continue analysis; we need to see all potential |