[PATCH] D56135: Allow reverse iterators for `MachineBasicBlock::findDebugLoc` and `MachineBasicBlock::findPrevDebugLoc`
Artyom Goncharov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 6 12:54:35 PST 2019
m4yers updated this revision to Diff 180413.
m4yers added a comment.
Newline the returns
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56135/new/
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,14 +1286,31 @@
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.
DebugLoc MachineBasicBlock::findPrevDebugLoc(instr_iterator MBBI) {
- if (MBBI == instr_begin()) return {};
+ if (MBBI == instr_begin())
+ return {};
// Skip debug declarations, we don't want a DebugLoc from them.
MBBI = skipDebugInstructionsBackward(std::prev(MBBI), instr_begin());
- if (!MBBI->isDebugInstr()) return MBBI->getDebugLoc();
+ 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::next(MBBI), instr_rend());
+ if (MBBI != instr_rend())
+ return MBBI->getDebugLoc();
return {};
}
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.180413.patch
Type: text/x-patch
Size: 2808 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190106/c7f17efc/attachment.bin>
More information about the llvm-commits
mailing list