Skip to content

Commit

Permalink
Hide dbgs() stream for when built with -fmodules.
Browse files Browse the repository at this point in the history
Summary: Make DebugCounter::print and dump methods to be const correct.

Reviewers: aprantl

Reviewed By: aprantl

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D34214

llvm-svn: 305408
  • Loading branch information
Frederich Munch committed Jun 14, 2017
1 parent f0e26e7 commit dceb612
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
6 changes: 3 additions & 3 deletions llvm/include/llvm/Support/DebugCounter.h
Expand Up @@ -121,10 +121,10 @@ class DebugCounter {
Us.Counters[ID] = Val;
}

// Dump or print the current counter set.
LLVM_DUMP_METHOD void dump() { print(dbgs()); }
// Dump or print the current counter set into llvm::dbgs().
LLVM_DUMP_METHOD void dump() const;

void print(raw_ostream &OS);
void print(raw_ostream &OS) const;

// Get the counter ID for a given named counter, or return 0 if none is found.
unsigned getCounterId(const std::string &Name) const {
Expand Down
5 changes: 1 addition & 4 deletions llvm/include/llvm/Transforms/Scalar/GVNExpression.h
Expand Up @@ -121,10 +121,7 @@ class Expression {
OS << "}";
}

LLVM_DUMP_METHOD void dump() const {
print(dbgs());
dbgs() << "\n";
}
LLVM_DUMP_METHOD void dump() const;
};

inline raw_ostream &operator<<(raw_ostream &OS, const Expression &E) {
Expand Down
6 changes: 5 additions & 1 deletion llvm/lib/Support/DebugCounter.cpp
Expand Up @@ -102,9 +102,13 @@ void DebugCounter::push_back(const std::string &Val) {
}
}

void DebugCounter::print(raw_ostream &OS) {
void DebugCounter::print(raw_ostream &OS) const {
OS << "Counters and values:\n";
for (const auto &KV : Counters)
OS << left_justify(RegisteredCounters[KV.first], 32) << ": {"
<< KV.second.first << "," << KV.second.second << "}\n";
}

LLVM_DUMP_METHOD void DebugCounter::dump() const {
print(dbgs());
}
11 changes: 11 additions & 0 deletions llvm/lib/Transforms/Scalar/GVNSink.cpp
Expand Up @@ -64,6 +64,17 @@ using namespace llvm;

STATISTIC(NumRemoved, "Number of instructions removed");

namespace llvm {
namespace GVNExpression {

LLVM_DUMP_METHOD void Expression::dump() const {
print(dbgs());
dbgs() << "\n";
}

}
}

namespace {

static bool isMemoryInst(const Instruction *I) {
Expand Down

0 comments on commit dceb612

Please sign in to comment.