[CodeGen] Generalize MachineFunctionProperties::print comma handling.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Tue, 2 Aug 2016 14:42:57 +0000 (14:42 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Tue, 2 Aug 2016 14:42:57 +0000 (14:42 +0000)
This is only used for debug prints, but the previous hardcoded ", "
caused it to be printed unnecessarily when OnlySet, and is annoying
when adding new properties.

llvm-svn: 277465

llvm/lib/CodeGen/MachineFunction.cpp

index a7c63ef..a4c4ea4 100644 (file)
@@ -57,16 +57,21 @@ void MachineFunctionInitializer::anchor() {}
 void MachineFunctionProperties::print(raw_ostream &ROS, bool OnlySet) const {
   // Leave this function even in NDEBUG as an out-of-line anchor.
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+  bool NeedsComma = false;
   for (BitVector::size_type i = 0; i < Properties.size(); ++i) {
     bool HasProperty = Properties[i];
     if (OnlySet && !HasProperty)
       continue;
+    if (NeedsComma)
+      ROS << ", ";
+    else
+      NeedsComma = true;
     switch(static_cast<Property>(i)) {
       case Property::IsSSA:
-        ROS << (HasProperty ? "SSA, " : "Post SSA, ");
+        ROS << (HasProperty ? "SSA" : "Post SSA");
         break;
       case Property::TracksLiveness:
-        ROS << (HasProperty ? "" : "not ") << "tracking liveness";
+        ROS << (HasProperty ? "" : "not ") << "tracking liveness";
         break;
       case Property::AllVRegsAllocated:
         ROS << (HasProperty ? "AllVRegsAllocated" : "HasVRegs");