[llvm] r246713 - [RewriteStatepointsForGC] Improve debug output [NFC]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 2 14:11:44 PDT 2015
Author: reames
Date: Wed Sep 2 16:11:44 2015
New Revision: 246713
URL: http://llvm.org/viewvc/llvm-project?rev=246713&view=rev
Log:
[RewriteStatepointsForGC] Improve debug output [NFC]
Modified:
llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
llvm/trunk/test/Transforms/RewriteStatepointsForGC/base-pointers.ll
Modified: llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp?rev=246713&r1=246712&r2=246713&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp Wed Sep 2 16:11:44 2015
@@ -47,10 +47,6 @@
using namespace llvm;
-// Print tracing output
-static cl::opt<bool> TraceLSP("trace-rewrite-statepoints", cl::Hidden,
- cl::init(false));
-
// Print the liveset found at the insert location
static cl::opt<bool> PrintLiveSet("spp-print-liveset", cl::Hidden,
cl::init(false));
@@ -277,14 +273,12 @@ static void analyzeParsePointLiveness(
// Note: This output is used by several of the test cases
// The order of elements in a set is not stable, put them in a vec and sort
// by name
- SmallVector<Value *, 64> temp;
- temp.insert(temp.end(), liveset.begin(), liveset.end());
- std::sort(temp.begin(), temp.end(), order_by_name);
+ SmallVector<Value *, 64> Temp;
+ Temp.insert(Temp.end(), liveset.begin(), liveset.end());
+ std::sort(Temp.begin(), Temp.end(), order_by_name);
errs() << "Live Variables:\n";
- for (Value *V : temp) {
- errs() << " " << V->getName(); // no newline
- V->dump();
- }
+ for (Value *V : Temp)
+ dbgs() << " " << V->getName() << " " << *V << "\n";
}
if (PrintLiveSetSize) {
errs() << "Safepoint For: " << CS.getCalledValue()->getName() << "\n";
@@ -602,7 +596,18 @@ public:
void dump() const { print(dbgs()); dbgs() << '\n'; }
void print(raw_ostream &OS) const {
- OS << status << " (" << base << " - "
+ switch (status) {
+ case Unknown:
+ OS << "U";
+ break;
+ case Base:
+ OS << "B";
+ break;
+ case Conflict:
+ OS << "C";
+ break;
+ };
+ OS << " (" << base << " - "
<< (base ? base->getName() : "nullptr") << "): ";
}
@@ -761,11 +766,12 @@ static Value *findBasePointer(Value *I,
}
}
- if (TraceLSP) {
- errs() << "States after initialization:\n";
- for (auto Pair : states)
- dbgs() << " " << Pair.second << " for " << *Pair.first << "\n";
+#ifndef NDEBUG
+ DEBUG(dbgs() << "States after initialization:\n");
+ for (auto Pair : states) {
+ DEBUG(dbgs() << " " << Pair.second << " for " << *Pair.first << "\n");
}
+#endif
// TODO: come back and revisit the state transitions around inputs which
// have reached conflict state. The current version seems too conservative.
@@ -825,12 +831,13 @@ static Value *findBasePointer(Value *I,
assert(oldSize == states.size() || progress);
}
- if (TraceLSP) {
- errs() << "States after meet iteration:\n";
- for (auto Pair : states)
- dbgs() << " " << Pair.second << " for " << *Pair.first << "\n";
+#ifndef NDEBUG
+ DEBUG(dbgs() << "States after meet iteration:\n");
+ for (auto Pair : states) {
+ DEBUG(dbgs() << " " << Pair.second << " for " << *Pair.first << "\n");
}
-
+#endif
+
// Insert Phis for all conflicts
// We want to keep naming deterministic in the loop that follows, so
// sort the keys before iteration. This is useful in allowing us to
@@ -1042,6 +1049,7 @@ static Value *findBasePointer(Value *I,
const DataLayout &DL = cast<Instruction>(def)->getModule()->getDataLayout();
while (!Worklist.empty()) {
Instruction *BaseI = Worklist.pop_back_val();
+ assert(NewInsts.count(BaseI));
Value *Bdv = ReverseMap[BaseI];
if (auto *BdvI = dyn_cast<Instruction>(Bdv))
if (BaseI->isIdenticalTo(BdvI)) {
@@ -1074,15 +1082,13 @@ static Value *findBasePointer(Value *I,
Value *base = item.second.getBase();
assert(v && base);
- if (TraceLSP) {
- std::string fromstr =
- cache.count(v) ? (cache[v]->hasName() ? cache[v]->getName() : "")
- : "none";
- errs() << "Updating base value cache"
- << " for: " << (v->hasName() ? v->getName() : "")
- << " from: " << fromstr
- << " to: " << (base->hasName() ? base->getName() : "") << "\n";
- }
+ std::string fromstr =
+ cache.count(v) ? (cache[v]->hasName() ? cache[v]->getName() : "")
+ : "none";
+ DEBUG(dbgs() << "Updating base value cache"
+ << " for: " << (v->hasName() ? v->getName() : "")
+ << " from: " << fromstr
+ << " to: " << (base->hasName() ? base->getName() : "") << "\n");
if (cache.count(v)) {
// Once we transition from the BDV relation being store in the cache to
Modified: llvm/trunk/test/Transforms/RewriteStatepointsForGC/base-pointers.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/RewriteStatepointsForGC/base-pointers.ll?rev=246713&r1=246712&r2=246713&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/RewriteStatepointsForGC/base-pointers.ll (original)
+++ llvm/trunk/test/Transforms/RewriteStatepointsForGC/base-pointers.ll Wed Sep 2 16:11:44 2015
@@ -111,6 +111,40 @@ merge:
ret i64 addrspace(1)* %bdv
}
+define i64 addrspace(1)* @test4(i1 %cnd, i64 addrspace(1)* %obj,
+ i64 addrspace(1)* %obj2)
+ gc "statepoint-example" {
+; CHECK-LABEL: @test4
+entry:
+ br i1 %cnd, label %merge, label %taken
+taken:
+ br label %merge
+merge:
+; CHECK-LABEL: merge:
+; CHECK-NEXT: %bdv = phi
+; CHECK-NEXT: gc.statepoint
+ %bdv = phi i64 addrspace(1)* [ %obj, %entry ], [ %obj, %taken ]
+ %safepoint_token = call i32 (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @foo, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0)
+ ret i64 addrspace(1)* %bdv
+}
+
+define i64 addrspace(1)* @test5(i1 %cnd, i64 addrspace(1)* %obj,
+ i64 addrspace(1)* %obj2)
+ gc "statepoint-example" {
+; CHECK-LABEL: @test5
+entry:
+ br label %merge
+merge:
+; CHECK-LABEL: merge:
+; CHECK-NEXT: %bdv = phi
+; CHECK-NEXT: br i1
+ %bdv = phi i64 addrspace(1)* [ %obj, %entry ], [ %obj2, %merge ]
+ br i1 %cnd, label %merge, label %next
+next:
+ %safepoint_token = call i32 (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @foo, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0)
+ ret i64 addrspace(1)* %bdv
+}
+
declare void @foo()
declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
More information about the llvm-commits
mailing list