summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/BranchFolding.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/BranchFolding.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/BranchFolding.cpp')
-rw-r--r--llvm/lib/CodeGen/BranchFolding.cpp23
1 files changed, 7 insertions, 16 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp
index 913d5d91890..9c30a14432b 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -1733,10 +1733,8 @@ MachineBasicBlock::iterator findHoistingInsertPosAndDeps(MachineBasicBlock *MBB,
// The terminator is probably a conditional branch, try not to separate the
// branch from condition setting instruction.
- MachineBasicBlock::iterator PI = Loc;
- --PI;
- while (PI != MBB->begin() && PI->isDebugValue())
- --PI;
+ MachineBasicBlock::iterator PI =
+ skipDebugInstructionsBackward(std::prev(Loc), MBB->begin());
bool IsDef = false;
for (const MachineOperand &MO : PI->operands()) {
@@ -1830,18 +1828,11 @@ bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) {
MachineBasicBlock::iterator FIE = FBB->end();
while (TIB != TIE && FIB != FIE) {
// Skip dbg_value instructions. These do not count.
- if (TIB->isDebugValue()) {
- while (TIB != TIE && TIB->isDebugValue())
- ++TIB;
- if (TIB == TIE)
- break;
- }
- if (FIB->isDebugValue()) {
- while (FIB != FIE && FIB->isDebugValue())
- ++FIB;
- if (FIB == FIE)
- break;
- }
+ TIB = skipDebugInstructionsForward(TIB, TIE);
+ FIB = skipDebugInstructionsForward(FIB, FIE);
+ if (TIB == TIE || FIB == FIE)
+ break;
+
if (!TIB->isIdenticalTo(*FIB, MachineInstr::CheckKillDead))
break;
OpenPOWER on IntegriCloud