[PATCH] D56135: Allow reverse iterators for `MachineBasicBlock::findDebugLoc` and `DebugLoc MachineBasicBlock::findPrevDebugLoc`
Artyom Goncharov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 28 12:16:36 PST 2018
m4yers created this revision.
Herald added a subscriber: llvm-commits.
Repository:
rL LLVM
https://reviews.llvm.org/D56135
Files:
include/llvm/CodeGen/MachineBasicBlock.h
lib/CodeGen/MachineBasicBlock.cpp
Index: lib/CodeGen/MachineBasicBlock.cpp
===================================================================
--- lib/CodeGen/MachineBasicBlock.cpp
+++ lib/CodeGen/MachineBasicBlock.cpp
@@ -1277,7 +1277,7 @@
}
/// Find the next valid DebugLoc starting at MBBI, skipping any DBG_VALUE
-/// instructions. Return UnknownLoc if there is none.
+/// instructions. Return UnknownLoc if there is none.
DebugLoc
MachineBasicBlock::findDebugLoc(instr_iterator MBBI) {
// Skip debug declarations, we don't want a DebugLoc from them.
@@ -1286,6 +1286,13 @@
return MBBI->getDebugLoc();
return {};
}
+DebugLoc
+MachineBasicBlock::findDebugLoc(reverse_instr_iterator MBBI) {
+ // Skip debug declarations, we don't want a DebugLoc from them.
+ MBBI = skipDebugInstructionsBackward(MBBI, instr_rbegin());
+ if (!MBBI->isDebugInstr()) return MBBI->getDebugLoc();
+ return {};
+}
/// Find the previous valid DebugLoc preceding MBBI, skipping and DBG_VALUE
/// instructions. Return UnknownLoc if there is none.
@@ -1296,6 +1303,13 @@
if (!MBBI->isDebugInstr()) return MBBI->getDebugLoc();
return {};
}
+DebugLoc MachineBasicBlock::findPrevDebugLoc(reverse_instr_iterator MBBI) {
+ // Skip debug declarations, we don't want a DebugLoc from them.
+ MBBI = skipDebugInstructionsForward(std::prev(MBBI), instr_rend());
+ if (MBBI != instr_rend())
+ return MBBI->getDebugLoc();
+ return {};
+}
/// Find and return the merged DebugLoc of the branch instructions of the block.
/// Return UnknownLoc if there is none.
Index: include/llvm/CodeGen/MachineBasicBlock.h
===================================================================
--- include/llvm/CodeGen/MachineBasicBlock.h
+++ include/llvm/CodeGen/MachineBasicBlock.h
@@ -729,6 +729,10 @@
DebugLoc findDebugLoc(iterator MBBI) {
return findDebugLoc(MBBI.getInstrIterator());
}
+ DebugLoc findDebugLoc(reverse_instr_iterator MBBI);
+ DebugLoc findDebugLoc(reverse_iterator MBBI) {
+ return findDebugLoc(MBBI.getInstrIterator());
+ }
/// Find the previous valid DebugLoc preceding MBBI, skipping and DBG_VALUE
/// instructions. Return UnknownLoc if there is none.
@@ -736,6 +740,10 @@
DebugLoc findPrevDebugLoc(iterator MBBI) {
return findPrevDebugLoc(MBBI.getInstrIterator());
}
+ DebugLoc findPrevDebugLoc(reverse_instr_iterator MBBI);
+ DebugLoc findPrevDebugLoc(reverse_iterator MBBI) {
+ return findPrevDebugLoc(MBBI.getInstrIterator());
+ }
/// Find and return the merged DebugLoc of the branch instructions of the
/// block. Return UnknownLoc if there is none.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56135.179654.patch
Type: text/x-patch
Size: 2589 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181228/ec5a5d77/attachment.bin>
More information about the llvm-commits
mailing list