diff options
author | Nikita Popov <npopov@redhat.com> | 2023-01-06 16:56:34 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2023-01-10 12:16:31 +0100 |
commit | 094ccee2c89e9fa12a3439f5561f9472f98654e5 (patch) | |
tree | efc89cbd6ce4494127cbfecb0df6f3aefd6b541e /llvm/lib/Analysis/CaptureTracking.cpp | |
parent | 1ee4a93b15bb5dee7a1045fd035e1a286bb5d162 (diff) | |
download | llvm-094ccee2c89e9fa12a3439f5561f9472f98654e5.zip llvm-094ccee2c89e9fa12a3439f5561f9472f98654e5.tar.gz llvm-094ccee2c89e9fa12a3439f5561f9472f98654e5.tar.bz2 |
Reapply [Dominators] Add findNearestCommonDominator() for Instructions (NFC)
Reapply with checks for instructions in unreachable blocks. A test
case for this was added in 1ee4a93b15bb.
-----
This is a recurring pattern: We want to find the nearest common
dominator (instruction) for two instructions, but currently only
provide an API for the nearest common dominator of two basic blocks.
Add an overload that accepts and return instructions.
Diffstat (limited to 'llvm/lib/Analysis/CaptureTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/CaptureTracking.cpp | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/llvm/lib/Analysis/CaptureTracking.cpp b/llvm/lib/Analysis/CaptureTracking.cpp index f4fd660..7f3a2b4 100644 --- a/llvm/lib/Analysis/CaptureTracking.cpp +++ b/llvm/lib/Analysis/CaptureTracking.cpp @@ -179,25 +179,10 @@ namespace { if (EphValues.contains(I)) return false; - if (!EarliestCapture) { + if (!EarliestCapture) 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(); - } - } + else + EarliestCapture = DT.findNearestCommonDominator(EarliestCapture, I); Captured = true; // Return false to continue analysis; we need to see all potential |