Skip to content

Commit

Permalink
[CodeGen] Generalize MachineFunctionProperties::print comma handling.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ahmedbougacha committed Aug 2, 2016
1 parent ed581ea commit c8454a7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions llvm/lib/CodeGen/MachineFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit c8454a7

Please sign in to comment.