summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/IfConversion.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <florian.hahn@arm.com>2016-12-16 11:10:26 +0000
committerFlorian Hahn <florian.hahn@arm.com>2016-12-16 11:10:26 +0000
commit3c8b8c98b00437a9f93f09db200892d33f91973b (patch)
tree23f81423a7f4e1ece3008ee2b7422a80d7b4476c /llvm/lib/CodeGen/IfConversion.cpp
parent2af9c389bf4eba1ca3d36e3123828cf52b73b532 (diff)
downloadbcm5719-llvm-3c8b8c98b00437a9f93f09db200892d33f91973b.tar.gz
bcm5719-llvm-3c8b8c98b00437a9f93f09db200892d33f91973b.zip
[codegen] Add generic functions to skip debug values.
Summary: This commits moves skipDebugInstructionsForward and skipDebugInstructionsBackward from lib/CodeGen/IfConversion.cpp to include/llvm/CodeGen/MachineBasicBlock.h and updates some codgen files to use them. This refactoring was suggested in https://reviews.llvm.org/D27688 and I thought it's best to do the refactoring in a separate review, but I could also put both changes in a single review if that's preferred. Also, the names for the functions aren't the snappiest and I would be happy to rename them if anybody has suggestions. Reviewers: eli.friedman, iteratee, aprantl, MatzeB Subscribers: MatzeB, llvm-commits Differential Revision: https://reviews.llvm.org/D27782 llvm-svn: 289933
Diffstat (limited to 'llvm/lib/CodeGen/IfConversion.cpp')
-rw-r--r--llvm/lib/CodeGen/IfConversion.cpp48
1 files changed, 14 insertions, 34 deletions
diff --git a/llvm/lib/CodeGen/IfConversion.cpp b/llvm/lib/CodeGen/IfConversion.cpp
index 56a25e0331d..0cac7b71e24 100644
--- a/llvm/lib/CodeGen/IfConversion.cpp
+++ b/llvm/lib/CodeGen/IfConversion.cpp
@@ -588,18 +588,6 @@ bool IfConverter::ValidTriangle(BBInfo &TrueBBI, BBInfo &FalseBBI,
return TExit && TExit == FalseBBI.BB;
}
-/// Increment \p It until it points to a non-debug instruction or to \p End.
-/// @param It Iterator to increment
-/// @param End Iterator that points to end. Will be compared to It
-/// @returns true if It == End, false otherwise.
-static inline bool skipDebugInstructionsForward(
- MachineBasicBlock::iterator &It,
- MachineBasicBlock::iterator &End) {
- while (It != End && It->isDebugValue())
- It++;
- return It == End;
-}
-
/// Shrink the provided inclusive range by one instruction.
/// If the range was one instruction (\p It == \p Begin), It is not modified,
/// but \p Empty is set to true.
@@ -613,21 +601,6 @@ static inline void shrinkInclusiveRange(
It--;
}
-/// Decrement \p It until it points to a non-debug instruction or the range is
-/// empty.
-/// @param It Iterator to decrement.
-/// @param Begin Iterator that points to beginning. Will be compared to It
-/// @param Empty Set to true if the resulting range is Empty
-/// @returns the value of Empty as a convenience.
-static inline bool skipDebugInstructionsBackward(
- MachineBasicBlock::iterator &Begin,
- MachineBasicBlock::iterator &It,
- bool &Empty) {
- while (!Empty && It->isDebugValue())
- shrinkInclusiveRange(Begin, It, Empty);
- return Empty;
-}
-
/// Count duplicated instructions and move the iterators to show where they
/// are.
/// @param TIB True Iterator Begin
@@ -659,9 +632,11 @@ bool IfConverter::CountDuplicatedInstructions(
while (TIB != TIE && FIB != FIE) {
// Skip dbg_value instructions. These do not count.
- if(skipDebugInstructionsForward(TIB, TIE))
+ TIB = skipDebugInstructionsForward(TIB, TIE);
+ if(TIB == TIE)
break;
- if(skipDebugInstructionsForward(FIB, FIE))
+ FIB = skipDebugInstructionsForward(FIB, FIE);
+ if(FIB == FIE)
break;
if (!TIB->isIdenticalTo(*FIB))
break;
@@ -718,9 +693,11 @@ bool IfConverter::CountDuplicatedInstructions(
// Count duplicate instructions at the ends of the blocks.
while (!TEmpty && !FEmpty) {
// Skip dbg_value instructions. These do not count.
- if (skipDebugInstructionsBackward(TIB, TIE, TEmpty))
- break;
- if (skipDebugInstructionsBackward(FIB, FIE, FEmpty))
+ TIE = skipDebugInstructionsBackward(TIE, TIB);
+ FIE = skipDebugInstructionsBackward(FIE, FIB);
+ TEmpty = TIE == TIB && TIE->isDebugValue();
+ FEmpty = FIE == FIB && FIE->isDebugValue();
+ if (TEmpty || FEmpty)
break;
if (!TIE->isIdenticalTo(*FIE))
break;
@@ -770,8 +747,11 @@ static void verifySameBranchInstructions(
MachineBasicBlock::iterator E2 = std::prev(MBB2->end());
bool Empty1 = false, Empty2 = false;
while (!Empty1 && !Empty2) {
- skipDebugInstructionsBackward(B1, E1, Empty1);
- skipDebugInstructionsBackward(B2, E2, Empty2);
+ E1 = skipDebugInstructionsBackward(E1, B1);
+ E2 = skipDebugInstructionsBackward(E2, B2);
+ Empty1 = E1 == B1 && E1->isDebugValue();
+ Empty2 = E2 == B2 && E2->isDebugValue();
+
if (Empty1 && Empty2)
break;
OpenPOWER on IntegriCloud