From 173e222715bd39377c41143560c6564bbc1ed345 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Thu, 23 Jul 2015 22:25:26 +0000 Subject: [PATCH] [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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243054 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Scalar/RewriteStatepointsForGC.cpp | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp index f704389a8b0..a133f01a55f 100644 --- a/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ b/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -546,13 +546,10 @@ static Value *findBaseDefiningValueCached(Value *I, DefiningValueMapTy &Cache) { 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 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, DefiningValueMapTy &cache) { if (TraceLSP) { errs() << "States after initialization:\n"; - for (auto Pair : states) { - Instruction *v = cast(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, DefiningValueMapTy &cache) { if (TraceLSP) { errs() << "States after meet iteration:\n"; - for (auto Pair : states) { - Instruction *v = cast(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 -- 2.34.1