Don't use all the #ifdefs to hide the stats counters and instead rely on

their being optimized out in debug mode. Realistically, this just isn't
going to be the slow part anyways. This also fixes unused variable
warnings that are breaking LLD build bots. =/ I didn't see these at
first, and kept losing track of the fact that they were broken.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187297 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chandler Carruth
2013-07-27 10:17:49 +00:00
parent 33ae899113
commit 89934cbd34

View File

@@ -3051,10 +3051,7 @@ bool SROA::rewritePartition(AllocaInst &AI, AllocaSlices &S,
unsigned PPWOldSize = PostPromotionWorklist.size(); unsigned PPWOldSize = PostPromotionWorklist.size();
unsigned SPOldSize = SpeculatablePHIs.size(); unsigned SPOldSize = SpeculatablePHIs.size();
unsigned SSOldSize = SpeculatableSelects.size(); unsigned SSOldSize = SpeculatableSelects.size();
#if !defined(NDEBUG) || defined(LLVM_ENABLE_STATS)
unsigned NumUses = 0; unsigned NumUses = 0;
#endif
AllocaSliceRewriter Rewriter(*DL, S, *this, AI, *NewAI, BeginOffset, AllocaSliceRewriter Rewriter(*DL, S, *this, AI, *NewAI, BeginOffset,
EndOffset, IsVectorPromotable, EndOffset, IsVectorPromotable,
@@ -3066,24 +3063,18 @@ bool SROA::rewritePartition(AllocaInst &AI, AllocaSlices &S,
DEBUG(dbgs() << " rewriting split "); DEBUG(dbgs() << " rewriting split ");
DEBUG(S.printSlice(dbgs(), *SUI, "")); DEBUG(S.printSlice(dbgs(), *SUI, ""));
Promotable &= Rewriter.visit(*SUI); Promotable &= Rewriter.visit(*SUI);
#if !defined(NDEBUG) || defined(LLVM_ENABLE_STATS)
++NumUses; ++NumUses;
#endif
} }
for (AllocaSlices::iterator I = B; I != E; ++I) { for (AllocaSlices::iterator I = B; I != E; ++I) {
DEBUG(dbgs() << " rewriting "); DEBUG(dbgs() << " rewriting ");
DEBUG(S.printSlice(dbgs(), I, "")); DEBUG(S.printSlice(dbgs(), I, ""));
Promotable &= Rewriter.visit(I); Promotable &= Rewriter.visit(I);
#if !defined(NDEBUG) || defined(LLVM_ENABLE_STATS)
++NumUses; ++NumUses;
#endif
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_STATS)
NumAllocaPartitionUses += NumUses; NumAllocaPartitionUses += NumUses;
MaxUsesPerAllocaPartition = MaxUsesPerAllocaPartition =
std::max<unsigned>(NumUses, MaxUsesPerAllocaPartition); std::max<unsigned>(NumUses, MaxUsesPerAllocaPartition);
#endif
if (Promotable && !Rewriter.isUsedByRewrittenSpeculatableInstructions()) { if (Promotable && !Rewriter.isUsedByRewrittenSpeculatableInstructions()) {
DEBUG(dbgs() << " and queuing for promotion\n"); DEBUG(dbgs() << " and queuing for promotion\n");
@@ -3160,10 +3151,7 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &S) {
if (S.begin() == S.end()) if (S.begin() == S.end())
return false; return false;
#if !defined(NDEBUG) || defined(LLVM_ENABLE_STATS)
unsigned NumPartitions = 0; unsigned NumPartitions = 0;
#endif
bool Changed = false; bool Changed = false;
SmallVector<AllocaSlices::iterator, 4> SplitUses; SmallVector<AllocaSlices::iterator, 4> SplitUses;
uint64_t MaxSplitUseEndOffset = 0; uint64_t MaxSplitUseEndOffset = 0;
@@ -3210,9 +3198,7 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &S) {
// Rewrite a sequence of overlapping slices. // Rewrite a sequence of overlapping slices.
Changed |= Changed |=
rewritePartition(AI, S, SI, SJ, BeginOffset, MaxEndOffset, SplitUses); rewritePartition(AI, S, SI, SJ, BeginOffset, MaxEndOffset, SplitUses);
#if !defined(NDEBUG) || defined(LLVM_ENABLE_STATS)
++NumPartitions; ++NumPartitions;
#endif
removeFinishedSplitUses(SplitUses, MaxSplitUseEndOffset, MaxEndOffset); removeFinishedSplitUses(SplitUses, MaxSplitUseEndOffset, MaxEndOffset);
} }
@@ -3252,9 +3238,7 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &S) {
Changed |= rewritePartition(AI, S, SJ, SJ, MaxEndOffset, PostSplitEndOffset, Changed |= rewritePartition(AI, S, SJ, SJ, MaxEndOffset, PostSplitEndOffset,
SplitUses); SplitUses);
#if !defined(NDEBUG) || defined(LLVM_ENABLE_STATS)
++NumPartitions; ++NumPartitions;
#endif
if (SJ == SE) if (SJ == SE)
break; // Skip the rest, we don't need to do any cleanup. break; // Skip the rest, we don't need to do any cleanup.
@@ -3266,11 +3250,9 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &S) {
BeginOffset = SJ->beginOffset(); BeginOffset = SJ->beginOffset();
} }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_STATS)
NumAllocaPartitions += NumPartitions; NumAllocaPartitions += NumPartitions;
MaxPartitionsPerAlloca = MaxPartitionsPerAlloca =
std::max<unsigned>(NumPartitions, MaxPartitionsPerAlloca); std::max<unsigned>(NumPartitions, MaxPartitionsPerAlloca);
#endif
return Changed; return Changed;
} }