aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBasicBlock.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/MachineBasicBlock.cpp
parent2af9c389bf4eba1ca3d36e3123828cf52b73b532 (diff)
downloadllvm-3c8b8c98b00437a9f93f09db200892d33f91973b.zip
llvm-3c8b8c98b00437a9f93f09db200892d33f91973b.tar.gz
llvm-3c8b8c98b00437a9f93f09db200892d33f91973b.tar.bz2
[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/MachineBasicBlock.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBasicBlock.cpp19
1 files changed, 5 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index df6dcee..491d863 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -191,10 +191,7 @@ MachineBasicBlock::instr_iterator MachineBasicBlock::getFirstInstrTerminator() {
MachineBasicBlock::iterator MachineBasicBlock::getFirstNonDebugInstr() {
// Skip over begin-of-block dbg_value instructions.
- iterator I = begin(), E = end();
- while (I != E && I->isDebugValue())
- ++I;
- return I;
+ return skipDebugInstructionsForward(begin(), end());
}
MachineBasicBlock::iterator MachineBasicBlock::getLastNonDebugInstr() {
@@ -1140,17 +1137,11 @@ bool MachineBasicBlock::CorrectExtraCFGEdges(MachineBasicBlock *DestA,
/// instructions. Return UnknownLoc if there is none.
DebugLoc
MachineBasicBlock::findDebugLoc(instr_iterator MBBI) {
- DebugLoc DL;
- instr_iterator E = instr_end();
- if (MBBI == E)
- return DL;
-
// Skip debug declarations, we don't want a DebugLoc from them.
- while (MBBI != E && MBBI->isDebugValue())
- MBBI++;
- if (MBBI != E)
- DL = MBBI->getDebugLoc();
- return DL;
+ MBBI = skipDebugInstructionsForward(MBBI, instr_end());
+ if (MBBI != instr_end())
+ return MBBI->getDebugLoc();
+ return {};
}
/// Return probability of the edge from this block to MBB.