[PATCH] D78260: [MachineBasicBlock] Add helpers for skipping debug instructions [1/10]

Vedant Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 18:14:30 PDT 2020


vsk created this revision.
vsk added reviewers: fhahn, aprantl, jpaquette.
Herald added a subscriber: kristof.beyls.
Herald added a reviewer: paquette.
Herald added a project: LLVM.

These helpers are exercised by follow-up commits in this patch series,
which is all about removing CodeGen differences with vs. without debug
info in the AArch64 backend.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78260

Files:
  llvm/include/llvm/CodeGen/MachineBasicBlock.h


Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h
===================================================================
--- llvm/include/llvm/CodeGen/MachineBasicBlock.h
+++ llvm/include/llvm/CodeGen/MachineBasicBlock.h
@@ -1061,6 +1061,35 @@
   return It;
 }
 
+/// Increment \p It, then continue incrementing it while it points to a debug
+/// instruction. A replacement for std::next.
+template <typename IterT> inline IterT next_nodbg(IterT It, IterT End) {
+  return skipDebugInstructionsForward(std::next(It), End);
+}
+
+/// Decrement \p It, then continue decrementing it while it points to a debug
+/// instruction. A replacement for std::prev.
+template <typename IterT> inline IterT prev_nodbg(IterT It, IterT Begin) {
+  return skipDebugInstructionsBackward(std::prev(It), Begin);
+}
+
+/// Construct a range iterator which begins at \p It and moves forwards until
+/// \p End is reached, skipping any debug instructions.
+template <typename IterT>
+inline auto instructionsWithoutDebug(IterT It, IterT End) {
+  return make_filter_range(make_range(It, End), [](const MachineInstr &MI) {
+    return !MI.isDebugInstr();
+  });
+}
+
+/// Construct a range iterator which begins at \p It and moves backwards until
+/// \p Begin is reached, skipping any debug instructions.
+template <typename IterT>
+inline auto reversedInstructionsWithoutDebug(IterT It, IterT Begin) {
+  return instructionsWithoutDebug(make_reverse_iterator(It),
+                                  make_reverse_iterator(Begin));
+}
+
 } // end namespace llvm
 
 #endif // LLVM_CODEGEN_MACHINEBASICBLOCK_H


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78260.257921.patch
Type: text/x-patch
Size: 1585 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200416/e774aa13/attachment.bin>


More information about the llvm-commits mailing list