diff options
Diffstat (limited to 'llvm/lib/Analysis')
21 files changed, 599 insertions, 565 deletions
diff --git a/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp b/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp index 748736b6080..3d095068e7f 100644 --- a/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp +++ b/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp @@ -316,13 +316,13 @@ bool BlockFrequencyInfoImplBase::addToDist(Distribution &Dist, #endif if (isLoopHeader(Resolved)) { - DEBUG(debugSuccessor("backedge")); + LLVM_DEBUG(debugSuccessor("backedge")); Dist.addBackedge(Resolved, Weight); return true; } if (Working[Resolved.Index].getContainingLoop() != OuterLoop) { - DEBUG(debugSuccessor(" exit ")); + LLVM_DEBUG(debugSuccessor(" exit ")); Dist.addExit(Resolved, Weight); return true; } @@ -334,7 +334,7 @@ bool BlockFrequencyInfoImplBase::addToDist(Distribution &Dist, "unhandled irreducible control flow"); // Irreducible backedge. Abort. - DEBUG(debugSuccessor("abort!!!")); + LLVM_DEBUG(debugSuccessor("abort!!!")); return false; } @@ -345,7 +345,7 @@ bool BlockFrequencyInfoImplBase::addToDist(Distribution &Dist, "unhandled irreducible control flow"); } - DEBUG(debugSuccessor(" local ")); + LLVM_DEBUG(debugSuccessor(" local ")); Dist.addLocal(Resolved, Weight); return true; } @@ -365,7 +365,7 @@ bool BlockFrequencyInfoImplBase::addLoopSuccessorsToDist( /// Compute the loop scale for a loop. void BlockFrequencyInfoImplBase::computeLoopScale(LoopData &Loop) { // Compute loop scale. - DEBUG(dbgs() << "compute-loop-scale: " << getLoopName(Loop) << "\n"); + LLVM_DEBUG(dbgs() << "compute-loop-scale: " << getLoopName(Loop) << "\n"); // Infinite loops need special handling. If we give the back edge an infinite // mass, they may saturate all the other scales in the function down to 1, @@ -391,20 +391,21 @@ void BlockFrequencyInfoImplBase::computeLoopScale(LoopData &Loop) { Loop.Scale = ExitMass.isEmpty() ? InfiniteLoopScale : ExitMass.toScaled().inverse(); - DEBUG(dbgs() << " - exit-mass = " << ExitMass << " (" << BlockMass::getFull() - << " - " << TotalBackedgeMass << ")\n" - << " - scale = " << Loop.Scale << "\n"); + LLVM_DEBUG(dbgs() << " - exit-mass = " << ExitMass << " (" + << BlockMass::getFull() << " - " << TotalBackedgeMass + << ")\n" + << " - scale = " << Loop.Scale << "\n"); } /// Package up a loop. void BlockFrequencyInfoImplBase::packageLoop(LoopData &Loop) { - DEBUG(dbgs() << "packaging-loop: " << getLoopName(Loop) << "\n"); + LLVM_DEBUG(dbgs() << "packaging-loop: " << getLoopName(Loop) << "\n"); // Clear the subloop exits to prevent quadratic memory usage. for (const BlockNode &M : Loop.Nodes) { if (auto *Loop = Working[M.Index].getPackagedLoop()) Loop->Exits.clear(); - DEBUG(dbgs() << " - node: " << getBlockName(M.Index) << "\n"); + LLVM_DEBUG(dbgs() << " - node: " << getBlockName(M.Index) << "\n"); } Loop.IsPackaged = true; } @@ -426,7 +427,7 @@ void BlockFrequencyInfoImplBase::distributeMass(const BlockNode &Source, LoopData *OuterLoop, Distribution &Dist) { BlockMass Mass = Working[Source.Index].getMass(); - DEBUG(dbgs() << " => mass: " << Mass << "\n"); + LLVM_DEBUG(dbgs() << " => mass: " << Mass << "\n"); // Distribute mass to successors as laid out in Dist. DitheringDistributer D(Dist, Mass); @@ -436,7 +437,7 @@ void BlockFrequencyInfoImplBase::distributeMass(const BlockNode &Source, BlockMass Taken = D.takeMass(W.Amount); if (W.Type == Weight::Local) { Working[W.TargetNode.Index].getMass() += Taken; - DEBUG(debugAssign(*this, D, W.TargetNode, Taken, nullptr)); + LLVM_DEBUG(debugAssign(*this, D, W.TargetNode, Taken, nullptr)); continue; } @@ -446,14 +447,14 @@ void BlockFrequencyInfoImplBase::distributeMass(const BlockNode &Source, // Check for a backedge. if (W.Type == Weight::Backedge) { OuterLoop->BackedgeMass[OuterLoop->getHeaderIndex(W.TargetNode)] += Taken; - DEBUG(debugAssign(*this, D, W.TargetNode, Taken, "back")); + LLVM_DEBUG(debugAssign(*this, D, W.TargetNode, Taken, "back")); continue; } // This must be an exit. assert(W.Type == Weight::Exit); OuterLoop->Exits.push_back(std::make_pair(W.TargetNode, Taken)); - DEBUG(debugAssign(*this, D, W.TargetNode, Taken, "exit")); + LLVM_DEBUG(debugAssign(*this, D, W.TargetNode, Taken, "exit")); } } @@ -481,14 +482,14 @@ static void convertFloatingToInteger(BlockFrequencyInfoImplBase &BFI, } // Translate the floats to integers. - DEBUG(dbgs() << "float-to-int: min = " << Min << ", max = " << Max - << ", factor = " << ScalingFactor << "\n"); + LLVM_DEBUG(dbgs() << "float-to-int: min = " << Min << ", max = " << Max + << ", factor = " << ScalingFactor << "\n"); for (size_t Index = 0; Index < BFI.Freqs.size(); ++Index) { Scaled64 Scaled = BFI.Freqs[Index].Scaled * ScalingFactor; BFI.Freqs[Index].Integer = std::max(UINT64_C(1), Scaled.toInt<uint64_t>()); - DEBUG(dbgs() << " - " << BFI.getBlockName(Index) << ": float = " - << BFI.Freqs[Index].Scaled << ", scaled = " << Scaled - << ", int = " << BFI.Freqs[Index].Integer << "\n"); + LLVM_DEBUG(dbgs() << " - " << BFI.getBlockName(Index) << ": float = " + << BFI.Freqs[Index].Scaled << ", scaled = " << Scaled + << ", int = " << BFI.Freqs[Index].Integer << "\n"); } } @@ -497,12 +498,12 @@ static void convertFloatingToInteger(BlockFrequencyInfoImplBase &BFI, /// Visits all the members of a loop, adjusting their BlockData according to /// the loop's pseudo-node. static void unwrapLoop(BlockFrequencyInfoImplBase &BFI, LoopData &Loop) { - DEBUG(dbgs() << "unwrap-loop-package: " << BFI.getLoopName(Loop) - << ": mass = " << Loop.Mass << ", scale = " << Loop.Scale - << "\n"); + LLVM_DEBUG(dbgs() << "unwrap-loop-package: " << BFI.getLoopName(Loop) + << ": mass = " << Loop.Mass << ", scale = " << Loop.Scale + << "\n"); Loop.Scale *= Loop.Mass.toScaled(); Loop.IsPackaged = false; - DEBUG(dbgs() << " => combined-scale = " << Loop.Scale << "\n"); + LLVM_DEBUG(dbgs() << " => combined-scale = " << Loop.Scale << "\n"); // Propagate the head scale through the loop. Since members are visited in // RPO, the head scale will be updated by the loop scale first, and then the @@ -512,8 +513,8 @@ static void unwrapLoop(BlockFrequencyInfoImplBase &BFI, LoopData &Loop) { Scaled64 &F = Working.isAPackage() ? Working.getPackagedLoop()->Scale : BFI.Freqs[N.Index].Scaled; Scaled64 New = Loop.Scale * F; - DEBUG(dbgs() << " - " << BFI.getBlockName(N) << ": " << F << " => " << New - << "\n"); + LLVM_DEBUG(dbgs() << " - " << BFI.getBlockName(N) << ": " << F << " => " + << New << "\n"); F = New; } } @@ -545,7 +546,7 @@ void BlockFrequencyInfoImplBase::finalizeMetrics() { cleanup(*this); // Print out the final stats. - DEBUG(dump()); + LLVM_DEBUG(dump()); } BlockFrequency @@ -695,7 +696,8 @@ static void findIrreducibleHeaders( // This is an entry block. I->second = true; Headers.push_back(Irr.Node); - DEBUG(dbgs() << " => entry = " << BFI.getBlockName(Irr.Node) << "\n"); + LLVM_DEBUG(dbgs() << " => entry = " << BFI.getBlockName(Irr.Node) + << "\n"); break; } } @@ -726,7 +728,8 @@ static void findIrreducibleHeaders( // Store the extra header. Headers.push_back(Irr.Node); - DEBUG(dbgs() << " => extra = " << BFI.getBlockName(Irr.Node) << "\n"); + LLVM_DEBUG(dbgs() << " => extra = " << BFI.getBlockName(Irr.Node) + << "\n"); break; } if (Headers.back() == Irr.Node) @@ -735,7 +738,7 @@ static void findIrreducibleHeaders( // This is not a header. Others.push_back(Irr.Node); - DEBUG(dbgs() << " => other = " << BFI.getBlockName(Irr.Node) << "\n"); + LLVM_DEBUG(dbgs() << " => other = " << BFI.getBlockName(Irr.Node) << "\n"); } llvm::sort(Headers.begin(), Headers.end()); llvm::sort(Others.begin(), Others.end()); @@ -746,7 +749,7 @@ static void createIrreducibleLoop( LoopData *OuterLoop, std::list<LoopData>::iterator Insert, const std::vector<const IrreducibleGraph::IrrNode *> &SCC) { // Translate the SCC into RPO. - DEBUG(dbgs() << " - found-scc\n"); + LLVM_DEBUG(dbgs() << " - found-scc\n"); LoopData::NodeList Headers; LoopData::NodeList Others; @@ -807,27 +810,28 @@ void BlockFrequencyInfoImplBase::adjustLoopHeaderMass(LoopData &Loop) { BlockMass LoopMass = BlockMass::getFull(); Distribution Dist; - DEBUG(dbgs() << "adjust-loop-header-mass:\n"); + LLVM_DEBUG(dbgs() << "adjust-loop-header-mass:\n"); for (uint32_t H = 0; H < Loop.NumHeaders; ++H) { auto &HeaderNode = Loop.Nodes[H]; auto &BackedgeMass = Loop.BackedgeMass[Loop.getHeaderIndex(HeaderNode)]; - DEBUG(dbgs() << " - Add back edge mass for node " - << getBlockName(HeaderNode) << ": " << BackedgeMass << "\n"); + LLVM_DEBUG(dbgs() << " - Add back edge mass for node " + << getBlockName(HeaderNode) << ": " << BackedgeMass + << "\n"); if (BackedgeMass.getMass() > 0) Dist.addLocal(HeaderNode, BackedgeMass.getMass()); else - DEBUG(dbgs() << " Nothing added. Back edge mass is zero\n"); + LLVM_DEBUG(dbgs() << " Nothing added. Back edge mass is zero\n"); } DitheringDistributer D(Dist, LoopMass); - DEBUG(dbgs() << " Distribute loop mass " << LoopMass - << " to headers using above weights\n"); + LLVM_DEBUG(dbgs() << " Distribute loop mass " << LoopMass + << " to headers using above weights\n"); for (const Weight &W : Dist.Weights) { BlockMass Taken = D.takeMass(W.Amount); assert(W.Type == Weight::Local && "all weights should be local"); Working[W.TargetNode.Index].getMass() = Taken; - DEBUG(debugAssign(*this, D, W.TargetNode, Taken, nullptr)); + LLVM_DEBUG(debugAssign(*this, D, W.TargetNode, Taken, nullptr)); } } @@ -838,6 +842,6 @@ void BlockFrequencyInfoImplBase::distributeIrrLoopHeaderMass(Distribution &Dist) BlockMass Taken = D.takeMass(W.Amount); assert(W.Type == Weight::Local && "all weights should be local"); Working[W.TargetNode.Index].getMass() = Taken; - DEBUG(debugAssign(*this, D, W.TargetNode, Taken, nullptr)); + LLVM_DEBUG(debugAssign(*this, D, W.TargetNode, Taken, nullptr)); } } diff --git a/llvm/lib/Analysis/BranchProbabilityInfo.cpp b/llvm/lib/Analysis/BranchProbabilityInfo.cpp index 4e8491355fd..7299ef45ff5 100644 --- a/llvm/lib/Analysis/BranchProbabilityInfo.cpp +++ b/llvm/lib/Analysis/BranchProbabilityInfo.cpp @@ -908,8 +908,9 @@ void BranchProbabilityInfo::setEdgeProbability(const BasicBlock *Src, BranchProbability Prob) { Probs[std::make_pair(Src, IndexInSuccessors)] = Prob; Handles.insert(BasicBlockCallbackVH(Src, this)); - DEBUG(dbgs() << "set edge " << Src->getName() << " -> " << IndexInSuccessors - << " successor probability to " << Prob << "\n"); + LLVM_DEBUG(dbgs() << "set edge " << Src->getName() << " -> " + << IndexInSuccessors << " successor probability to " << Prob + << "\n"); } raw_ostream & @@ -934,8 +935,8 @@ void BranchProbabilityInfo::eraseBlock(const BasicBlock *BB) { void BranchProbabilityInfo::calculate(const Function &F, const LoopInfo &LI, const TargetLibraryInfo *TLI) { - DEBUG(dbgs() << "---- Branch Probability Info : " << F.getName() - << " ----\n\n"); + LLVM_DEBUG(dbgs() << "---- Branch Probability Info : " << F.getName() + << " ----\n\n"); LastF = &F; // Store the last function we ran on for printing. assert(PostDominatedByUnreachable.empty()); assert(PostDominatedByColdCall.empty()); @@ -953,18 +954,19 @@ void BranchProbabilityInfo::calculate(const Function &F, const LoopInfo &LI, if (Scc.size() == 1) continue; - DEBUG(dbgs() << "BPI: SCC " << SccNum << ":"); + LLVM_DEBUG(dbgs() << "BPI: SCC " << SccNum << ":"); for (auto *BB : Scc) { - DEBUG(dbgs() << " " << BB->getName()); + LLVM_DEBUG(dbgs() << " " << BB->getName()); SccI.SccNums[BB] = SccNum; } - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n"); } // Walk the basic blocks in post-order so that we can build up state about // the successors of a block iteratively. for (auto BB : post_order(&F.getEntryBlock())) { - DEBUG(dbgs() << "Computing probabilities for " << BB->getName() << "\n"); + LLVM_DEBUG(dbgs() << "Computing probabilities for " << BB->getName() + << "\n"); updatePostDominatedByUnreachable(BB); updatePostDominatedByColdCall(BB); // If there is no at least two successors, no sense to set probability. diff --git a/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp b/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp index cdb7ca9fb69..ef7e95ffb1f 100644 --- a/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp +++ b/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp @@ -855,8 +855,9 @@ AliasResult CFLAndersAAResult::query(const MemoryLocation &LocA, if (!Fn) { // The only times this is known to happen are when globals + InlineAsm are // involved - DEBUG(dbgs() - << "CFLAndersAA: could not extract parent function information.\n"); + LLVM_DEBUG( + dbgs() + << "CFLAndersAA: could not extract parent function information.\n"); return MayAlias; } } else { diff --git a/llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp b/llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp index eee6d26ba78..30ce13578e5 100644 --- a/llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp +++ b/llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp @@ -276,8 +276,9 @@ AliasResult CFLSteensAAResult::query(const MemoryLocation &LocA, if (!MaybeFnA && !MaybeFnB) { // The only times this is known to happen are when globals + InlineAsm are // involved - DEBUG(dbgs() - << "CFLSteensAA: could not extract parent function information.\n"); + LLVM_DEBUG( + dbgs() + << "CFLSteensAA: could not extract parent function information.\n"); return MayAlias; } diff --git a/llvm/lib/Analysis/CGSCCPassManager.cpp b/llvm/lib/Analysis/CGSCCPassManager.cpp index 62e3dfc8b06..b325afb8e7c 100644 --- a/llvm/lib/Analysis/CGSCCPassManager.cpp +++ b/llvm/lib/Analysis/CGSCCPassManager.cpp @@ -75,7 +75,7 @@ PassManager<LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, // If the CGSCC pass wasn't able to provide a valid updated SCC, the // current SCC may simply need to be skipped if invalid. if (UR.InvalidatedSCCs.count(C)) { - DEBUG(dbgs() << "Skipping invalidated root or island SCC!\n"); + LLVM_DEBUG(dbgs() << "Skipping invalidated root or island SCC!\n"); break; } // Check that we didn't miss any update scenario. @@ -353,7 +353,8 @@ incorporateNewSCCRange(const SCCRangeT &NewSCCRange, LazyCallGraph &G, // Add the current SCC to the worklist as its shape has changed. UR.CWorklist.insert(C); - DEBUG(dbgs() << "Enqueuing the existing SCC in the worklist:" << *C << "\n"); + LLVM_DEBUG(dbgs() << "Enqueuing the existing SCC in the worklist:" << *C + << "\n"); SCC *OldC = C; @@ -389,7 +390,7 @@ incorporateNewSCCRange(const SCCRangeT &NewSCCRange, LazyCallGraph &G, assert(C != &NewC && "No need to re-visit the current SCC!"); assert(OldC != &NewC && "Already handled the original SCC!"); UR.CWorklist.insert(&NewC); - DEBUG(dbgs() << "Enqueuing a newly formed SCC:" << NewC << "\n"); + LLVM_DEBUG(dbgs() << "Enqueuing a newly formed SCC:" << NewC << "\n"); // Ensure new SCCs' function analyses are updated. if (NeedFAMProxy) @@ -514,8 +515,8 @@ LazyCallGraph::SCC &llvm::updateCGAndAnalysisManagerForFunctionPass( return false; RC->removeOutgoingEdge(N, *TargetN); - DEBUG(dbgs() << "Deleting outgoing edge from '" << N - << "' to '" << TargetN << "'\n"); + LLVM_DEBUG(dbgs() << "Deleting outgoing edge from '" + << N << "' to '" << TargetN << "'\n"); return true; }), DeadTargets.end()); @@ -546,8 +547,8 @@ LazyCallGraph::SCC &llvm::updateCGAndAnalysisManagerForFunctionPass( assert(NewRC != RC && "Should not encounter the current RefSCC further " "in the postorder list of new RefSCCs."); UR.RCWorklist.insert(NewRC); - DEBUG(dbgs() << "Enqueuing a new RefSCC in the update worklist: " - << *NewRC << "\n"); + LLVM_DEBUG(dbgs() << "Enqueuing a new RefSCC in the update worklist: " + << *NewRC << "\n"); } } @@ -564,8 +565,8 @@ LazyCallGraph::SCC &llvm::updateCGAndAnalysisManagerForFunctionPass( assert(RC->isAncestorOf(TargetRC) && "Cannot potentially form RefSCC cycles here!"); RC->switchOutgoingEdgeToRef(N, *RefTarget); - DEBUG(dbgs() << "Switch outgoing call edge to a ref edge from '" << N - << "' to '" << *RefTarget << "'\n"); + LLVM_DEBUG(dbgs() << "Switch outgoing call edge to a ref edge from '" << N + << "' to '" << *RefTarget << "'\n"); continue; } @@ -593,12 +594,12 @@ LazyCallGraph::SCC &llvm::updateCGAndAnalysisManagerForFunctionPass( assert(RC->isAncestorOf(TargetRC) && "Cannot potentially form RefSCC cycles here!"); RC->switchOutgoingEdgeToCall(N, *CallTarget); - DEBUG(dbgs() << "Switch outgoing ref edge to a call edge from '" << N - << "' to '" << *CallTarget << "'\n"); + LLVM_DEBUG(dbgs() << "Switch outgoing ref edge to a call edge from '" << N + << "' to '" << *CallTarget << "'\n"); continue; } - DEBUG(dbgs() << "Switch an internal ref edge to a call edge from '" << N - << "' to '" << *CallTarget << "'\n"); + LLVM_DEBUG(dbgs() << "Switch an internal ref edge to a call edge from '" + << N << "' to '" << *CallTarget << "'\n"); // Otherwise we are switching an internal ref edge to a call edge. This // may merge away some SCCs, and we add those to the UpdateResult. We also @@ -661,14 +662,14 @@ LazyCallGraph::SCC &llvm::updateCGAndAnalysisManagerForFunctionPass( // post-order sequence, and may end up observing more precise context to // optimize the current SCC. UR.CWorklist.insert(C); - DEBUG(dbgs() << "Enqueuing the existing SCC in the worklist: " << *C - << "\n"); + LLVM_DEBUG(dbgs() << "Enqueuing the existing SCC in the worklist: " << *C + << "\n"); // Enqueue in reverse order as we pop off the back of the worklist. for (SCC &MovedC : llvm::reverse(make_range(RC->begin() + InitialSCCIndex, RC->begin() + NewSCCIndex))) { UR.CWorklist.insert(&MovedC); - DEBUG(dbgs() << "Enqueuing a newly earlier in post-order SCC: " - << MovedC << "\n"); + LLVM_DEBUG(dbgs() << "Enqueuing a newly earlier in post-order SCC: " + << MovedC << "\n"); } } } diff --git a/llvm/lib/Analysis/CallGraphSCCPass.cpp b/llvm/lib/Analysis/CallGraphSCCPass.cpp index b1b3b79b407..4bb181e352d 100644 --- a/llvm/lib/Analysis/CallGraphSCCPass.cpp +++ b/llvm/lib/Analysis/CallGraphSCCPass.cpp @@ -162,8 +162,8 @@ bool CGPassManager::RunPassOnSCC(Pass *P, CallGraphSCC &CurSCC, // The function pass(es) modified the IR, they may have clobbered the // callgraph. if (Changed && CallGraphUpToDate) { - DEBUG(dbgs() << "CGSCCPASSMGR: Pass Dirtied SCC: " - << P->getPassName() << '\n'); + LLVM_DEBUG(dbgs() << "CGSCCPASSMGR: Pass Dirtied SCC: " << P->getPassName() + << '\n'); CallGraphUpToDate = false; } return Changed; @@ -181,12 +181,11 @@ bool CGPassManager::RunPassOnSCC(Pass *P, CallGraphSCC &CurSCC, bool CGPassManager::RefreshCallGraph(const CallGraphSCC &CurSCC, CallGraph &CG, bool CheckingMode) { DenseMap<Value*, CallGraphNode*> CallSites; - - DEBUG(dbgs() << "CGSCCPASSMGR: Refreshing SCC with " << CurSCC.size() - << " nodes:\n"; - for (CallGraphNode *CGN : CurSCC) - CGN->dump(); - ); + + LLVM_DEBUG(dbgs() << "CGSCCPASSMGR: Refreshing SCC with " << CurSCC.size() + << " nodes:\n"; + for (CallGraphNode *CGN + : CurSCC) CGN->dump();); bool MadeChange = false; bool DevirtualizedCall = false; @@ -307,8 +306,8 @@ bool CGPassManager::RefreshCallGraph(const CallGraphSCC &CurSCC, CallGraph &CG, // one. if (!ExistingNode->getFunction()) { DevirtualizedCall = true; - DEBUG(dbgs() << " CGSCCPASSMGR: Devirtualized call to '" - << Callee->getName() << "'\n"); + LLVM_DEBUG(dbgs() << " CGSCCPASSMGR: Devirtualized call to '" + << Callee->getName() << "'\n"); } } else { CalleeNode = CG.getCallsExternalNode(); @@ -363,17 +362,15 @@ bool CGPassManager::RefreshCallGraph(const CallGraphSCC &CurSCC, CallGraph &CG, CallSites.clear(); } - DEBUG(if (MadeChange) { - dbgs() << "CGSCCPASSMGR: Refreshed SCC is now:\n"; - for (CallGraphNode *CGN : CurSCC) - CGN->dump(); - if (DevirtualizedCall) - dbgs() << "CGSCCPASSMGR: Refresh devirtualized a call!\n"; - - } else { - dbgs() << "CGSCCPASSMGR: SCC Refresh didn't change call graph.\n"; - } - ); + LLVM_DEBUG(if (MadeChange) { + dbgs() << "CGSCCPASSMGR: Refreshed SCC is now:\n"; + for (CallGraphNode *CGN : CurSCC) + CGN->dump(); + if (DevirtualizedCall) + dbgs() << "CGSCCPASSMGR: Refresh devirtualized a call!\n"; + } else { + dbgs() << "CGSCCPASSMGR: SCC Refresh didn't change call graph.\n"; + }); (void)MadeChange; return DevirtualizedCall; @@ -472,16 +469,17 @@ bool CGPassManager::runOnModule(Module &M) { unsigned Iteration = 0; bool DevirtualizedCall = false; do { - DEBUG(if (Iteration) - dbgs() << " SCCPASSMGR: Re-visiting SCC, iteration #" - << Iteration << '\n'); + LLVM_DEBUG(if (Iteration) dbgs() + << " SCCPASSMGR: Re-visiting SCC, iteration #" << Iteration + << '\n'); DevirtualizedCall = false; Changed |= RunAllPassesOnSCC(CurSCC, CG, DevirtualizedCall); } while (Iteration++ < MaxIterations && DevirtualizedCall); if (DevirtualizedCall) - DEBUG(dbgs() << " CGSCCPASSMGR: Stopped iteration after " << Iteration - << " times, due to -max-cg-scc-iterations\n"); + LLVM_DEBUG(dbgs() << " CGSCCPASSMGR: Stopped iteration after " + << Iteration + << " times, due to -max-cg-scc-iterations\n"); MaxSCCIterations.updateMax(Iteration); } diff --git a/llvm/lib/Analysis/CodeMetrics.cpp b/llvm/lib/Analysis/CodeMetrics.cpp index ac7d14ebdae..46cc87d2b17 100644 --- a/llvm/lib/Analysis/CodeMetrics.cpp +++ b/llvm/lib/Analysis/CodeMetrics.cpp @@ -61,7 +61,7 @@ static void completeEphemeralValues(SmallPtrSetImpl<const Value *> &Visited, continue; EphValues.insert(V); - DEBUG(dbgs() << "Ephemeral Value: " << *V << "\n"); + LLVM_DEBUG(dbgs() << "Ephemeral Value: " << *V << "\n"); // Append any more operands to consider. appendSpeculatableOperands(V, Visited, Worklist); diff --git a/llvm/lib/Analysis/DemandedBits.cpp b/llvm/lib/Analysis/DemandedBits.cpp index de7d21f9f13..58c5bccff65 100644 --- a/llvm/lib/Analysis/DemandedBits.cpp +++ b/llvm/lib/Analysis/DemandedBits.cpp @@ -283,7 +283,7 @@ void DemandedBits::performAnalysis() { if (!isAlwaysLive(&I)) continue; - DEBUG(dbgs() << "DemandedBits: Root: " << I << "\n"); + LLVM_DEBUG(dbgs() << "DemandedBits: Root: " << I << "\n"); // For integer-valued instructions, set up an initial empty set of alive // bits and add the instruction to the work list. For other instructions // add their operands to the work list (for integer values operands, mark @@ -313,13 +313,13 @@ void DemandedBits::performAnalysis() { while (!Worklist.empty()) { Instruction *UserI = Worklist.pop_back_val(); - DEBUG(dbgs() << "DemandedBits: Visiting: " << *UserI); + LLVM_DEBUG(dbgs() << "DemandedBits: Visiting: " << *UserI); APInt AOut; if (UserI->getType()->isIntegerTy()) { AOut = AliveBits[UserI]; - DEBUG(dbgs() << " Alive Out: " << AOut); + LLVM_DEBUG(dbgs() << " Alive Out: " << AOut); } - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n"); if (!UserI->getType()->isIntegerTy()) Visited.insert(UserI); diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp index aa4c3f21758..252341721f1 100644 --- a/llvm/lib/Analysis/DependenceAnalysis.cpp +++ b/llvm/lib/Analysis/DependenceAnalysis.cpp @@ -415,9 +415,9 @@ LLVM_DUMP_METHOD void DependenceInfo::Constraint::dump(raw_ostream &OS) const { // PLDI 1991 bool DependenceInfo::intersectConstraints(Constraint *X, const Constraint *Y) { ++DeltaApplications; - DEBUG(dbgs() << "\tintersect constraints\n"); - DEBUG(dbgs() << "\t X ="; X->dump(dbgs())); - DEBUG(dbgs() << "\t Y ="; Y->dump(dbgs())); + LLVM_DEBUG(dbgs() << "\tintersect constraints\n"); + LLVM_DEBUG(dbgs() << "\t X ="; X->dump(dbgs())); + LLVM_DEBUG(dbgs() << "\t Y ="; Y->dump(dbgs())); assert(!Y->isPoint() && "Y must not be a Point"); if (X->isAny()) { if (Y->isAny()) @@ -433,7 +433,7 @@ bool DependenceInfo::intersectConstraints(Constraint *X, const Constraint *Y) { } if (X->isDistance() && Y->isDistance()) { - DEBUG(dbgs() << "\t intersect 2 distances\n"); + LLVM_DEBUG(dbgs() << "\t intersect 2 distances\n"); if (isKnownPredicate(CmpInst::ICMP_EQ, X->getD(), Y->getD())) return false; if (isKnownPredicate(CmpInst::ICMP_NE, X->getD(), Y->getD())) { @@ -460,12 +460,12 @@ bool DependenceInfo::intersectConstraints(Constraint *X, const Constraint *Y) { "We shouldn't ever see X->isPoint() && Y->isPoint()"); if (X->isLine() && Y->isLine()) { - DEBUG(dbgs() << "\t intersect 2 lines\n"); + LLVM_DEBUG(dbgs() << "\t intersect 2 lines\n"); const SCEV *Prod1 = SE->getMulExpr(X->getA(), Y->getB()); const SCEV *Prod2 = SE->getMulExpr(X->getB(), Y->getA()); if (isKnownPredicate(CmpInst::ICMP_EQ, Prod1, Prod2)) { // slopes are equal, so lines are parallel - DEBUG(dbgs() << "\t\tsame slope\n"); + LLVM_DEBUG(dbgs() << "\t\tsame slope\n"); Prod1 = SE->getMulExpr(X->getC(), Y->getB()); Prod2 = SE->getMulExpr(X->getB(), Y->getC()); if (isKnownPredicate(CmpInst::ICMP_EQ, Prod1, Prod2)) @@ -479,7 +479,7 @@ bool DependenceInfo::intersectConstraints(Constraint *X, const Constraint *Y) { } if (isKnownPredicate(CmpInst::ICMP_NE, Prod1, Prod2)) { // slopes differ, so lines intersect - DEBUG(dbgs() << "\t\tdifferent slopes\n"); + LLVM_DEBUG(dbgs() << "\t\tdifferent slopes\n"); const SCEV *C1B2 = SE->getMulExpr(X->getC(), Y->getB()); const SCEV *C1A2 = SE->getMulExpr(X->getC(), Y->getA()); const SCEV *C2B1 = SE->getMulExpr(Y->getC(), X->getB()); @@ -501,10 +501,10 @@ bool DependenceInfo::intersectConstraints(Constraint *X, const Constraint *Y) { APInt Xbot = A1B2_A2B1->getAPInt(); APInt Ytop = C1A2_C2A1->getAPInt(); APInt Ybot = A2B1_A1B2->getAPInt(); - DEBUG(dbgs() << "\t\tXtop = " << Xtop << "\n"); - DEBUG(dbgs() << "\t\tXbot = " << Xbot << "\n"); - DEBUG(dbgs() << "\t\tYtop = " << Ytop << "\n"); - DEBUG(dbgs() << "\t\tYbot = " << Ybot << "\n"); + LLVM_DEBUG(dbgs() << "\t\tXtop = " << Xtop << "\n"); + LLVM_DEBUG(dbgs() << "\t\tXbot = " << Xbot << "\n"); + LLVM_DEBUG(dbgs() << "\t\tYtop = " << Ytop << "\n"); + LLVM_DEBUG(dbgs() << "\t\tYbot = " << Ybot << "\n"); APInt Xq = Xtop; // these need to be initialized, even APInt Xr = Xtop; // though they're just going to be overwritten APInt::sdivrem(Xtop, Xbot, Xq, Xr); @@ -516,7 +516,7 @@ bool DependenceInfo::intersectConstraints(Constraint *X, const Constraint *Y) { ++DeltaSuccesses; return true; } - DEBUG(dbgs() << "\t\tX = " << Xq << ", Y = " << Yq << "\n"); + LLVM_DEBUG(dbgs() << "\t\tX = " << Xq << ", Y = " << Yq << "\n"); if (Xq.slt(0) || Yq.slt(0)) { X->setEmpty(); ++DeltaSuccesses; @@ -525,7 +525,7 @@ bool DependenceInfo::intersectConstraints(Constraint *X, const Constraint *Y) { if (const SCEVConstant *CUB = collectConstantUpperBound(X->getAssociatedLoop(), Prod1->getType())) { const APInt &UpperBound = CUB->getAPInt(); - DEBUG(dbgs() << "\t\tupper bound = " << UpperBound << "\n"); + LLVM_DEBUG(dbgs() << "\t\tupper bound = " << UpperBound << "\n"); if (Xq.sgt(UpperBound) || Yq.sgt(UpperBound)) { X->setEmpty(); ++DeltaSuccesses; @@ -545,7 +545,7 @@ bool DependenceInfo::intersectConstraints(Constraint *X, const Constraint *Y) { assert(!(X->isLine() && Y->isPoint()) && "This case should never occur"); if (X->isPoint() && Y->isLine()) { - DEBUG(dbgs() << "\t intersect Point and Line\n"); + LLVM_DEBUG(dbgs() << "\t intersect Point and Line\n"); const SCEV *A1X1 = SE->getMulExpr(Y->getA(), X->getX()); const SCEV *B1Y1 = SE->getMulExpr(Y->getB(), X->getY()); const SCEV *Sum = SE->getAddExpr(A1X1, B1Y1); @@ -1033,19 +1033,19 @@ const SCEVConstant *DependenceInfo::collectConstantUpperBound(const Loop *L, // Return true if dependence disproved. bool DependenceInfo::testZIV(const SCEV *Src, const SCEV *Dst, FullDependence &Result) const { - DEBUG(dbgs() << " src = " << *Src << "\n"); - DEBUG(dbgs() << " dst = " << *Dst << "\n"); + LLVM_DEBUG(dbgs() << " src = " << *Src << "\n"); + LLVM_DEBUG(dbgs() << " dst = " << *Dst << "\n"); ++ZIVapplications; if (isKnownPredicate(CmpInst::ICMP_EQ, Src, Dst)) { - DEBUG(dbgs() << " provably dependent\n"); + LLVM_DEBUG(dbgs() << " provably dependent\n"); return false; // provably dependent } if (isKnownPredicate(CmpInst::ICMP_NE, Src, Dst)) { - DEBUG(dbgs() << " provably independent\n"); + LLVM_DEBUG(dbgs() << " provably independent\n"); ++ZIVindependence; return true; // provably independent } - DEBUG(dbgs() << " possibly dependent\n"); + LLVM_DEBUG(dbgs() << " possibly dependent\n"); Result.Consistent = false; return false; // possibly dependent } @@ -1082,25 +1082,25 @@ bool DependenceInfo::strongSIVtest(const SCEV *Coeff, const SCEV *SrcConst, const SCEV *DstConst, const Loop *CurLoop, unsigned Level, FullDependence &Result, Constraint &NewConstraint) const { - DEBUG(dbgs() << "\tStrong SIV test\n"); - DEBUG(dbgs() << "\t Coeff = " << *Coeff); - DEBUG(dbgs() << ", " << *Coeff->getType() << "\n"); - DEBUG(dbgs() << "\t SrcConst = " << *SrcConst); - DEBUG(dbgs() << ", " << *SrcConst->getType() << "\n"); - DEBUG(dbgs() << "\t DstConst = " << *DstConst); - DEBUG(dbgs() << ", " << *DstConst->getType() << "\n"); + LLVM_DEBUG(dbgs() << "\tStrong SIV test\n"); + LLVM_DEBUG(dbgs() << "\t Coeff = " << *Coeff); + LLVM_DEBUG(dbgs() << ", " << *Coeff->getType() << "\n"); + LLVM_DEBUG(dbgs() << "\t SrcConst = " << *SrcConst); + LLVM_DEBUG(dbgs() << ", " << *SrcConst->getType() << "\n"); + LLVM_DEBUG(dbgs() << "\t DstConst = " << *DstConst); + LLVM_DEBUG(dbgs() << ", " << *DstConst->getType() << "\n"); ++StrongSIVapplications; assert(0 < Level && Level <= CommonLevels && "level out of range"); Level--; const SCEV *Delta = SE->getMinusSCEV(SrcConst, DstConst); - DEBUG(dbgs() << "\t Delta = " << *Delta); - DEBUG(dbgs() << ", " << *Delta->getType() << "\n"); + LLVM_DEBUG(dbgs() << "\t Delta = " << *Delta); + LLVM_DEBUG(dbgs() << ", " << *Delta->getType() << "\n"); // check that |Delta| < iteration count if (const SCEV *UpperBound = collectUpperBound(CurLoop, Delta->getType())) { - DEBUG(dbgs() << "\t UpperBound = " << *UpperBound); - DEBUG(dbgs() << ", " << *UpperBound->getType() << "\n"); + LLVM_DEBUG(dbgs() << "\t UpperBound = " << *UpperBound); + LLVM_DEBUG(dbgs() << ", " << *UpperBound->getType() << "\n"); const SCEV *AbsDelta = SE->isKnownNonNegative(Delta) ? Delta : SE->getNegativeSCEV(Delta); const SCEV *AbsCoeff = @@ -1121,8 +1121,8 @@ bool DependenceInfo::strongSIVtest(const SCEV *Coeff, const SCEV *SrcConst, APInt Distance = ConstDelta; // these need to be initialized APInt Remainder = ConstDelta; APInt::sdivrem(ConstDelta, ConstCoeff, Distance, Remainder); - DEBUG(dbgs() << "\t Distance = " << Distance << "\n"); - DEBUG(dbgs() << "\t Remainder = " << Remainder << "\n"); + LLVM_DEBUG(dbgs() << "\t Distance = " << Distance << "\n"); + LLVM_DEBUG(dbgs() << "\t Remainder = " << Remainder << "\n"); // Make sure Coeff divides Delta exactly if (Remainder != 0) { // Coeff doesn't divide Distance, no dependence @@ -1149,7 +1149,7 @@ bool DependenceInfo::strongSIVtest(const SCEV *Coeff, const SCEV *SrcConst, } else { if (Coeff->isOne()) { - DEBUG(dbgs() << "\t Distance = " << *Delta << "\n"); + LLVM_DEBUG(dbgs() << "\t Distance = " << *Delta << "\n"); Result.DV[Level].Distance = Delta; // since X/1 == X NewConstraint.setDistance(Delta, CurLoop); } @@ -1218,16 +1218,16 @@ bool DependenceInfo::weakCrossingSIVtest( const SCEV *Coeff, const SCEV *SrcConst, const SCEV *DstConst, const Loop *CurLoop, unsigned Level, FullDependence &Result, Constraint &NewConstraint, const SCEV *&SplitIter) const { - DEBUG(dbgs() << "\tWeak-Crossing SIV test\n"); - DEBUG(dbgs() << "\t Coeff = " << *Coeff << "\n"); - DEBUG(dbgs() << "\t SrcConst = " << *SrcConst << "\n"); - DEBUG(dbgs() << "\t DstConst = " << *DstConst << "\n"); + LLVM_DEBUG(dbgs() << "\tWeak-Crossing SIV test\n"); + LLVM_DEBUG(dbgs() << "\t Coeff = " << *Coeff << "\n"); + LLVM_DEBUG(dbgs() << "\t SrcConst = " << *SrcConst << "\n"); + LLVM_DEBUG(dbgs() << "\t DstConst = " << *DstConst << "\n"); ++WeakCrossingSIVapplications; assert(0 < Level && Level <= CommonLevels && "Level out of range"); Level--; Result.Consistent = false; const SCEV *Delta = SE->getMinusSCEV(DstConst, SrcConst); - DEBUG(dbgs() << "\t Delta = " << *Delta << "\n"); + LLVM_DEBUG(dbgs() << "\t Delta = " << *Delta << "\n"); NewConstraint.setLine(Coeff, Coeff, Delta, CurLoop); if (Delta->isZero()) { Result.DV[Level].Direction &= unsigned(~Dependence::DVEntry::LT); @@ -1257,7 +1257,7 @@ bool DependenceInfo::weakCrossingSIVtest( SplitIter = SE->getUDivExpr( SE->getSMaxExpr(SE->getZero(Delta->getType()), Delta), SE->getMulExpr(SE->getConstant(Delta->getType(), 2), ConstCoeff)); - DEBUG(dbgs() << "\t Split iter = " << *SplitIter << "\n"); + LLVM_DEBUG(dbgs() << "\t Split iter = " << *SplitIter << "\n"); const SCEVConstant *ConstDelta = dyn_cast<SCEVConstant>(Delta); if (!ConstDelta) @@ -1265,8 +1265,8 @@ bool DependenceInfo::weakCrossingSIVtest( // We're certain that ConstCoeff > 0; therefore, // if Delta < 0, then no dependence. - DEBUG(dbgs() << "\t Delta = " << *Delta << "\n"); - DEBUG(dbgs() << "\t ConstCoeff = " << *ConstCoeff << "\n"); + LLVM_DEBUG(dbgs() << "\t Delta = " << *Delta << "\n"); + LLVM_DEBUG(dbgs() << "\t ConstCoeff = " << *ConstCoeff << "\n"); if (SE->isKnownNegative(Delta)) { // No dependence, Delta < 0 ++WeakCrossingSIVindependence; @@ -1277,11 +1277,11 @@ bool DependenceInfo::weakCrossingSIVtest( // We're certain that Delta > 0 and ConstCoeff > 0. // Check Delta/(2*ConstCoeff) against upper loop bound if (const SCEV *UpperBound = collectUpperBound(CurLoop, Delta->getType())) { - DEBUG(dbgs() << "\t UpperBound = " << *UpperBound << "\n"); + LLVM_DEBUG(dbgs() << "\t UpperBound = " << *UpperBound << "\n"); const SCEV *ConstantTwo = SE->getConstant(UpperBound->getType(), 2); const SCEV *ML = SE->getMulExpr(SE->getMulExpr(ConstCoeff, UpperBound), ConstantTwo); - DEBUG(dbgs() << "\t ML = " << *ML << "\n"); + LLVM_DEBUG(dbgs() << "\t ML = " << *ML << "\n"); if (isKnownPredicate(CmpInst::ICMP_SGT, Delta, ML)) { // Delta too big, no dependence ++WeakCrossingSIVindependence; @@ -1309,19 +1309,19 @@ bool DependenceInfo::weakCrossingSIVtest( APInt Distance = APDelta; // these need to be initialzed APInt Remainder = APDelta; APInt::sdivrem(APDelta, APCoeff, Distance, Remainder); - DEBUG(dbgs() << "\t Remainder = " << Remainder << "\n"); + LLVM_DEBUG(dbgs() << "\t Remainder = " << Remainder << "\n"); if (Remainder != 0) { // Coeff doesn't divide Delta, no dependence ++WeakCrossingSIVindependence; ++WeakCrossingSIVsuccesses; return true; } - DEBUG(dbgs() << "\t Distance = " << Distance << "\n"); + LLVM_DEBUG(dbgs() << "\t Distance = " << Distance << "\n"); // if 2*Coeff doesn't divide Delta, then the equal direction isn't possible APInt Two = APInt(Distance.getBitWidth(), 2, true); Remainder = Distance.srem(Two); - DEBUG(dbgs() << "\t Remainder = " << Remainder << "\n"); + LLVM_DEBUG(dbgs() << "\t Remainder = " << Remainder << "\n"); if (Remainder != 0) { // Equal direction isn't possible Result.DV[Level].Direction &= unsigned(~Dependence::DVEntry::EQ); @@ -1357,7 +1357,7 @@ static bool findGCD(unsigned Bits, const APInt &AM, const APInt &BM, APInt::sdivrem(G0, G1, Q, R); } G = G1; - DEBUG(dbgs() << "\t GCD = " << G << "\n"); + LLVM_DEBUG(dbgs() << "\t GCD = " << G << "\n"); X = AM.slt(0) ? -A1 : A1; Y = BM.slt(0) ? B1 : -B1; @@ -1430,17 +1430,17 @@ bool DependenceInfo::exactSIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff, const Loop *CurLoop, unsigned Level, FullDependence &Result, Constraint &NewConstraint) const { - DEBUG(dbgs() << "\tExact SIV test\n"); - DEBUG(dbgs() << "\t SrcCoeff = " << *SrcCoeff << " = AM\n"); - DEBUG(dbgs() << "\t DstCoeff = " << *DstCoeff << " = BM\n"); - DEBUG(dbgs() << "\t SrcConst = " << *SrcConst << "\n"); - DEBUG(dbgs() << "\t DstConst = " << *DstConst << "\n"); + LLVM_DEBUG(dbgs() << "\tExact SIV test\n"); + LLVM_DEBUG(dbgs() << "\t SrcCoeff = " << *SrcCoeff << " = AM\n"); + LLVM_DEBUG(dbgs() << "\t DstCoeff = " << *DstCoeff << " = BM\n"); + LLVM_DEBUG(dbgs() << "\t SrcConst = " << *SrcConst << "\n"); + LLVM_DEBUG(dbgs() << "\t DstConst = " << *DstConst << "\n"); ++ExactSIVapplications; assert(0 < Level && Level <= CommonLevels && "Level out of range"); Level--; Result.Consistent = false; const SCEV *Delta = SE->getMinusSCEV(DstConst, SrcConst); - DEBUG(dbgs() << "\t Delta = " << *Delta << "\n"); + LLVM_DEBUG(dbgs() << "\t Delta = " << *Delta << "\n"); NewConstraint.setLine(SrcCoeff, SE->getNegativeSCEV(DstCoeff), Delta, CurLoop); const SCEVConstant *ConstDelta = dyn_cast<SCEVConstant>(Delta); @@ -1461,7 +1461,7 @@ bool DependenceInfo::exactSIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff, return true; } - DEBUG(dbgs() << "\t X = " << X << ", Y = " << Y << "\n"); + LLVM_DEBUG(dbgs() << "\t X = " << X << ", Y = " << Y << "\n"); // since SCEV construction normalizes, LM = 0 APInt UM(Bits, 1, true); @@ -1470,7 +1470,7 @@ bool DependenceInfo::exactSIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff, if (const SCEVConstant *CUB = collectConstantUpperBound(CurLoop, Delta->getType())) { UM = CUB->getAPInt(); - DEBUG(dbgs() << "\t UM = " << UM << "\n"); + LLVM_DEBUG(dbgs() << "\t UM = " << UM << "\n"); UMvalid = true; } @@ -1481,18 +1481,18 @@ bool DependenceInfo::exactSIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff, APInt TMUL = BM.sdiv(G); if (TMUL.sgt(0)) { TL = maxAPInt(TL, ceilingOfQuotient(-X, TMUL)); - DEBUG(dbgs() << "\t TL = " << TL << "\n"); + LLVM_DEBUG(dbgs() << "\t TL = " << TL << "\n"); if (UMvalid) { TU = minAPInt(TU, floorOfQuotient(UM - X, TMUL)); - DEBUG(dbgs() << "\t TU = " << TU << "\n"); + LLVM_DEBUG(dbgs() << "\t TU = " << TU << "\n"); } } else { TU = minAPInt(TU, floorOfQuotient(-X, TMUL)); - DEBUG(dbgs() << "\t TU = " << TU << "\n"); + LLVM_DEBUG(dbgs() << "\t TU = " << TU << "\n"); if (UMvalid) { TL = maxAPInt(TL, ceilingOfQuotient(UM - X, TMUL)); - DEBUG(dbgs() << "\t TL = " << TL << "\n"); + LLVM_DEBUG(dbgs() << "\t TL = " << TL << "\n"); } } @@ -1500,18 +1500,18 @@ bool DependenceInfo::exactSIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff, TMUL = AM.sdiv(G); if (TMUL.sgt(0)) { TL = maxAPInt(TL, ceilingOfQuotient(-Y, TMUL)); - DEBUG(dbgs() << "\t TL = " << TL << "\n"); + LLVM_DEBUG(dbgs() << "\t TL = " << TL << "\n"); if (UMvalid) { TU = minAPInt(TU, floorOfQuotient(UM - Y, TMUL)); - DEBUG(dbgs() << "\t TU = " << TU << "\n"); + LLVM_DEBUG(dbgs() << "\t TU = " << TU << "\n"); } } else { TU = minAPInt(TU, floorOfQuotient(-Y, TMUL)); - DEBUG(dbgs() << "\t TU = " << TU << "\n"); + LLVM_DEBUG(dbgs() << "\t TU = " << TU << "\n"); if (UMvalid) { TL = maxAPInt(TL, ceilingOfQuotient(UM - Y, TMUL)); - DEBUG(dbgs() << "\t TL = " << TL << "\n"); + LLVM_DEBUG(dbgs() << "\t TL = " << TL << "\n"); } } if (TL.sgt(TU)) { @@ -1526,15 +1526,15 @@ bool DependenceInfo::exactSIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff, // less than APInt SaveTU(TU); // save these APInt SaveTL(TL); - DEBUG(dbgs() << "\t exploring LT direction\n"); + LLVM_DEBUG(dbgs() << "\t exploring LT direction\n"); TMUL = AM - BM; if (TMUL.sgt(0)) { TL = maxAPInt(TL, ceilingOfQuotient(X - Y + 1, TMUL)); - DEBUG(dbgs() << "\t\t TL = " << TL << "\n"); + LLVM_DEBUG(dbgs() << "\t\t TL = " << TL << "\n"); } else { TU = minAPInt(TU, floorOfQuotient(X - Y + 1, TMUL)); - DEBUG(dbgs() << "\t\t TU = " << TU << "\n"); + LLVM_DEBUG(dbgs() << "\t\t TU = " << TU << "\n"); } if (TL.sle(TU)) { NewDirection |= Dependence::DVEntry::LT; @@ -1544,23 +1544,23 @@ bool DependenceInfo::exactSIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff, // equal TU = SaveTU; // restore TL = SaveTL; - DEBUG(dbgs() << "\t exploring EQ direction\n"); + LLVM_DEBUG(dbgs() << "\t exploring EQ direction\n"); if (TMUL.sgt(0)) { TL = maxAPInt(TL, ceilingOfQuotient(X - Y, TMUL)); - DEBUG(dbgs() << "\t\t TL = " << TL << "\n"); + LLVM_DEBUG(dbgs() << "\t\t TL = " << TL << "\n"); } else { TU = minAPInt(TU, floorOfQuotient(X - Y, TMUL)); - DEBUG(dbgs() << "\t\t TU = " << TU << "\n"); + LLVM_DEBUG(dbgs() << "\t\t TU = " << TU << "\n"); } TMUL = BM - AM; if (TMUL.sgt(0)) { TL = maxAPInt(TL, ceilingOfQuotient(Y - X, TMUL)); - DEBUG(dbgs() << "\t\t TL = " << TL << "\n"); + LLVM_DEBUG(dbgs() << "\t\t TL = " << TL << "\n"); } else { TU = minAPInt(TU, floorOfQuotient(Y - X, TMUL)); - DEBUG(dbgs() << "\t\t TU = " << TU << "\n"); + LLVM_DEBUG(dbgs() << "\t\t TU = " << TU << "\n"); } if (TL.sle(TU)) { NewDirection |= Dependence::DVEntry::EQ; @@ -1570,14 +1570,14 @@ bool DependenceInfo::exactSIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff, // greater than TU = SaveTU; // restore TL = SaveTL; - DEBUG(dbgs() << "\t exploring GT direction\n"); + LLVM_DEBUG(dbgs() << "\t exploring GT direction\n"); if (TMUL.sgt(0)) { TL = maxAPInt(TL, ceilingOfQuotient(Y - X + 1, TMUL)); - DEBUG(dbgs() << "\t\t TL = " << TL << "\n"); + LLVM_DEBUG(dbgs() << "\t\t TL = " << TL << "\n"); } else { TU = minAPInt(TU, floorOfQuotient(Y - X + 1, TMUL)); - DEBUG(dbgs() << "\t\t TU = " << TU << "\n"); + LLVM_DEBUG(dbgs() << "\t\t TU = " << TU << "\n"); } if (TL.sle(TU)) { NewDirection |= Dependence::DVEntry::GT; @@ -1643,10 +1643,10 @@ bool DependenceInfo::weakZeroSrcSIVtest(const SCEV *DstCoeff, // For the WeakSIV test, it's possible the loop isn't common to // the Src and Dst loops. If it isn't, then there's no need to // record a direction. - DEBUG(dbgs() << "\tWeak-Zero (src) SIV test\n"); - DEBUG(dbgs() << "\t DstCoeff = " << *DstCoeff << "\n"); - DEBUG(dbgs() << "\t SrcConst = " << *SrcConst << "\n"); - DEBUG(dbgs() << "\t DstConst = " << *DstConst << "\n"); + LLVM_DEBUG(dbgs() << "\tWeak-Zero (src) SIV test\n"); + LLVM_DEBUG(dbgs() << "\t DstCoeff = " << *DstCoeff << "\n"); + LLVM_DEBUG(dbgs() << "\t SrcConst = " << *SrcConst << "\n"); + LLVM_DEBUG(dbgs() << "\t DstConst = " << *DstConst << "\n"); ++WeakZeroSIVapplications; assert(0 < Level && Level <= MaxLevels && "Level out of range"); Level--; @@ -1654,7 +1654,7 @@ bool DependenceInfo::weakZeroSrcSIVtest(const SCEV *DstCoeff, const SCEV *Delta = SE->getMinusSCEV(SrcConst, DstConst); NewConstraint.setLine(SE->getZero(Delta->getType()), DstCoeff, Delta, CurLoop); - DEBUG(dbgs() << "\t Delta = " << *Delta << "\n"); + LLVM_DEBUG(dbgs() << "\t Delta = " << *Delta << "\n"); if (isKnownPredicate(CmpInst::ICMP_EQ, SrcConst, DstConst)) { if (Level < CommonLevels) { Result.DV[Level].Direction &= Dependence::DVEntry::LE; @@ -1675,7 +1675,7 @@ bool DependenceInfo::weakZeroSrcSIVtest(const SCEV *DstCoeff, // check that Delta/SrcCoeff < iteration count // really check NewDelta < count*AbsCoeff if (const SCEV *UpperBound = collectUpperBound(CurLoop, Delta->getType())) { - DEBUG(dbgs() << "\t UpperBound = " << *UpperBound << "\n"); + LLVM_DEBUG(dbgs() << "\t UpperBound = " << *UpperBound << "\n"); const SCEV *Product = SE->getMulExpr(AbsCoeff, UpperBound); if (isKnownPredicate(CmpInst::ICMP_SGT, NewDelta, Product)) { ++WeakZeroSIVindependence; @@ -1752,10 +1752,10 @@ bool DependenceInfo::weakZeroDstSIVtest(const SCEV *SrcCoeff, Constraint &NewConstraint) const { // For the WeakSIV test, it's possible the loop isn't common to the // Src and Dst loops. If it isn't, then there's no need to record a direction. - DEBUG(dbgs() << "\tWeak-Zero (dst) SIV test\n"); - DEBUG(dbgs() << "\t SrcCoeff = " << *SrcCoeff << "\n"); - DEBUG(dbgs() << "\t SrcConst = " << *SrcConst << "\n"); - DEBUG(dbgs() << "\t DstConst = " << *DstConst << "\n"); + LLVM_DEBUG(dbgs() << "\tWeak-Zero (dst) SIV test\n"); + LLVM_DEBUG(dbgs() << "\t SrcCoeff = " << *SrcCoeff << "\n"); + LLVM_DEBUG(dbgs() << "\t SrcConst = " << *SrcConst << "\n"); + LLVM_DEBUG(dbgs() << "\t DstConst = " << *DstConst << "\n"); ++WeakZeroSIVapplications; assert(0 < Level && Level <= SrcLevels && "Level out of range"); Level--; @@ -1763,7 +1763,7 @@ bool DependenceInfo::weakZeroDstSIVtest(const SCEV *SrcCoeff, const SCEV *Delta = SE->getMinusSCEV(DstConst, SrcConst); NewConstraint.setLine(SrcCoeff, SE->getZero(Delta->getType()), Delta, CurLoop); - DEBUG(dbgs() << "\t Delta = " << *Delta << "\n"); + LLVM_DEBUG(dbgs() << "\t Delta = " << *Delta << "\n"); if (isKnownPredicate(CmpInst::ICMP_EQ, DstConst, SrcConst)) { if (Level < CommonLevels) { Result.DV[Level].Direction &= Dependence::DVEntry::LE; @@ -1784,7 +1784,7 @@ bool DependenceInfo::weakZeroDstSIVtest(const SCEV *SrcCoeff, // check that Delta/SrcCoeff < iteration count // really check NewDelta < count*AbsCoeff if (const SCEV *UpperBound = collectUpperBound(CurLoop, Delta->getType())) { - DEBUG(dbgs() << "\t UpperBound = " << *UpperBound << "\n"); + LLVM_DEBUG(dbgs() << "\t UpperBound = " << *UpperBound << "\n"); const SCEV *Product = SE->getMulExpr(AbsCoeff, UpperBound); if (isKnownPredicate(CmpInst::ICMP_SGT, NewDelta, Product)) { ++WeakZeroSIVindependence; @@ -1833,15 +1833,15 @@ bool DependenceInfo::exactRDIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff, const SCEV *SrcConst, const SCEV *DstConst, const Loop *SrcLoop, const Loop *DstLoop, FullDependence &Result) const { - DEBUG(dbgs() << "\tExact RDIV test\n"); - DEBUG(dbgs() << "\t SrcCoeff = " << *SrcCoeff << " = AM\n"); - DEBUG(dbgs() << "\t DstCoeff = " << *DstCoeff << " = BM\n"); - DEBUG(dbgs() << "\t SrcConst = " << *SrcConst << "\n"); - DEBUG(dbgs() << "\t DstConst = " << *DstConst << "\n"); + LLVM_DEBUG(dbgs() << "\tExact RDIV test\n"); + LLVM_DEBUG(dbgs() << "\t SrcCoeff = " << *SrcCoeff << " = AM\n"); + LLVM_DEBUG(dbgs() << "\t DstCoeff = " << *DstCoeff << " = BM\n"); + LLVM_DEBUG(dbgs() << "\t SrcConst = " << *SrcConst << "\n"); + LLVM_DEBUG(dbgs() << "\t DstConst = " << *DstConst << "\n"); ++ExactRDIVapplications; Result.Consistent = false; const SCEV *Delta = SE->getMinusSCEV(DstConst, SrcConst); - DEBUG(dbgs() << "\t Delta = " << *Delta << "\n"); + LLVM_DEBUG(dbgs() << "\t Delta = " << *Delta << "\n"); const SCEVConstant *ConstDelta = dyn_cast<SCEVConstant>(Delta); const SCEVConstant *ConstSrcCoeff = dyn_cast<SCEVConstant>(SrcCoeff); const SCEVConstant *ConstDstCoeff = dyn_cast<SCEVConstant>(DstCoeff); @@ -1859,7 +1859,7 @@ bool DependenceInfo::exactRDIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff, return true; } - DEBUG(dbgs() << "\t X = " << X << ", Y = " << Y << "\n"); + LLVM_DEBUG(dbgs() << "\t X = " << X << ", Y = " << Y << "\n"); // since SCEV construction seems to normalize, LM = 0 APInt SrcUM(Bits, 1, true); @@ -1868,7 +1868,7 @@ bool DependenceInfo::exactRDIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff, if (const SCEVConstant *UpperBound = collectConstantUpperBound(SrcLoop, Delta->getType())) { SrcUM = UpperBound->getAPInt(); - DEBUG(dbgs() << "\t SrcUM = " << SrcUM << "\n"); + LLVM_DEBUG(dbgs() << "\t SrcUM = " << SrcUM << "\n"); SrcUMvalid = true; } @@ -1878,7 +1878,7 @@ bool DependenceInfo::exactRDIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff, if (const SCEVConstant *UpperBound = collectConstantUpperBound(DstLoop, Delta->getType())) { DstUM = UpperBound->getAPInt(); - DEBUG(dbgs() << "\t DstUM = " << DstUM << "\n"); + LLVM_DEBUG(dbgs() << "\t DstUM = " << DstUM << "\n"); DstUMvalid = true; } @@ -1889,18 +1889,18 @@ bool DependenceInfo::exactRDIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff, APInt TMUL = BM.sdiv(G); if (TMUL.sgt(0)) { TL = maxAPInt(TL, ceilingOfQuotient(-X, TMUL)); - DEBUG(dbgs() << "\t TL = " << TL << "\n"); + LLVM_DEBUG(dbgs() << "\t TL = " << TL << "\n"); if (SrcUMvalid) { TU = minAPInt(TU, floorOfQuotient(SrcUM - X, TMUL)); - DEBUG(dbgs() << "\t TU = " << TU << "\n"); + LLVM_DEBUG(dbgs() << "\t TU = " << TU << "\n"); } } else { TU = minAPInt(TU, floorOfQuotient(-X, TMUL)); - DEBUG(dbgs() << "\t TU = " << TU << "\n"); + LLVM_DEBUG(dbgs() << "\t TU = " << TU << "\n"); if (SrcUMvalid) { TL = maxAPInt(TL, ceilingOfQuotient(SrcUM - X, TMUL)); - DEBUG(dbgs() << "\t TL = " << TL << "\n"); + LLVM_DEBUG(dbgs() << "\t TL = " << TL << "\n"); } } @@ -1908,18 +1908,18 @@ bool DependenceInfo::exactRDIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff, TMUL = AM.sdiv(G); if (TMUL.sgt(0)) { TL = maxAPInt(TL, ceilingOfQuotient(-Y, TMUL)); - DEBUG(dbgs() << "\t TL = " << TL << "\n"); + LLVM_DEBUG(dbgs() << "\t TL = " << TL << "\n"); if (DstUMvalid) { TU = minAPInt(TU, floorOfQuotient(DstUM - Y, TMUL)); - DEBUG(dbgs() << "\t TU = " << TU << "\n"); + LLVM_DEBUG(dbgs() << "\t TU = " << TU << "\n"); } } else { TU = minAPInt(TU, floorOfQuotient(-Y, TMUL)); - DEBUG(dbgs() << "\t TU = " << TU << "\n"); + LLVM_DEBUG(dbgs() << "\t TU = " << TU << "\n"); if (DstUMvalid) { TL = maxAPInt(TL, ceilingOfQuotient(DstUM - Y, TMUL)); - DEBUG(dbgs() << "\t TL = " << TL << "\n"); + LLVM_DEBUG(dbgs() << "\t TL = " << TL << "\n"); } } if (TL.sgt(TU)) @@ -1975,27 +1975,27 @@ bool DependenceInfo::symbolicRDIVtest(const SCEV *A1, const SCEV *A2, const Loop *Loop1, const Loop *Loop2) const { ++SymbolicRDIVapplications; - DEBUG(dbgs() << "\ttry symbolic RDIV test\n"); - DEBUG(dbgs() << "\t A1 = " << *A1); - DEBUG(dbgs() << ", type = " << *A1->getType() << "\n"); - DEBUG(dbgs() << "\t A2 = " << *A2 << "\n"); - DEBUG(dbgs() << "\t C1 = " << *C1 << "\n"); - DEBUG(dbgs() << "\t C2 = " << *C2 << "\n"); + LLVM_DEBUG(dbgs() << "\ttry symbolic RDIV test\n"); + LLVM_DEBUG(dbgs() << "\t A1 = " << *A1); + LLVM_DEBUG(dbgs() << ", type = " << *A1->getType() << "\n"); + LLVM_DEBUG(dbgs() << "\t A2 = " << *A2 << "\n"); + LLVM_DEBUG(dbgs() << "\t C1 = " << *C1 << "\n"); + LLVM_DEBUG(dbgs() << "\t C2 = " << *C2 << "\n"); const SCEV *N1 = collectUpperBound(Loop1, A1->getType()); const SCEV *N2 = collectUpperBound(Loop2, A1->getType()); - DEBUG(if (N1) dbgs() << "\t N1 = " << *N1 << "\n"); - DEBUG(if (N2) dbgs() << "\t N2 = " << *N2 << "\n"); + LLVM_DEBUG(if (N1) dbgs() << "\t N1 = " << *N1 << "\n"); + LLVM_DEBUG(if (N2) dbgs() << "\t N2 = " << *N2 << "\n"); const SCEV *C2_C1 = SE->getMinusSCEV(C2, C1); const SCEV *C1_C2 = SE->getMinusSCEV(C1, C2); - DEBUG(dbgs() << "\t C2 - C1 = " << *C2_C1 << "\n"); - DEBUG(dbgs() << "\t C1 - C2 = " << *C1_C2 << "\n"); + LLVM_DEBUG(dbgs() << "\t C2 - C1 = " << *C2_C1 << "\n"); + LLVM_DEBUG(dbgs() << "\t C1 - C2 = " << *C1_C2 << "\n"); if (SE->isKnownNonNegative(A1)) { if (SE->isKnownNonNegative(A2)) { // A1 >= 0 && A2 >= 0 if (N1) { // make sure that c2 - c1 <= a1*N1 const SCEV *A1N1 = SE->getMulExpr(A1, N1); - DEBUG(dbgs() << "\t A1*N1 = " << *A1N1 << "\n"); + LLVM_DEBUG(dbgs() << "\t A1*N1 = " << *A1N1 << "\n"); if (isKnownPredicate(CmpInst::ICMP_SGT, C2_C1, A1N1)) { ++SymbolicRDIVindependence; return true; @@ -2004,7 +2004,7 @@ bool DependenceInfo::symbolicRDIVtest(const SCEV *A1, const SCEV *A2, if (N2) { // make sure that -a2*N2 <= c2 - c1, or a2*N2 >= c1 - c2 const SCEV *A2N2 = SE->getMulExpr(A2, N2); - DEBUG(dbgs() << "\t A2*N2 = " << *A2N2 << "\n"); + LLVM_DEBUG(dbgs() << "\t A2*N2 = " << *A2N2 << "\n"); if (isKnownPredicate(CmpInst::ICMP_SLT, A2N2, C1_C2)) { ++SymbolicRDIVindependence; return true; @@ -2018,7 +2018,7 @@ bool DependenceInfo::symbolicRDIVtest(const SCEV *A1, const SCEV *A2, const SCEV *A1N1 = SE->getMulExpr(A1, N1); const SCEV *A2N2 = SE->getMulExpr(A2, N2); const SCEV *A1N1_A2N2 = SE->getMinusSCEV(A1N1, A2N2); - DEBUG(dbgs() << "\t A1*N1 - A2*N2 = " << *A1N1_A2N2 << "\n"); + LLVM_DEBUG(dbgs() << "\t A1*N1 - A2*N2 = " << *A1N1_A2N2 << "\n"); if (isKnownPredicate(CmpInst::ICMP_SGT, C2_C1, A1N1_A2N2)) { ++SymbolicRDIVindependence; return true; @@ -2039,7 +2039,7 @@ bool DependenceInfo::symbolicRDIVtest(const SCEV *A1, const SCEV *A2, const SCEV *A1N1 = SE->getMulExpr(A1, N1); const SCEV *A2N2 = SE->getMulExpr(A2, N2); const SCEV *A1N1_A2N2 = SE->getMinusSCEV(A1N1, A2N2); - DEBUG(dbgs() << "\t A1*N1 - A2*N2 = " << *A1N1_A2N2 << "\n"); + LLVM_DEBUG(dbgs() << "\t A1*N1 - A2*N2 = " << *A1N1_A2N2 << "\n"); if (isKnownPredicate(CmpInst::ICMP_SGT, A1N1_A2N2, C2_C1)) { ++SymbolicRDIVindependence; return true; @@ -2056,7 +2056,7 @@ bool DependenceInfo::symbolicRDIVtest(const SCEV *A1, const SCEV *A2, if (N1) { // make sure that a1*N1 <= c2 - c1 const SCEV *A1N1 = SE->getMulExpr(A1, N1); - DEBUG(dbgs() << "\t A1*N1 = " << *A1N1 << "\n"); + LLVM_DEBUG(dbgs() << "\t A1*N1 = " << *A1N1 << "\n"); if (isKnownPredicate(CmpInst::ICMP_SGT, A1N1, C2_C1)) { ++SymbolicRDIVindependence; return true; @@ -2065,7 +2065,7 @@ bool DependenceInfo::symbolicRDIVtest(const SCEV *A1, const SCEV *A2, if (N2) { // make sure that c2 - c1 <= -a2*N2, or c1 - c2 >= a2*N2 const SCEV *A2N2 = SE->getMulExpr(A2, N2); - DEBUG(dbgs() << "\t A2*N2 = " << *A2N2 << "\n"); + LLVM_DEBUG(dbgs() << "\t A2*N2 = " << *A2N2 << "\n"); if (isKnownPredicate(CmpInst::ICMP_SLT, C1_C2, A2N2)) { ++SymbolicRDIVindependence; return true; @@ -2088,8 +2088,8 @@ bool DependenceInfo::symbolicRDIVtest(const SCEV *A1, const SCEV *A2, bool DependenceInfo::testSIV(const SCEV *Src, const SCEV *Dst, unsigned &Level, FullDependence &Result, Constraint &NewConstraint, const SCEV *&SplitIter) const { - DEBUG(dbgs() << " src = " << *Src << "\n"); - DEBUG(dbgs() << " dst = " << *Dst << "\n"); + LLVM_DEBUG(dbgs() << " src = " << *Src << "\n"); + LLVM_DEBUG(dbgs() << " dst = " << *Dst << "\n"); const SCEVAddRecExpr *SrcAddRec = dyn_cast<SCEVAddRecExpr>(Src); const SCEVAddRecExpr *DstAddRec = dyn_cast<SCEVAddRecExpr>(Dst); if (SrcAddRec && DstAddRec) { @@ -2165,8 +2165,8 @@ bool DependenceInfo::testRDIV(const SCEV *Src, const SCEV *Dst, const SCEV *SrcCoeff, *DstCoeff; const Loop *SrcLoop, *DstLoop; - DEBUG(dbgs() << " src = " << *Src << "\n"); - DEBUG(dbgs() << " dst = " << *Dst << "\n"); + LLVM_DEBUG(dbgs() << " src = " << *Src << "\n"); + LLVM_DEBUG(dbgs() << " dst = " << *Dst << "\n"); const SCEVAddRecExpr *SrcAddRec = dyn_cast<SCEVAddRecExpr>(Src); const SCEVAddRecExpr *DstAddRec = dyn_cast<SCEVAddRecExpr>(Dst); if (SrcAddRec && DstAddRec) { @@ -2222,8 +2222,8 @@ bool DependenceInfo::testRDIV(const SCEV *Src, const SCEV *Dst, bool DependenceInfo::testMIV(const SCEV *Src, const SCEV *Dst, const SmallBitVector &Loops, FullDependence &Result) const { - DEBUG(dbgs() << " src = " << *Src << "\n"); - DEBUG(dbgs() << " dst = " << *Dst << "\n"); + LLVM_DEBUG(dbgs() << " src = " << *Src << "\n"); + LLVM_DEBUG(dbgs() << " dst = " << *Dst << "\n"); Result.Consistent = false; return gcdMIVtest(Src, Dst, Result) || banerjeeMIVtest(Src, Dst, Loops, Result); @@ -2263,7 +2263,7 @@ const SCEVConstant *getConstantPart(const SCEV *Expr) { // to "a common divisor". bool DependenceInfo::gcdMIVtest(const SCEV *Src, const SCEV *Dst, FullDependence &Result) const { - DEBUG(dbgs() << "starting gcd\n"); + LLVM_DEBUG(dbgs() << "starting gcd\n"); ++GCDapplications; unsigned BitWidth = SE->getTypeSizeInBits(Src->getType()); APInt RunningGCD = APInt::getNullValue(BitWidth); @@ -2308,7 +2308,7 @@ bool DependenceInfo::gcdMIVtest(const SCEV *Src, const SCEV *Dst, APInt ExtraGCD = APInt::getNullValue(BitWidth); const SCEV *Delta = SE->getMinusSCEV(DstConst, SrcConst); - DEBUG(dbgs() << " Delta = " << *Delta << "\n"); + LLVM_DEBUG(dbgs() << " Delta = " << *Delta << "\n"); const SCEVConstant *Constant = dyn_cast<SCEVConstant>(Delta); if (const SCEVAddExpr *Sum = dyn_cast<SCEVAddExpr>(Delta)) { // If Delta is a sum of products, we may be able to make further progress. @@ -2335,11 +2335,11 @@ bool DependenceInfo::gcdMIVtest(const SCEV *Src, const SCEV *Dst, if (!Constant) return false; APInt ConstDelta = cast<SCEVConstant>(Constant)->getAPInt(); - DEBUG(dbgs() << " ConstDelta = " << ConstDelta << "\n"); + LLVM_DEBUG(dbgs() << " ConstDelta = " << ConstDelta << "\n"); if (ConstDelta == 0) return false; RunningGCD = APIntOps::GreatestCommonDivisor(RunningGCD, ExtraGCD); - DEBUG(dbgs() << " RunningGCD = " << RunningGCD << "\n"); + LLVM_DEBUG(dbgs() << " RunningGCD = " << RunningGCD << "\n"); APInt Remainder = ConstDelta.srem(RunningGCD); if (Remainder != 0) { ++GCDindependence; @@ -2358,7 +2358,7 @@ bool DependenceInfo::gcdMIVtest(const SCEV *Src, const SCEV *Dst, // Given A[5*i + 10*j*M + 9*M*N] and A[15*i + 20*j*M - 21*N*M + 5], // we need to remember that the constant part is 5 and the RunningGCD should // be initialized to ExtraGCD = 30. - DEBUG(dbgs() << " ExtraGCD = " << ExtraGCD << '\n'); + LLVM_DEBUG(dbgs() << " ExtraGCD = " << ExtraGCD << '\n'); bool Improved = false; Coefficients = Src; @@ -2413,10 +2413,10 @@ bool DependenceInfo::gcdMIVtest(const SCEV *Src, const SCEV *Dst, continue; APInt ConstCoeff = Constant->getAPInt(); RunningGCD = APIntOps::GreatestCommonDivisor(RunningGCD, ConstCoeff.abs()); - DEBUG(dbgs() << "\tRunningGCD = " << RunningGCD << "\n"); + LLVM_DEBUG(dbgs() << "\tRunningGCD = " << RunningGCD << "\n"); if (RunningGCD != 0) { Remainder = ConstDelta.srem(RunningGCD); - DEBUG(dbgs() << "\tRemainder = " << Remainder << "\n"); + LLVM_DEBUG(dbgs() << "\tRemainder = " << Remainder << "\n"); if (Remainder != 0) { unsigned Level = mapSrcLoop(CurLoop); Result.DV[Level - 1].Direction &= unsigned(~Dependence::DVEntry::EQ); @@ -2426,7 +2426,7 @@ bool DependenceInfo::gcdMIVtest(const SCEV *Src, const SCEV *Dst, } if (Improved) ++GCDsuccesses; - DEBUG(dbgs() << "all done\n"); + LLVM_DEBUG(dbgs() << "all done\n"); return false; } @@ -2467,35 +2467,35 @@ bool DependenceInfo::gcdMIVtest(const SCEV *Src, const SCEV *Dst, bool DependenceInfo::banerjeeMIVtest(const SCEV *Src, const SCEV *Dst, const SmallBitVector &Loops, FullDependence &Result) const { - DEBUG(dbgs() << "starting Banerjee\n"); + LLVM_DEBUG(dbgs() << "starting Banerjee\n"); ++BanerjeeApplications; - DEBUG(dbgs() << " Src = " << *Src << '\n'); + LLVM_DEBUG(dbgs() << " Src = " << *Src << '\n'); const SCEV *A0; CoefficientInfo *A = collectCoeffInfo(Src, true, A0); - DEBUG(dbgs() << " Dst = " << *Dst << '\n'); + LLVM_DEBUG(dbgs() << " Dst = " << *Dst << '\n'); const SCEV *B0; CoefficientInfo *B = collectCoeffInfo(Dst, false, B0); BoundInfo *Bound = new BoundInfo[MaxLevels + 1]; const SCEV *Delta = SE->getMinusSCEV(B0, A0); - DEBUG(dbgs() << "\tDelta = " << *Delta << '\n'); + LLVM_DEBUG(dbgs() << "\tDelta = " << *Delta << '\n'); // Compute bounds for all the * directions. - DEBUG(dbgs() << "\tBounds[*]\n"); + LLVM_DEBUG(dbgs() << "\tBounds[*]\n"); for (unsigned K = 1; K <= MaxLevels; ++K) { Bound[K].Iterations = A[K].Iterations ? A[K].Iterations : B[K].Iterations; Bound[K].Direction = Dependence::DVEntry::ALL; Bound[K].DirSet = Dependence::DVEntry::NONE; findBoundsALL(A, B, Bound, K); #ifndef NDEBUG - DEBUG(dbgs() << "\t " << K << '\t'); + LLVM_DEBUG(dbgs() << "\t " << K << '\t'); if (Bound[K].Lower[Dependence::DVEntry::ALL]) - DEBUG(dbgs() << *Bound[K].Lower[Dependence::DVEntry::ALL] << '\t'); + LLVM_DEBUG(dbgs() << *Bound[K].Lower[Dependence::DVEntry::ALL] << '\t'); else - DEBUG(dbgs() << "-inf\t"); + LLVM_DEBUG(dbgs() << "-inf\t"); if (Bound[K].Upper[Dependence::DVEntry::ALL]) - DEBUG(dbgs() << *Bound[K].Upper[Dependence::DVEntry::ALL] << '\n'); + LLVM_DEBUG(dbgs() << *Bound[K].Upper[Dependence::DVEntry::ALL] << '\n'); else - DEBUG(dbgs() << "+inf\n"); + LLVM_DEBUG(dbgs() << "+inf\n"); #endif } @@ -2551,23 +2551,23 @@ unsigned DependenceInfo::exploreDirections(unsigned Level, CoefficientInfo *A, const SCEV *Delta) const { if (Level > CommonLevels) { // record result - DEBUG(dbgs() << "\t["); + LLVM_DEBUG(dbgs() << "\t["); for (unsigned K = 1; K <= CommonLevels; ++K) { if (Loops[K]) { Bound[K].DirSet |= Bound[K].Direction; #ifndef NDEBUG switch (Bound[K].Direction) { case Dependence::DVEntry::LT: - DEBUG(dbgs() << " <"); + LLVM_DEBUG(dbgs() << " <"); break; case Dependence::DVEntry::EQ: - DEBUG(dbgs() << " ="); + LLVM_DEBUG(dbgs() << " ="); break; case Dependence::DVEntry::GT: - DEBUG(dbgs() << " >"); + LLVM_DEBUG(dbgs() << " >"); break; case Dependence::DVEntry::ALL: - DEBUG(dbgs() << " *"); + LLVM_DEBUG(dbgs() << " *"); break; default: llvm_unreachable("unexpected Bound[K].Direction"); @@ -2575,7 +2575,7 @@ unsigned DependenceInfo::exploreDirections(unsigned Level, CoefficientInfo *A, #endif } } - DEBUG(dbgs() << " ]\n"); + LLVM_DEBUG(dbgs() << " ]\n"); return 1; } if (Loops[Level]) { @@ -2586,34 +2586,40 @@ unsigned DependenceInfo::exploreDirections(unsigned Level, CoefficientInfo *A, findBoundsGT(A, B, Bound, Level); findBoundsEQ(A, B, Bound, Level); #ifndef NDEBUG - DEBUG(dbgs() << "\tBound for level = " << Level << '\n'); - DEBUG(dbgs() << "\t <\t"); + LLVM_DEBUG(dbgs() << "\tBound for level = " << Level << '\n'); + LLVM_DEBUG(dbgs() << "\t <\t"); if (Bound[Level].Lower[Dependence::DVEntry::LT]) - DEBUG(dbgs() << *Bound[Level].Lower[Dependence::DVEntry::LT] << '\t'); + LLVM_DEBUG(dbgs() << *Bound[Level].Lower[Dependence::DVEntry::LT] + << '\t'); else - DEBUG(dbgs() << "-inf\t"); + LLVM_DEBUG(dbgs() << "-inf\t"); if (Bound[Level].Upper[Dependence::DVEntry::LT]) - DEBUG(dbgs() << *Bound[Level].Upper[Dependence::DVEntry::LT] << '\n'); + LLVM_DEBUG(dbgs() << *Bound[Level].Upper[Dependence::DVEntry::LT] + << '\n'); else - DEBUG(dbgs() << "+inf\n"); - DEBUG(dbgs() << "\t =\t"); + LLVM_DEBUG(dbgs() << "+inf\n"); + LLVM_DEBUG(dbgs() << "\t =\t"); if (Bound[Level].Lower[Dependence::DVEntry::EQ]) - DEBUG(dbgs() << *Bound[Level].Lower[Dependence::DVEntry::EQ] << '\t'); + LLVM_DEBUG(dbgs() << *Bound[Level].Lower[Dependence::DVEntry::EQ] + << '\t'); else - DEBUG(dbgs() << "-inf\t"); + LLVM_DEBUG(dbgs() << "-inf\t"); if (Bound[Level].Upper[Dependence::DVEntry::EQ]) - DEBUG(dbgs() << *Bound[Level].Upper[Dependence::DVEntry::EQ] << '\n'); + LLVM_DEBUG(dbgs() << *Bound[Level].Upper[Dependence::DVEntry::EQ] + << '\n'); else - DEBUG(dbgs() << "+inf\n"); - DEBUG(dbgs() << "\t >\t"); + LLVM_DEBUG(dbgs() << "+inf\n"); + LLVM_DEBUG(dbgs() << "\t >\t"); if (Bound[Level].Lower[Dependence::DVEntry::GT]) - DEBUG(dbgs() << *Bound[Level].Lower[Dependence::DVEntry::GT] << '\t'); + LLVM_DEBUG(dbgs() << *Bound[Level].Lower[Dependence::DVEntry::GT] + << '\t'); else - DEBUG(dbgs() << "-inf\t"); + LLVM_DEBUG(dbgs() << "-inf\t"); if (Bound[Level].Upper[Dependence::DVEntry::GT]) - DEBUG(dbgs() << *Bound[Level].Upper[Dependence::DVEntry::GT] << '\n'); + LLVM_DEBUG(dbgs() << *Bound[Level].Upper[Dependence::DVEntry::GT] + << '\n'); else - DEBUG(dbgs() << "+inf\n"); + LLVM_DEBUG(dbgs() << "+inf\n"); #endif } @@ -2860,21 +2866,21 @@ DependenceInfo::collectCoeffInfo(const SCEV *Subscript, bool SrcFlag, } Constant = Subscript; #ifndef NDEBUG - DEBUG(dbgs() << "\tCoefficient Info\n"); + LLVM_DEBUG(dbgs() << "\tCoefficient Info\n"); for (unsigned K = 1; K <= MaxLevels; ++K) { - DEBUG(dbgs() << "\t " << K << "\t" << *CI[K].Coeff); - DEBUG(dbgs() << "\tPos Part = "); - DEBUG(dbgs() << *CI[K].PosPart); - DEBUG(dbgs() << "\tNeg Part = "); - DEBUG(dbgs() << *CI[K].NegPart); - DEBUG(dbgs() << "\tUpper Bound = "); + LLVM_DEBUG(dbgs() << "\t " << K << "\t" << *CI[K].Coeff); + LLVM_DEBUG(dbgs() << "\tPos Part = "); + LLVM_DEBUG(dbgs() << *CI[K].PosPart); + LLVM_DEBUG(dbgs() << "\tNeg Part = "); + LLVM_DEBUG(dbgs() << *CI[K].NegPart); + LLVM_DEBUG(dbgs() << "\tUpper Bound = "); if (CI[K].Iterations) - DEBUG(dbgs() << *CI[K].Iterations); + LLVM_DEBUG(dbgs() << *CI[K].Iterations); else - DEBUG(dbgs() << "+inf"); - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "+inf"); + LLVM_DEBUG(dbgs() << '\n'); } - DEBUG(dbgs() << "\t Constant = " << *Subscript << '\n'); + LLVM_DEBUG(dbgs() << "\t Constant = " << *Subscript << '\n'); #endif return CI; } @@ -2999,8 +3005,8 @@ bool DependenceInfo::propagate(const SCEV *&Src, const SCEV *&Dst, bool &Consistent) { bool Result = false; for (unsigned LI : Loops.set_bits()) { - DEBUG(dbgs() << "\t Constraint[" << LI << "] is"); - DEBUG(Constraints[LI].dump(dbgs())); + LLVM_DEBUG(dbgs() << "\t Constraint[" << LI << "] is"); + LLVM_DEBUG(Constraints[LI].dump(dbgs())); if (Constraints[LI].isDistance()) Result |= propagateDistance(Src, Dst, Constraints[LI], Consistent); else if (Constraints[LI].isLine()) @@ -3021,17 +3027,17 @@ bool DependenceInfo::propagateDistance(const SCEV *&Src, const SCEV *&Dst, Constraint &CurConstraint, bool &Consistent) { const Loop *CurLoop = CurConstraint.getAssociatedLoop(); - DEBUG(dbgs() << "\t\tSrc is " << *Src << "\n"); + LLVM_DEBUG(dbgs() << "\t\tSrc is " << *Src << "\n"); const SCEV *A_K = findCoefficient(Src, CurLoop); if (A_K->isZero()) return false; const SCEV *DA_K = SE->getMulExpr(A_K, CurConstraint.getD()); Src = SE->getMinusSCEV(Src, DA_K); Src = zeroCoefficient(Src, CurLoop); - DEBUG(dbgs() << "\t\tnew Src is " << *Src << "\n"); - DEBUG(dbgs() << "\t\tDst is " << *Dst << "\n"); + LLVM_DEBUG(dbgs() << "\t\tnew Src is " << *Src << "\n"); + LLVM_DEBUG(dbgs() << "\t\tDst is " << *Dst << "\n"); Dst = addToCoefficient(Dst, CurLoop, SE->getNegativeSCEV(A_K)); - DEBUG(dbgs() << "\t\tnew Dst is " << *Dst << "\n"); + LLVM_DEBUG(dbgs() << "\t\tnew Dst is " << *Dst << "\n"); if (!findCoefficient(Dst, CurLoop)->isZero()) Consistent = false; return true; @@ -3050,9 +3056,10 @@ bool DependenceInfo::propagateLine(const SCEV *&Src, const SCEV *&Dst, const SCEV *A = CurConstraint.getA(); const SCEV *B = CurConstraint.getB(); const SCEV *C = CurConstraint.getC(); - DEBUG(dbgs() << "\t\tA = " << *A << ", B = " << *B << ", C = " << *C << "\n"); - DEBUG(dbgs() << "\t\tSrc = " << *Src << "\n"); - DEBUG(dbgs() << "\t\tDst = " << *Dst << "\n"); + LLVM_DEBUG(dbgs() << "\t\tA = " << *A << ", B = " << *B << ", C = " << *C + << "\n"); + LLVM_DEBUG(dbgs() << "\t\tSrc = " << *Src << "\n"); + LLVM_DEBUG(dbgs() << "\t\tDst = " << *Dst << "\n"); if (A->isZero()) { const SCEVConstant *Bconst = dyn_cast<SCEVConstant>(B); const SCEVConstant *Cconst = dyn_cast<SCEVConstant>(C); @@ -3108,8 +3115,8 @@ bool DependenceInfo::propagateLine(const SCEV *&Src, const SCEV *&Dst, if (!findCoefficient(Dst, CurLoop)->isZero()) Consistent = false; } - DEBUG(dbgs() << "\t\tnew Src = " << *Src << "\n"); - DEBUG(dbgs() << "\t\tnew Dst = " << *Dst << "\n"); + LLVM_DEBUG(dbgs() << "\t\tnew Src = " << *Src << "\n"); + LLVM_DEBUG(dbgs() << "\t\tnew Dst = " << *Dst << "\n"); return true; } @@ -3124,13 +3131,13 @@ bool DependenceInfo::propagatePoint(const SCEV *&Src, const SCEV *&Dst, const SCEV *AP_K = findCoefficient(Dst, CurLoop); const SCEV *XA_K = SE->getMulExpr(A_K, CurConstraint.getX()); const SCEV *YAP_K = SE->getMulExpr(AP_K, CurConstraint.getY()); - DEBUG(dbgs() << "\t\tSrc is " << *Src << "\n"); + LLVM_DEBUG(dbgs() << "\t\tSrc is " << *Src << "\n"); Src = SE->getAddExpr(Src, SE->getMinusSCEV(XA_K, YAP_K)); Src = zeroCoefficient(Src, CurLoop); - DEBUG(dbgs() << "\t\tnew Src is " << *Src << "\n"); - DEBUG(dbgs() << "\t\tDst is " << *Dst << "\n"); + LLVM_DEBUG(dbgs() << "\t\tnew Src is " << *Src << "\n"); + LLVM_DEBUG(dbgs() << "\t\tDst is " << *Dst << "\n"); Dst = zeroCoefficient(Dst, CurLoop); - DEBUG(dbgs() << "\t\tnew Dst is " << *Dst << "\n"); + LLVM_DEBUG(dbgs() << "\t\tnew Dst is " << *Dst << "\n"); return true; } @@ -3138,8 +3145,8 @@ bool DependenceInfo::propagatePoint(const SCEV *&Src, const SCEV *&Dst, // Update direction vector entry based on the current constraint. void DependenceInfo::updateDirection(Dependence::DVEntry &Level, const Constraint &CurConstraint) const { - DEBUG(dbgs() << "\tUpdate direction, constraint ="); - DEBUG(CurConstraint.dump(dbgs())); + LLVM_DEBUG(dbgs() << "\tUpdate direction, constraint ="); + LLVM_DEBUG(CurConstraint.dump(dbgs())); if (CurConstraint.isAny()) ; // use defaults else if (CurConstraint.isDistance()) { @@ -3246,14 +3253,14 @@ bool DependenceInfo::tryDelinearize(Instruction *Src, Instruction *Dst, int size = SrcSubscripts.size(); - DEBUG({ - dbgs() << "\nSrcSubscripts: "; + LLVM_DEBUG({ + dbgs() << "\nSrcSubscripts: "; for (int i = 0; i < size; i++) dbgs() << *SrcSubscripts[i]; dbgs() << "\nDstSubscripts: "; for (int i = 0; i < size; i++) dbgs() << *DstSubscripts[i]; - }); + }); // The delinearization transforms a single-subscript MIV dependence test into // a multi-subscript SIV dependence test that is easier to compute. So we @@ -3315,7 +3322,7 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst, if (!isLoadOrStore(Src) || !isLoadOrStore(Dst)) { // can only analyze simple loads and stores, i.e., no calls, invokes, etc. - DEBUG(dbgs() << "can only handle simple loads and stores\n"); + LLVM_DEBUG(dbgs() << "can only handle simple loads and stores\n"); return make_unique<Dependence>(Src, Dst); } @@ -3330,11 +3337,11 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst, case MayAlias: case PartialAlias: // cannot analyse objects if we don't understand their aliasing. - DEBUG(dbgs() << "can't analyze may or partial alias\n"); + LLVM_DEBUG(dbgs() << "can't analyze may or partial alias\n"); return make_unique<Dependence>(Src, Dst); case NoAlias: // If the objects noalias, they are distinct, accesses are independent. - DEBUG(dbgs() << "no alias\n"); + LLVM_DEBUG(dbgs() << "no alias\n"); return nullptr; case MustAlias: break; // The underlying objects alias; test accesses for dependence. @@ -3342,8 +3349,8 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst, // establish loop nesting levels establishNestingLevels(Src, Dst); - DEBUG(dbgs() << " common nesting levels = " << CommonLevels << "\n"); - DEBUG(dbgs() << " maximum nesting levels = " << MaxLevels << "\n"); + LLVM_DEBUG(dbgs() << " common nesting levels = " << CommonLevels << "\n"); + LLVM_DEBUG(dbgs() << " maximum nesting levels = " << MaxLevels << "\n"); FullDependence Result(Src, Dst, PossiblyLoopIndependent, CommonLevels); ++TotalArrayPairs; @@ -3352,14 +3359,14 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst, SmallVector<Subscript, 2> Pair(Pairs); const SCEV *SrcSCEV = SE->getSCEV(SrcPtr); const SCEV *DstSCEV = SE->getSCEV(DstPtr); - DEBUG(dbgs() << " SrcSCEV = " << *SrcSCEV << "\n"); - DEBUG(dbgs() << " DstSCEV = " << *DstSCEV << "\n"); + LLVM_DEBUG(dbgs() << " SrcSCEV = " << *SrcSCEV << "\n"); + LLVM_DEBUG(dbgs() << " DstSCEV = " << *DstSCEV << "\n"); Pair[0].Src = SrcSCEV; Pair[0].Dst = DstSCEV; if (Delinearize) { if (tryDelinearize(Src, Dst, Pair)) { - DEBUG(dbgs() << " delinearized\n"); + LLVM_DEBUG(dbgs() << " delinearized\n"); Pairs = Pair.size(); } } @@ -3375,12 +3382,12 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst, Pair[P].Loops); Pair[P].GroupLoops = Pair[P].Loops; Pair[P].Group.set(P); - DEBUG(dbgs() << " subscript " << P << "\n"); - DEBUG(dbgs() << "\tsrc = " << *Pair[P].Src << "\n"); - DEBUG(dbgs() << "\tdst = " << *Pair[P].Dst << "\n"); - DEBUG(dbgs() << "\tclass = " << Pair[P].Classification << "\n"); - DEBUG(dbgs() << "\tloops = "); - DEBUG(dumpSmallBitVector(Pair[P].Loops)); + LLVM_DEBUG(dbgs() << " subscript " << P << "\n"); + LLVM_DEBUG(dbgs() << "\tsrc = " << *Pair[P].Src << "\n"); + LLVM_DEBUG(dbgs() << "\tdst = " << *Pair[P].Dst << "\n"); + LLVM_DEBUG(dbgs() << "\tclass = " << Pair[P].Classification << "\n"); + LLVM_DEBUG(dbgs() << "\tloops = "); + LLVM_DEBUG(dumpSmallBitVector(Pair[P].Loops)); } SmallBitVector Separable(Pairs); @@ -3485,25 +3492,25 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst, } } - DEBUG(dbgs() << " Separable = "); - DEBUG(dumpSmallBitVector(Separable)); - DEBUG(dbgs() << " Coupled = "); - DEBUG(dumpSmallBitVector(Coupled)); + LLVM_DEBUG(dbgs() << " Separable = "); + LLVM_DEBUG(dumpSmallBitVector(Separable)); + LLVM_DEBUG(dbgs() << " Coupled = "); + LLVM_DEBUG(dumpSmallBitVector(Coupled)); Constraint NewConstraint; NewConstraint.setAny(SE); // test separable subscripts for (unsigned SI : Separable.set_bits()) { - DEBUG(dbgs() << "testing subscript " << SI); + LLVM_DEBUG(dbgs() << "testing subscript " << SI); switch (Pair[SI].Classification) { case Subscript::ZIV: - DEBUG(dbgs() << ", ZIV\n"); + LLVM_DEBUG(dbgs() << ", ZIV\n"); if (testZIV(Pair[SI].Src, Pair[SI].Dst, Result)) return nullptr; break; case Subscript::SIV: { - DEBUG(dbgs() << ", SIV\n"); + LLVM_DEBUG(dbgs() << ", SIV\n"); unsigned Level; const SCEV *SplitIter = nullptr; if (testSIV(Pair[SI].Src, Pair[SI].Dst, Level, Result, NewConstraint, @@ -3512,12 +3519,12 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst, break; } case Subscript::RDIV: - DEBUG(dbgs() << ", RDIV\n"); + LLVM_DEBUG(dbgs() << ", RDIV\n"); if (testRDIV(Pair[SI].Src, Pair[SI].Dst, Result)) return nullptr; break; case Subscript::MIV: - DEBUG(dbgs() << ", MIV\n"); + LLVM_DEBUG(dbgs() << ", MIV\n"); if (testMIV(Pair[SI].Src, Pair[SI].Dst, Pair[SI].Loops, Result)) return nullptr; break; @@ -3528,20 +3535,20 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst, if (Coupled.count()) { // test coupled subscript groups - DEBUG(dbgs() << "starting on coupled subscripts\n"); - DEBUG(dbgs() << "MaxLevels + 1 = " << MaxLevels + 1 << "\n"); + LLVM_DEBUG(dbgs() << "starting on coupled subscripts\n"); + LLVM_DEBUG(dbgs() << "MaxLevels + 1 = " << MaxLevels + 1 << "\n"); SmallVector<Constraint, 4> Constraints(MaxLevels + 1); for (unsigned II = 0; II <= MaxLevels; ++II) Constraints[II].setAny(SE); for (unsigned SI : Coupled.set_bits()) { - DEBUG(dbgs() << "testing subscript group " << SI << " { "); + LLVM_DEBUG(dbgs() << "testing subscript group " << SI << " { "); SmallBitVector Group(Pair[SI].Group); SmallBitVector Sivs(Pairs); SmallBitVector Mivs(Pairs); SmallBitVector ConstrainedLevels(MaxLevels + 1); SmallVector<Subscript *, 4> PairsInGroup; for (unsigned SJ : Group.set_bits()) { - DEBUG(dbgs() << SJ << " "); + LLVM_DEBUG(dbgs() << SJ << " "); if (Pair[SJ].Classification == Subscript::SIV) Sivs.set(SJ); else @@ -3549,15 +3556,15 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst, PairsInGroup.push_back(&Pair[SJ]); } unifySubscriptType(PairsInGroup); - DEBUG(dbgs() << "}\n"); + LLVM_DEBUG(dbgs() << "}\n"); while (Sivs.any()) { bool Changed = false; for (unsigned SJ : Sivs.set_bits()) { - DEBUG(dbgs() << "testing subscript " << SJ << ", SIV\n"); + LLVM_DEBUG(dbgs() << "testing subscript " << SJ << ", SIV\n"); // SJ is an SIV subscript that's part of the current coupled group unsigned Level; const SCEV *SplitIter = nullptr; - DEBUG(dbgs() << "SIV\n"); + LLVM_DEBUG(dbgs() << "SIV\n"); if (testSIV(Pair[SJ].Src, Pair[SJ].Dst, Level, Result, NewConstraint, SplitIter)) return nullptr; @@ -3573,15 +3580,15 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst, } if (Changed) { // propagate, possibly creating new SIVs and ZIVs - DEBUG(dbgs() << " propagating\n"); - DEBUG(dbgs() << "\tMivs = "); - DEBUG(dumpSmallBitVector(Mivs)); + LLVM_DEBUG(dbgs() << " propagating\n"); + LLVM_DEBUG(dbgs() << "\tMivs = "); + LLVM_DEBUG(dumpSmallBitVector(Mivs)); for (unsigned SJ : Mivs.set_bits()) { // SJ is an MIV subscript that's part of the current coupled group - DEBUG(dbgs() << "\tSJ = " << SJ << "\n"); + LLVM_DEBUG(dbgs() << "\tSJ = " << SJ << "\n"); if (propagate(Pair[SJ].Src, Pair[SJ].Dst, Pair[SJ].Loops, Constraints, Result.Consistent)) { - DEBUG(dbgs() << "\t Changed\n"); + LLVM_DEBUG(dbgs() << "\t Changed\n"); ++DeltaPropagations; Pair[SJ].Classification = classifyPair(Pair[SJ].Src, LI->getLoopFor(Src->getParent()), @@ -3589,7 +3596,7 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst, Pair[SJ].Loops); switch (Pair[SJ].Classification) { case Subscript::ZIV: - DEBUG(dbgs() << "ZIV\n"); + LLVM_DEBUG(dbgs() << "ZIV\n"); if (testZIV(Pair[SJ].Src, Pair[SJ].Dst, Result)) return nullptr; Mivs.reset(SJ); @@ -3612,7 +3619,7 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst, // test & propagate remaining RDIVs for (unsigned SJ : Mivs.set_bits()) { if (Pair[SJ].Classification == Subscript::RDIV) { - DEBUG(dbgs() << "RDIV test\n"); + LLVM_DEBUG(dbgs() << "RDIV test\n"); if (testRDIV(Pair[SJ].Src, Pair[SJ].Dst, Result)) return nullptr; // I don't yet understand how to propagate RDIV results @@ -3625,7 +3632,7 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst, // Better to somehow test all remaining subscripts simultaneously. for (unsigned SJ : Mivs.set_bits()) { if (Pair[SJ].Classification == Subscript::MIV) { - DEBUG(dbgs() << "MIV test\n"); + LLVM_DEBUG(dbgs() << "MIV test\n"); if (testMIV(Pair[SJ].Src, Pair[SJ].Dst, Pair[SJ].Loops, Result)) return nullptr; } @@ -3634,7 +3641,7 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst, } // update Result.DV from constraint vector - DEBUG(dbgs() << " updating\n"); + LLVM_DEBUG(dbgs() << " updating\n"); for (unsigned SJ : ConstrainedLevels.set_bits()) { if (SJ > CommonLevels) break; @@ -3760,7 +3767,7 @@ const SCEV *DependenceInfo::getSplitIteration(const Dependence &Dep, if (Delinearize) { if (tryDelinearize(Src, Dst, Pair)) { - DEBUG(dbgs() << " delinearized\n"); + LLVM_DEBUG(dbgs() << " delinearized\n"); Pairs = Pair.size(); } } diff --git a/llvm/lib/Analysis/IVUsers.cpp b/llvm/lib/Analysis/IVUsers.cpp index f028dd0ef0d..609e5e3a144 100644 --- a/llvm/lib/Analysis/IVUsers.cpp +++ b/llvm/lib/Analysis/IVUsers.cpp @@ -235,13 +235,13 @@ bool IVUsers::AddUsersImpl(Instruction *I, if (LI->getLoopFor(User->getParent()) != L) { if (isa<PHINode>(User) || Processed.count(User) || !AddUsersImpl(User, SimpleLoopNests)) { - DEBUG(dbgs() << "FOUND USER in other loop: " << *User << '\n' - << " OF SCEV: " << *ISE << '\n'); + LLVM_DEBUG(dbgs() << "FOUND USER in other loop: " << *User << '\n' + << " OF SCEV: " << *ISE << '\n'); AddUserToIVUsers = true; } } else if (Processed.count(User) || !AddUsersImpl(User, SimpleLoopNests)) { - DEBUG(dbgs() << "FOUND USER: " << *User << '\n' - << " OF SCEV: " << *ISE << '\n'); + LLVM_DEBUG(dbgs() << "FOUND USER: " << *User << '\n' + << " OF SCEV: " << *ISE << '\n'); AddUserToIVUsers = true; } @@ -274,14 +274,15 @@ bool IVUsers::AddUsersImpl(Instruction *I, // If we normalized the expression, but denormalization doesn't give the // original one, discard this user. if (OriginalISE != DenormalizedISE) { - DEBUG(dbgs() << " DISCARDING (NORMALIZATION ISN'T INVERTIBLE): " - << *ISE << '\n'); + LLVM_DEBUG(dbgs() + << " DISCARDING (NORMALIZATION ISN'T INVERTIBLE): " + << *ISE << '\n'); IVUses.pop_back(); return false; } } - DEBUG(if (SE->getSCEV(I) != ISE) - dbgs() << " NORMALIZED TO: " << *ISE << '\n'); + LLVM_DEBUG(if (SE->getSCEV(I) != ISE) dbgs() + << " NORMALIZED TO: " << *ISE << '\n'); } } return true; diff --git a/llvm/lib/Analysis/IndirectCallPromotionAnalysis.cpp b/llvm/lib/Analysis/IndirectCallPromotionAnalysis.cpp index c11176bbb9c..4659c0a0062 100644 --- a/llvm/lib/Analysis/IndirectCallPromotionAnalysis.cpp +++ b/llvm/lib/Analysis/IndirectCallPromotionAnalysis.cpp @@ -71,19 +71,19 @@ uint32_t ICallPromotionAnalysis::getProfitablePromotionCandidates( const Instruction *Inst, uint32_t NumVals, uint64_t TotalCount) { ArrayRef<InstrProfValueData> ValueDataRef(ValueDataArray.get(), NumVals); - DEBUG(dbgs() << " \nWork on callsite " << *Inst << " Num_targets: " << NumVals - << "\n"); + LLVM_DEBUG(dbgs() << " \nWork on callsite " << *Inst + << " Num_targets: " << NumVals << "\n"); uint32_t I = 0; uint64_t RemainingCount = TotalCount; for (; I < MaxNumPromotions && I < NumVals; I++) { uint64_t Count = ValueDataRef[I].Count; assert(Count <= RemainingCount); - DEBUG(dbgs() << " Candidate " << I << " Count=" << Count - << " Target_func: " << ValueDataRef[I].Value << "\n"); + LLVM_DEBUG(dbgs() << " Candidate " << I << " Count=" << Count + << " Target_func: " << ValueDataRef[I].Value << "\n"); if (!isPromotionProfitable(Count, TotalCount, RemainingCount)) { - DEBUG(dbgs() << " Not promote: Cold target.\n"); + LLVM_DEBUG(dbgs() << " Not promote: Cold target.\n"); return I; } RemainingCount -= Count; diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index c81a66a051a..7a28ad431f6 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -921,14 +921,14 @@ void CallAnalyzer::updateThreshold(CallSite CS, Function &Callee) { BlockFrequencyInfo *CallerBFI = GetBFI ? &((*GetBFI)(*Caller)) : nullptr; auto HotCallSiteThreshold = getHotCallSiteThreshold(CS, CallerBFI); if (!Caller->optForSize() && HotCallSiteThreshold) { - DEBUG(dbgs() << "Hot callsite.\n"); + LLVM_DEBUG(dbgs() << "Hot callsite.\n"); // FIXME: This should update the threshold only if it exceeds the // current threshold, but AutoFDO + ThinLTO currently relies on this // behavior to prevent inlining of hot callsites during ThinLTO // compile phase. Threshold = HotCallSiteThreshold.getValue(); } else if (isColdCallSite(CS, CallerBFI)) { - DEBUG(dbgs() << "Cold callsite.\n"); + LLVM_DEBUG(dbgs() << "Cold callsite.\n"); // Do not apply bonuses for a cold callsite including the // LastCallToStatic bonus. While this bonus might result in code size // reduction, it can cause the size of a non-cold caller to increase @@ -939,13 +939,13 @@ void CallAnalyzer::updateThreshold(CallSite CS, Function &Callee) { // Use callee's global profile information only if we have no way of // determining this via callsite information. if (PSI->isFunctionEntryHot(&Callee)) { - DEBUG(dbgs() << "Hot callee.\n"); + LLVM_DEBUG(dbgs() << "Hot callee.\n"); // If callsite hotness can not be determined, we may still know // that the callee is hot and treat it as a weaker hint for threshold // increase. Threshold = MaxIfValid(Threshold, Params.HintThreshold); } else if (PSI->isFunctionEntryCold(&Callee)) { - DEBUG(dbgs() << "Cold callee.\n"); + LLVM_DEBUG(dbgs() << "Cold callee.\n"); // Do not apply bonuses for a cold callee including the // LastCallToStatic bonus. While this bonus might result in code size // reduction, it can cause the size of a non-cold caller to increase @@ -2002,14 +2002,14 @@ InlineCost llvm::getInlineCost( CS.isNoInline()) return llvm::InlineCost::getNever(); - DEBUG(llvm::dbgs() << " Analyzing call of " << Callee->getName() - << "... (caller:" << Caller->getName() << ")\n"); + LLVM_DEBUG(llvm::dbgs() << " Analyzing call of " << Callee->getName() + << "... (caller:" << Caller->getName() << ")\n"); CallAnalyzer CA(CalleeTTI, GetAssumptionCache, GetBFI, PSI, ORE, *Callee, CS, Params); bool ShouldInline = CA.analyzeCall(CS); - DEBUG(CA.dump()); + LLVM_DEBUG(CA.dump()); // Check if there was a reason to force inlining or no inlining. if (!ShouldInline && CA.getCost() < CA.getThreshold()) diff --git a/llvm/lib/Analysis/LazyCallGraph.cpp b/llvm/lib/Analysis/LazyCallGraph.cpp index 420a71c9ffe..c001f55bb62 100644 --- a/llvm/lib/Analysis/LazyCallGraph.cpp +++ b/llvm/lib/Analysis/LazyCallGraph.cpp @@ -66,15 +66,15 @@ static void addEdge(SmallVectorImpl<LazyCallGraph::Edge> &Edges, if (!EdgeIndexMap.insert({&N, Edges.size()}).second) return; - DEBUG(dbgs() << " Added callable function: " << N.getName() << "\n"); + LLVM_DEBUG(dbgs() << " Added callable function: " << N.getName() << "\n"); Edges.emplace_back(LazyCallGraph::Edge(N, EK)); } LazyCallGraph::EdgeSequence &LazyCallGraph::Node::populateSlow() { assert(!Edges && "Must not have already populated the edges for this node!"); - DEBUG(dbgs() << " Adding functions called by '" << getName() - << "' to the graph.\n"); + LLVM_DEBUG(dbgs() << " Adding functions called by '" << getName() + << "' to the graph.\n"); Edges = EdgeSequence(); @@ -152,8 +152,8 @@ static bool isKnownLibFunction(Function &F, TargetLibraryInfo &TLI) { } LazyCallGraph::LazyCallGraph(Module &M, TargetLibraryInfo &TLI) { - DEBUG(dbgs() << "Building CG for module: " << M.getModuleIdentifier() - << "\n"); + LLVM_DEBUG(dbgs() << "Building CG for module: " << M.getModuleIdentifier() + << "\n"); for (Function &F : M) { if (F.isDeclaration()) continue; @@ -168,8 +168,8 @@ LazyCallGraph::LazyCallGraph(Module &M, TargetLibraryInfo &TLI) { // External linkage defined functions have edges to them from other // modules. - DEBUG(dbgs() << " Adding '" << F.getName() - << "' to entry set of the graph.\n"); + LLVM_DEBUG(dbgs() << " Adding '" << F.getName() + << "' to entry set of the graph.\n"); addEdge(EntryEdges.Edges, EntryEdges.EdgeIndexMap, get(F), Edge::Ref); } @@ -181,8 +181,9 @@ LazyCallGraph::LazyCallGraph(Module &M, TargetLibraryInfo &TLI) { if (Visited.insert(GV.getInitializer()).second) Worklist.push_back(GV.getInitializer()); - DEBUG(dbgs() << " Adding functions referenced by global initializers to the " - "entry set.\n"); + LLVM_DEBUG( + dbgs() << " Adding functions referenced by global initializers to the " + "entry set.\n"); visitReferences(Worklist, Visited, [&](Function &F) { addEdge(EntryEdges.Edges, EntryEdges.EdgeIndexMap, get(F), LazyCallGraph::Edge::Ref); diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp index 4bb1e56d086..a133357979b 100644 --- a/llvm/lib/Analysis/LazyValueInfo.cpp +++ b/llvm/lib/Analysis/LazyValueInfo.cpp @@ -392,8 +392,8 @@ namespace { if (!BlockValueSet.insert(BV).second) return false; // It's already in the stack. - DEBUG(dbgs() << "PUSH: " << *BV.second << " in " << BV.first->getName() - << "\n"); + LLVM_DEBUG(dbgs() << "PUSH: " << *BV.second << " in " + << BV.first->getName() << "\n"); BlockValueStack.push_back(BV); return true; } @@ -508,7 +508,8 @@ void LazyValueInfoImpl::solve() { // PredicateInfo is used in LVI or CVP, we should be able to make the // overdefined cache global, and remove this throttle. if (processedCount > MaxProcessedPerValue) { - DEBUG(dbgs() << "Giving up on stack because we are getting too deep\n"); + LLVM_DEBUG( + dbgs() << "Giving up on stack because we are getting too deep\n"); // Fill in the original values while (!StartingStack.empty()) { std::pair<BasicBlock *, Value *> &e = StartingStack.back(); @@ -529,8 +530,9 @@ void LazyValueInfoImpl::solve() { assert(TheCache.hasCachedValueInfo(e.second, e.first) && "Result should be in cache!"); - DEBUG(dbgs() << "POP " << *e.second << " in " << e.first->getName() - << " = " << TheCache.getCachedValueInfo(e.second, e.first) << "\n"); + LLVM_DEBUG( + dbgs() << "POP " << *e.second << " in " << e.first->getName() << " = " + << TheCache.getCachedValueInfo(e.second, e.first) << "\n"); BlockValueStack.pop_back(); BlockValueSet.erase(e); @@ -581,8 +583,8 @@ bool LazyValueInfoImpl::solveBlockValue(Value *Val, BasicBlock *BB) { if (TheCache.hasCachedValueInfo(Val, BB)) { // If we have a cached value, use that. - DEBUG(dbgs() << " reuse BB '" << BB->getName() - << "' val=" << TheCache.getCachedValueInfo(Val, BB) << '\n'); + LLVM_DEBUG(dbgs() << " reuse BB '" << BB->getName() << "' val=" + << TheCache.getCachedValueInfo(Val, BB) << '\n'); // Since we're reusing a cached value, we don't need to update the // OverDefinedCache. The cache will have been properly updated whenever the @@ -637,8 +639,8 @@ bool LazyValueInfoImpl::solveBlockValueImpl(ValueLatticeElement &Res, return solveBlockValueBinaryOp(Res, BO, BB); } - DEBUG(dbgs() << " compute BB '" << BB->getName() - << "' - unknown inst def found.\n"); + LLVM_DEBUG(dbgs() << " compute BB '" << BB->getName() + << "' - unknown inst def found.\n"); Res = getFromRangeMetadata(BBI); return true; } @@ -733,8 +735,8 @@ bool LazyValueInfoImpl::solveBlockValueNonLocal(ValueLatticeElement &BBLV, // If we hit overdefined, exit early. The BlockVals entry is already set // to overdefined. if (Result.isOverdefined()) { - DEBUG(dbgs() << " compute BB '" << BB->getName() - << "' - overdefined because of pred (non local).\n"); + LLVM_DEBUG(dbgs() << " compute BB '" << BB->getName() + << "' - overdefined because of pred (non local).\n"); // Before giving up, see if we can prove the pointer non-null local to // this particular block. if (Val->getType()->isPointerTy() && @@ -777,8 +779,8 @@ bool LazyValueInfoImpl::solveBlockValuePHINode(ValueLatticeElement &BBLV, // If we hit overdefined, exit early. The BlockVals entry is already set // to overdefined. if (Result.isOverdefined()) { - DEBUG(dbgs() << " compute BB '" << BB->getName() - << "' - overdefined because of pred (local).\n"); + LLVM_DEBUG(dbgs() << " compute BB '" << BB->getName() + << "' - overdefined because of pred (local).\n"); BBLV = Result; return true; @@ -968,8 +970,8 @@ bool LazyValueInfoImpl::solveBlockValueCast(ValueLatticeElement &BBLV, break; default: // Unhandled instructions are overdefined. - DEBUG(dbgs() << " compute BB '" << BB->getName() - << "' - overdefined (unknown cast).\n"); + LLVM_DEBUG(dbgs() << " compute BB '" << BB->getName() + << "' - overdefined (unknown cast).\n"); BBLV = ValueLatticeElement::getOverdefined(); return true; } @@ -1027,8 +1029,8 @@ bool LazyValueInfoImpl::solveBlockValueBinaryOp(ValueLatticeElement &BBLV, break; default: // Unhandled instructions are overdefined. - DEBUG(dbgs() << " compute BB '" << BB->getName() - << "' - overdefined (unknown binary operator).\n"); + LLVM_DEBUG(dbgs() << " compute BB '" << BB->getName() + << "' - overdefined (unknown binary operator).\n"); BBLV = ValueLatticeElement::getOverdefined(); return true; }; @@ -1399,8 +1401,8 @@ bool LazyValueInfoImpl::getEdgeValue(Value *Val, BasicBlock *BBFrom, ValueLatticeElement LazyValueInfoImpl::getValueInBlock(Value *V, BasicBlock *BB, Instruction *CxtI) { - DEBUG(dbgs() << "LVI Getting block end value " << *V << " at '" - << BB->getName() << "'\n"); + LLVM_DEBUG(dbgs() << "LVI Getting block end value " << *V << " at '" + << BB->getName() << "'\n"); assert(BlockValueStack.empty() && BlockValueSet.empty()); if (!hasBlockValue(V, BB)) { @@ -1410,13 +1412,13 @@ ValueLatticeElement LazyValueInfoImpl::getValueInBlock(Value *V, BasicBlock *BB, ValueLatticeElement Result = getBlockValue(V, BB); intersectAssumeOrGuardBlockValueConstantRange(V, Result, CxtI); - DEBUG(dbgs() << " Result = " << Result << "\n"); + LLVM_DEBUG(dbgs() << " Result = " << Result << "\n"); return Result; } ValueLatticeElement LazyValueInfoImpl::getValueAt(Value *V, Instruction *CxtI) { - DEBUG(dbgs() << "LVI Getting value " << *V << " at '" - << CxtI->getName() << "'\n"); + LLVM_DEBUG(dbgs() << "LVI Getting value " << *V << " at '" << CxtI->getName() + << "'\n"); if (auto *C = dyn_cast<Constant>(V)) return ValueLatticeElement::get(C); @@ -1426,15 +1428,16 @@ ValueLatticeElement LazyValueInfoImpl::getValueAt(Value *V, Instruction *CxtI) { Result = getFromRangeMetadata(I); intersectAssumeOrGuardBlockValueConstantRange(V, Result, CxtI); - DEBUG(dbgs() << " Result = " << Result << "\n"); + LLVM_DEBUG(dbgs() << " Result = " << Result << "\n"); return Result; } ValueLatticeElement LazyValueInfoImpl:: getValueOnEdge(Value *V, BasicBlock *FromBB, BasicBlock *ToBB, Instruction *CxtI) { - DEBUG(dbgs() << "LVI Getting edge value " << *V << " from '" - << FromBB->getName() << "' to '" << ToBB->getName() << "'\n"); + LLVM_DEBUG(dbgs() << "LVI Getting edge value " << *V << " from '" + << FromBB->getName() << "' to '" << ToBB->getName() + << "'\n"); ValueLatticeElement Result; if (!getEdgeValue(V, FromBB, ToBB, Result, CxtI)) { @@ -1444,7 +1447,7 @@ getValueOnEdge(Value *V, BasicBlock *FromBB, BasicBlock *ToBB, assert(WasFastQuery && "More work to do after problem solved?"); } - DEBUG(dbgs() << " Result = " << Result << "\n"); + LLVM_DEBUG(dbgs() << " Result = " << Result << "\n"); return Result; } diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index 6f94d30855c..17b13802e1d 100644 --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -165,8 +165,8 @@ const SCEV *llvm::replaceSymbolicStrideSCEV(PredicatedScalarEvolution &PSE, PSE.addPredicate(*SE->getEqualPredicate(U, CT)); auto *Expr = PSE.getSCEV(Ptr); - DEBUG(dbgs() << "LAA: Replacing SCEV: " << *OrigSCEV << " by: " << *Expr - << "\n"); + LLVM_DEBUG(dbgs() << "LAA: Replacing SCEV: " << *OrigSCEV + << " by: " << *Expr << "\n"); return Expr; } @@ -684,7 +684,7 @@ bool AccessAnalysis::createCheckForAccess(RuntimePointerChecking &RtCheck, bool IsWrite = Access.getInt(); RtCheck.insert(TheLoop, Ptr, IsWrite, DepId, ASId, StridesMap, PSE); - DEBUG(dbgs() << "LAA: Found a runtime check ptr:" << *Ptr << '\n'); + LLVM_DEBUG(dbgs() << "LAA: Found a runtime check ptr:" << *Ptr << '\n'); return true; } @@ -729,7 +729,7 @@ bool AccessAnalysis::canCheckPtrAtRT(RuntimePointerChecking &RtCheck, if (!createCheckForAccess(RtCheck, Access, StridesMap, DepSetId, TheLoop, RunningDepId, ASId, ShouldCheckWrap, false)) { - DEBUG(dbgs() << "LAA: Can't find bounds for ptr:" << *Ptr << '\n'); + LLVM_DEBUG(dbgs() << "LAA: Can't find bounds for ptr:" << *Ptr << '\n'); Retries.push_back(Access); CanDoAliasSetRT = false; } @@ -791,8 +791,9 @@ bool AccessAnalysis::canCheckPtrAtRT(RuntimePointerChecking &RtCheck, unsigned ASi = PtrI->getType()->getPointerAddressSpace(); unsigned ASj = PtrJ->getType()->getPointerAddressSpace(); if (ASi != ASj) { - DEBUG(dbgs() << "LAA: Runtime check would require comparison between" - " different address spaces\n"); + LLVM_DEBUG( + dbgs() << "LAA: Runtime check would require comparison between" + " different address spaces\n"); return false; } } @@ -801,8 +802,8 @@ bool AccessAnalysis::canCheckPtrAtRT(RuntimePointerChecking &RtCheck, if (NeedRTCheck && CanDoRT) RtCheck.generateChecks(DepCands, IsDepCheckNeeded); - DEBUG(dbgs() << "LAA: We need to do " << RtCheck.getNumberOfChecks() - << " pointer comparisons.\n"); + LLVM_DEBUG(dbgs() << "LAA: We need to do " << RtCheck.getNumberOfChecks() + << " pointer comparisons.\n"); RtCheck.Need = NeedRTCheck; @@ -817,10 +818,10 @@ void AccessAnalysis::processMemAccesses() { // process read-only pointers. This allows us to skip dependence tests for // read-only pointers. - DEBUG(dbgs() << "LAA: Processing memory accesses...\n"); - DEBUG(dbgs() << " AST: "; AST.dump()); - DEBUG(dbgs() << "LAA: Accesses(" << Accesses.size() << "):\n"); - DEBUG({ + LLVM_DEBUG(dbgs() << "LAA: Processing memory accesses...\n"); + LLVM_DEBUG(dbgs() << " AST: "; AST.dump()); + LLVM_DEBUG(dbgs() << "LAA: Accesses(" << Accesses.size() << "):\n"); + LLVM_DEBUG({ for (auto A : Accesses) dbgs() << "\t" << *A.getPointer() << " (" << (A.getInt() ? "write" : (ReadOnlyPtr.count(A.getPointer()) ? @@ -904,7 +905,8 @@ void AccessAnalysis::processMemAccesses() { ValueVector TempObjects; GetUnderlyingObjects(Ptr, TempObjects, DL, LI); - DEBUG(dbgs() << "Underlying objects for pointer " << *Ptr << "\n"); + LLVM_DEBUG(dbgs() + << "Underlying objects for pointer " << *Ptr << "\n"); for (Value *UnderlyingObj : TempObjects) { // nullptr never alias, don't join sets for pointer that have "null" // in their UnderlyingObjects list. @@ -917,7 +919,7 @@ void AccessAnalysis::processMemAccesses() { DepCands.unionSets(Access, Prev->second); ObjToLastAccess[UnderlyingObj] = Access; - DEBUG(dbgs() << " " << *UnderlyingObj << "\n"); + LLVM_DEBUG(dbgs() << " " << *UnderlyingObj << "\n"); } } } @@ -989,8 +991,8 @@ int64_t llvm::getPtrStride(PredicatedScalarEvolution &PSE, Value *Ptr, // Make sure that the pointer does not point to aggregate types. auto *PtrTy = cast<PointerType>(Ty); if (PtrTy->getElementType()->isAggregateType()) { - DEBUG(dbgs() << "LAA: Bad stride - Not a pointer to a scalar type" << *Ptr - << "\n"); + LLVM_DEBUG(dbgs() << "LAA: Bad stride - Not a pointer to a scalar type" + << *Ptr << "\n"); return 0; } @@ -1001,15 +1003,15 @@ int64_t llvm::getPtrStride(PredicatedScalarEvolution &PSE, Value *Ptr, AR = PSE.getAsAddRec(Ptr); if (!AR) { - DEBUG(dbgs() << "LAA: Bad stride - Not an AddRecExpr pointer " << *Ptr - << " SCEV: " << *PtrScev << "\n"); + LLVM_DEBUG(dbgs() << "LAA: Bad stride - Not an AddRecExpr pointer " << *Ptr + << " SCEV: " << *PtrScev << "\n"); return 0; } // The accesss function must stride over the innermost loop. if (Lp != AR->getLoop()) { - DEBUG(dbgs() << "LAA: Bad stride - Not striding over innermost loop " << - *Ptr << " SCEV: " << *AR << "\n"); + LLVM_DEBUG(dbgs() << "LAA: Bad stride - Not striding over innermost loop " + << *Ptr << " SCEV: " << *AR << "\n"); return 0; } @@ -1029,13 +1031,14 @@ int64_t llvm::getPtrStride(PredicatedScalarEvolution &PSE, Value *Ptr, if (Assume) { PSE.setNoOverflow(Ptr, SCEVWrapPredicate::IncrementNUSW); IsNoWrapAddRec = true; - DEBUG(dbgs() << "LAA: Pointer may wrap in the address space:\n" - << "LAA: Pointer: " << *Ptr << "\n" - << "LAA: SCEV: " << *AR << "\n" - << "LAA: Added an overflow assumption\n"); + LLVM_DEBUG(dbgs() << "LAA: Pointer may wrap in the address space:\n" + << "LAA: Pointer: " << *Ptr << "\n" + << "LAA: SCEV: " << *AR << "\n" + << "LAA: Added an overflow assumption\n"); } else { - DEBUG(dbgs() << "LAA: Bad stride - Pointer may wrap in the address space " - << *Ptr << " SCEV: " << *AR << "\n"); + LLVM_DEBUG( + dbgs() << "LAA: Bad stride - Pointer may wrap in the address space " + << *Ptr << " SCEV: " << *AR << "\n"); return 0; } } @@ -1046,8 +1049,8 @@ int64_t llvm::getPtrStride(PredicatedScalarEvolution &PSE, Value *Ptr, // Calculate the pointer stride and check if it is constant. const SCEVConstant *C = dyn_cast<SCEVConstant>(Step); if (!C) { - DEBUG(dbgs() << "LAA: Bad stride - Not a constant strided " << *Ptr << - " SCEV: " << *AR << "\n"); + LLVM_DEBUG(dbgs() << "LAA: Bad stride - Not a constant strided " << *Ptr + << " SCEV: " << *AR << "\n"); return 0; } @@ -1074,11 +1077,11 @@ int64_t llvm::getPtrStride(PredicatedScalarEvolution &PSE, Value *Ptr, Stride != 1 && Stride != -1) { if (Assume) { // We can avoid this case by adding a run-time check. - DEBUG(dbgs() << "LAA: Non unit strided pointer which is not either " - << "inbouds or in address space 0 may wrap:\n" - << "LAA: Pointer: " << *Ptr << "\n" - << "LAA: SCEV: " << *AR << "\n" - << "LAA: Added an overflow assumption\n"); + LLVM_DEBUG(dbgs() << "LAA: Non unit strided pointer which is not either " + << "inbouds or in address space 0 may wrap:\n" + << "LAA: Pointer: " << *Ptr << "\n" + << "LAA: SCEV: " << *AR << "\n" + << "LAA: Added an overflow assumption\n"); PSE.setNoOverflow(Ptr, SCEVWrapPredicate::IncrementNUSW); } else return 0; @@ -1293,8 +1296,9 @@ bool MemoryDepChecker::couldPreventStoreLoadForward(uint64_t Distance, } if (MaxVFWithoutSLForwardIssues < 2 * TypeByteSize) { - DEBUG(dbgs() << "LAA: Distance " << Distance - << " that could cause a store-load forwarding conflict\n"); + LLVM_DEBUG( + dbgs() << "LAA: Distance " << Distance + << " that could cause a store-load forwarding conflict\n"); return true; } @@ -1446,16 +1450,16 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx, const SCEV *Dist = PSE.getSE()->getMinusSCEV(Sink, Src); - DEBUG(dbgs() << "LAA: Src Scev: " << *Src << "Sink Scev: " << *Sink - << "(Induction step: " << StrideAPtr << ")\n"); - DEBUG(dbgs() << "LAA: Distance for " << *InstMap[AIdx] << " to " - << *InstMap[BIdx] << ": " << *Dist << "\n"); + LLVM_DEBUG(dbgs() << "LAA: Src Scev: " << *Src << "Sink Scev: " << *Sink + << "(Induction step: " << StrideAPtr << ")\n"); + LLVM_DEBUG(dbgs() << "LAA: Distance for " << *InstMap[AIdx] << " to " + << *InstMap[BIdx] << ": " << *Dist << "\n"); // Need accesses with constant stride. We don't want to vectorize // "A[B[i]] += ..." and similar code or pointer arithmetic that could wrap in // the address space. if (!StrideAPtr || !StrideBPtr || StrideAPtr != StrideBPtr){ - DEBUG(dbgs() << "Pointer access with non-constant stride\n"); + LLVM_DEBUG(dbgs() << "Pointer access with non-constant stride\n"); return Dependence::Unknown; } @@ -1472,7 +1476,7 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx, TypeByteSize)) return Dependence::NoDep; - DEBUG(dbgs() << "LAA: Dependence because of non-constant distance\n"); + LLVM_DEBUG(dbgs() << "LAA: Dependence because of non-constant distance\n"); ShouldRetryWithRuntimeCheck = true; return Dependence::Unknown; } @@ -1483,7 +1487,7 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx, // Attempt to prove strided accesses independent. if (std::abs(Distance) > 0 && Stride > 1 && ATy == BTy && areStridedAccessesIndependent(std::abs(Distance), Stride, TypeByteSize)) { - DEBUG(dbgs() << "LAA: Strided accesses are independent\n"); + LLVM_DEBUG(dbgs() << "LAA: Strided accesses are independent\n"); return Dependence::NoDep; } @@ -1493,11 +1497,11 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx, if (IsTrueDataDependence && EnableForwardingConflictDetection && (couldPreventStoreLoadForward(Val.abs().getZExtValue(), TypeByteSize) || ATy != BTy)) { - DEBUG(dbgs() << "LAA: Forward but may prevent st->ld forwarding\n"); + LLVM_DEBUG(dbgs() << "LAA: Forward but may prevent st->ld forwarding\n"); return Dependence::ForwardButPreventsForwarding; } - DEBUG(dbgs() << "LAA: Dependence is negative\n"); + LLVM_DEBUG(dbgs() << "LAA: Dependence is negative\n"); return Dependence::Forward; } @@ -1506,15 +1510,17 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx, if (Val == 0) { if (ATy == BTy) return Dependence::Forward; - DEBUG(dbgs() << "LAA: Zero dependence difference but different types\n"); + LLVM_DEBUG( + dbgs() << "LAA: Zero dependence difference but different types\n"); return Dependence::Unknown; } assert(Val.isStrictlyPositive() && "Expect a positive value"); if (ATy != BTy) { - DEBUG(dbgs() << - "LAA: ReadWrite-Write positive dependency with different types\n"); + LLVM_DEBUG( + dbgs() + << "LAA: ReadWrite-Write positive dependency with different types\n"); return Dependence::Unknown; } @@ -1555,15 +1561,15 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx, uint64_t MinDistanceNeeded = TypeByteSize * Stride * (MinNumIter - 1) + TypeByteSize; if (MinDistanceNeeded > static_cast<uint64_t>(Distance)) { - DEBUG(dbgs() << "LAA: Failure because of positive distance " << Distance - << '\n'); + LLVM_DEBUG(dbgs() << "LAA: Failure because of positive distance " + << Distance << '\n'); return Dependence::Backward; } // Unsafe if the minimum distance needed is greater than max safe distance. if (MinDistanceNeeded > MaxSafeDepDistBytes) { - DEBUG(dbgs() << "LAA: Failure because it needs at least " - << MinDistanceNeeded << " size in bytes"); + LLVM_DEBUG(dbgs() << "LAA: Failure because it needs at least " + << MinDistanceNeeded << " size in bytes"); return Dependence::Backward; } @@ -1592,8 +1598,8 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx, return Dependence::BackwardVectorizableButPreventsForwarding; uint64_t MaxVF = MaxSafeDepDistBytes / (TypeByteSize * Stride); - DEBUG(dbgs() << "LAA: Positive distance " << Val.getSExtValue() - << " with max VF = " << MaxVF << '\n'); + LLVM_DEBUG(dbgs() << "LAA: Positive distance " << Val.getSExtValue() + << " with max VF = " << MaxVF << '\n'); uint64_t MaxVFInBits = MaxVF * TypeByteSize * 8; MaxSafeRegisterWidth = std::min(MaxSafeRegisterWidth, MaxVFInBits); return Dependence::BackwardVectorizable; @@ -1651,7 +1657,8 @@ bool MemoryDepChecker::areDepsSafe(DepCandidates &AccessSets, if (Dependences.size() >= MaxDependences) { RecordDependences = false; Dependences.clear(); - DEBUG(dbgs() << "Too many dependences, stopped recording\n"); + LLVM_DEBUG(dbgs() + << "Too many dependences, stopped recording\n"); } } if (!RecordDependences && !SafeForVectorization) @@ -1663,7 +1670,7 @@ bool MemoryDepChecker::areDepsSafe(DepCandidates &AccessSets, } } - DEBUG(dbgs() << "Total Dependences: " << Dependences.size() << "\n"); + LLVM_DEBUG(dbgs() << "Total Dependences: " << Dependences.size() << "\n"); return SafeForVectorization; } @@ -1693,20 +1700,21 @@ void MemoryDepChecker::Dependence::print( bool LoopAccessInfo::canAnalyzeLoop() { // We need to have a loop header. - DEBUG(dbgs() << "LAA: Found a loop in " - << TheLoop->getHeader()->getParent()->getName() << ": " - << TheLoop->getHeader()->getName() << '\n'); + LLVM_DEBUG(dbgs() << "LAA: Found a loop in " + << TheLoop->getHeader()->getParent()->getName() << ": " + << TheLoop->getHeader()->getName() << '\n'); // We can only analyze innermost loops. if (!TheLoop->empty()) { - DEBUG(dbgs() << "LAA: loop is not the innermost loop\n"); + LLVM_DEBUG(dbgs() << "LAA: loop is not the innermost loop\n"); recordAnalysis("NotInnerMostLoop") << "loop is not the innermost loop"; return false; } // We must have a single backedge. if (TheLoop->getNumBackEdges() != 1) { - DEBUG(dbgs() << "LAA: loop control flow is not understood by analyzer\n"); + LLVM_DEBUG( + dbgs() << "LAA: loop control flow is not understood by analyzer\n"); recordAnalysis("CFGNotUnderstood") << "loop control flow is not understood by analyzer"; return false; @@ -1714,7 +1722,8 @@ bool LoopAccessInfo::canAnalyzeLoop() { // We must have a single exiting block. if (!TheLoop->getExitingBlock()) { - DEBUG(dbgs() << "LAA: loop control flow is not understood by analyzer\n"); + LLVM_DEBUG( + dbgs() << "LAA: loop control flow is not understood by analyzer\n"); recordAnalysis("CFGNotUnderstood") << "loop control flow is not understood by analyzer"; return false; @@ -1724,7 +1733,8 @@ bool LoopAccessInfo::canAnalyzeLoop() { // checked at the end of each iteration. With that we can assume that all // instructions in the loop are executed the same number of times. if (TheLoop->getExitingBlock() != TheLoop->getLoopLatch()) { - DEBUG(dbgs() << "LAA: loop control flow is not understood by analyzer\n"); + LLVM_DEBUG( + dbgs() << "LAA: loop control flow is not understood by analyzer\n"); recordAnalysis("CFGNotUnderstood") << "loop control flow is not understood by analyzer"; return false; @@ -1735,7 +1745,7 @@ bool LoopAccessInfo::canAnalyzeLoop() { if (ExitCount == PSE->getSE()->getCouldNotCompute()) { recordAnalysis("CantComputeNumberOfIterations") << "could not determine number of loop iterations"; - DEBUG(dbgs() << "LAA: SCEV could not compute the loop exit count.\n"); + LLVM_DEBUG(dbgs() << "LAA: SCEV could not compute the loop exit count.\n"); return false; } @@ -1785,7 +1795,7 @@ void LoopAccessInfo::analyzeLoop(AliasAnalysis *AA, LoopInfo *LI, if (!Ld || (!Ld->isSimple() && !IsAnnotatedParallel)) { recordAnalysis("NonSimpleLoad", Ld) << "read with atomic ordering or volatile read"; - DEBUG(dbgs() << "LAA: Found a non-simple load.\n"); + LLVM_DEBUG(dbgs() << "LAA: Found a non-simple load.\n"); CanVecMem = false; return; } @@ -1809,7 +1819,7 @@ void LoopAccessInfo::analyzeLoop(AliasAnalysis *AA, LoopInfo *LI, if (!St->isSimple() && !IsAnnotatedParallel) { recordAnalysis("NonSimpleStore", St) << "write with atomic ordering or volatile write"; - DEBUG(dbgs() << "LAA: Found a non-simple store.\n"); + LLVM_DEBUG(dbgs() << "LAA: Found a non-simple store.\n"); CanVecMem = false; return; } @@ -1828,7 +1838,7 @@ void LoopAccessInfo::analyzeLoop(AliasAnalysis *AA, LoopInfo *LI, // Check if we see any stores. If there are no stores, then we don't // care if the pointers are *restrict*. if (!Stores.size()) { - DEBUG(dbgs() << "LAA: Found a read-only loop!\n"); + LLVM_DEBUG(dbgs() << "LAA: Found a read-only loop!\n"); CanVecMem = true; return; } @@ -1865,9 +1875,9 @@ void LoopAccessInfo::analyzeLoop(AliasAnalysis *AA, LoopInfo *LI, } if (IsAnnotatedParallel) { - DEBUG(dbgs() - << "LAA: A loop annotated parallel, ignore memory dependency " - << "checks.\n"); + LLVM_DEBUG( + dbgs() << "LAA: A loop annotated parallel, ignore memory dependency " + << "checks.\n"); CanVecMem = true; return; } @@ -1902,7 +1912,7 @@ void LoopAccessInfo::analyzeLoop(AliasAnalysis *AA, LoopInfo *LI, // If we write (or read-write) to a single destination and there are no // other reads in this loop then is it safe to vectorize. if (NumReadWrites == 1 && NumReads == 0) { - DEBUG(dbgs() << "LAA: Found a write-only loop!\n"); + LLVM_DEBUG(dbgs() << "LAA: Found a write-only loop!\n"); CanVecMem = true; return; } @@ -1917,23 +1927,24 @@ void LoopAccessInfo::analyzeLoop(AliasAnalysis *AA, LoopInfo *LI, TheLoop, SymbolicStrides); if (!CanDoRTIfNeeded) { recordAnalysis("CantIdentifyArrayBounds") << "cannot identify array bounds"; - DEBUG(dbgs() << "LAA: We can't vectorize because we can't find " - << "the array bounds.\n"); + LLVM_DEBUG(dbgs() << "LAA: We can't vectorize because we can't find " + << "the array bounds.\n"); CanVecMem = false; return; } - DEBUG(dbgs() << "LAA: We can perform a memory runtime check if needed.\n"); + LLVM_DEBUG( + dbgs() << "LAA: We can perform a memory runtime check if needed.\n"); CanVecMem = true; if (Accesses.isDependencyCheckNeeded()) { - DEBUG(dbgs() << "LAA: Checking memory dependencies\n"); + LLVM_DEBUG(dbgs() << "LAA: Checking memory dependencies\n"); CanVecMem = DepChecker->areDepsSafe( DependentAccesses, Accesses.getDependenciesToCheck(), SymbolicStrides); MaxSafeDepDistBytes = DepChecker->getMaxSafeDepDistBytes(); if (!CanVecMem && DepChecker->shouldRetryWithRuntimeCheck()) { - DEBUG(dbgs() << "LAA: Retrying with memory checks\n"); + LLVM_DEBUG(dbgs() << "LAA: Retrying with memory checks\n"); // Clear the dependency checks. We assume they are not needed. Accesses.resetDepChecks(*DepChecker); @@ -1949,7 +1960,7 @@ void LoopAccessInfo::analyzeLoop(AliasAnalysis *AA, LoopInfo *LI, if (!CanDoRTIfNeeded) { recordAnalysis("CantCheckMemDepsAtRunTime") << "cannot check memory dependencies at runtime"; - DEBUG(dbgs() << "LAA: Can't vectorize with memory checks\n"); + LLVM_DEBUG(dbgs() << "LAA: Can't vectorize with memory checks\n"); CanVecMem = false; return; } @@ -1959,16 +1970,17 @@ void LoopAccessInfo::analyzeLoop(AliasAnalysis *AA, LoopInfo *LI, } if (CanVecMem) - DEBUG(dbgs() << "LAA: No unsafe dependent memory operations in loop. We" - << (PtrRtChecking->Need ? "" : " don't") - << " need runtime memory checks.\n"); + LLVM_DEBUG( + dbgs() << "LAA: No unsafe dependent memory operations in loop. We" + << (PtrRtChecking->Need ? "" : " don't") + << " need runtime memory checks.\n"); else { recordAnalysis("UnsafeMemDep") << "unsafe dependent memory operations in loop. Use " "#pragma loop distribute(enable) to allow loop distribution " "to attempt to isolate the offending operations into a separate " "loop"; - DEBUG(dbgs() << "LAA: unsafe dependent memory operations in loop\n"); + LLVM_DEBUG(dbgs() << "LAA: unsafe dependent memory operations in loop\n"); } } @@ -2052,8 +2064,8 @@ expandBounds(const RuntimePointerChecking::CheckingPtrGroup *CG, Loop *TheLoop, Type *PtrArithTy = Type::getInt8PtrTy(Ctx, AS); if (SE->isLoopInvariant(Sc, TheLoop)) { - DEBUG(dbgs() << "LAA: Adding RT check for a loop invariant ptr:" << *Ptr - << "\n"); + LLVM_DEBUG(dbgs() << "LAA: Adding RT check for a loop invariant ptr:" + << *Ptr << "\n"); // Ptr could be in the loop body. If so, expand a new one at the correct // location. Instruction *Inst = dyn_cast<Instruction>(Ptr); @@ -2066,10 +2078,11 @@ expandBounds(const RuntimePointerChecking::CheckingPtrGroup *CG, Loop *TheLoop, return {NewPtr, NewPtrPlusOne}; } else { Value *Start = nullptr, *End = nullptr; - DEBUG(dbgs() << "LAA: Adding RT check for range:\n"); + LLVM_DEBUG(dbgs() << "LAA: Adding RT check for range:\n"); Start = Exp.expandCodeFor(CG->Low, PtrArithTy, Loc); End = Exp.expandCodeFor(CG->High, PtrArithTy, Loc); - DEBUG(dbgs() << "Start: " << *CG->Low << " End: " << *CG->High << "\n"); + LLVM_DEBUG(dbgs() << "Start: " << *CG->Low << " End: " << *CG->High + << "\n"); return {Start, End}; } } @@ -2187,9 +2200,9 @@ void LoopAccessInfo::collectStridedAccess(Value *MemAccess) { if (!Stride) return; - DEBUG(dbgs() << "LAA: Found a strided access that is a candidate for " - "versioning:"); - DEBUG(dbgs() << " Ptr: " << *Ptr << " Stride: " << *Stride << "\n"); + LLVM_DEBUG(dbgs() << "LAA: Found a strided access that is a candidate for " + "versioning:"); + LLVM_DEBUG(dbgs() << " Ptr: " << *Ptr << " Stride: " << *Stride << "\n"); // Avoid adding the "Stride == 1" predicate when we know that // Stride >= Trip-Count. Such a predicate will effectively optimize a single @@ -2225,12 +2238,13 @@ void LoopAccessInfo::collectStridedAccess(Value *MemAccess) { // "Stride >= TripCount" is equivalent to checking: // Stride - BETakenCount > 0 if (SE->isKnownPositive(StrideMinusBETaken)) { - DEBUG(dbgs() << "LAA: Stride>=TripCount; No point in versioning as the " - "Stride==1 predicate will imply that the loop executes " - "at most once.\n"); + LLVM_DEBUG( + dbgs() << "LAA: Stride>=TripCount; No point in versioning as the " + "Stride==1 predicate will imply that the loop executes " + "at most once.\n"); return; - } - DEBUG(dbgs() << "LAA: Found a strided access that we can version."); + } + LLVM_DEBUG(dbgs() << "LAA: Found a strided access that we can version."); SymbolicStrides[Ptr] = Stride; StrideSet.insert(Stride); diff --git a/llvm/lib/Analysis/LoopPass.cpp b/llvm/lib/Analysis/LoopPass.cpp index e39dc2070a3..208bd53a3a8 100644 --- a/llvm/lib/Analysis/LoopPass.cpp +++ b/llvm/lib/Analysis/LoopPass.cpp @@ -362,8 +362,8 @@ bool LoopPass::skipLoop(const Loop *L) const { // Check for the OptimizeNone attribute. if (F->hasFnAttribute(Attribute::OptimizeNone)) { // FIXME: Report this to dbgs() only once per function. - DEBUG(dbgs() << "Skipping pass '" << getPassName() - << "' in function " << F->getName() << "\n"); + LLVM_DEBUG(dbgs() << "Skipping pass '" << getPassName() << "' in function " + << F->getName() << "\n"); // FIXME: Delete loop from pass manager's queue? return true; } diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp index 186fda18886..deacdb9e324 100644 --- a/llvm/lib/Analysis/MemoryBuiltins.cpp +++ b/llvm/lib/Analysis/MemoryBuiltins.cpp @@ -528,8 +528,8 @@ SizeOffsetType ObjectSizeOffsetVisitor::compute(Value *V) { return visitGEPOperator(cast<GEPOperator>(*CE)); } - DEBUG(dbgs() << "ObjectSizeOffsetVisitor::compute() unhandled value: " << *V - << '\n'); + LLVM_DEBUG(dbgs() << "ObjectSizeOffsetVisitor::compute() unhandled value: " + << *V << '\n'); return unknown(); } @@ -729,7 +729,8 @@ SizeOffsetType ObjectSizeOffsetVisitor::visitUndefValue(UndefValue&) { } SizeOffsetType ObjectSizeOffsetVisitor::visitInstruction(Instruction &I) { - DEBUG(dbgs() << "ObjectSizeOffsetVisitor unknown instruction:" << I << '\n'); + LLVM_DEBUG(dbgs() << "ObjectSizeOffsetVisitor unknown instruction:" << I + << '\n'); return unknown(); } @@ -808,8 +809,9 @@ SizeOffsetEvalType ObjectSizeOffsetEvaluator::compute_(Value *V) { // Ignore values where we cannot do more than ObjectSizeVisitor. Result = unknown(); } else { - DEBUG(dbgs() << "ObjectSizeOffsetEvaluator::compute() unhandled value: " - << *V << '\n'); + LLVM_DEBUG( + dbgs() << "ObjectSizeOffsetEvaluator::compute() unhandled value: " << *V + << '\n'); Result = unknown(); } @@ -946,6 +948,7 @@ SizeOffsetEvalType ObjectSizeOffsetEvaluator::visitSelectInst(SelectInst &I) { } SizeOffsetEvalType ObjectSizeOffsetEvaluator::visitInstruction(Instruction &I) { - DEBUG(dbgs() << "ObjectSizeOffsetEvaluator unknown instruction:" << I <<'\n'); + LLVM_DEBUG(dbgs() << "ObjectSizeOffsetEvaluator unknown instruction:" << I + << '\n'); return unknown(); } diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp index 9b080e19f19..64ceae72f71 100644 --- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -824,7 +824,7 @@ MemoryDependenceResults::getNonLocalCallDependency(CallSite QueryCS) { SmallPtrSet<BasicBlock *, 32> Visited; unsigned NumSortedEntries = Cache.size(); - DEBUG(AssertSorted(Cache)); + LLVM_DEBUG(AssertSorted(Cache)); // Iterate while we still have blocks to update. while (!DirtyBlocks.empty()) { @@ -837,7 +837,7 @@ MemoryDependenceResults::getNonLocalCallDependency(CallSite QueryCS) { // Do a binary search to see if we already have an entry for this block in // the cache set. If so, find it. - DEBUG(AssertSorted(Cache, NumSortedEntries)); + LLVM_DEBUG(AssertSorted(Cache, NumSortedEntries)); NonLocalDepInfo::iterator Entry = std::upper_bound(Cache.begin(), Cache.begin() + NumSortedEntries, NonLocalDepEntry(DirtyBB)); @@ -1210,7 +1210,7 @@ bool MemoryDependenceResults::getNonLocalPointerDepFromBB( unsigned NumSortedEntries = Cache->size(); unsigned WorklistEntries = BlockNumberLimit; bool GotWorklistLimit = false; - DEBUG(AssertSorted(*Cache)); + LLVM_DEBUG(AssertSorted(*Cache)); while (!Worklist.empty()) { BasicBlock *BB = Worklist.pop_back_val(); @@ -1241,7 +1241,7 @@ bool MemoryDependenceResults::getNonLocalPointerDepFromBB( // Get the dependency info for Pointer in BB. If we have cached // information, we will use it, otherwise we compute it. - DEBUG(AssertSorted(*Cache, NumSortedEntries)); + LLVM_DEBUG(AssertSorted(*Cache, NumSortedEntries)); MemDepResult Dep = GetNonLocalInfoForBlock(QueryInst, Loc, isLoad, BB, Cache, NumSortedEntries); @@ -1455,7 +1455,7 @@ bool MemoryDependenceResults::getNonLocalPointerDepFromBB( // Okay, we're done now. If we added new values to the cache, re-sort it. SortNonLocalDepInfoCache(*Cache, NumSortedEntries); - DEBUG(AssertSorted(*Cache)); + LLVM_DEBUG(AssertSorted(*Cache)); return true; } @@ -1651,7 +1651,7 @@ void MemoryDependenceResults::removeInstruction(Instruction *RemInst) { } assert(!NonLocalDeps.count(RemInst) && "RemInst got reinserted?"); - DEBUG(verifyRemoved(RemInst)); + LLVM_DEBUG(verifyRemoved(RemInst)); } /// Verify that the specified instruction does not occur in our internal data diff --git a/llvm/lib/Analysis/MemorySSA.cpp b/llvm/lib/Analysis/MemorySSA.cpp index 661922df359..f2fd2041a6b 100644 --- a/llvm/lib/Analysis/MemorySSA.cpp +++ b/llvm/lib/Analysis/MemorySSA.cpp @@ -1240,10 +1240,11 @@ void MemorySSA::OptimizeUses::optimizeUsesInBlock( unsigned long UpperBound = VersionStack.size() - 1; if (UpperBound - LocInfo.LowerBound > MaxCheckLimit) { - DEBUG(dbgs() << "MemorySSA skipping optimization of " << *MU << " (" - << *(MU->getMemoryInst()) << ")" - << " because there are " << UpperBound - LocInfo.LowerBound - << " stores to disambiguate\n"); + LLVM_DEBUG(dbgs() << "MemorySSA skipping optimization of " << *MU << " (" + << *(MU->getMemoryInst()) << ")" + << " because there are " + << UpperBound - LocInfo.LowerBound + << " stores to disambiguate\n"); // Because we did not walk, LastKill is no longer valid, as this may // have been a kill. LocInfo.LastKillValid = false; @@ -2036,10 +2037,10 @@ MemoryAccess *MemorySSA::CachingWalker::getClobberingMemoryAccess( : StartingUseOrDef; MemoryAccess *Clobber = getClobberingMemoryAccess(DefiningAccess, Q); - DEBUG(dbgs() << "Starting Memory SSA clobber for " << *I << " is "); - DEBUG(dbgs() << *StartingUseOrDef << "\n"); - DEBUG(dbgs() << "Final Memory SSA clobber for " << *I << " is "); - DEBUG(dbgs() << *Clobber << "\n"); + LLVM_DEBUG(dbgs() << "Starting Memory SSA clobber for " << *I << " is "); + LLVM_DEBUG(dbgs() << *StartingUseOrDef << "\n"); + LLVM_DEBUG(dbgs() << "Final Memory SSA clobber for " << *I << " is "); + LLVM_DEBUG(dbgs() << *Clobber << "\n"); return Clobber; } @@ -2083,10 +2084,10 @@ MemorySSA::CachingWalker::getClobberingMemoryAccess(MemoryAccess *MA) { } MemoryAccess *Result = getClobberingMemoryAccess(DefiningAccess, Q); - DEBUG(dbgs() << "Starting Memory SSA clobber for " << *I << " is "); - DEBUG(dbgs() << *DefiningAccess << "\n"); - DEBUG(dbgs() << "Final Memory SSA clobber for " << *I << " is "); - DEBUG(dbgs() << *Result << "\n"); + LLVM_DEBUG(dbgs() << "Starting Memory SSA clobber for " << *I << " is "); + LLVM_DEBUG(dbgs() << *DefiningAccess << "\n"); + LLVM_DEBUG(dbgs() << "Final Memory SSA clobber for " << *I << " is "); + LLVM_DEBUG(dbgs() << *Result << "\n"); StartingAccess->setOptimized(Result); if (MSSA->isLiveOnEntryDef(Result)) diff --git a/llvm/lib/Analysis/RegionPass.cpp b/llvm/lib/Analysis/RegionPass.cpp index 00282db8431..ed17df2e7e9 100644 --- a/llvm/lib/Analysis/RegionPass.cpp +++ b/llvm/lib/Analysis/RegionPass.cpp @@ -158,12 +158,9 @@ bool RGPassManager::runOnFunction(Function &F) { } // Print the region tree after all pass. - DEBUG( - dbgs() << "\nRegion tree of function " << F.getName() - << " after all region Pass:\n"; - RI->dump(); - dbgs() << "\n"; - ); + LLVM_DEBUG(dbgs() << "\nRegion tree of function " << F.getName() + << " after all region Pass:\n"; + RI->dump(); dbgs() << "\n";); return Changed; } @@ -289,8 +286,8 @@ bool RegionPass::skipRegion(Region &R) const { if (F.hasFnAttribute(Attribute::OptimizeNone)) { // Report this only once per function. if (R.getEntry() == &F.getEntryBlock()) - DEBUG(dbgs() << "Skipping pass '" << getPassName() - << "' on function " << F.getName() << "\n"); + LLVM_DEBUG(dbgs() << "Skipping pass '" << getPassName() + << "' on function " << F.getName() << "\n"); return true; } return false; diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 47de68c1a35..7cc72c6c1ea 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -4723,7 +4723,7 @@ ScalarEvolution::createAddRecFromPHIWithCastsImpl(const SCEVUnknown *SymbolicPHI const SCEV *StartExtended = getExtendedExpr(StartVal, Signed); if (PredIsKnownFalse(StartVal, StartExtended)) { - DEBUG(dbgs() << "P2 is compile-time false\n";); + LLVM_DEBUG(dbgs() << "P2 is compile-time false\n";); return None; } @@ -4731,7 +4731,7 @@ ScalarEvolution::createAddRecFromPHIWithCastsImpl(const SCEVUnknown *SymbolicPHI // NSSW or NUSW) const SCEV *AccumExtended = getExtendedExpr(Accum, /*CreateSignExtend=*/true); if (PredIsKnownFalse(Accum, AccumExtended)) { - DEBUG(dbgs() << "P3 is compile-time false\n";); + LLVM_DEBUG(dbgs() << "P3 is compile-time false\n";); return None; } @@ -4740,7 +4740,7 @@ ScalarEvolution::createAddRecFromPHIWithCastsImpl(const SCEVUnknown *SymbolicPHI if (Expr != ExtendedExpr && !isKnownPredicate(ICmpInst::ICMP_EQ, Expr, ExtendedExpr)) { const SCEVPredicate *Pred = getEqualPredicate(Expr, ExtendedExpr); - DEBUG (dbgs() << "Added Predicate: " << *Pred); + LLVM_DEBUG(dbgs() << "Added Predicate: " << *Pred); Predicates.push_back(Pred); } }; @@ -10633,22 +10633,22 @@ void ScalarEvolution::collectParametricTerms(const SCEV *Expr, SCEVCollectStrides StrideCollector(*this, Strides); visitAll(Expr, StrideCollector); - DEBUG({ - dbgs() << "Strides:\n"; - for (const SCEV *S : Strides) - dbgs() << *S << "\n"; - }); + LLVM_DEBUG({ + dbgs() << "Strides:\n"; + for (const SCEV *S : Strides) + dbgs() << *S << "\n"; + }); for (const SCEV *S : Strides) { SCEVCollectTerms TermCollector(Terms); visitAll(S, TermCollector); } - DEBUG({ - dbgs() << "Terms:\n"; - for (const SCEV *T : Terms) - dbgs() << *T << "\n"; - }); + LLVM_DEBUG({ + dbgs() << "Terms:\n"; + for (const SCEV *T : Terms) + dbgs() << *T << "\n"; + }); SCEVCollectAddRecMultiplies MulCollector(Terms, *this); visitAll(Expr, MulCollector); @@ -10759,11 +10759,11 @@ void ScalarEvolution::findArrayDimensions(SmallVectorImpl<const SCEV *> &Terms, if (!containsParameters(Terms)) return; - DEBUG({ - dbgs() << "Terms:\n"; - for (const SCEV *T : Terms) - dbgs() << *T << "\n"; - }); + LLVM_DEBUG({ + dbgs() << "Terms:\n"; + for (const SCEV *T : Terms) + dbgs() << *T << "\n"; + }); // Remove duplicates. array_pod_sort(Terms.begin(), Terms.end()); @@ -10790,11 +10790,11 @@ void ScalarEvolution::findArrayDimensions(SmallVectorImpl<const SCEV *> &Terms, if (const SCEV *NewT = removeConstantFactors(*this, T)) NewTerms.push_back(NewT); - DEBUG({ - dbgs() << "Terms after sorting:\n"; - for (const SCEV *T : NewTerms) - dbgs() << *T << "\n"; - }); + LLVM_DEBUG({ + dbgs() << "Terms after sorting:\n"; + for (const SCEV *T : NewTerms) + dbgs() << *T << "\n"; + }); if (NewTerms.empty() || !findArrayDimensionsRec(*this, NewTerms, Sizes)) { Sizes.clear(); @@ -10804,11 +10804,11 @@ void ScalarEvolution::findArrayDimensions(SmallVectorImpl<const SCEV *> &Terms, // The last element to be pushed into Sizes is the size of an element. Sizes.push_back(ElementSize); - DEBUG({ - dbgs() << "Sizes:\n"; - for (const SCEV *S : Sizes) - dbgs() << *S << "\n"; - }); + LLVM_DEBUG({ + dbgs() << "Sizes:\n"; + for (const SCEV *S : Sizes) + dbgs() << *S << "\n"; + }); } void ScalarEvolution::computeAccessFunctions( @@ -10828,13 +10828,13 @@ void ScalarEvolution::computeAccessFunctions( const SCEV *Q, *R; SCEVDivision::divide(*this, Res, Sizes[i], &Q, &R); - DEBUG({ - dbgs() << "Res: " << *Res << "\n"; - dbgs() << "Sizes[i]: " << *Sizes[i] << "\n"; - dbgs() << "Res divided by Sizes[i]:\n"; - dbgs() << "Quotient: " << *Q << "\n"; - dbgs() << "Remainder: " << *R << "\n"; - }); + LLVM_DEBUG({ + dbgs() << "Res: " << *Res << "\n"; + dbgs() << "Sizes[i]: " << *Sizes[i] << "\n"; + dbgs() << "Res divided by Sizes[i]:\n"; + dbgs() << "Quotient: " << *Q << "\n"; + dbgs() << "Remainder: " << *R << "\n"; + }); Res = Q; @@ -10862,11 +10862,11 @@ void ScalarEvolution::computeAccessFunctions( std::reverse(Subscripts.begin(), Subscripts.end()); - DEBUG({ - dbgs() << "Subscripts:\n"; - for (const SCEV *S : Subscripts) - dbgs() << *S << "\n"; - }); + LLVM_DEBUG({ + dbgs() << "Subscripts:\n"; + for (const SCEV *S : Subscripts) + dbgs() << *S << "\n"; + }); } /// Splits the SCEV into two vectors of SCEVs representing the subscripts and @@ -10940,17 +10940,17 @@ void ScalarEvolution::delinearize(const SCEV *Expr, if (Subscripts.empty()) return; - DEBUG({ - dbgs() << "succeeded to delinearize " << *Expr << "\n"; - dbgs() << "ArrayDecl[UnknownSize]"; - for (const SCEV *S : Sizes) - dbgs() << "[" << *S << "]"; + LLVM_DEBUG({ + dbgs() << "succeeded to delinearize " << *Expr << "\n"; + dbgs() << "ArrayDecl[UnknownSize]"; + for (const SCEV *S : Sizes) + dbgs() << "[" << *S << "]"; - dbgs() << "\nArrayRef"; - for (const SCEV *S : Subscripts) - dbgs() << "[" << *S << "]"; - dbgs() << "\n"; - }); + dbgs() << "\nArrayRef"; + for (const SCEV *S : Subscripts) + dbgs() << "[" << *S << "]"; + dbgs() << "\n"; + }); } //===----------------------------------------------------------------------===// |