[llvm] c671e34 - [VPlan] Add dump() helper to VPValue & VPRecipeBase.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 07:55:41 PDT 2020


Author: Florian Hahn
Date: 2020-09-22T15:55:16+01:00
New Revision: c671e34bf2ae0eaa78d214b849ddd5de30b3b5be

URL: https://github.com/llvm/llvm-project/commit/c671e34bf2ae0eaa78d214b849ddd5de30b3b5be
DIFF: https://github.com/llvm/llvm-project/commit/c671e34bf2ae0eaa78d214b849ddd5de30b3b5be.diff

LOG: [VPlan] Add dump() helper to VPValue & VPRecipeBase.

This provides a convenient way to print VPValues and recipes in a
debugger. In particular it saves the user from instantiating
VPSlotTracker to print recipes or values.

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/VPlan.cpp
    llvm/lib/Transforms/Vectorize/VPlan.h
    llvm/lib/Transforms/Vectorize/VPlanValue.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index 679445455a45..417983241023 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -63,6 +63,20 @@ void VPValue::print(raw_ostream &OS, VPSlotTracker &SlotTracker) const {
     printAsOperand(OS, SlotTracker);
 }
 
+void VPValue::dump() const {
+  const VPInstruction *Instr = dyn_cast<VPInstruction>(this);
+  VPSlotTracker SlotTracker(
+      (Instr && Instr->getParent()) ? Instr->getParent()->getPlan() : nullptr);
+  print(dbgs(), SlotTracker);
+  dbgs() << "\n";
+}
+
+void VPRecipeBase::dump() const {
+  VPSlotTracker SlotTracker(nullptr);
+  print(dbgs(), "", SlotTracker);
+  dbgs() << "\n";
+}
+
 // Get the top-most entry block of \p Start. This is the entry block of the
 // containing VPlan. This function is templated to support both const and non-const blocks
 template <typename T> static T *getPlanEntry(T *Start) {

diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 9c9e2ec8222d..cdc18266f4ea 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -653,6 +653,9 @@ class VPRecipeBase : public ilist_node_with_parent<VPRecipeBase, VPBasicBlock> {
   virtual void print(raw_ostream &O, const Twine &Indent,
                      VPSlotTracker &SlotTracker) const = 0;
 
+  /// Dump the recipe to stderr (for debugging).
+  void dump() const;
+
   /// Insert an unlinked recipe into a basic block immediately before
   /// the specified recipe.
   void insertBefore(VPRecipeBase *InsertPos);

diff  --git a/llvm/lib/Transforms/Vectorize/VPlanValue.h b/llvm/lib/Transforms/Vectorize/VPlanValue.h
index f73505d0279a..3fec4d603c27 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanValue.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanValue.h
@@ -90,6 +90,9 @@ class VPValue {
   void printAsOperand(raw_ostream &OS, VPSlotTracker &Tracker) const;
   void print(raw_ostream &OS, VPSlotTracker &Tracker) const;
 
+  /// Dump the value to stderr (for debugging).
+  void dump() const;
+
   unsigned getNumUsers() const { return Users.size(); }
   void addUser(VPUser &User) { Users.push_back(&User); }
 


        


More information about the llvm-commits mailing list