[llvm] r243054 - [RewriteStatepointsForGC] Use idomatic mechanisms for debug tracing [NFC]
Philip Reames
listmail at philipreames.com
Thu Jul 23 15:25:26 PDT 2015
Author: reames
Date: Thu Jul 23 17:25:26 2015
New Revision: 243054
URL: http://llvm.org/viewvc/llvm-project?rev=243054&view=rev
Log:
[RewriteStatepointsForGC] Use idomatic mechanisms for debug tracing [NFC]
Deleting much of the code using trace-rewrite-statepoints and use idiomatic DEBUG statements instead. This includes adding operator<< to a helper class.
Modified:
llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp?rev=243054&r1=243053&r2=243054&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp Thu Jul 23 17:25:26 2015
@@ -546,13 +546,10 @@ static Value *findBaseDefiningValueCache
Value *&Cached = Cache[I];
if (!Cached) {
Cached = findBaseDefiningValue(I);
+ DEBUG(dbgs() << "fBDV-cached: " << I->getName() << " -> "
+ << Cached->getName() << "\n");
}
assert(Cache[I] != nullptr);
-
- if (TraceLSP) {
- dbgs() << "fBDV-cached: " << I->getName() << " -> " << Cached->getName()
- << "\n";
- }
return Cached;
}
@@ -612,9 +609,12 @@ public:
bool operator!=(const PhiState &other) const { return !(*this == other); }
- void dump() {
- errs() << status << " (" << base << " - "
- << (base ? base->getName() : "nullptr") << "): ";
+ LLVM_DUMP_METHOD
+ void dump() const { print(dbgs()); dbgs() << '\n'; }
+
+ void print(raw_ostream &OS) const {
+ OS << status << " (" << base << " - "
+ << (base ? base->getName() : "nullptr") << "): ";
}
private:
@@ -622,6 +622,12 @@ private:
Value *base; // non null only if status == base
};
+inline raw_ostream &operator<<(raw_ostream &OS, const PhiState &State) {
+ State.print(OS);
+ return OS;
+}
+
+
typedef DenseMap<Value *, PhiState> ConflictStateMapTy;
// Values of type PhiState form a lattice, and this is a helper
// class that implementes the meet operation. The meat of the meet
@@ -646,7 +652,10 @@ private:
static PhiState meet(PhiState LHS, PhiState RHS) {
assert((pureMeet(LHS, RHS) == pureMeet(RHS, LHS)) &&
"math is wrong: meet does not commute!");
- return pureMeet(LHS, RHS);
+ PhiState Result = pureMeet(LHS, RHS);
+ DEBUG(dbgs() << "meet of " << LHS << " with " << RHS
+ << " produced " << Result << "\n");
+ return Result;
}
static PhiState pureMeet(const PhiState &stateA, const PhiState &stateB) {
@@ -754,12 +763,8 @@ static Value *findBasePointer(Value *I,
if (TraceLSP) {
errs() << "States after initialization:\n";
- for (auto Pair : states) {
- Instruction *v = cast<Instruction>(Pair.first);
- PhiState state = Pair.second;
- state.dump();
- v->dump();
- }
+ for (auto Pair : states)
+ dbgs() << " " << Pair.second << " for " << Pair.first << "\n";
}
// TODO: come back and revisit the state transitions around inputs which
@@ -815,12 +820,8 @@ static Value *findBasePointer(Value *I,
if (TraceLSP) {
errs() << "States after meet iteration:\n";
- for (auto Pair : states) {
- Instruction *v = cast<Instruction>(Pair.first);
- PhiState state = Pair.second;
- state.dump();
- v->dump();
- }
+ for (auto Pair : states)
+ dbgs() << " " << Pair.second << " for " << Pair.first << "\n";
}
// Insert Phis for all conflicts
More information about the llvm-commits
mailing list