diff options
Diffstat (limited to 'llvm/lib/Transforms/Scalar/NewGVN.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/NewGVN.cpp | 236 |
1 files changed, 126 insertions, 110 deletions
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp index 369f59ec3c3..0cf9979b40a 100644 --- a/llvm/lib/Transforms/Scalar/NewGVN.cpp +++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp @@ -221,13 +221,13 @@ private: Components.resize(Components.size() + 1); auto &Component = Components.back(); Component.insert(I); - DEBUG(dbgs() << "Component root is " << *I << "\n"); + LLVM_DEBUG(dbgs() << "Component root is " << *I << "\n"); InComponent.insert(I); ValueToComponent[I] = ComponentID; // Pop a component off the stack and label it. while (!Stack.empty() && Root.lookup(Stack.back()) >= OurDFS) { auto *Member = Stack.back(); - DEBUG(dbgs() << "Component member is " << *Member << "\n"); + LLVM_DEBUG(dbgs() << "Component member is " << *Member << "\n"); Component.insert(Member); InComponent.insert(Member); ValueToComponent[Member] = ComponentID; @@ -1068,8 +1068,8 @@ const Expression *NewGVN::checkSimplificationResults(Expression *E, return nullptr; if (auto *C = dyn_cast<Constant>(V)) { if (I) - DEBUG(dbgs() << "Simplified " << *I << " to " - << " constant " << *C << "\n"); + LLVM_DEBUG(dbgs() << "Simplified " << *I << " to " + << " constant " << *C << "\n"); NumGVNOpsSimplified++; assert(isa<BasicExpression>(E) && "We should always have had a basic expression here"); @@ -1077,8 +1077,8 @@ const Expression *NewGVN::checkSimplificationResults(Expression *E, return createConstantExpression(C); } else if (isa<Argument>(V) || isa<GlobalVariable>(V)) { if (I) - DEBUG(dbgs() << "Simplified " << *I << " to " - << " variable " << *V << "\n"); + LLVM_DEBUG(dbgs() << "Simplified " << *I << " to " + << " variable " << *V << "\n"); deleteExpression(E); return createVariableExpression(V); } @@ -1101,8 +1101,8 @@ const Expression *NewGVN::checkSimplificationResults(Expression *E, } if (I) - DEBUG(dbgs() << "Simplified " << *I << " to " - << " expression " << *CC->getDefiningExpr() << "\n"); + LLVM_DEBUG(dbgs() << "Simplified " << *I << " to " + << " expression " << *CC->getDefiningExpr() << "\n"); NumGVNOpsSimplified++; deleteExpression(E); return CC->getDefiningExpr(); @@ -1422,8 +1422,8 @@ NewGVN::performSymbolicLoadCoercion(Type *LoadType, Value *LoadPtr, if (Offset >= 0) { if (auto *C = dyn_cast<Constant>( lookupOperandLeader(DepSI->getValueOperand()))) { - DEBUG(dbgs() << "Coercing load from store " << *DepSI << " to constant " - << *C << "\n"); + LLVM_DEBUG(dbgs() << "Coercing load from store " << *DepSI + << " to constant " << *C << "\n"); return createConstantExpression( getConstantStoreValueForLoad(C, Offset, LoadType, DL)); } @@ -1438,8 +1438,8 @@ NewGVN::performSymbolicLoadCoercion(Type *LoadType, Value *LoadPtr, if (auto *C = dyn_cast<Constant>(lookupOperandLeader(DepLI))) if (auto *PossibleConstant = getConstantLoadValueForLoad(C, Offset, LoadType, DL)) { - DEBUG(dbgs() << "Coercing load from load " << *LI << " to constant " - << *PossibleConstant << "\n"); + LLVM_DEBUG(dbgs() << "Coercing load from load " << *LI + << " to constant " << *PossibleConstant << "\n"); return createConstantExpression(PossibleConstant); } } @@ -1448,8 +1448,8 @@ NewGVN::performSymbolicLoadCoercion(Type *LoadType, Value *LoadPtr, if (Offset >= 0) { if (auto *PossibleConstant = getConstantMemInstValueForLoad(DepMI, Offset, LoadType, DL)) { - DEBUG(dbgs() << "Coercing load from meminst " << *DepMI - << " to constant " << *PossibleConstant << "\n"); + LLVM_DEBUG(dbgs() << "Coercing load from meminst " << *DepMI + << " to constant " << *PossibleConstant << "\n"); return createConstantExpression(PossibleConstant); } } @@ -1530,7 +1530,7 @@ NewGVN::performSymbolicPredicateInfoEvaluation(Instruction *I) const { if (!PI) return nullptr; - DEBUG(dbgs() << "Found predicate info from instruction !\n"); + LLVM_DEBUG(dbgs() << "Found predicate info from instruction !\n"); auto *PWC = dyn_cast<PredicateWithCondition>(PI); if (!PWC) @@ -1570,7 +1570,7 @@ NewGVN::performSymbolicPredicateInfoEvaluation(Instruction *I) const { return nullptr; if (CopyOf != Cmp->getOperand(0) && CopyOf != Cmp->getOperand(1)) { - DEBUG(dbgs() << "Copy is not of any condition operands!\n"); + LLVM_DEBUG(dbgs() << "Copy is not of any condition operands!\n"); return nullptr; } Value *FirstOp = lookupOperandLeader(Cmp->getOperand(0)); @@ -1653,10 +1653,11 @@ bool NewGVN::setMemoryClass(const MemoryAccess *From, CongruenceClass *NewClass) { assert(NewClass && "Every MemoryAccess should be getting mapped to a non-null class"); - DEBUG(dbgs() << "Setting " << *From); - DEBUG(dbgs() << " equivalent to congruence class "); - DEBUG(dbgs() << NewClass->getID() << " with current MemoryAccess leader "); - DEBUG(dbgs() << *NewClass->getMemoryLeader() << "\n"); + LLVM_DEBUG(dbgs() << "Setting " << *From); + LLVM_DEBUG(dbgs() << " equivalent to congruence class "); + LLVM_DEBUG(dbgs() << NewClass->getID() + << " with current MemoryAccess leader "); + LLVM_DEBUG(dbgs() << *NewClass->getMemoryLeader() << "\n"); auto LookupResult = MemoryAccessToClass.find(From); bool Changed = false; @@ -1674,11 +1675,11 @@ bool NewGVN::setMemoryClass(const MemoryAccess *From, OldClass->setMemoryLeader(nullptr); } else { OldClass->setMemoryLeader(getNextMemoryLeader(OldClass)); - DEBUG(dbgs() << "Memory class leader change for class " - << OldClass->getID() << " to " - << *OldClass->getMemoryLeader() - << " due to removal of a memory member " << *From - << "\n"); + LLVM_DEBUG(dbgs() << "Memory class leader change for class " + << OldClass->getID() << " to " + << *OldClass->getMemoryLeader() + << " due to removal of a memory member " << *From + << "\n"); markMemoryLeaderChangeTouched(OldClass); } } @@ -1754,12 +1755,13 @@ NewGVN::performSymbolicPHIEvaluation(ArrayRef<ValPair> PHIOps, // If it has undef at this point, it means there are no-non-undef arguments, // and thus, the value of the phi node must be undef. if (HasUndef) { - DEBUG(dbgs() << "PHI Node " << *I - << " has no non-undef arguments, valuing it as undef\n"); + LLVM_DEBUG( + dbgs() << "PHI Node " << *I + << " has no non-undef arguments, valuing it as undef\n"); return createConstantExpression(UndefValue::get(I->getType())); } - DEBUG(dbgs() << "No arguments of PHI node " << *I << " are live\n"); + LLVM_DEBUG(dbgs() << "No arguments of PHI node " << *I << " are live\n"); deleteExpression(E); return createDeadExpression(); } @@ -1798,8 +1800,8 @@ NewGVN::performSymbolicPHIEvaluation(ArrayRef<ValPair> PHIOps, InstrToDFSNum(AllSameValue) > InstrToDFSNum(I)) return E; NumGVNPhisAllSame++; - DEBUG(dbgs() << "Simplified PHI node " << *I << " to " << *AllSameValue - << "\n"); + LLVM_DEBUG(dbgs() << "Simplified PHI node " << *I << " to " << *AllSameValue + << "\n"); deleteExpression(E); return createVariableOrConstant(AllSameValue); } @@ -2092,7 +2094,7 @@ void NewGVN::markUsersTouched(Value *V) { } void NewGVN::addMemoryUsers(const MemoryAccess *To, MemoryAccess *U) const { - DEBUG(dbgs() << "Adding memory user " << *U << " to " << *To << "\n"); + LLVM_DEBUG(dbgs() << "Adding memory user " << *U << " to " << *To << "\n"); MemoryToUsers[To].insert(U); } @@ -2228,8 +2230,9 @@ void NewGVN::moveMemoryToNewCongruenceClass(Instruction *I, (isa<StoreInst>(I) && NewClass->getStoreCount() == 1)); NewClass->setMemoryLeader(InstMA); // Mark it touched if we didn't just create a singleton - DEBUG(dbgs() << "Memory class leader change for class " << NewClass->getID() - << " due to new memory instruction becoming leader\n"); + LLVM_DEBUG(dbgs() << "Memory class leader change for class " + << NewClass->getID() + << " due to new memory instruction becoming leader\n"); markMemoryLeaderChangeTouched(NewClass); } setMemoryClass(InstMA, NewClass); @@ -2237,10 +2240,10 @@ void NewGVN::moveMemoryToNewCongruenceClass(Instruction *I, if (OldClass->getMemoryLeader() == InstMA) { if (!OldClass->definesNoMemory()) { OldClass->setMemoryLeader(getNextMemoryLeader(OldClass)); - DEBUG(dbgs() << "Memory class leader change for class " - << OldClass->getID() << " to " - << *OldClass->getMemoryLeader() - << " due to removal of old leader " << *InstMA << "\n"); + LLVM_DEBUG(dbgs() << "Memory class leader change for class " + << OldClass->getID() << " to " + << *OldClass->getMemoryLeader() + << " due to removal of old leader " << *InstMA << "\n"); markMemoryLeaderChangeTouched(OldClass); } else OldClass->setMemoryLeader(nullptr); @@ -2277,9 +2280,10 @@ void NewGVN::moveValueToNewCongruenceClass(Instruction *I, const Expression *E, NewClass->setStoredValue(SE->getStoredValue()); markValueLeaderChangeTouched(NewClass); // Shift the new class leader to be the store - DEBUG(dbgs() << "Changing leader of congruence class " - << NewClass->getID() << " from " << *NewClass->getLeader() - << " to " << *SI << " because store joined class\n"); + LLVM_DEBUG(dbgs() << "Changing leader of congruence class " + << NewClass->getID() << " from " + << *NewClass->getLeader() << " to " << *SI + << " because store joined class\n"); // If we changed the leader, we have to mark it changed because we don't // know what it will do to symbolic evaluation. NewClass->setLeader(SI); @@ -2299,8 +2303,8 @@ void NewGVN::moveValueToNewCongruenceClass(Instruction *I, const Expression *E, // See if we destroyed the class or need to swap leaders. if (OldClass->empty() && OldClass != TOPClass) { if (OldClass->getDefiningExpr()) { - DEBUG(dbgs() << "Erasing expression " << *OldClass->getDefiningExpr() - << " from table\n"); + LLVM_DEBUG(dbgs() << "Erasing expression " << *OldClass->getDefiningExpr() + << " from table\n"); // We erase it as an exact expression to make sure we don't just erase an // equivalent one. auto Iter = ExpressionToClass.find_as( @@ -2317,8 +2321,8 @@ void NewGVN::moveValueToNewCongruenceClass(Instruction *I, const Expression *E, // When the leader changes, the value numbering of // everything may change due to symbolization changes, so we need to // reprocess. - DEBUG(dbgs() << "Value class leader change for class " << OldClass->getID() - << "\n"); + LLVM_DEBUG(dbgs() << "Value class leader change for class " + << OldClass->getID() << "\n"); ++NumGVNLeaderChanges; // Destroy the stored value if there are no more stores to represent it. // Note that this is basically clean up for the expression removal that @@ -2381,12 +2385,14 @@ void NewGVN::performCongruenceFinding(Instruction *I, const Expression *E) { "VariableExpression should have been handled already"); EClass = NewClass; - DEBUG(dbgs() << "Created new congruence class for " << *I - << " using expression " << *E << " at " << NewClass->getID() - << " and leader " << *(NewClass->getLeader())); + LLVM_DEBUG(dbgs() << "Created new congruence class for " << *I + << " using expression " << *E << " at " + << NewClass->getID() << " and leader " + << *(NewClass->getLeader())); if (NewClass->getStoredValue()) - DEBUG(dbgs() << " and stored value " << *(NewClass->getStoredValue())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " and stored value " + << *(NewClass->getStoredValue())); + LLVM_DEBUG(dbgs() << "\n"); } else { EClass = lookupResult.first->second; if (isa<ConstantExpression>(E)) @@ -2404,8 +2410,8 @@ void NewGVN::performCongruenceFinding(Instruction *I, const Expression *E) { bool ClassChanged = IClass != EClass; bool LeaderChanged = LeaderChanges.erase(I); if (ClassChanged || LeaderChanged) { - DEBUG(dbgs() << "New class " << EClass->getID() << " for expression " << *E - << "\n"); + LLVM_DEBUG(dbgs() << "New class " << EClass->getID() << " for expression " + << *E << "\n"); if (ClassChanged) { moveValueToNewCongruenceClass(I, E, IClass, EClass); markPhiOfOpsChanged(E); @@ -2443,13 +2449,15 @@ void NewGVN::updateReachableEdge(BasicBlock *From, BasicBlock *To) { if (ReachableEdges.insert({From, To}).second) { // If this block wasn't reachable before, all instructions are touched. if (ReachableBlocks.insert(To).second) { - DEBUG(dbgs() << "Block " << getBlockName(To) << " marked reachable\n"); + LLVM_DEBUG(dbgs() << "Block " << getBlockName(To) + << " marked reachable\n"); const auto &InstRange = BlockInstRange.lookup(To); TouchedInstructions.set(InstRange.first, InstRange.second); } else { - DEBUG(dbgs() << "Block " << getBlockName(To) - << " was reachable, but new edge {" << getBlockName(From) - << "," << getBlockName(To) << "} to it found\n"); + LLVM_DEBUG(dbgs() << "Block " << getBlockName(To) + << " was reachable, but new edge {" + << getBlockName(From) << "," << getBlockName(To) + << "} to it found\n"); // We've made an edge reachable to an existing block, which may // impact predicates. Otherwise, only mark the phi nodes as touched, as @@ -2496,12 +2504,12 @@ void NewGVN::processOutgoingEdges(TerminatorInst *TI, BasicBlock *B) { BasicBlock *FalseSucc = BR->getSuccessor(1); if (CondEvaluated && (CI = dyn_cast<ConstantInt>(CondEvaluated))) { if (CI->isOne()) { - DEBUG(dbgs() << "Condition for Terminator " << *TI - << " evaluated to true\n"); + LLVM_DEBUG(dbgs() << "Condition for Terminator " << *TI + << " evaluated to true\n"); updateReachableEdge(B, TrueSucc); } else if (CI->isZero()) { - DEBUG(dbgs() << "Condition for Terminator " << *TI - << " evaluated to false\n"); + LLVM_DEBUG(dbgs() << "Condition for Terminator " << *TI + << " evaluated to false\n"); updateReachableEdge(B, FalseSucc); } } else { @@ -2686,8 +2694,8 @@ Value *NewGVN::findLeaderForInst(Instruction *TransInst, auto *FoundVal = findPHIOfOpsLeader(E, OrigInst, PredBB); if (!FoundVal) { ExpressionToPhiOfOps[E].insert(OrigInst); - DEBUG(dbgs() << "Cannot find phi of ops operand for " << *TransInst - << " in block " << getBlockName(PredBB) << "\n"); + LLVM_DEBUG(dbgs() << "Cannot find phi of ops operand for " << *TransInst + << " in block " << getBlockName(PredBB) << "\n"); return nullptr; } if (auto *SI = dyn_cast<StoreInst>(FoundVal)) @@ -2736,15 +2744,16 @@ NewGVN::makePossiblePHIOfOps(Instruction *I, auto *ValuePHI = RealToTemp.lookup(Op); if (!ValuePHI) continue; - DEBUG(dbgs() << "Found possible dependent phi of ops\n"); + LLVM_DEBUG(dbgs() << "Found possible dependent phi of ops\n"); Op = ValuePHI; } OpPHI = cast<PHINode>(Op); if (!SamePHIBlock) { SamePHIBlock = getBlockForValue(OpPHI); } else if (SamePHIBlock != getBlockForValue(OpPHI)) { - DEBUG(dbgs() - << "PHIs for operands are not all in the same block, aborting\n"); + LLVM_DEBUG( + dbgs() + << "PHIs for operands are not all in the same block, aborting\n"); return nullptr; } // No point in doing this for one-operand phis. @@ -2812,25 +2821,26 @@ NewGVN::makePossiblePHIOfOps(Instruction *I, } Deps.insert(CurrentDeps.begin(), CurrentDeps.end()); } else { - DEBUG(dbgs() << "Skipping phi of ops operand for incoming block " - << getBlockName(PredBB) - << " because the block is unreachable\n"); + LLVM_DEBUG(dbgs() << "Skipping phi of ops operand for incoming block " + << getBlockName(PredBB) + << " because the block is unreachable\n"); FoundVal = UndefValue::get(I->getType()); RevisitOnReachabilityChange[PHIBlock].set(InstrToDFSNum(I)); } PHIOps.push_back({FoundVal, PredBB}); - DEBUG(dbgs() << "Found phi of ops operand " << *FoundVal << " in " - << getBlockName(PredBB) << "\n"); + LLVM_DEBUG(dbgs() << "Found phi of ops operand " << *FoundVal << " in " + << getBlockName(PredBB) << "\n"); } for (auto Dep : Deps) addAdditionalUsers(Dep, I); sortPHIOps(PHIOps); auto *E = performSymbolicPHIEvaluation(PHIOps, I, PHIBlock); if (isa<ConstantExpression>(E) || isa<VariableExpression>(E)) { - DEBUG(dbgs() - << "Not creating real PHI of ops because it simplified to existing " - "value or constant\n"); + LLVM_DEBUG( + dbgs() + << "Not creating real PHI of ops because it simplified to existing " + "value or constant\n"); return E; } auto *ValuePHI = RealToTemp.lookup(I); @@ -2855,7 +2865,8 @@ NewGVN::makePossiblePHIOfOps(Instruction *I, } } RevisitOnReachabilityChange[PHIBlock].set(InstrToDFSNum(I)); - DEBUG(dbgs() << "Created phi of ops " << *ValuePHI << " for " << *I << "\n"); + LLVM_DEBUG(dbgs() << "Created phi of ops " << *ValuePHI << " for " << *I + << "\n"); return E; } @@ -2927,8 +2938,9 @@ void NewGVN::initializeCongruenceClasses(Function &F) { void NewGVN::cleanupTables() { for (unsigned i = 0, e = CongruenceClasses.size(); i != e; ++i) { - DEBUG(dbgs() << "Congruence class " << CongruenceClasses[i]->getID() - << " has " << CongruenceClasses[i]->size() << " members\n"); + LLVM_DEBUG(dbgs() << "Congruence class " << CongruenceClasses[i]->getID() + << " has " << CongruenceClasses[i]->size() + << " members\n"); // Make sure we delete the congruence class (probably worth switching to // a unique_ptr at some point. delete CongruenceClasses[i]; @@ -2998,7 +3010,7 @@ std::pair<unsigned, unsigned> NewGVN::assignDFSNumbers(BasicBlock *B, // we change its DFS number so that it doesn't get value numbered. if (isInstructionTriviallyDead(&I, TLI)) { InstrDFS[&I] = 0; - DEBUG(dbgs() << "Skipping trivially dead instruction " << I << "\n"); + LLVM_DEBUG(dbgs() << "Skipping trivially dead instruction " << I << "\n"); markInstructionForDeletion(&I); continue; } @@ -3064,9 +3076,10 @@ void NewGVN::valueNumberMemoryPhi(MemoryPhi *MP) { [&AllSameValue](const MemoryAccess *V) { return V == AllSameValue; }); if (AllEqual) - DEBUG(dbgs() << "Memory Phi value numbered to " << *AllSameValue << "\n"); + LLVM_DEBUG(dbgs() << "Memory Phi value numbered to " << *AllSameValue + << "\n"); else - DEBUG(dbgs() << "Memory Phi value numbered to itself\n"); + LLVM_DEBUG(dbgs() << "Memory Phi value numbered to itself\n"); // If it's equal to something, it's in that class. Otherwise, it has to be in // a class where it is the leader (other things may be equivalent to it, but // it needs to start off in its own class, which means it must have been the @@ -3085,7 +3098,7 @@ void NewGVN::valueNumberMemoryPhi(MemoryPhi *MP) { // Value number a single instruction, symbolically evaluating, performing // congruence finding, and updating mappings. void NewGVN::valueNumberInstruction(Instruction *I) { - DEBUG(dbgs() << "Processing instruction " << *I << "\n"); + LLVM_DEBUG(dbgs() << "Processing instruction " << *I << "\n"); if (!I->isTerminator()) { const Expression *Symbolized = nullptr; SmallPtrSet<Value *, 2> Visited; @@ -3271,7 +3284,7 @@ void NewGVN::verifyMemoryCongruency() const { // and redoing the iteration to see if anything changed. void NewGVN::verifyIterationSettled(Function &F) { #ifndef NDEBUG - DEBUG(dbgs() << "Beginning iteration verification\n"); + LLVM_DEBUG(dbgs() << "Beginning iteration verification\n"); if (DebugCounter::isCounterSet(VNCounter)) DebugCounter::setCounterValue(VNCounter, StartingVNCounter); @@ -3389,9 +3402,9 @@ void NewGVN::iterateTouchedInstructions() { // If it's not reachable, erase any touched instructions and move on. if (!BlockReachable) { TouchedInstructions.reset(CurrInstRange.first, CurrInstRange.second); - DEBUG(dbgs() << "Skipping instructions in block " - << getBlockName(CurrBlock) - << " because it is unreachable\n"); + LLVM_DEBUG(dbgs() << "Skipping instructions in block " + << getBlockName(CurrBlock) + << " because it is unreachable\n"); continue; } updateProcessedCount(CurrBlock); @@ -3401,7 +3414,7 @@ void NewGVN::iterateTouchedInstructions() { TouchedInstructions.reset(InstrNum); if (auto *MP = dyn_cast<MemoryPhi>(V)) { - DEBUG(dbgs() << "Processing MemoryPhi " << *MP << "\n"); + LLVM_DEBUG(dbgs() << "Processing MemoryPhi " << *MP << "\n"); valueNumberMemoryPhi(MP); } else if (auto *I = dyn_cast<Instruction>(V)) { valueNumberInstruction(I); @@ -3471,8 +3484,8 @@ bool NewGVN::runGVN() { // Initialize the touched instructions to include the entry block. const auto &InstRange = BlockInstRange.lookup(&F.getEntryBlock()); TouchedInstructions.set(InstRange.first, InstRange.second); - DEBUG(dbgs() << "Block " << getBlockName(&F.getEntryBlock()) - << " marked reachable\n"); + LLVM_DEBUG(dbgs() << "Block " << getBlockName(&F.getEntryBlock()) + << " marked reachable\n"); ReachableBlocks.insert(&F.getEntryBlock()); iterateTouchedInstructions(); @@ -3497,8 +3510,8 @@ bool NewGVN::runGVN() { }; for (auto &BB : make_filter_range(F, UnreachableBlockPred)) { - DEBUG(dbgs() << "We believe block " << getBlockName(&BB) - << " is unreachable\n"); + LLVM_DEBUG(dbgs() << "We believe block " << getBlockName(&BB) + << " is unreachable\n"); deleteInstructionsInBlock(&BB); Changed = true; } @@ -3720,7 +3733,7 @@ static void patchAndReplaceAllUsesWith(Instruction *I, Value *Repl) { } void NewGVN::deleteInstructionsInBlock(BasicBlock *BB) { - DEBUG(dbgs() << " BasicBlock Dead:" << *BB); + LLVM_DEBUG(dbgs() << " BasicBlock Dead:" << *BB); ++NumGVNBlocksDeleted; // Delete the instructions backwards, as it has a reduced likelihood of having @@ -3747,12 +3760,12 @@ void NewGVN::deleteInstructionsInBlock(BasicBlock *BB) { } void NewGVN::markInstructionForDeletion(Instruction *I) { - DEBUG(dbgs() << "Marking " << *I << " for deletion\n"); + LLVM_DEBUG(dbgs() << "Marking " << *I << " for deletion\n"); InstructionsToErase.insert(I); } void NewGVN::replaceInstruction(Instruction *I, Value *V) { - DEBUG(dbgs() << "Replacing " << *I << " with " << *V << "\n"); + LLVM_DEBUG(dbgs() << "Replacing " << *I << " with " << *V << "\n"); patchAndReplaceAllUsesWith(I, V); // We save the actual erasing to avoid invalidating memory // dependencies until we are done with everything. @@ -3878,9 +3891,10 @@ bool NewGVN::eliminateInstructions(Function &F) { auto ReplaceUnreachablePHIArgs = [&](PHINode *PHI, BasicBlock *BB) { for (auto &Operand : PHI->incoming_values()) if (!ReachableEdges.count({PHI->getIncomingBlock(Operand), BB})) { - DEBUG(dbgs() << "Replacing incoming value of " << PHI << " for block " - << getBlockName(PHI->getIncomingBlock(Operand)) - << " with undef due to it being unreachable\n"); + LLVM_DEBUG(dbgs() << "Replacing incoming value of " << PHI + << " for block " + << getBlockName(PHI->getIncomingBlock(Operand)) + << " with undef due to it being unreachable\n"); Operand.set(UndefValue::get(PHI->getType())); } }; @@ -3912,7 +3926,8 @@ bool NewGVN::eliminateInstructions(Function &F) { // Map to store the use counts DenseMap<const Value *, unsigned int> UseCounts; for (auto *CC : reverse(CongruenceClasses)) { - DEBUG(dbgs() << "Eliminating in congruence class " << CC->getID() << "\n"); + LLVM_DEBUG(dbgs() << "Eliminating in congruence class " << CC->getID() + << "\n"); // Track the equivalent store info so we can decide whether to try // dead store elimination. SmallVector<ValueDFS, 8> PossibleDeadStores; @@ -3950,8 +3965,8 @@ bool NewGVN::eliminateInstructions(Function &F) { MembersLeft.insert(Member); continue; } - DEBUG(dbgs() << "Found replacement " << *(Leader) << " for " << *Member - << "\n"); + LLVM_DEBUG(dbgs() << "Found replacement " << *(Leader) << " for " + << *Member << "\n"); auto *I = cast<Instruction>(Member); assert(Leader != I && "About to accidentally remove our leader"); replaceInstruction(I, Leader); @@ -3991,24 +4006,24 @@ bool NewGVN::eliminateInstructions(Function &F) { // remove from temp instruction list. AllTempInstructions.erase(PN); auto *DefBlock = getBlockForValue(Def); - DEBUG(dbgs() << "Inserting fully real phi of ops" << *Def - << " into block " - << getBlockName(getBlockForValue(Def)) << "\n"); + LLVM_DEBUG(dbgs() << "Inserting fully real phi of ops" << *Def + << " into block " + << getBlockName(getBlockForValue(Def)) << "\n"); PN->insertBefore(&DefBlock->front()); Def = PN; NumGVNPHIOfOpsEliminations++; } if (EliminationStack.empty()) { - DEBUG(dbgs() << "Elimination Stack is empty\n"); + LLVM_DEBUG(dbgs() << "Elimination Stack is empty\n"); } else { - DEBUG(dbgs() << "Elimination Stack Top DFS numbers are (" - << EliminationStack.dfs_back().first << "," - << EliminationStack.dfs_back().second << ")\n"); + LLVM_DEBUG(dbgs() << "Elimination Stack Top DFS numbers are (" + << EliminationStack.dfs_back().first << "," + << EliminationStack.dfs_back().second << ")\n"); } - DEBUG(dbgs() << "Current DFS numbers are (" << MemberDFSIn << "," - << MemberDFSOut << ")\n"); + LLVM_DEBUG(dbgs() << "Current DFS numbers are (" << MemberDFSIn << "," + << MemberDFSOut << ")\n"); // First, we see if we are out of scope or empty. If so, // and there equivalences, we try to replace the top of // stack with equivalences (if it's on the stack, it must @@ -4090,8 +4105,9 @@ bool NewGVN::eliminateInstructions(Function &F) { // Don't replace our existing users with ourselves. if (U->get() == DominatingLeader) continue; - DEBUG(dbgs() << "Found replacement " << *DominatingLeader << " for " - << *U->get() << " in " << *(U->getUser()) << "\n"); + LLVM_DEBUG(dbgs() + << "Found replacement " << *DominatingLeader << " for " + << *U->get() << " in " << *(U->getUser()) << "\n"); // If we replaced something in an instruction, handle the patching of // metadata. Skip this if we are replacing predicateinfo with its @@ -4157,8 +4173,8 @@ bool NewGVN::eliminateInstructions(Function &F) { (void)Leader; assert(DT->dominates(Leader->getParent(), Member->getParent())); // Member is dominater by Leader, and thus dead - DEBUG(dbgs() << "Marking dead store " << *Member - << " that is dominated by " << *Leader << "\n"); + LLVM_DEBUG(dbgs() << "Marking dead store " << *Member + << " that is dominated by " << *Leader << "\n"); markInstructionForDeletion(Member); CC->erase(Member); ++NumGVNDeadStores; |