Index: docs/Bugpoint.rst =================================================================== --- docs/Bugpoint.rst +++ docs/Bugpoint.rst @@ -198,14 +198,14 @@ static int calledCount = 0; calledCount++; - DEBUG(if (calledCount < 212) return false); - DEBUG(if (calledCount > 217) return false); - DEBUG(if (calledCount == 213) return false); - DEBUG(if (calledCount == 214) return false); - DEBUG(if (calledCount == 215) return false); - DEBUG(if (calledCount == 216) return false); - DEBUG(dbgs() << "visitXOR calledCount: " << calledCount << "\n"); - DEBUG(dbgs() << "I: "; I->dump()); + LLVM_DEBUG(if (calledCount < 212) return false); + LLVM_DEBUG(if (calledCount > 217) return false); + LLVM_DEBUG(if (calledCount == 213) return false); + LLVM_DEBUG(if (calledCount == 214) return false); + LLVM_DEBUG(if (calledCount == 215) return false); + LLVM_DEBUG(if (calledCount == 216) return false); + LLVM_DEBUG(dbgs() << "visitXOR calledCount: " << calledCount << "\n"); + LLVM_DEBUG(dbgs() << "I: "; I->dump()); could be added to ``visitXOR`` to limit ``visitXor`` to being applied only to calls 212 and 217. This is from an actual test case and raises an important Index: docs/CommandGuide/opt.rst =================================================================== --- docs/CommandGuide/opt.rst +++ docs/CommandGuide/opt.rst @@ -96,7 +96,7 @@ .. option:: -debug If this is a debug build, this option will enable debug printouts from passes - which use the ``DEBUG()`` macro. See the `LLVM Programmer's Manual + which use the ``LLVM_DEBUG()`` macro. See the `LLVM Programmer's Manual <../ProgrammersManual.html>`_, section ``#DEBUG`` for more information. .. option:: -load= Index: docs/CommandLine.rst =================================================================== --- docs/CommandLine.rst +++ docs/CommandLine.rst @@ -886,12 +886,12 @@ // debug build, then the code specified as the option to the macro will be // executed. Otherwise it will not be. #ifdef NDEBUG - #define DEBUG(X) + #define LLVM_DEBUG(X) #else - #define DEBUG(X) do { if (DebugFlag) { X; } } while (0) + #define LLVM_DEBUG(X) do { if (DebugFlag) { X; } } while (0) #endif -This allows clients to blissfully use the ``DEBUG()`` macro, or the +This allows clients to blissfully use the ``LLVM_DEBUG()`` macro, or the ``DebugFlag`` explicitly if they want to. Now we just need to be able to set the ``DebugFlag`` boolean when the option is set. To do this, we pass an additional argument to our command line argument processor, and we specify where Index: docs/ProgrammersManual.rst =================================================================== --- docs/ProgrammersManual.rst +++ docs/ProgrammersManual.rst @@ -1020,7 +1020,7 @@ .. _DEBUG: -The ``DEBUG()`` macro and ``-debug`` option +The ``LLVM_DEBUG()`` macro and ``-debug`` option ------------------------------------------- Often when working on your pass you will put a bunch of debugging printouts and @@ -1033,14 +1033,14 @@ The ``llvm/Support/Debug.h`` (`doxygen `__) file provides a macro named -``DEBUG()`` that is a much nicer solution to this problem. Basically, you can +``LLVM_DEBUG()`` that is a much nicer solution to this problem. Basically, you can put arbitrary code into the argument of the ``DEBUG`` macro, and it is only executed if '``opt``' (or any other tool) is run with the '``-debug``' command line argument: .. code-block:: c++ - DEBUG(dbgs() << "I am here!\n"); + LLVM_DEBUG(dbgs() << "I am here!\n"); Then you can run your pass like this: @@ -1051,13 +1051,13 @@ $ opt < a.bc > /dev/null -mypass -debug I am here! -Using the ``DEBUG()`` macro instead of a home-brewed solution allows you to not +Using the ``LLVM_DEBUG()`` macro instead of a home-brewed solution allows you to not have to create "yet another" command line option for the debug output for your -pass. Note that ``DEBUG()`` macros are disabled for non-asserts builds, so they +pass. Note that ``LLVM_DEBUG()`` macros are disabled for non-asserts builds, so they do not cause a performance impact at all (for the same reason, they should also not contain side-effects!). -One additional nice thing about the ``DEBUG()`` macro is that you can enable or +One additional nice thing about the ``LLVM_DEBUG()`` macro is that you can enable or disable it directly in gdb. Just use "``set DebugFlag=0``" or "``set DebugFlag=1``" from the gdb if the program is running. If the program hasn't been started yet, you can always just run it with ``-debug``. @@ -1076,10 +1076,10 @@ .. code-block:: c++ #define DEBUG_TYPE "foo" - DEBUG(dbgs() << "'foo' debug type\n"); + LLVM_DEBUG(dbgs() << "'foo' debug type\n"); #undef DEBUG_TYPE #define DEBUG_TYPE "bar" - DEBUG(dbgs() << "'bar' debug type\n"); + LLVM_DEBUG(dbgs() << "'bar' debug type\n"); #undef DEBUG_TYPE Then you can run your pass like this: Index: include/llvm/Analysis/BlockFrequencyInfoImpl.h =================================================================== --- include/llvm/Analysis/BlockFrequencyInfoImpl.h +++ include/llvm/Analysis/BlockFrequencyInfoImpl.h @@ -1030,7 +1030,7 @@ Nodes.clear(); // Initialize. - DEBUG(dbgs() << "\nblock-frequency: " << F.getName() << "\n=================" + LLVM_DEBUG(dbgs() << "\nblock-frequency: " << F.getName() << "\n=================" << std::string(F.getName().size(), '=') << "\n"); initializeRPOT(); initializeLoops(); @@ -1067,10 +1067,10 @@ assert(RPOT.size() - 1 <= BlockNode::getMaxIndex() && "More nodes in function than Block Frequency Info supports"); - DEBUG(dbgs() << "reverse-post-order-traversal\n"); + LLVM_DEBUG(dbgs() << "reverse-post-order-traversal\n"); for (rpot_iterator I = rpot_begin(), E = rpot_end(); I != E; ++I) { BlockNode Node = getNode(I); - DEBUG(dbgs() << " - " << getIndex(I) << ": " << getBlockName(Node) << "\n"); + LLVM_DEBUG(dbgs() << " - " << getIndex(I) << ": " << getBlockName(Node) << "\n"); Nodes[*I] = Node; } @@ -1081,7 +1081,7 @@ } template void BlockFrequencyInfoImpl::initializeLoops() { - DEBUG(dbgs() << "loop-detection\n"); + LLVM_DEBUG(dbgs() << "loop-detection\n"); if (LI->empty()) return; @@ -1099,7 +1099,7 @@ Loops.emplace_back(Parent, Header); Working[Header.Index].Loop = &Loops.back(); - DEBUG(dbgs() << " - loop = " << getBlockName(Header) << "\n"); + LLVM_DEBUG(dbgs() << " - loop = " << getBlockName(Header) << "\n"); for (const LoopT *L : *Loop) Q.emplace_back(L, &Loops.back()); @@ -1128,7 +1128,7 @@ Working[Index].Loop = HeaderData.Loop; HeaderData.Loop->Nodes.push_back(Index); - DEBUG(dbgs() << " - loop = " << getBlockName(Header) + LLVM_DEBUG(dbgs() << " - loop = " << getBlockName(Header) << ": member = " << getBlockName(Index) << "\n"); } } @@ -1150,10 +1150,10 @@ template bool BlockFrequencyInfoImpl::computeMassInLoop(LoopData &Loop) { // Compute mass in loop. - DEBUG(dbgs() << "compute-mass-in-loop: " << getLoopName(Loop) << "\n"); + LLVM_DEBUG(dbgs() << "compute-mass-in-loop: " << getLoopName(Loop) << "\n"); if (Loop.isIrreducible()) { - DEBUG(dbgs() << "isIrreducible = true\n"); + LLVM_DEBUG(dbgs() << "isIrreducible = true\n"); Distribution Dist; unsigned NumHeadersWithWeight = 0; Optional MinHeaderWeight; @@ -1165,12 +1165,12 @@ IsIrrLoopHeader.set(Loop.Nodes[H].Index); Optional HeaderWeight = Block->getIrrLoopHeaderWeight(); if (!HeaderWeight) { - DEBUG(dbgs() << "Missing irr loop header metadata on " + LLVM_DEBUG(dbgs() << "Missing irr loop header metadata on " << getBlockName(HeaderNode) << "\n"); HeadersWithoutWeight.insert(H); continue; } - DEBUG(dbgs() << getBlockName(HeaderNode) + LLVM_DEBUG(dbgs() << getBlockName(HeaderNode) << " has irr loop header weight " << HeaderWeight.getValue() << "\n"); NumHeadersWithWeight++; @@ -1194,7 +1194,7 @@ assert(!getBlock(HeaderNode)->getIrrLoopHeaderWeight() && "Shouldn't have a weight metadata"); uint64_t MinWeight = MinHeaderWeight.getValue(); - DEBUG(dbgs() << "Giving weight " << MinWeight + LLVM_DEBUG(dbgs() << "Giving weight " << MinWeight << " to " << getBlockName(HeaderNode) << "\n"); if (MinWeight) Dist.addLocal(HeaderNode, MinWeight); @@ -1224,7 +1224,7 @@ template bool BlockFrequencyInfoImpl::tryToComputeMassInFunction() { // Compute mass in function. - DEBUG(dbgs() << "compute-mass-in-function\n"); + LLVM_DEBUG(dbgs() << "compute-mass-in-function\n"); assert(!Working.empty() && "no blocks in function"); assert(!Working[0].isLoopHeader() && "entry block is a loop header"); @@ -1276,7 +1276,7 @@ template void BlockFrequencyInfoImpl::computeIrreducibleMass( LoopData *OuterLoop, std::list::iterator Insert) { - DEBUG(dbgs() << "analyze-irreducible-in-"; + LLVM_DEBUG(dbgs() << "analyze-irreducible-in-"; if (OuterLoop) dbgs() << "loop: " << getLoopName(*OuterLoop) << "\n"; else dbgs() << "function\n"); @@ -1304,7 +1304,7 @@ bool BlockFrequencyInfoImpl::propagateMassToSuccessors(LoopData *OuterLoop, const BlockNode &Node) { - DEBUG(dbgs() << " - node: " << getBlockName(Node) << "\n"); + LLVM_DEBUG(dbgs() << " - node: " << getBlockName(Node) << "\n"); // Calculate probability for successors. Distribution Dist; if (auto *Loop = Working[Node.Index].getPackagedLoop()) { Index: include/llvm/Analysis/CGSCCPassManager.h =================================================================== --- include/llvm/Analysis/CGSCCPassManager.h +++ include/llvm/Analysis/CGSCCPassManager.h @@ -387,14 +387,14 @@ do { LazyCallGraph::RefSCC *RC = RCWorklist.pop_back_val(); if (InvalidRefSCCSet.count(RC)) { - DEBUG(dbgs() << "Skipping an invalid RefSCC...\n"); + LLVM_DEBUG(dbgs() << "Skipping an invalid RefSCC...\n"); continue; } assert(CWorklist.empty() && "Should always start with an empty SCC worklist"); - DEBUG(dbgs() << "Running an SCC pass across the RefSCC: " << *RC + LLVM_DEBUG(dbgs() << "Running an SCC pass across the RefSCC: " << *RC << "\n"); // Push the initial SCCs in reverse post-order as we'll pop off the @@ -409,11 +409,11 @@ // other RefSCCs should be queued above, so we just need to skip both // scenarios here. if (InvalidSCCSet.count(C)) { - DEBUG(dbgs() << "Skipping an invalid SCC...\n"); + LLVM_DEBUG(dbgs() << "Skipping an invalid SCC...\n"); continue; } if (&C->getOuterRefSCC() != RC) { - DEBUG(dbgs() << "Skipping an SCC that is now part of some other " + LLVM_DEBUG(dbgs() << "Skipping an SCC that is now part of some other " "RefSCC...\n"); continue; } @@ -436,7 +436,7 @@ // 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. @@ -464,7 +464,7 @@ // FIXME: If we ever start having RefSCC passes, we'll want to // iterate there too. if (UR.UpdatedC) - DEBUG(dbgs() << "Re-running SCC passes after a refinement of the " + LLVM_DEBUG(dbgs() << "Re-running SCC passes after a refinement of the " "current SCC: " << *UR.UpdatedC << "\n"); @@ -601,7 +601,7 @@ // a pointer we can overwrite. LazyCallGraph::SCC *CurrentC = &C; - DEBUG(dbgs() << "Running function passes across an SCC: " << C << "\n"); + LLVM_DEBUG(dbgs() << "Running function passes across an SCC: " << C << "\n"); PreservedAnalyses PA = PreservedAnalyses::all(); for (LazyCallGraph::Node *N : Nodes) { @@ -757,7 +757,7 @@ if (!F) return false; - DEBUG(dbgs() << "Found devirutalized call from " + LLVM_DEBUG(dbgs() << "Found devirutalized call from " << CS.getParent()->getParent()->getName() << " to " << F->getName() << "\n"); @@ -793,14 +793,14 @@ // Otherwise, if we've already hit our max, we're done. if (Iteration >= MaxIterations) { - DEBUG(dbgs() << "Found another devirtualization after hitting the max " + LLVM_DEBUG(dbgs() << "Found another devirtualization after hitting the max " "number of repetitions (" << MaxIterations << ") on SCC: " << *C << "\n"); PA.intersect(std::move(PassPA)); break; } - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "Repeating an SCC pass after finding a devirtualization in: " << *C << "\n"); Index: include/llvm/Analysis/RegionInfoImpl.h =================================================================== --- include/llvm/Analysis/RegionInfoImpl.h +++ include/llvm/Analysis/RegionInfoImpl.h @@ -674,7 +674,7 @@ #ifdef EXPENSIVE_CHECKS region->verifyRegion(); #else - DEBUG(region->verifyRegion()); + LLVM_DEBUG(region->verifyRegion()); #endif updateStatistics(region); Index: include/llvm/Analysis/SparsePropagation.h =================================================================== --- include/llvm/Analysis/SparsePropagation.h +++ include/llvm/Analysis/SparsePropagation.h @@ -260,7 +260,7 @@ BasicBlock *BB) { if (!BBExecutable.insert(BB).second) return; - DEBUG(dbgs() << "Marking Block Executable: " << BB->getName() << "\n"); + LLVM_DEBUG(dbgs() << "Marking Block Executable: " << BB->getName() << "\n"); BBWorkList.push_back(BB); // Add the block to the work list! } @@ -270,7 +270,7 @@ if (!KnownFeasibleEdges.insert(Edge(Source, Dest)).second) return; // This edge is already known to be executable! - DEBUG(dbgs() << "Marking Edge Executable: " << Source->getName() << " -> " + LLVM_DEBUG(dbgs() << "Marking Edge Executable: " << Source->getName() << " -> " << Dest->getName() << "\n"); if (BBExecutable.count(Dest)) { @@ -477,7 +477,7 @@ Value *V = ValueWorkList.back(); ValueWorkList.pop_back(); - DEBUG(dbgs() << "\nPopped off V-WL: " << *V << "\n"); + LLVM_DEBUG(dbgs() << "\nPopped off V-WL: " << *V << "\n"); // "V" got into the work list because it made a transition. See if any // users are both live and in need of updating. @@ -492,7 +492,7 @@ BasicBlock *BB = BBWorkList.back(); BBWorkList.pop_back(); - DEBUG(dbgs() << "\nPopped off BBWL: " << *BB); + LLVM_DEBUG(dbgs() << "\nPopped off BBWL: " << *BB); // Notify all instructions in this basic block that they are newly // executable. Index: include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h =================================================================== --- include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h +++ include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h @@ -38,7 +38,7 @@ return false; if (MachineInstr *DefMI = getOpcodeDef(TargetOpcode::G_TRUNC, MI.getOperand(1).getReg(), MRI)) { - DEBUG(dbgs() << ".. Combine MI: " << MI;); + LLVM_DEBUG(dbgs() << ".. Combine MI: " << MI;); unsigned DstReg = MI.getOperand(0).getReg(); unsigned SrcReg = DefMI->getOperand(1).getReg(); Builder.setInstr(MI); @@ -62,7 +62,7 @@ if (isInstUnsupported({TargetOpcode::G_AND, {DstTy}}) || isInstUnsupported({TargetOpcode::G_CONSTANT, {DstTy}})) return false; - DEBUG(dbgs() << ".. Combine MI: " << MI;); + LLVM_DEBUG(dbgs() << ".. Combine MI: " << MI;); Builder.setInstr(MI); unsigned ZExtSrc = MI.getOperand(1).getReg(); LLT ZExtSrcTy = MRI.getType(ZExtSrc); @@ -91,7 +91,7 @@ isInstUnsupported({TargetOpcode::G_ASHR, {DstTy}}) || isInstUnsupported({TargetOpcode::G_CONSTANT, {DstTy}})) return false; - DEBUG(dbgs() << ".. Combine MI: " << MI;); + LLVM_DEBUG(dbgs() << ".. Combine MI: " << MI;); Builder.setInstr(MI); unsigned SExtSrc = MI.getOperand(1).getReg(); LLT SExtSrcTy = MRI.getType(SExtSrc); @@ -123,7 +123,7 @@ LLT DstTy = MRI.getType(DstReg); if (isInstUnsupported({TargetOpcode::G_IMPLICIT_DEF, {DstTy}})) return false; - DEBUG(dbgs() << ".. Combine EXT(IMPLICIT_DEF) " << MI;); + LLVM_DEBUG(dbgs() << ".. Combine EXT(IMPLICIT_DEF) " << MI;); Builder.setInstr(MI); Builder.buildInstr(TargetOpcode::G_IMPLICIT_DEF, DstReg); markInstAndDefDead(MI, *DefMI, DeadInsts); Index: include/llvm/DebugInfo/PDB/DIA/DIASupport.h =================================================================== --- include/llvm/DebugInfo/PDB/DIA/DIASupport.h +++ include/llvm/DebugInfo/PDB/DIA/DIASupport.h @@ -28,7 +28,7 @@ // something less generic than DEBUG, such as LLVM_DEBUG(), but it's // fairly prevalent. So for now, we save the definition state and // restore it. -#pragma push_macro("DEBUG") +#pragma push_macro("LLVM_DEBUG") // atlbase.h has to come before windows.h #include @@ -39,6 +39,6 @@ #include #include -#pragma pop_macro("DEBUG") +#pragma pop_macro("LLVM_DEBUG") #endif // LLVM_DEBUGINFO_PDB_DIA_DIASUPPORT_H Index: include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h =================================================================== --- include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h +++ include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h @@ -63,7 +63,7 @@ public: ~RemoteRTDyldMemoryManager() { Client.destroyRemoteAllocator(Id); - DEBUG(dbgs() << "Destroyed remote allocator " << Id << "\n"); + LLVM_DEBUG(dbgs() << "Destroyed remote allocator " << Id << "\n"); } RemoteRTDyldMemoryManager(const RemoteRTDyldMemoryManager &) = delete; @@ -79,7 +79,7 @@ Unmapped.back().CodeAllocs.emplace_back(Size, Alignment); uint8_t *Alloc = reinterpret_cast( Unmapped.back().CodeAllocs.back().getLocalAddress()); - DEBUG(dbgs() << "Allocator " << Id << " allocated code for " + LLVM_DEBUG(dbgs() << "Allocator " << Id << " allocated code for " << SectionName << ": " << Alloc << " (" << Size << " bytes, alignment " << Alignment << ")\n"); return Alloc; @@ -92,7 +92,7 @@ Unmapped.back().RODataAllocs.emplace_back(Size, Alignment); uint8_t *Alloc = reinterpret_cast( Unmapped.back().RODataAllocs.back().getLocalAddress()); - DEBUG(dbgs() << "Allocator " << Id << " allocated ro-data for " + LLVM_DEBUG(dbgs() << "Allocator " << Id << " allocated ro-data for " << SectionName << ": " << Alloc << " (" << Size << " bytes, alignment " << Alignment << ")\n"); return Alloc; @@ -101,7 +101,7 @@ Unmapped.back().RWDataAllocs.emplace_back(Size, Alignment); uint8_t *Alloc = reinterpret_cast( Unmapped.back().RWDataAllocs.back().getLocalAddress()); - DEBUG(dbgs() << "Allocator " << Id << " allocated rw-data for " + LLVM_DEBUG(dbgs() << "Allocator " << Id << " allocated rw-data for " << SectionName << ": " << Alloc << " (" << Size << " bytes, alignment " << Alignment << ")\n"); return Alloc; @@ -113,13 +113,13 @@ uint32_t RWDataAlign) override { Unmapped.push_back(ObjectAllocs()); - DEBUG(dbgs() << "Allocator " << Id << " reserved:\n"); + LLVM_DEBUG(dbgs() << "Allocator " << Id << " reserved:\n"); if (CodeSize != 0) { Unmapped.back().RemoteCodeAddr = Client.reserveMem(Id, CodeSize, CodeAlign); - DEBUG(dbgs() << " code: " + LLVM_DEBUG(dbgs() << " code: " << format("0x%016x", Unmapped.back().RemoteCodeAddr) << " (" << CodeSize << " bytes, alignment " << CodeAlign << ")\n"); @@ -129,7 +129,7 @@ Unmapped.back().RemoteRODataAddr = Client.reserveMem(Id, RODataSize, RODataAlign); - DEBUG(dbgs() << " ro-data: " + LLVM_DEBUG(dbgs() << " ro-data: " << format("0x%016x", Unmapped.back().RemoteRODataAddr) << " (" << RODataSize << " bytes, alignment " << RODataAlign << ")\n"); @@ -139,7 +139,7 @@ Unmapped.back().RemoteRWDataAddr = Client.reserveMem(Id, RWDataSize, RWDataAlign); - DEBUG(dbgs() << " rw-data: " + LLVM_DEBUG(dbgs() << " rw-data: " << format("0x%016x", Unmapped.back().RemoteRWDataAddr) << " (" << RWDataSize << " bytes, alignment " << RWDataAlign << ")\n"); @@ -162,7 +162,7 @@ void notifyObjectLoaded(RuntimeDyld &Dyld, const object::ObjectFile &Obj) override { - DEBUG(dbgs() << "Allocator " << Id << " applied mappings:\n"); + LLVM_DEBUG(dbgs() << "Allocator " << Id << " applied mappings:\n"); for (auto &ObjAllocs : Unmapped) { mapAllocsToRemoteAddrs(Dyld, ObjAllocs.CodeAllocs, ObjAllocs.RemoteCodeAddr); @@ -176,7 +176,7 @@ } bool finalizeMemory(std::string *ErrMsg = nullptr) override { - DEBUG(dbgs() << "Allocator " << Id << " finalizing:\n"); + LLVM_DEBUG(dbgs() << "Allocator " << Id << " finalizing:\n"); for (auto &ObjAllocs : Unfinalized) { if (copyAndProtect(ObjAllocs.CodeAllocs, ObjAllocs.RemoteCodeAddr, @@ -261,7 +261,7 @@ RemoteRTDyldMemoryManager(OrcRemoteTargetClient &Client, ResourceIdMgr::ResourceId Id) : Client(Client), Id(Id) { - DEBUG(dbgs() << "Created remote allocator " << Id << "\n"); + LLVM_DEBUG(dbgs() << "Created remote allocator " << Id << "\n"); } // Maps all allocations in Allocs to aligned blocks @@ -270,7 +270,7 @@ for (auto &Alloc : Allocs) { NextAddr = alignTo(NextAddr, Alloc.getAlign()); Dyld.mapSectionAddress(Alloc.getLocalAddress(), NextAddr); - DEBUG(dbgs() << " " << static_cast(Alloc.getLocalAddress()) + LLVM_DEBUG(dbgs() << " " << static_cast(Alloc.getLocalAddress()) << " -> " << format("0x%016x", NextAddr) << "\n"); Alloc.setRemoteAddress(NextAddr); @@ -290,7 +290,7 @@ assert(!Allocs.empty() && "No sections in allocated segment"); for (auto &Alloc : Allocs) { - DEBUG(dbgs() << " copying section: " + LLVM_DEBUG(dbgs() << " copying section: " << static_cast(Alloc.getLocalAddress()) << " -> " << format("0x%016x", Alloc.getRemoteAddress()) << " (" << Alloc.getSize() << " bytes)\n";); @@ -300,7 +300,7 @@ return true; } - DEBUG(dbgs() << " setting " + LLVM_DEBUG(dbgs() << " setting " << (Permissions & sys::Memory::MF_READ ? 'R' : '-') << (Permissions & sys::Memory::MF_WRITE ? 'W' : '-') << (Permissions & sys::Memory::MF_EXEC ? 'X' : '-') @@ -487,7 +487,7 @@ /// Call the int(void) function at the given address in the target and return /// its result. Expected callIntVoid(JITTargetAddress Addr) { - DEBUG(dbgs() << "Calling int(*)(void) " << format("0x%016x", Addr) << "\n"); + LLVM_DEBUG(dbgs() << "Calling int(*)(void) " << format("0x%016x", Addr) << "\n"); return callB(Addr); } @@ -495,7 +495,7 @@ /// return its result. Expected callMain(JITTargetAddress Addr, const std::vector &Args) { - DEBUG(dbgs() << "Calling int(*)(int, char*[]) " << format("0x%016x", Addr) + LLVM_DEBUG(dbgs() << "Calling int(*)(int, char*[]) " << format("0x%016x", Addr) << "\n"); return callB(Addr, Args); } @@ -503,7 +503,7 @@ /// Call the void() function at the given address in the target and wait for /// it to finish. Error callVoidVoid(JITTargetAddress Addr) { - DEBUG(dbgs() << "Calling void(*)(void) " << format("0x%016x", Addr) + LLVM_DEBUG(dbgs() << "Calling void(*)(void) " << format("0x%016x", Addr) << "\n"); return callB(Addr); } Index: include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h =================================================================== --- include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h +++ include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h @@ -161,9 +161,9 @@ IntVoidFnTy Fn = reinterpret_cast(static_cast(Addr)); - DEBUG(dbgs() << " Calling " << format("0x%016x", Addr) << "\n"); + LLVM_DEBUG(dbgs() << " Calling " << format("0x%016x", Addr) << "\n"); int Result = Fn(); - DEBUG(dbgs() << " Result = " << Result << "\n"); + LLVM_DEBUG(dbgs() << " Result = " << Result << "\n"); return Result; } @@ -180,15 +180,15 @@ for (auto &Arg : Args) ArgV[Idx++] = Arg.c_str(); ArgV[ArgC] = 0; - DEBUG( + LLVM_DEBUG( for (int Idx = 0; Idx < ArgC; ++Idx) { llvm::dbgs() << "Arg " << Idx << ": " << ArgV[Idx] << "\n"; } ); - DEBUG(dbgs() << " Calling " << format("0x%016x", Addr) << "\n"); + LLVM_DEBUG(dbgs() << " Calling " << format("0x%016x", Addr) << "\n"); int Result = Fn(ArgC, ArgV.get()); - DEBUG(dbgs() << " Result = " << Result << "\n"); + LLVM_DEBUG(dbgs() << " Result = " << Result << "\n"); return Result; } @@ -199,9 +199,9 @@ VoidVoidFnTy Fn = reinterpret_cast(static_cast(Addr)); - DEBUG(dbgs() << " Calling " << format("0x%016x", Addr) << "\n"); + LLVM_DEBUG(dbgs() << " Calling " << format("0x%016x", Addr) << "\n"); Fn(); - DEBUG(dbgs() << " Complete.\n"); + LLVM_DEBUG(dbgs() << " Complete.\n"); return Error::success(); } @@ -211,7 +211,7 @@ if (I != Allocators.end()) return errorCodeToError( orcError(OrcErrorCode::RemoteAllocatorIdAlreadyInUse)); - DEBUG(dbgs() << " Created allocator " << Id << "\n"); + LLVM_DEBUG(dbgs() << " Created allocator " << Id << "\n"); Allocators[Id] = Allocator(); return Error::success(); } @@ -221,14 +221,14 @@ if (I != IndirectStubsOwners.end()) return errorCodeToError( orcError(OrcErrorCode::RemoteIndirectStubsOwnerIdAlreadyInUse)); - DEBUG(dbgs() << " Create indirect stubs owner " << Id << "\n"); + LLVM_DEBUG(dbgs() << " Create indirect stubs owner " << Id << "\n"); IndirectStubsOwners[Id] = ISBlockOwnerList(); return Error::success(); } Error handleDeregisterEHFrames(JITTargetAddress TAddr, uint32_t Size) { uint8_t *Addr = reinterpret_cast(static_cast(TAddr)); - DEBUG(dbgs() << " Registering EH frames at " << format("0x%016x", TAddr) + LLVM_DEBUG(dbgs() << " Registering EH frames at " << format("0x%016x", TAddr) << ", Size = " << Size << " bytes\n"); EHFramesDeregister(Addr, Size); return Error::success(); @@ -240,7 +240,7 @@ return errorCodeToError( orcError(OrcErrorCode::RemoteAllocatorDoesNotExist)); Allocators.erase(I); - DEBUG(dbgs() << " Destroyed allocator " << Id << "\n"); + LLVM_DEBUG(dbgs() << " Destroyed allocator " << Id << "\n"); return Error::success(); } @@ -256,7 +256,7 @@ Expected> handleEmitIndirectStubs(ResourceIdMgr::ResourceId Id, uint32_t NumStubsRequired) { - DEBUG(dbgs() << " ISMgr " << Id << " request " << NumStubsRequired + LLVM_DEBUG(dbgs() << " ISMgr " << Id << " request " << NumStubsRequired << " stubs.\n"); auto StubOwnerItr = IndirectStubsOwners.find(Id); @@ -328,7 +328,7 @@ Expected handleGetSymbolAddress(const std::string &Name) { JITTargetAddress Addr = SymbolLookup(Name); - DEBUG(dbgs() << " Symbol '" << Name << "' = " << format("0x%016x", Addr) + LLVM_DEBUG(dbgs() << " Symbol '" << Name << "' = " << format("0x%016x", Addr) << "\n"); return Addr; } @@ -340,7 +340,7 @@ uint32_t PageSize = sys::Process::getPageSize(); uint32_t TrampolineSize = TargetT::TrampolineSize; uint32_t IndirectStubSize = TargetT::IndirectStubsInfo::StubSize; - DEBUG(dbgs() << " Remote info:\n" + LLVM_DEBUG(dbgs() << " Remote info:\n" << " triple = '" << ProcessTriple << "'\n" << " pointer size = " << PointerSize << "\n" << " page size = " << PageSize << "\n" @@ -354,7 +354,7 @@ uint64_t Size) { uint8_t *Src = reinterpret_cast(static_cast(RSrc)); - DEBUG(dbgs() << " Reading " << Size << " bytes from " + LLVM_DEBUG(dbgs() << " Reading " << Size << " bytes from " << format("0x%016x", RSrc) << "\n"); std::vector Buffer; @@ -367,7 +367,7 @@ Error handleRegisterEHFrames(JITTargetAddress TAddr, uint32_t Size) { uint8_t *Addr = reinterpret_cast(static_cast(TAddr)); - DEBUG(dbgs() << " Registering EH frames at " << format("0x%016x", TAddr) + LLVM_DEBUG(dbgs() << " Registering EH frames at " << format("0x%016x", TAddr) << ", Size = " << Size << " bytes\n"); EHFramesRegister(Addr, Size); return Error::success(); @@ -384,7 +384,7 @@ if (auto Err = Allocator.allocate(LocalAllocAddr, Size, Align)) return std::move(Err); - DEBUG(dbgs() << " Allocator " << Id << " reserved " << LocalAllocAddr + LLVM_DEBUG(dbgs() << " Allocator " << Id << " reserved " << LocalAllocAddr << " (" << Size << " bytes, alignment " << Align << ")\n"); JITTargetAddress AllocAddr = static_cast( @@ -401,7 +401,7 @@ orcError(OrcErrorCode::RemoteAllocatorDoesNotExist)); auto &Allocator = I->second; void *LocalAddr = reinterpret_cast(static_cast(Addr)); - DEBUG(dbgs() << " Allocator " << Id << " set permissions on " << LocalAddr + LLVM_DEBUG(dbgs() << " Allocator " << Id << " set permissions on " << LocalAddr << " to " << (Flags & sys::Memory::MF_READ ? 'R' : '-') << (Flags & sys::Memory::MF_WRITE ? 'W' : '-') << (Flags & sys::Memory::MF_EXEC ? 'X' : '-') << "\n"); @@ -414,13 +414,13 @@ } Error handleWriteMem(DirectBufferWriter DBW) { - DEBUG(dbgs() << " Writing " << DBW.getSize() << " bytes to " + LLVM_DEBUG(dbgs() << " Writing " << DBW.getSize() << " bytes to " << format("0x%016x", DBW.getDst()) << "\n"); return Error::success(); } Error handleWritePtr(JITTargetAddress Addr, JITTargetAddress PtrVal) { - DEBUG(dbgs() << " Writing pointer *" << format("0x%016x", Addr) << " = " + LLVM_DEBUG(dbgs() << " Writing pointer *" << format("0x%016x", Addr) << " = " << format("0x%016x", PtrVal) << "\n"); uintptr_t *Ptr = reinterpret_cast(static_cast(Addr)); Index: include/llvm/Support/Debug.h =================================================================== --- include/llvm/Support/Debug.h +++ include/llvm/Support/Debug.h @@ -11,17 +11,17 @@ // code, without it being enabled all of the time, and without having to add // command line options to enable it. // -// In particular, just wrap your code with the DEBUG() macro, and it will be +// In particular, just wrap your code with the LLVM_DEBUG() macro, and it will be // enabled automatically if you specify '-debug' on the command-line. -// DEBUG() requires the DEBUG_TYPE macro to be defined. Set it to "foo" specify +// LLVM_DEBUG() requires the DEBUG_TYPE macro to be defined. Set it to "foo" specify // that your debug code belongs to class "foo". Be careful that you only do // this after including Debug.h and not around any #include of headers. Headers // should define and undef the macro acround the code that needs to use the -// DEBUG() macro. Then, on the command line, you can specify '-debug-only=foo' +// LLVM_DEBUG() macro. Then, on the command line, you can specify '-debug-only=foo' // to enable JUST the debug information for the foo class. // // When compiling without assertions, the -debug-* options and all code in -// DEBUG() statements disappears, so it does not affect the runtime of the code. +// LLVM_DEBUG() statements disappears, so it does not affect the runtime of the code. // //===----------------------------------------------------------------------===// @@ -113,9 +113,9 @@ // debug build, then the code specified as the option to the macro will be // executed. Otherwise it will not be. Example: // -// DEBUG(dbgs() << "Bitset contains: " << Bitset << "\n"); +// LLVM_DEBUG(dbgs() << "Bitset contains: " << Bitset << "\n"); // -#define DEBUG(X) DEBUG_WITH_TYPE(DEBUG_TYPE, X) +#define LLVM_DEBUG(X) DEBUG_WITH_TYPE(DEBUG_TYPE, X) } // end namespace llvm Index: include/llvm/Support/GenericDomTreeConstruction.h =================================================================== --- include/llvm/Support/GenericDomTreeConstruction.h +++ include/llvm/Support/GenericDomTreeConstruction.h @@ -146,14 +146,14 @@ assert(llvm::find(Res, Child) != Res.end() && "Expected child not found in the CFG"); Res.erase(std::remove(Res.begin(), Res.end(), Child), Res.end()); - DEBUG(dbgs() << "\tHiding edge " << BlockNamePrinter(N) << " -> " + LLVM_DEBUG(dbgs() << "\tHiding edge " << BlockNamePrinter(N) << " -> " << BlockNamePrinter(Child) << "\n"); } else { // If there's an deletion in the future, it means that the edge cannot // exist in the current CFG, but existed in it before. assert(llvm::find(Res, Child) == Res.end() && "Unexpected child found in the CFG"); - DEBUG(dbgs() << "\tShowing virtual edge " << BlockNamePrinter(N) + LLVM_DEBUG(dbgs() << "\tShowing virtual edge " << BlockNamePrinter(N) << " -> " << BlockNamePrinter(Child) << "\n"); Res.push_back(Child); } @@ -387,7 +387,7 @@ SNCA.addVirtualRoot(); unsigned Num = 1; - DEBUG(dbgs() << "\t\tLooking for trivial roots\n"); + LLVM_DEBUG(dbgs() << "\t\tLooking for trivial roots\n"); // Step #1: Find all the trivial roots that are going to will definitely // remain tree roots. @@ -404,14 +404,14 @@ Roots.push_back(N); // Run DFS not to walk this part of CFG later. Num = SNCA.runDFS(N, Num, AlwaysDescend, 1); - DEBUG(dbgs() << "Found a new trivial root: " << BlockNamePrinter(N) + LLVM_DEBUG(dbgs() << "Found a new trivial root: " << BlockNamePrinter(N) << "\n"); - DEBUG(dbgs() << "Last visited node: " + LLVM_DEBUG(dbgs() << "Last visited node: " << BlockNamePrinter(SNCA.NumToNode[Num]) << "\n"); } } - DEBUG(dbgs() << "\t\tLooking for non-trivial roots\n"); + LLVM_DEBUG(dbgs() << "\t\tLooking for non-trivial roots\n"); // Step #2: Find all non-trivial root candidates. Those are CFG nodes that // are reverse-unreachable were not visited by previous DFS walks (i.e. CFG @@ -431,7 +431,7 @@ SmallPtrSet ConnectToExitBlock; for (const NodePtr I : nodes(DT.Parent)) { if (SNCA.NodeToInfo.count(I) == 0) { - DEBUG(dbgs() << "\t\t\tVisiting node " << BlockNamePrinter(I) + LLVM_DEBUG(dbgs() << "\t\t\tVisiting node " << BlockNamePrinter(I) << "\n"); // Find the furthest away we can get by following successors, then // follow them in reverse. This gives us some reasonable answer about @@ -443,37 +443,37 @@ // the lowest and highest points in the infinite loop. In theory, it // would be nice to give the canonical backedge for the loop, but it's // expensive and does not always lead to a minimal set of roots. - DEBUG(dbgs() << "\t\t\tRunning forward DFS\n"); + LLVM_DEBUG(dbgs() << "\t\t\tRunning forward DFS\n"); const unsigned NewNum = SNCA.runDFS(I, Num, AlwaysDescend, Num); const NodePtr FurthestAway = SNCA.NumToNode[NewNum]; - DEBUG(dbgs() << "\t\t\tFound a new furthest away node " + LLVM_DEBUG(dbgs() << "\t\t\tFound a new furthest away node " << "(non-trivial root): " << BlockNamePrinter(FurthestAway) << "\n"); ConnectToExitBlock.insert(FurthestAway); Roots.push_back(FurthestAway); - DEBUG(dbgs() << "\t\t\tPrev DFSNum: " << Num << ", new DFSNum: " + LLVM_DEBUG(dbgs() << "\t\t\tPrev DFSNum: " << Num << ", new DFSNum: " << NewNum << "\n\t\t\tRemoving DFS info\n"); for (unsigned i = NewNum; i > Num; --i) { const NodePtr N = SNCA.NumToNode[i]; - DEBUG(dbgs() << "\t\t\t\tRemoving DFS info for " + LLVM_DEBUG(dbgs() << "\t\t\t\tRemoving DFS info for " << BlockNamePrinter(N) << "\n"); SNCA.NodeToInfo.erase(N); SNCA.NumToNode.pop_back(); } const unsigned PrevNum = Num; - DEBUG(dbgs() << "\t\t\tRunning reverse DFS\n"); + LLVM_DEBUG(dbgs() << "\t\t\tRunning reverse DFS\n"); Num = SNCA.runDFS(FurthestAway, Num, AlwaysDescend, 1); for (unsigned i = PrevNum + 1; i <= Num; ++i) - DEBUG(dbgs() << "\t\t\t\tfound node " + LLVM_DEBUG(dbgs() << "\t\t\t\tfound node " << BlockNamePrinter(SNCA.NumToNode[i]) << "\n"); } } } - DEBUG(dbgs() << "Total: " << Total << ", Num: " << Num << "\n"); - DEBUG(dbgs() << "Discovered CFG nodes:\n"); - DEBUG(for (size_t i = 0; i <= Num; ++i) dbgs() + LLVM_DEBUG(dbgs() << "Total: " << Total << ", Num: " << Num << "\n"); + LLVM_DEBUG(dbgs() << "Discovered CFG nodes:\n"); + LLVM_DEBUG(for (size_t i = 0; i <= Num; ++i) dbgs() << i << ": " << BlockNamePrinter(SNCA.NumToNode[i]) << "\n"); assert((Total + 1 == Num) && "Everything should have been visited"); @@ -481,9 +481,9 @@ // Step #3: If we found some non-trivial roots, make them non-redundant. if (HasNonTrivialRoots) RemoveRedundantRoots(DT, BUI, Roots); - DEBUG(dbgs() << "Found roots: "); - DEBUG(for (auto *Root : Roots) dbgs() << BlockNamePrinter(Root) << " "); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Found roots: "); + LLVM_DEBUG(for (auto *Root : Roots) dbgs() << BlockNamePrinter(Root) << " "); + LLVM_DEBUG(dbgs() << "\n"); return Roots; } @@ -499,7 +499,7 @@ static void RemoveRedundantRoots(const DomTreeT &DT, BatchUpdatePtr BUI, RootsT &Roots) { assert(IsPostDom && "This function is for postdominators only"); - DEBUG(dbgs() << "Removing redundant roots\n"); + LLVM_DEBUG(dbgs() << "Removing redundant roots\n"); SemiNCAInfo SNCA(BUI); @@ -507,7 +507,7 @@ auto &Root = Roots[i]; // Trivial roots are always non-redundant. if (!HasForwardSuccessors(Root, BUI)) continue; - DEBUG(dbgs() << "\tChecking if " << BlockNamePrinter(Root) + LLVM_DEBUG(dbgs() << "\tChecking if " << BlockNamePrinter(Root) << " remains a root\n"); SNCA.clear(); // Do a forward walk looking for the other roots. @@ -520,7 +520,7 @@ // root from the set of roots, as it is reverse-reachable from the other // one. if (llvm::find(Roots, N) != Roots.end()) { - DEBUG(dbgs() << "\tForward DFS walk found another root " + LLVM_DEBUG(dbgs() << "\tForward DFS walk found another root " << BlockNamePrinter(N) << "\n\tRemoving root " << BlockNamePrinter(Root) << "\n"); std::swap(Root, Roots.back()); @@ -563,7 +563,7 @@ SNCA.runSemiNCA(DT); if (BUI) { BUI->IsRecalculated = true; - DEBUG(dbgs() << "DomTree recalculated, skipping future batch updates\n"); + LLVM_DEBUG(dbgs() << "DomTree recalculated, skipping future batch updates\n"); } if (DT.Roots.empty()) return; @@ -585,7 +585,7 @@ // Loop over all of the discovered blocks in the function... for (size_t i = 1, e = NumToNode.size(); i != e; ++i) { NodePtr W = NumToNode[i]; - DEBUG(dbgs() << "\tdiscovered a new reachable node " + LLVM_DEBUG(dbgs() << "\tdiscovered a new reachable node " << BlockNamePrinter(W) << "\n"); // Don't replace this with 'count', the insertion side effect is important @@ -638,7 +638,7 @@ assert((From || IsPostDom) && "From has to be a valid CFG node or a virtual root"); assert(To && "Cannot be a nullptr"); - DEBUG(dbgs() << "Inserting edge " << BlockNamePrinter(From) << " -> " + LLVM_DEBUG(dbgs() << "Inserting edge " << BlockNamePrinter(From) << " -> " << BlockNamePrinter(To) << "\n"); TreeNodePtr FromTN = DT.getNode(From); @@ -678,7 +678,7 @@ if (RIt == DT.Roots.end()) return false; // To is not a root, nothing to update. - DEBUG(dbgs() << "\t\tAfter the insertion, " << BlockNamePrinter(To) + LLVM_DEBUG(dbgs() << "\t\tAfter the insertion, " << BlockNamePrinter(To) << " is no longer a root\n\t\tRebuilding the tree!!!\n"); CalculateFromScratch(DT, BUI); @@ -706,7 +706,7 @@ // can make a different (implicit) decision about which node within an // infinite loop becomes a root. - DEBUG(dbgs() << "Roots are different in updated trees\n" + LLVM_DEBUG(dbgs() << "Roots are different in updated trees\n" << "The entire tree needs to be rebuilt\n"); // It may be possible to update the tree without recalculating it, but // we do not know yet how to do it, and it happens rarely in practise. @@ -718,7 +718,7 @@ // Handles insertion to a node already in the dominator tree. static void InsertReachable(DomTreeT &DT, const BatchUpdatePtr BUI, const TreeNodePtr From, const TreeNodePtr To) { - DEBUG(dbgs() << "\tReachable " << BlockNamePrinter(From->getBlock()) + LLVM_DEBUG(dbgs() << "\tReachable " << BlockNamePrinter(From->getBlock()) << " -> " << BlockNamePrinter(To->getBlock()) << "\n"); if (IsPostDom && UpdateRootsBeforeInsertion(DT, BUI, From, To)) return; // DT.findNCD expects both pointers to be valid. When From is a virtual @@ -732,7 +732,7 @@ const TreeNodePtr NCD = DT.getNode(NCDBlock); assert(NCD); - DEBUG(dbgs() << "\t\tNCA == " << BlockNamePrinter(NCD) << "\n"); + LLVM_DEBUG(dbgs() << "\t\tNCA == " << BlockNamePrinter(NCD) << "\n"); const TreeNodePtr ToIDom = To->getIDom(); // Nothing affected -- NCA property holds. @@ -741,17 +741,17 @@ // Identify and collect affected nodes. InsertionInfo II; - DEBUG(dbgs() << "Marking " << BlockNamePrinter(To) << " as affected\n"); + LLVM_DEBUG(dbgs() << "Marking " << BlockNamePrinter(To) << " as affected\n"); II.Affected.insert(To); const unsigned ToLevel = To->getLevel(); - DEBUG(dbgs() << "Putting " << BlockNamePrinter(To) << " into a Bucket\n"); + LLVM_DEBUG(dbgs() << "Putting " << BlockNamePrinter(To) << " into a Bucket\n"); II.Bucket.push({ToLevel, To}); while (!II.Bucket.empty()) { const TreeNodePtr CurrentNode = II.Bucket.top().second; const unsigned CurrentLevel = CurrentNode->getLevel(); II.Bucket.pop(); - DEBUG(dbgs() << "\tAdding to Visited and AffectedQueue: " + LLVM_DEBUG(dbgs() << "\tAdding to Visited and AffectedQueue: " << BlockNamePrinter(CurrentNode) << "\n"); II.Visited.insert({CurrentNode, CurrentLevel}); @@ -770,7 +770,7 @@ const TreeNodePtr TN, const unsigned RootLevel, const TreeNodePtr NCD, InsertionInfo &II) { const unsigned NCDLevel = NCD->getLevel(); - DEBUG(dbgs() << "Visiting " << BlockNamePrinter(TN) << ", RootLevel " + LLVM_DEBUG(dbgs() << "Visiting " << BlockNamePrinter(TN) << ", RootLevel " << RootLevel << "\n"); SmallVector Stack = {TN}; @@ -780,7 +780,7 @@ do { TreeNodePtr Next = Stack.pop_back_val(); - DEBUG(dbgs() << " Next: " << BlockNamePrinter(Next) << "\n"); + LLVM_DEBUG(dbgs() << " Next: " << BlockNamePrinter(Next) << "\n"); for (const NodePtr Succ : ChildrenGetter::Get(Next->getBlock(), BUI)) { @@ -788,7 +788,7 @@ assert(SuccTN && "Unreachable successor found at reachable insertion"); const unsigned SuccLevel = SuccTN->getLevel(); - DEBUG(dbgs() << "\tSuccessor " << BlockNamePrinter(Succ) << ", level = " + LLVM_DEBUG(dbgs() << "\tSuccessor " << BlockNamePrinter(Succ) << ", level = " << SuccLevel << "\n"); // Do not process the same node multiple times. @@ -798,9 +798,9 @@ // Succ dominated by subtree From -- not affected. // (Based on the lemma 2.5 from the second paper.) if (SuccLevel > RootLevel) { - DEBUG(dbgs() << "\t\tDominated by subtree From\n"); + LLVM_DEBUG(dbgs() << "\t\tDominated by subtree From\n"); if (II.Visited.count(SuccTN) != 0) { - DEBUG(dbgs() << "\t\t\talready visited at level " + LLVM_DEBUG(dbgs() << "\t\t\talready visited at level " << II.Visited[SuccTN] << "\n\t\t\tcurrent level " << RootLevel << ")\n"); @@ -810,14 +810,14 @@ continue; } - DEBUG(dbgs() << "\t\tMarking visited not affected " + LLVM_DEBUG(dbgs() << "\t\tMarking visited not affected " << BlockNamePrinter(Succ) << "\n"); II.Visited.insert({SuccTN, RootLevel}); II.VisitedNotAffectedQueue.push_back(SuccTN); Stack.push_back(SuccTN); } else if ((SuccLevel > NCDLevel + 1) && II.Affected.count(SuccTN) == 0) { - DEBUG(dbgs() << "\t\tMarking affected and adding " + LLVM_DEBUG(dbgs() << "\t\tMarking affected and adding " << BlockNamePrinter(Succ) << " to a Bucket\n"); II.Affected.insert(SuccTN); II.Bucket.push({SuccLevel, SuccTN}); @@ -831,10 +831,10 @@ // Updates immediate dominators and levels after insertion. static void UpdateInsertion(DomTreeT &DT, const BatchUpdatePtr BUI, const TreeNodePtr NCD, InsertionInfo &II) { - DEBUG(dbgs() << "Updating NCD = " << BlockNamePrinter(NCD) << "\n"); + LLVM_DEBUG(dbgs() << "Updating NCD = " << BlockNamePrinter(NCD) << "\n"); for (const TreeNodePtr TN : II.AffectedQueue) { - DEBUG(dbgs() << "\tIDom(" << BlockNamePrinter(TN) + LLVM_DEBUG(dbgs() << "\tIDom(" << BlockNamePrinter(TN) << ") = " << BlockNamePrinter(NCD) << "\n"); TN->setIDom(NCD); } @@ -844,10 +844,10 @@ } static void UpdateLevelsAfterInsertion(InsertionInfo &II) { - DEBUG(dbgs() << "Updating levels for visited but not affected nodes\n"); + LLVM_DEBUG(dbgs() << "Updating levels for visited but not affected nodes\n"); for (const TreeNodePtr TN : II.VisitedNotAffectedQueue) { - DEBUG(dbgs() << "\tlevel(" << BlockNamePrinter(TN) << ") = (" + LLVM_DEBUG(dbgs() << "\tlevel(" << BlockNamePrinter(TN) << ") = (" << BlockNamePrinter(TN->getIDom()) << ") " << TN->getIDom()->getLevel() << " + 1\n"); TN->UpdateLevel(); @@ -857,7 +857,7 @@ // Handles insertion to previously unreachable nodes. static void InsertUnreachable(DomTreeT &DT, const BatchUpdatePtr BUI, const TreeNodePtr From, const NodePtr To) { - DEBUG(dbgs() << "Inserting " << BlockNamePrinter(From) + LLVM_DEBUG(dbgs() << "Inserting " << BlockNamePrinter(From) << " -> (unreachable) " << BlockNamePrinter(To) << "\n"); // Collect discovered edges to already reachable nodes. @@ -865,13 +865,13 @@ // Discover and connect nodes that became reachable with the insertion. ComputeUnreachableDominators(DT, BUI, To, From, DiscoveredEdgesToReachable); - DEBUG(dbgs() << "Inserted " << BlockNamePrinter(From) + LLVM_DEBUG(dbgs() << "Inserted " << BlockNamePrinter(From) << " -> (prev unreachable) " << BlockNamePrinter(To) << "\n"); // Used the discovered edges and inset discovered connecting (incoming) // edges. for (const auto &Edge : DiscoveredEdgesToReachable) { - DEBUG(dbgs() << "\tInserting discovered connecting edge " + LLVM_DEBUG(dbgs() << "\tInserting discovered connecting edge " << BlockNamePrinter(Edge.first) << " -> " << BlockNamePrinter(Edge.second) << "\n"); InsertReachable(DT, BUI, DT.getNode(Edge.first), Edge.second); @@ -901,13 +901,13 @@ SNCA.runSemiNCA(DT); SNCA.attachNewSubtree(DT, Incoming); - DEBUG(dbgs() << "After adding unreachable nodes\n"); + LLVM_DEBUG(dbgs() << "After adding unreachable nodes\n"); } static void DeleteEdge(DomTreeT &DT, const BatchUpdatePtr BUI, const NodePtr From, const NodePtr To) { assert(From && To && "Cannot disconnect nullptrs"); - DEBUG(dbgs() << "Deleting edge " << BlockNamePrinter(From) << " -> " + LLVM_DEBUG(dbgs() << "Deleting edge " << BlockNamePrinter(From) << " -> " << BlockNamePrinter(To) << "\n"); #ifndef NDEBUG @@ -928,7 +928,7 @@ const TreeNodePtr ToTN = DT.getNode(To); if (!ToTN) { - DEBUG(dbgs() << "\tTo (" << BlockNamePrinter(To) + LLVM_DEBUG(dbgs() << "\tTo (" << BlockNamePrinter(To) << ") already unreachable -- there is no edge to delete\n"); return; } @@ -941,7 +941,7 @@ DT.DFSInfoValid = false; const TreeNodePtr ToIDom = ToTN->getIDom(); - DEBUG(dbgs() << "\tNCD " << BlockNamePrinter(NCD) << ", ToIDom " + LLVM_DEBUG(dbgs() << "\tNCD " << BlockNamePrinter(NCD) << ", ToIDom " << BlockNamePrinter(ToIDom) << "\n"); // To remains reachable after deletion. @@ -959,9 +959,9 @@ static void DeleteReachable(DomTreeT &DT, const BatchUpdatePtr BUI, const TreeNodePtr FromTN, const TreeNodePtr ToTN) { - DEBUG(dbgs() << "Deleting reachable " << BlockNamePrinter(FromTN) << " -> " + LLVM_DEBUG(dbgs() << "Deleting reachable " << BlockNamePrinter(FromTN) << " -> " << BlockNamePrinter(ToTN) << "\n"); - DEBUG(dbgs() << "\tRebuilding subtree\n"); + LLVM_DEBUG(dbgs() << "\tRebuilding subtree\n"); // Find the top of the subtree that needs to be rebuilt. // (Based on the lemma 2.6 from the second paper.) @@ -974,7 +974,7 @@ // Top of the subtree to rebuild is the root node. Rebuild the tree from // scratch. if (!PrevIDomSubTree) { - DEBUG(dbgs() << "The entire tree needs to be rebuilt\n"); + LLVM_DEBUG(dbgs() << "The entire tree needs to be rebuilt\n"); CalculateFromScratch(DT, BUI); return; } @@ -985,11 +985,11 @@ return DT.getNode(To)->getLevel() > Level; }; - DEBUG(dbgs() << "\tTop of subtree: " << BlockNamePrinter(ToIDomTN) << "\n"); + LLVM_DEBUG(dbgs() << "\tTop of subtree: " << BlockNamePrinter(ToIDomTN) << "\n"); SemiNCAInfo SNCA(BUI); SNCA.runDFS(ToIDom, 0, DescendBelow, 0); - DEBUG(dbgs() << "\tRunning Semi-NCA\n"); + LLVM_DEBUG(dbgs() << "\tRunning Semi-NCA\n"); SNCA.runSemiNCA(DT, Level); SNCA.reattachExistingSubtree(DT, PrevIDomSubTree); } @@ -998,17 +998,17 @@ // explained on the page 7 of the second paper. static bool HasProperSupport(DomTreeT &DT, const BatchUpdatePtr BUI, const TreeNodePtr TN) { - DEBUG(dbgs() << "IsReachableFromIDom " << BlockNamePrinter(TN) << "\n"); + LLVM_DEBUG(dbgs() << "IsReachableFromIDom " << BlockNamePrinter(TN) << "\n"); for (const NodePtr Pred : ChildrenGetter::Get(TN->getBlock(), BUI)) { - DEBUG(dbgs() << "\tPred " << BlockNamePrinter(Pred) << "\n"); + LLVM_DEBUG(dbgs() << "\tPred " << BlockNamePrinter(Pred) << "\n"); if (!DT.getNode(Pred)) continue; const NodePtr Support = DT.findNearestCommonDominator(TN->getBlock(), Pred); - DEBUG(dbgs() << "\tSupport " << BlockNamePrinter(Support) << "\n"); + LLVM_DEBUG(dbgs() << "\tSupport " << BlockNamePrinter(Support) << "\n"); if (Support != TN->getBlock()) { - DEBUG(dbgs() << "\t" << BlockNamePrinter(TN) + LLVM_DEBUG(dbgs() << "\t" << BlockNamePrinter(TN) << " is reachable from support " << BlockNamePrinter(Support) << "\n"); return true; @@ -1022,7 +1022,7 @@ // (Based on the lemma 2.7 from the second paper.) static void DeleteUnreachable(DomTreeT &DT, const BatchUpdatePtr BUI, const TreeNodePtr ToTN) { - DEBUG(dbgs() << "Deleting unreachable subtree " << BlockNamePrinter(ToTN) + LLVM_DEBUG(dbgs() << "Deleting unreachable subtree " << BlockNamePrinter(ToTN) << "\n"); assert(ToTN); assert(ToTN->getBlock()); @@ -1031,8 +1031,8 @@ // Deletion makes a region reverse-unreachable and creates a new root. // Simulate that by inserting an edge from the virtual root to ToTN and // adding it as a new root. - DEBUG(dbgs() << "\tDeletion made a region reverse-unreachable\n"); - DEBUG(dbgs() << "\tAdding new root " << BlockNamePrinter(ToTN) << "\n"); + LLVM_DEBUG(dbgs() << "\tDeletion made a region reverse-unreachable\n"); + LLVM_DEBUG(dbgs() << "\tAdding new root " << BlockNamePrinter(ToTN) << "\n"); DT.Roots.push_back(ToTN->getBlock()); InsertReachable(DT, BUI, DT.getNode(nullptr), ToTN); return; @@ -1069,7 +1069,7 @@ const TreeNodePtr NCD = DT.getNode(NCDBlock); assert(NCD); - DEBUG(dbgs() << "Processing affected node " << BlockNamePrinter(TN) + LLVM_DEBUG(dbgs() << "Processing affected node " << BlockNamePrinter(TN) << " with NCD = " << BlockNamePrinter(NCD) << ", MinNode =" << BlockNamePrinter(MinNode) << "\n"); if (NCD != TN && NCD->getLevel() < MinNode->getLevel()) MinNode = NCD; @@ -1077,7 +1077,7 @@ // Root reached, rebuild the whole tree from scratch. if (!MinNode->getIDom()) { - DEBUG(dbgs() << "The entire tree needs to be rebuilt\n"); + LLVM_DEBUG(dbgs() << "The entire tree needs to be rebuilt\n"); CalculateFromScratch(DT, BUI); return; } @@ -1087,7 +1087,7 @@ for (unsigned i = LastDFSNum; i > 0; --i) { const NodePtr N = SNCA.NumToNode[i]; const TreeNodePtr TN = DT.getNode(N); - DEBUG(dbgs() << "Erasing node " << BlockNamePrinter(TN) << "\n"); + LLVM_DEBUG(dbgs() << "Erasing node " << BlockNamePrinter(TN) << "\n"); EraseNode(DT, TN); } @@ -1095,7 +1095,7 @@ // The affected subtree start at the To node -- there's no extra work to do. if (MinNode == ToTN) return; - DEBUG(dbgs() << "DeleteUnreachable: running DFS with MinNode = " + LLVM_DEBUG(dbgs() << "DeleteUnreachable: running DFS with MinNode = " << BlockNamePrinter(MinNode) << "\n"); const unsigned MinLevel = MinNode->getLevel(); const TreeNodePtr PrevIDom = MinNode->getIDom(); @@ -1109,7 +1109,7 @@ }; SNCA.runDFS(MinNode->getBlock(), 0, DescendBelow, 0); - DEBUG(dbgs() << "Previous IDom(MinNode) = " << BlockNamePrinter(PrevIDom) + LLVM_DEBUG(dbgs() << "Previous IDom(MinNode) = " << BlockNamePrinter(PrevIDom) << "\nRunning Semi-NCA\n"); // Rebuild the remaining part of affected subtree. @@ -1169,11 +1169,11 @@ BUI.FuturePredecessors[U.getTo()].insert({U.getFrom(), U.getKind()}); } - DEBUG(dbgs() << "About to apply " << NumLegalized << " updates\n"); - DEBUG(if (NumLegalized < 32) for (const auto &U + LLVM_DEBUG(dbgs() << "About to apply " << NumLegalized << " updates\n"); + LLVM_DEBUG(if (NumLegalized < 32) for (const auto &U : reverse(BUI.Updates)) dbgs() << '\t' << U << "\n"); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n"); // If the DominatorTree was recalculated at some point, stop the batch // updates. Full recalculations ignore batch updates and look at the actual @@ -1201,7 +1201,7 @@ // minimizes the amount of work needed done during incremental updates. static void LegalizeUpdates(ArrayRef AllUpdates, SmallVectorImpl &Result) { - DEBUG(dbgs() << "Legalizing " << AllUpdates.size() << " updates\n"); + LLVM_DEBUG(dbgs() << "Legalizing " << AllUpdates.size() << " updates\n"); // Count the total number of inserions of each edge. // Each insertion adds 1 and deletion subtracts 1. The end number should be // one of {-1 (deletion), 0 (NOP), +1 (insertion)}. Otherwise, the sequence @@ -1251,7 +1251,7 @@ static void ApplyNextUpdate(DomTreeT &DT, BatchUpdateInfo &BUI) { assert(!BUI.Updates.empty() && "No updates to apply!"); UpdateT CurrentUpdate = BUI.Updates.pop_back_val(); - DEBUG(dbgs() << "Applying update: " << CurrentUpdate << "\n"); + LLVM_DEBUG(dbgs() << "Applying update: " << CurrentUpdate << "\n"); // Move to the next snapshot of the CFG by removing the reverse-applied // current update. @@ -1530,7 +1530,7 @@ const NodePtr BB = TN->getBlock(); if (!BB || TN->getChildren().empty()) continue; - DEBUG(dbgs() << "Verifying parent property of node " + LLVM_DEBUG(dbgs() << "Verifying parent property of node " << BlockNamePrinter(TN) << "\n"); clear(); doFullDFSWalk(DT, [BB](NodePtr From, NodePtr To) { Index: include/llvm/Support/UnicodeCharRanges.h =================================================================== --- include/llvm/Support/UnicodeCharRanges.h +++ include/llvm/Support/UnicodeCharRanges.h @@ -77,17 +77,17 @@ for (CharRanges::const_iterator I = Ranges.begin(), E = Ranges.end(); I != E; ++I) { if (I != Ranges.begin() && Prev >= I->Lower) { - DEBUG(dbgs() << "Upper bound 0x"); - DEBUG(dbgs().write_hex(Prev)); - DEBUG(dbgs() << " should be less than succeeding lower bound 0x"); - DEBUG(dbgs().write_hex(I->Lower) << "\n"); + LLVM_DEBUG(dbgs() << "Upper bound 0x"); + LLVM_DEBUG(dbgs().write_hex(Prev)); + LLVM_DEBUG(dbgs() << " should be less than succeeding lower bound 0x"); + LLVM_DEBUG(dbgs().write_hex(I->Lower) << "\n"); return false; } if (I->Upper < I->Lower) { - DEBUG(dbgs() << "Upper bound 0x"); - DEBUG(dbgs().write_hex(I->Lower)); - DEBUG(dbgs() << " should not be less than lower bound 0x"); - DEBUG(dbgs().write_hex(I->Upper) << "\n"); + LLVM_DEBUG(dbgs() << "Upper bound 0x"); + LLVM_DEBUG(dbgs().write_hex(I->Lower)); + LLVM_DEBUG(dbgs() << " should not be less than lower bound 0x"); + LLVM_DEBUG(dbgs().write_hex(I->Upper) << "\n"); return false; } Prev = I->Upper; Index: include/llvm/Transforms/InstCombine/InstCombineWorklist.h =================================================================== --- include/llvm/Transforms/InstCombine/InstCombineWorklist.h +++ include/llvm/Transforms/InstCombine/InstCombineWorklist.h @@ -40,7 +40,7 @@ /// in it. void Add(Instruction *I) { if (WorklistMap.insert(std::make_pair(I, Worklist.size())).second) { - DEBUG(dbgs() << "IC: ADD: " << *I << '\n'); + LLVM_DEBUG(dbgs() << "IC: ADD: " << *I << '\n'); Worklist.push_back(I); } } @@ -57,7 +57,7 @@ assert(Worklist.empty() && "Worklist must be empty to add initial group"); Worklist.reserve(List.size()+16); WorklistMap.reserve(List.size()); - DEBUG(dbgs() << "IC: ADDING: " << List.size() << " instrs to worklist\n"); + LLVM_DEBUG(dbgs() << "IC: ADDING: " << List.size() << " instrs to worklist\n"); unsigned Idx = 0; for (Instruction *I : reverse(List)) { WorklistMap.insert(std::make_pair(I, Idx++)); Index: include/llvm/Transforms/Utils/SSAUpdaterImpl.h =================================================================== --- include/llvm/Transforms/Utils/SSAUpdaterImpl.h +++ include/llvm/Transforms/Utils/SSAUpdaterImpl.h @@ -379,7 +379,7 @@ Traits::AddPHIOperand(PHI, PredInfo->AvailableVal, Pred); } - DEBUG(dbgs() << " Inserted PHI: " << *PHI << "\n"); + LLVM_DEBUG(dbgs() << " Inserted PHI: " << *PHI << "\n"); // If the client wants to know about all new instructions, tell it. if (InsertedPHIs) InsertedPHIs->push_back(PHI); Index: lib/Analysis/BlockFrequencyInfoImpl.cpp =================================================================== --- lib/Analysis/BlockFrequencyInfoImpl.cpp +++ lib/Analysis/BlockFrequencyInfoImpl.cpp @@ -315,13 +315,13 @@ #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; } @@ -333,7 +333,7 @@ "unhandled irreducible control flow"); // Irreducible backedge. Abort. - DEBUG(debugSuccessor("abort!!!")); + LLVM_DEBUG(debugSuccessor("abort!!!")); return false; } @@ -344,7 +344,7 @@ "unhandled irreducible control flow"); } - DEBUG(debugSuccessor(" local ")); + LLVM_DEBUG(debugSuccessor(" local ")); Dist.addLocal(Resolved, Weight); return true; } @@ -364,7 +364,7 @@ /// \brief 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, @@ -390,20 +390,20 @@ Loop.Scale = ExitMass.isEmpty() ? InfiniteLoopScale : ExitMass.toScaled().inverse(); - DEBUG(dbgs() << " - exit-mass = " << ExitMass << " (" << BlockMass::getFull() + LLVM_DEBUG(dbgs() << " - exit-mass = " << ExitMass << " (" << BlockMass::getFull() << " - " << TotalBackedgeMass << ")\n" << " - scale = " << Loop.Scale << "\n"); } /// \brief 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; } @@ -425,7 +425,7 @@ 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); @@ -435,7 +435,7 @@ 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; } @@ -445,14 +445,14 @@ // 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")); } } @@ -480,12 +480,12 @@ } // Translate the floats to integers. - DEBUG(dbgs() << "float-to-int: min = " << Min << ", max = " << Max + 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()); - DEBUG(dbgs() << " - " << BFI.getBlockName(Index) << ": float = " + LLVM_DEBUG(dbgs() << " - " << BFI.getBlockName(Index) << ": float = " << BFI.Freqs[Index].Scaled << ", scaled = " << Scaled << ", int = " << BFI.Freqs[Index].Integer << "\n"); } @@ -496,12 +496,12 @@ /// 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) + 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 @@ -511,7 +511,7 @@ Scaled64 &F = Working.isAPackage() ? Working.getPackagedLoop()->Scale : BFI.Freqs[N.Index].Scaled; Scaled64 New = Loop.Scale * F; - DEBUG(dbgs() << " - " << BFI.getBlockName(N) << ": " << F << " => " << New + LLVM_DEBUG(dbgs() << " - " << BFI.getBlockName(N) << ": " << F << " => " << New << "\n"); F = New; } @@ -544,7 +544,7 @@ cleanup(*this); // Print out the final stats. - DEBUG(dump()); + LLVM_DEBUG(dump()); } BlockFrequency @@ -694,7 +694,7 @@ // 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; } } @@ -725,7 +725,7 @@ // 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) @@ -734,7 +734,7 @@ // 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"); } std::sort(Headers.begin(), Headers.end()); std::sort(Others.begin(), Others.end()); @@ -745,7 +745,7 @@ LoopData *OuterLoop, std::list::iterator Insert, const std::vector &SCC) { // Translate the SCC into RPO. - DEBUG(dbgs() << " - found-scc\n"); + LLVM_DEBUG(dbgs() << " - found-scc\n"); LoopData::NodeList Headers; LoopData::NodeList Others; @@ -806,27 +806,27 @@ 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 " + 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 + 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)); } } @@ -837,6 +837,6 @@ 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)); } } Index: lib/Analysis/BranchProbabilityInfo.cpp =================================================================== --- lib/Analysis/BranchProbabilityInfo.cpp +++ lib/Analysis/BranchProbabilityInfo.cpp @@ -788,7 +788,7 @@ BranchProbability Prob) { Probs[std::make_pair(Src, IndexInSuccessors)] = Prob; Handles.insert(BasicBlockCallbackVH(Src, this)); - DEBUG(dbgs() << "set edge " << Src->getName() << " -> " << IndexInSuccessors + LLVM_DEBUG(dbgs() << "set edge " << Src->getName() << " -> " << IndexInSuccessors << " successor probability to " << Prob << "\n"); } @@ -814,7 +814,7 @@ void BranchProbabilityInfo::calculate(const Function &F, const LoopInfo &LI, const TargetLibraryInfo *TLI) { - DEBUG(dbgs() << "---- Branch Probability Info : " << F.getName() + LLVM_DEBUG(dbgs() << "---- Branch Probability Info : " << F.getName() << " ----\n\n"); LastF = &F; // Store the last function we ran on for printing. assert(PostDominatedByUnreachable.empty()); @@ -833,18 +833,18 @@ 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. Index: lib/Analysis/CFLAndersAliasAnalysis.cpp =================================================================== --- lib/Analysis/CFLAndersAliasAnalysis.cpp +++ lib/Analysis/CFLAndersAliasAnalysis.cpp @@ -855,7 +855,7 @@ if (!Fn) { // The only times this is known to happen are when globals + InlineAsm are // involved - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "CFLAndersAA: could not extract parent function information.\n"); return MayAlias; } Index: lib/Analysis/CFLSteensAliasAnalysis.cpp =================================================================== --- lib/Analysis/CFLSteensAliasAnalysis.cpp +++ lib/Analysis/CFLSteensAliasAnalysis.cpp @@ -276,7 +276,7 @@ if (!MaybeFnA && !MaybeFnB) { // The only times this is known to happen are when globals + InlineAsm are // involved - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "CFLSteensAA: could not extract parent function information.\n"); return MayAlias; } Index: lib/Analysis/CGSCCPassManager.cpp =================================================================== --- lib/Analysis/CGSCCPassManager.cpp +++ lib/Analysis/CGSCCPassManager.cpp @@ -75,7 +75,7 @@ // 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,7 @@ // 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 +389,7 @@ 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,7 +514,7 @@ return false; RC->removeOutgoingEdge(N, *TargetN); - DEBUG(dbgs() << "Deleting outgoing edge from '" << N + LLVM_DEBUG(dbgs() << "Deleting outgoing edge from '" << N << "' to '" << TargetN << "'\n"); return true; }), @@ -546,7 +546,7 @@ 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: " + LLVM_DEBUG(dbgs() << "Enqueuing a new RefSCC in the update worklist: " << *NewRC << "\n"); } } @@ -564,7 +564,7 @@ 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 + LLVM_DEBUG(dbgs() << "Switch outgoing call edge to a ref edge from '" << N << "' to '" << *RefTarget << "'\n"); continue; } @@ -593,11 +593,11 @@ 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 + 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 + 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 @@ -661,13 +661,13 @@ // 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 + 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: " + LLVM_DEBUG(dbgs() << "Enqueuing a newly earlier in post-order SCC: " << MovedC << "\n"); } } Index: lib/Analysis/CallGraphSCCPass.cpp =================================================================== --- lib/Analysis/CallGraphSCCPass.cpp +++ lib/Analysis/CallGraphSCCPass.cpp @@ -162,7 +162,7 @@ // The function pass(es) modified the IR, they may have clobbered the // callgraph. if (Changed && CallGraphUpToDate) { - DEBUG(dbgs() << "CGSCCPASSMGR: Pass Dirtied SCC: " + LLVM_DEBUG(dbgs() << "CGSCCPASSMGR: Pass Dirtied SCC: " << P->getPassName() << '\n'); CallGraphUpToDate = false; } @@ -182,7 +182,7 @@ bool CheckingMode) { DenseMap CallSites; - DEBUG(dbgs() << "CGSCCPASSMGR: Refreshing SCC with " << CurSCC.size() + LLVM_DEBUG(dbgs() << "CGSCCPASSMGR: Refreshing SCC with " << CurSCC.size() << " nodes:\n"; for (CallGraphNode *CGN : CurSCC) CGN->dump(); @@ -307,7 +307,7 @@ // one. if (!ExistingNode->getFunction()) { DevirtualizedCall = true; - DEBUG(dbgs() << " CGSCCPASSMGR: Devirtualized call to '" + LLVM_DEBUG(dbgs() << " CGSCCPASSMGR: Devirtualized call to '" << Callee->getName() << "'\n"); } } else { @@ -363,7 +363,7 @@ CallSites.clear(); } - DEBUG(if (MadeChange) { + LLVM_DEBUG(if (MadeChange) { dbgs() << "CGSCCPASSMGR: Refreshed SCC is now:\n"; for (CallGraphNode *CGN : CurSCC) CGN->dump(); @@ -472,7 +472,7 @@ unsigned Iteration = 0; bool DevirtualizedCall = false; do { - DEBUG(if (Iteration) + LLVM_DEBUG(if (Iteration) dbgs() << " SCCPASSMGR: Re-visiting SCC, iteration #" << Iteration << '\n'); DevirtualizedCall = false; @@ -480,7 +480,7 @@ } while (Iteration++ < MaxIterations && DevirtualizedCall); if (DevirtualizedCall) - DEBUG(dbgs() << " CGSCCPASSMGR: Stopped iteration after " << Iteration + LLVM_DEBUG(dbgs() << " CGSCCPASSMGR: Stopped iteration after " << Iteration << " times, due to -max-cg-scc-iterations\n"); MaxSCCIterations.updateMax(Iteration); Index: lib/Analysis/CodeMetrics.cpp =================================================================== --- lib/Analysis/CodeMetrics.cpp +++ lib/Analysis/CodeMetrics.cpp @@ -61,7 +61,7 @@ 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); Index: lib/Analysis/DemandedBits.cpp =================================================================== --- lib/Analysis/DemandedBits.cpp +++ lib/Analysis/DemandedBits.cpp @@ -283,7 +283,7 @@ 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 @@ 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); Index: lib/Analysis/DependenceAnalysis.cpp =================================================================== --- lib/Analysis/DependenceAnalysis.cpp +++ lib/Analysis/DependenceAnalysis.cpp @@ -415,9 +415,9 @@ // 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 @@ } 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 @@ "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 @@ } 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 @@ 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 @@ ++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 @@ 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 @@ 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); @@ -1019,19 +1019,19 @@ // 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 } @@ -1068,25 +1068,25 @@ 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 = @@ -1107,8 +1107,8 @@ 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 @@ -1135,7 +1135,7 @@ } 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); } @@ -1204,16 +1204,16 @@ 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); @@ -1243,7 +1243,7 @@ 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(Delta); if (!ConstDelta) @@ -1251,8 +1251,8 @@ // 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; @@ -1263,11 +1263,11 @@ // 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; @@ -1295,19 +1295,19 @@ 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); @@ -1343,7 +1343,7 @@ 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; @@ -1416,17 +1416,17 @@ 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(Delta); @@ -1447,7 +1447,7 @@ 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); @@ -1456,7 +1456,7 @@ 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; } @@ -1467,18 +1467,18 @@ 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"); } } @@ -1486,18 +1486,18 @@ 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)) { @@ -1512,15 +1512,15 @@ // 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; @@ -1530,23 +1530,23 @@ // 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; @@ -1556,14 +1556,14 @@ // 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; @@ -1629,10 +1629,10 @@ // 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--; @@ -1640,7 +1640,7 @@ 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; @@ -1661,7 +1661,7 @@ // 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; @@ -1738,10 +1738,10 @@ 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--; @@ -1749,7 +1749,7 @@ 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; @@ -1770,7 +1770,7 @@ // 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; @@ -1819,15 +1819,15 @@ 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(Delta); const SCEVConstant *ConstSrcCoeff = dyn_cast(SrcCoeff); const SCEVConstant *ConstDstCoeff = dyn_cast(DstCoeff); @@ -1845,7 +1845,7 @@ 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); @@ -1854,7 +1854,7 @@ 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; } @@ -1864,7 +1864,7 @@ 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; } @@ -1875,18 +1875,18 @@ 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"); } } @@ -1894,18 +1894,18 @@ 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)) @@ -1961,27 +1961,27 @@ 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; @@ -1990,7 +1990,7 @@ 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; @@ -2004,7 +2004,7 @@ 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; @@ -2025,7 +2025,7 @@ 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; @@ -2042,7 +2042,7 @@ 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; @@ -2051,7 +2051,7 @@ 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; @@ -2074,8 +2074,8 @@ 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(Src); const SCEVAddRecExpr *DstAddRec = dyn_cast(Dst); if (SrcAddRec && DstAddRec) { @@ -2151,8 +2151,8 @@ 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(Src); const SCEVAddRecExpr *DstAddRec = dyn_cast(Dst); if (SrcAddRec && DstAddRec) { @@ -2208,8 +2208,8 @@ 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); @@ -2249,7 +2249,7 @@ // 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); @@ -2294,7 +2294,7 @@ 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(Delta); if (const SCEVAddExpr *Sum = dyn_cast(Delta)) { // If Delta is a sum of products, we may be able to make further progress. @@ -2321,11 +2321,11 @@ if (!Constant) return false; APInt ConstDelta = cast(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; @@ -2344,7 +2344,7 @@ // 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; @@ -2399,10 +2399,10 @@ 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); @@ -2412,7 +2412,7 @@ } if (Improved) ++GCDsuccesses; - DEBUG(dbgs() << "all done\n"); + LLVM_DEBUG(dbgs() << "all done\n"); return false; } @@ -2453,35 +2453,35 @@ 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 } @@ -2537,23 +2537,23 @@ 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"); @@ -2561,7 +2561,7 @@ #endif } } - DEBUG(dbgs() << " ]\n"); + LLVM_DEBUG(dbgs() << " ]\n"); return 1; } if (Loops[Level]) { @@ -2572,34 +2572,34 @@ 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 } @@ -2846,21 +2846,21 @@ } 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; } @@ -2985,8 +2985,8 @@ 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()) @@ -3007,17 +3007,17 @@ 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; @@ -3036,9 +3036,9 @@ 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(B); const SCEVConstant *Cconst = dyn_cast(C); @@ -3094,8 +3094,8 @@ 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; } @@ -3110,13 +3110,13 @@ 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; } @@ -3124,8 +3124,8 @@ // 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()) { @@ -3230,7 +3230,7 @@ int size = SrcSubscripts.size(); - DEBUG({ + LLVM_DEBUG({ dbgs() << "\nSrcSubscripts: "; for (int i = 0; i < size; i++) dbgs() << *SrcSubscripts[i]; @@ -3299,7 +3299,7 @@ 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(Src, Dst); } @@ -3311,11 +3311,11 @@ 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(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. @@ -3323,8 +3323,8 @@ // 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; @@ -3337,8 +3337,8 @@ SrcGEP->getPointerOperandType() == DstGEP->getPointerOperandType()) { const SCEV *SrcPtrSCEV = SE->getSCEV(SrcGEP->getPointerOperand()); const SCEV *DstPtrSCEV = SE->getSCEV(DstGEP->getPointerOperand()); - DEBUG(dbgs() << " SrcPtrSCEV = " << *SrcPtrSCEV << "\n"); - DEBUG(dbgs() << " DstPtrSCEV = " << *DstPtrSCEV << "\n"); + LLVM_DEBUG(dbgs() << " SrcPtrSCEV = " << *SrcPtrSCEV << "\n"); + LLVM_DEBUG(dbgs() << " DstPtrSCEV = " << *DstPtrSCEV << "\n"); UsefulGEP = isLoopInvariant(SrcPtrSCEV, LI->getLoopFor(Src->getParent())) && isLoopInvariant(DstPtrSCEV, LI->getLoopFor(Dst->getParent())) && @@ -3348,7 +3348,7 @@ unsigned Pairs = UsefulGEP ? SrcGEP->idx_end() - SrcGEP->idx_begin() : 1; SmallVector Pair(Pairs); if (UsefulGEP) { - DEBUG(dbgs() << " using GEPs\n"); + LLVM_DEBUG(dbgs() << " using GEPs\n"); unsigned P = 0; for (GEPOperator::const_op_iterator SrcIdx = SrcGEP->idx_begin(), SrcEnd = SrcGEP->idx_end(), @@ -3361,18 +3361,18 @@ } } else { - DEBUG(dbgs() << " ignoring GEPs\n"); + LLVM_DEBUG(dbgs() << " ignoring GEPs\n"); 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 && CommonLevels > 1) { if (tryDelinearize(Src, Dst, Pair)) { - DEBUG(dbgs() << " delinearized GEP\n"); + LLVM_DEBUG(dbgs() << " delinearized GEP\n"); Pairs = Pair.size(); } } @@ -3388,12 +3388,12 @@ 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); @@ -3498,25 +3498,25 @@ } } - 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, @@ -3525,12 +3525,12 @@ 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; @@ -3541,20 +3541,20 @@ 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 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 PairsInGroup; for (unsigned SJ : Group.set_bits()) { - DEBUG(dbgs() << SJ << " "); + LLVM_DEBUG(dbgs() << SJ << " "); if (Pair[SJ].Classification == Subscript::SIV) Sivs.set(SJ); else @@ -3562,15 +3562,15 @@ 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; @@ -3586,15 +3586,15 @@ } 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()), @@ -3602,7 +3602,7 @@ 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); @@ -3625,7 +3625,7 @@ // 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 @@ -3638,7 +3638,7 @@ // 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; } @@ -3647,7 +3647,7 @@ } // 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; @@ -3797,7 +3797,7 @@ if (Delinearize && CommonLevels > 1) { if (tryDelinearize(Src, Dst, Pair)) { - DEBUG(dbgs() << " delinearized GEP\n"); + LLVM_DEBUG(dbgs() << " delinearized GEP\n"); Pairs = Pair.size(); } } Index: lib/Analysis/IVUsers.cpp =================================================================== --- lib/Analysis/IVUsers.cpp +++ lib/Analysis/IVUsers.cpp @@ -234,12 +234,12 @@ if (LI->getLoopFor(User->getParent()) != L) { if (isa(User) || Processed.count(User) || !AddUsersImpl(User, SimpleLoopNests)) { - DEBUG(dbgs() << "FOUND USER in other loop: " << *User << '\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' + LLVM_DEBUG(dbgs() << "FOUND USER: " << *User << '\n' << " OF SCEV: " << *ISE << '\n'); AddUserToIVUsers = true; } @@ -273,13 +273,13 @@ // 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): " + LLVM_DEBUG(dbgs() << " DISCARDING (NORMALIZATION ISN'T INVERTIBLE): " << *ISE << '\n'); IVUses.pop_back(); return false; } } - DEBUG(if (SE->getSCEV(I) != ISE) + LLVM_DEBUG(if (SE->getSCEV(I) != ISE) dbgs() << " NORMALIZED TO: " << *ISE << '\n'); } } Index: lib/Analysis/IndirectCallPromotionAnalysis.cpp =================================================================== --- lib/Analysis/IndirectCallPromotionAnalysis.cpp +++ lib/Analysis/IndirectCallPromotionAnalysis.cpp @@ -71,7 +71,7 @@ const Instruction *Inst, uint32_t NumVals, uint64_t TotalCount) { ArrayRef ValueDataRef(ValueDataArray.get(), NumVals); - DEBUG(dbgs() << " \nWork on callsite " << *Inst << " Num_targets: " << NumVals + LLVM_DEBUG(dbgs() << " \nWork on callsite " << *Inst << " Num_targets: " << NumVals << "\n"); uint32_t I = 0; @@ -79,11 +79,11 @@ for (; I < MaxNumPromotions && I < NumVals; I++) { uint64_t Count = ValueDataRef[I].Count; assert(Count <= RemainingCount); - DEBUG(dbgs() << " Candidate " << I << " Count=" << Count + 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; Index: lib/Analysis/InlineCost.cpp =================================================================== --- lib/Analysis/InlineCost.cpp +++ lib/Analysis/InlineCost.cpp @@ -919,14 +919,14 @@ 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 @@ -937,13 +937,13 @@ // 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 @@ -1999,14 +1999,14 @@ CS.isNoInline()) return llvm::InlineCost::getNever(); - DEBUG(llvm::dbgs() << " Analyzing call of " << Callee->getName() + 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()) Index: lib/Analysis/LazyCallGraph.cpp =================================================================== --- lib/Analysis/LazyCallGraph.cpp +++ lib/Analysis/LazyCallGraph.cpp @@ -65,14 +65,14 @@ 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() + LLVM_DEBUG(dbgs() << " Adding functions called by '" << getName() << "' to the graph.\n"); Edges = EdgeSequence(); @@ -151,7 +151,7 @@ } LazyCallGraph::LazyCallGraph(Module &M, TargetLibraryInfo &TLI) { - DEBUG(dbgs() << "Building CG for module: " << M.getModuleIdentifier() + LLVM_DEBUG(dbgs() << "Building CG for module: " << M.getModuleIdentifier() << "\n"); for (Function &F : M) { if (F.isDeclaration()) @@ -167,7 +167,7 @@ // External linkage defined functions have edges to them from other // modules. - DEBUG(dbgs() << " Adding '" << F.getName() + LLVM_DEBUG(dbgs() << " Adding '" << F.getName() << "' to entry set of the graph.\n"); addEdge(EntryEdges.Edges, EntryEdges.EdgeIndexMap, get(F), Edge::Ref); } @@ -180,7 +180,7 @@ if (Visited.insert(GV.getInitializer()).second) Worklist.push_back(GV.getInitializer()); - DEBUG(dbgs() << " Adding functions referenced by global initializers to the " + 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), Index: lib/Analysis/LazyValueInfo.cpp =================================================================== --- lib/Analysis/LazyValueInfo.cpp +++ lib/Analysis/LazyValueInfo.cpp @@ -392,7 +392,7 @@ if (!BlockValueSet.insert(BV).second) return false; // It's already in the stack. - DEBUG(dbgs() << "PUSH: " << *BV.second << " in " << BV.first->getName() + LLVM_DEBUG(dbgs() << "PUSH: " << *BV.second << " in " << BV.first->getName() << "\n"); BlockValueStack.push_back(BV); return true; @@ -508,7 +508,7 @@ // 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 &e = StartingStack.back(); @@ -529,7 +529,7 @@ assert(TheCache.hasCachedValueInfo(e.second, e.first) && "Result should be in cache!"); - DEBUG(dbgs() << "POP " << *e.second << " in " << e.first->getName() + LLVM_DEBUG(dbgs() << "POP " << *e.second << " in " << e.first->getName() << " = " << TheCache.getCachedValueInfo(e.second, e.first) << "\n"); BlockValueStack.pop_back(); @@ -581,7 +581,7 @@ if (TheCache.hasCachedValueInfo(Val, BB)) { // If we have a cached value, use that. - DEBUG(dbgs() << " reuse BB '" << BB->getName() + 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 @@ -637,7 +637,7 @@ return solveBlockValueBinaryOp(Res, BO, BB); } - DEBUG(dbgs() << " compute BB '" << BB->getName() + LLVM_DEBUG(dbgs() << " compute BB '" << BB->getName() << "' - unknown inst def found.\n"); Res = getFromRangeMetadata(BBI); return true; @@ -733,7 +733,7 @@ // If we hit overdefined, exit early. The BlockVals entry is already set // to overdefined. if (Result.isOverdefined()) { - DEBUG(dbgs() << " compute BB '" << BB->getName() + 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. @@ -777,7 +777,7 @@ // If we hit overdefined, exit early. The BlockVals entry is already set // to overdefined. if (Result.isOverdefined()) { - DEBUG(dbgs() << " compute BB '" << BB->getName() + LLVM_DEBUG(dbgs() << " compute BB '" << BB->getName() << "' - overdefined because of pred (local).\n"); BBLV = Result; @@ -968,7 +968,7 @@ break; default: // Unhandled instructions are overdefined. - DEBUG(dbgs() << " compute BB '" << BB->getName() + LLVM_DEBUG(dbgs() << " compute BB '" << BB->getName() << "' - overdefined (unknown cast).\n"); BBLV = ValueLatticeElement::getOverdefined(); return true; @@ -1027,7 +1027,7 @@ break; default: // Unhandled instructions are overdefined. - DEBUG(dbgs() << " compute BB '" << BB->getName() + LLVM_DEBUG(dbgs() << " compute BB '" << BB->getName() << "' - overdefined (unknown binary operator).\n"); BBLV = ValueLatticeElement::getOverdefined(); return true; @@ -1391,7 +1391,7 @@ ValueLatticeElement LazyValueInfoImpl::getValueInBlock(Value *V, BasicBlock *BB, Instruction *CxtI) { - DEBUG(dbgs() << "LVI Getting block end value " << *V << " at '" + LLVM_DEBUG(dbgs() << "LVI Getting block end value " << *V << " at '" << BB->getName() << "'\n"); assert(BlockValueStack.empty() && BlockValueSet.empty()); @@ -1402,12 +1402,12 @@ 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 '" + LLVM_DEBUG(dbgs() << "LVI Getting value " << *V << " at '" << CxtI->getName() << "'\n"); if (auto *C = dyn_cast(V)) @@ -1418,14 +1418,14 @@ 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 '" + LLVM_DEBUG(dbgs() << "LVI Getting edge value " << *V << " from '" << FromBB->getName() << "' to '" << ToBB->getName() << "'\n"); ValueLatticeElement Result; @@ -1436,7 +1436,7 @@ assert(WasFastQuery && "More work to do after problem solved?"); } - DEBUG(dbgs() << " Result = " << Result << "\n"); + LLVM_DEBUG(dbgs() << " Result = " << Result << "\n"); return Result; } Index: lib/Analysis/LoopAccessAnalysis.cpp =================================================================== --- lib/Analysis/LoopAccessAnalysis.cpp +++ lib/Analysis/LoopAccessAnalysis.cpp @@ -165,7 +165,7 @@ PSE.addPredicate(*SE->getEqualPredicate(U, CT)); auto *Expr = PSE.getSCEV(Ptr); - DEBUG(dbgs() << "LAA: Replacing SCEV: " << *OrigSCEV << " by: " << *Expr + LLVM_DEBUG(dbgs() << "LAA: Replacing SCEV: " << *OrigSCEV << " by: " << *Expr << "\n"); return Expr; } @@ -684,7 +684,7 @@ 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 @@ 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,7 +791,7 @@ unsigned ASi = PtrI->getType()->getPointerAddressSpace(); unsigned ASj = PtrJ->getType()->getPointerAddressSpace(); if (ASi != ASj) { - DEBUG(dbgs() << "LAA: Runtime check would require comparison between" + LLVM_DEBUG(dbgs() << "LAA: Runtime check would require comparison between" " different address spaces\n"); return false; } @@ -801,7 +801,7 @@ if (NeedRTCheck && CanDoRT) RtCheck.generateChecks(DepCands, IsDepCheckNeeded); - DEBUG(dbgs() << "LAA: We need to do " << RtCheck.getNumberOfChecks() + LLVM_DEBUG(dbgs() << "LAA: We need to do " << RtCheck.getNumberOfChecks() << " pointer comparisons.\n"); RtCheck.Need = NeedRTCheck; @@ -817,10 +817,10 @@ // 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 +904,7 @@ 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 +917,7 @@ DepCands.unionSets(Access, Prev->second); ObjToLastAccess[UnderlyingObj] = Access; - DEBUG(dbgs() << " " << *UnderlyingObj << "\n"); + LLVM_DEBUG(dbgs() << " " << *UnderlyingObj << "\n"); } } } @@ -989,7 +989,7 @@ // Make sure that the pointer does not point to aggregate types. auto *PtrTy = cast(Ty); if (PtrTy->getElementType()->isAggregateType()) { - DEBUG(dbgs() << "LAA: Bad stride - Not a pointer to a scalar type" << *Ptr + LLVM_DEBUG(dbgs() << "LAA: Bad stride - Not a pointer to a scalar type" << *Ptr << "\n"); return 0; } @@ -1001,14 +1001,14 @@ AR = PSE.getAsAddRec(Ptr); if (!AR) { - DEBUG(dbgs() << "LAA: Bad stride - Not an AddRecExpr pointer " << *Ptr + 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 " << + LLVM_DEBUG(dbgs() << "LAA: Bad stride - Not striding over innermost loop " << *Ptr << " SCEV: " << *AR << "\n"); return 0; } @@ -1029,12 +1029,12 @@ if (Assume) { PSE.setNoOverflow(Ptr, SCEVWrapPredicate::IncrementNUSW); IsNoWrapAddRec = true; - DEBUG(dbgs() << "LAA: Pointer may wrap in the address space:\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 " + LLVM_DEBUG(dbgs() << "LAA: Bad stride - Pointer may wrap in the address space " << *Ptr << " SCEV: " << *AR << "\n"); return 0; } @@ -1046,7 +1046,7 @@ // Calculate the pointer stride and check if it is constant. const SCEVConstant *C = dyn_cast(Step); if (!C) { - DEBUG(dbgs() << "LAA: Bad stride - Not a constant strided " << *Ptr << + LLVM_DEBUG(dbgs() << "LAA: Bad stride - Not a constant strided " << *Ptr << " SCEV: " << *AR << "\n"); return 0; } @@ -1074,7 +1074,7 @@ 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 " + 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" @@ -1242,7 +1242,7 @@ } if (MaxVFWithoutSLForwardIssues < 2 * TypeByteSize) { - DEBUG(dbgs() << "LAA: Distance " << Distance + LLVM_DEBUG(dbgs() << "LAA: Distance " << Distance << " that could cause a store-load forwarding conflict\n"); return true; } @@ -1395,16 +1395,16 @@ const SCEV *Dist = PSE.getSE()->getMinusSCEV(Sink, Src); - DEBUG(dbgs() << "LAA: Src Scev: " << *Src << "Sink Scev: " << *Sink + LLVM_DEBUG(dbgs() << "LAA: Src Scev: " << *Src << "Sink Scev: " << *Sink << "(Induction step: " << StrideAPtr << ")\n"); - DEBUG(dbgs() << "LAA: Distance for " << *InstMap[AIdx] << " to " + 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; } @@ -1421,7 +1421,7 @@ 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; } @@ -1432,7 +1432,7 @@ // 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; } @@ -1442,11 +1442,11 @@ 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; } @@ -1455,14 +1455,14 @@ 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() << + LLVM_DEBUG(dbgs() << "LAA: ReadWrite-Write positive dependency with different types\n"); return Dependence::Unknown; } @@ -1504,14 +1504,14 @@ uint64_t MinDistanceNeeded = TypeByteSize * Stride * (MinNumIter - 1) + TypeByteSize; if (MinDistanceNeeded > static_cast(Distance)) { - DEBUG(dbgs() << "LAA: Failure because of positive distance " << Distance + 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 " + LLVM_DEBUG(dbgs() << "LAA: Failure because it needs at least " << MinDistanceNeeded << " size in bytes"); return Dependence::Backward; } @@ -1541,7 +1541,7 @@ return Dependence::BackwardVectorizableButPreventsForwarding; uint64_t MaxVF = MaxSafeDepDistBytes / (TypeByteSize * Stride); - DEBUG(dbgs() << "LAA: Positive distance " << Val.getSExtValue() + LLVM_DEBUG(dbgs() << "LAA: Positive distance " << Val.getSExtValue() << " with max VF = " << MaxVF << '\n'); uint64_t MaxVFInBits = MaxVF * TypeByteSize * 8; MaxSafeRegisterWidth = std::min(MaxSafeRegisterWidth, MaxVFInBits); @@ -1600,7 +1600,7 @@ 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) @@ -1612,7 +1612,7 @@ } } - DEBUG(dbgs() << "Total Dependences: " << Dependences.size() << "\n"); + LLVM_DEBUG(dbgs() << "Total Dependences: " << Dependences.size() << "\n"); return SafeForVectorization; } @@ -1642,20 +1642,20 @@ bool LoopAccessInfo::canAnalyzeLoop() { // We need to have a loop header. - DEBUG(dbgs() << "LAA: Found a loop in " + 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; @@ -1663,7 +1663,7 @@ // 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; @@ -1673,7 +1673,7 @@ // 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; @@ -1684,7 +1684,7 @@ 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; } @@ -1734,7 +1734,7 @@ 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; } @@ -1758,7 +1758,7 @@ 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; } @@ -1777,7 +1777,7 @@ // 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; } @@ -1814,7 +1814,7 @@ } if (IsAnnotatedParallel) { - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "LAA: A loop annotated parallel, ignore memory dependency " << "checks.\n"); CanVecMem = true; @@ -1851,7 +1851,7 @@ // 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; } @@ -1866,23 +1866,23 @@ TheLoop, SymbolicStrides); if (!CanDoRTIfNeeded) { recordAnalysis("CantIdentifyArrayBounds") << "cannot identify array bounds"; - DEBUG(dbgs() << "LAA: We can't vectorize because we can't find " + 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); @@ -1898,7 +1898,7 @@ 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; } @@ -1908,7 +1908,7 @@ } if (CanVecMem) - DEBUG(dbgs() << "LAA: No unsafe dependent memory operations in loop. We" + LLVM_DEBUG(dbgs() << "LAA: No unsafe dependent memory operations in loop. We" << (PtrRtChecking->Need ? "" : " don't") << " need runtime memory checks.\n"); else { @@ -1917,7 +1917,7 @@ "#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"); } } @@ -2001,7 +2001,7 @@ Type *PtrArithTy = Type::getInt8PtrTy(Ctx, AS); if (SE->isLoopInvariant(Sc, TheLoop)) { - DEBUG(dbgs() << "LAA: Adding RT check for a loop invariant ptr:" << *Ptr + 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. @@ -2015,10 +2015,10 @@ 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}; } } @@ -2136,9 +2136,9 @@ if (!Stride) return; - DEBUG(dbgs() << "LAA: Found a strided access that is a candidate for " + LLVM_DEBUG(dbgs() << "LAA: Found a strided access that is a candidate for " "versioning:"); - DEBUG(dbgs() << " Ptr: " << *Ptr << " Stride: " << *Stride << "\n"); + 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 @@ -2174,12 +2174,12 @@ // "Stride >= TripCount" is equivalent to checking: // Stride - BETakenCount > 0 if (SE->isKnownPositive(StrideMinusBETaken)) { - DEBUG(dbgs() << "LAA: Stride>=TripCount; No point in versioning as the " + 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); Index: lib/Analysis/LoopPass.cpp =================================================================== --- lib/Analysis/LoopPass.cpp +++ lib/Analysis/LoopPass.cpp @@ -362,7 +362,7 @@ // Check for the OptimizeNone attribute. if (F->hasFnAttribute(Attribute::OptimizeNone)) { // FIXME: Report this to dbgs() only once per function. - DEBUG(dbgs() << "Skipping pass '" << getPassName() + LLVM_DEBUG(dbgs() << "Skipping pass '" << getPassName() << "' in function " << F->getName() << "\n"); // FIXME: Delete loop from pass manager's queue? return true; Index: lib/Analysis/MemoryBuiltins.cpp =================================================================== --- lib/Analysis/MemoryBuiltins.cpp +++ lib/Analysis/MemoryBuiltins.cpp @@ -511,7 +511,7 @@ return visitGEPOperator(cast(*CE)); } - DEBUG(dbgs() << "ObjectSizeOffsetVisitor::compute() unhandled value: " << *V + LLVM_DEBUG(dbgs() << "ObjectSizeOffsetVisitor::compute() unhandled value: " << *V << '\n'); return unknown(); } @@ -712,7 +712,7 @@ } SizeOffsetType ObjectSizeOffsetVisitor::visitInstruction(Instruction &I) { - DEBUG(dbgs() << "ObjectSizeOffsetVisitor unknown instruction:" << I << '\n'); + LLVM_DEBUG(dbgs() << "ObjectSizeOffsetVisitor unknown instruction:" << I << '\n'); return unknown(); } @@ -791,7 +791,7 @@ // Ignore values where we cannot do more than ObjectSizeVisitor. Result = unknown(); } else { - DEBUG(dbgs() << "ObjectSizeOffsetEvaluator::compute() unhandled value: " + LLVM_DEBUG(dbgs() << "ObjectSizeOffsetEvaluator::compute() unhandled value: " << *V << '\n'); Result = unknown(); } @@ -929,6 +929,6 @@ } SizeOffsetEvalType ObjectSizeOffsetEvaluator::visitInstruction(Instruction &I) { - DEBUG(dbgs() << "ObjectSizeOffsetEvaluator unknown instruction:" << I <<'\n'); + LLVM_DEBUG(dbgs() << "ObjectSizeOffsetEvaluator unknown instruction:" << I <<'\n'); return unknown(); } Index: lib/Analysis/MemoryDependenceAnalysis.cpp =================================================================== --- lib/Analysis/MemoryDependenceAnalysis.cpp +++ lib/Analysis/MemoryDependenceAnalysis.cpp @@ -824,7 +824,7 @@ SmallPtrSet 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 @@ // 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 @@ 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 @@ // 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 @@ // 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 @@ } 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 Index: lib/Analysis/MemorySSA.cpp =================================================================== --- lib/Analysis/MemorySSA.cpp +++ lib/Analysis/MemorySSA.cpp @@ -1208,7 +1208,7 @@ unsigned long UpperBound = VersionStack.size() - 1; if (UpperBound - LocInfo.LowerBound > MaxCheckLimit) { - DEBUG(dbgs() << "MemorySSA skipping optimization of " << *MU << " (" + LLVM_DEBUG(dbgs() << "MemorySSA skipping optimization of " << *MU << " (" << *(MU->getMemoryInst()) << ")" << " because there are " << UpperBound - LocInfo.LowerBound << " stores to disambiguate\n"); @@ -2012,10 +2012,10 @@ : 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; } @@ -2057,10 +2057,10 @@ return DefiningAccess; 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"); if (auto *MUD = dyn_cast(StartingAccess)) MUD->setOptimized(Result); Index: lib/Analysis/RegionPass.cpp =================================================================== --- lib/Analysis/RegionPass.cpp +++ lib/Analysis/RegionPass.cpp @@ -158,7 +158,7 @@ } // Print the region tree after all pass. - DEBUG( + LLVM_DEBUG( dbgs() << "\nRegion tree of function " << F.getName() << " after all region Pass:\n"; RI->dump(); @@ -289,7 +289,7 @@ if (F.hasFnAttribute(Attribute::OptimizeNone)) { // Report this only once per function. if (R.getEntry() == &F.getEntryBlock()) - DEBUG(dbgs() << "Skipping pass '" << getPassName() + LLVM_DEBUG(dbgs() << "Skipping pass '" << getPassName() << "' on function " << F.getName() << "\n"); return true; } Index: lib/Analysis/ScalarEvolution.cpp =================================================================== --- lib/Analysis/ScalarEvolution.cpp +++ lib/Analysis/ScalarEvolution.cpp @@ -4693,7 +4693,7 @@ 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; } @@ -4701,7 +4701,7 @@ // 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; } @@ -4710,7 +4710,7 @@ 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); } }; @@ -10440,7 +10440,7 @@ SCEVCollectStrides StrideCollector(*this, Strides); visitAll(Expr, StrideCollector); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Strides:\n"; for (const SCEV *S : Strides) dbgs() << *S << "\n"; @@ -10451,7 +10451,7 @@ visitAll(S, TermCollector); } - DEBUG({ + LLVM_DEBUG({ dbgs() << "Terms:\n"; for (const SCEV *T : Terms) dbgs() << *T << "\n"; @@ -10566,7 +10566,7 @@ if (!containsParameters(Terms)) return; - DEBUG({ + LLVM_DEBUG({ dbgs() << "Terms:\n"; for (const SCEV *T : Terms) dbgs() << *T << "\n"; @@ -10597,7 +10597,7 @@ if (const SCEV *NewT = removeConstantFactors(*this, T)) NewTerms.push_back(NewT); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Terms after sorting:\n"; for (const SCEV *T : NewTerms) dbgs() << *T << "\n"; @@ -10611,7 +10611,7 @@ // The last element to be pushed into Sizes is the size of an element. Sizes.push_back(ElementSize); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Sizes:\n"; for (const SCEV *S : Sizes) dbgs() << *S << "\n"; @@ -10635,7 +10635,7 @@ const SCEV *Q, *R; SCEVDivision::divide(*this, Res, Sizes[i], &Q, &R); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Res: " << *Res << "\n"; dbgs() << "Sizes[i]: " << *Sizes[i] << "\n"; dbgs() << "Res divided by Sizes[i]:\n"; @@ -10669,7 +10669,7 @@ std::reverse(Subscripts.begin(), Subscripts.end()); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Subscripts:\n"; for (const SCEV *S : Subscripts) dbgs() << *S << "\n"; @@ -10747,7 +10747,7 @@ if (Subscripts.empty()) return; - DEBUG({ + LLVM_DEBUG({ dbgs() << "succeeded to delinearize " << *Expr << "\n"; dbgs() << "ArrayDecl[UnknownSize]"; for (const SCEV *S : Sizes) Index: lib/CodeGen/AggressiveAntiDepBreaker.cpp =================================================================== --- lib/CodeGen/AggressiveAntiDepBreaker.cpp +++ lib/CodeGen/AggressiveAntiDepBreaker.cpp @@ -139,10 +139,10 @@ CriticalPathSet |= CPSet; } - DEBUG(dbgs() << "AntiDep Critical-Path Registers:"); - DEBUG(for (unsigned r : CriticalPathSet.set_bits()) + LLVM_DEBUG(dbgs() << "AntiDep Critical-Path Registers:"); + LLVM_DEBUG(for (unsigned r : CriticalPathSet.set_bits()) dbgs() << " " << printReg(r, TRI)); - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); } AggressiveAntiDepBreaker::~AggressiveAntiDepBreaker() { @@ -202,9 +202,9 @@ PrescanInstruction(MI, Count, PassthruRegs); ScanInstruction(MI, Count); - DEBUG(dbgs() << "Observe: "); - DEBUG(MI.dump()); - DEBUG(dbgs() << "\tRegs:"); + LLVM_DEBUG(dbgs() << "Observe: "); + LLVM_DEBUG(MI.dump()); + LLVM_DEBUG(dbgs() << "\tRegs:"); std::vector &DefIndices = State->GetDefIndices(); for (unsigned Reg = 0; Reg != TRI->getNumRegs(); ++Reg) { @@ -215,7 +215,7 @@ // conservative location (i.e. the beginning of the previous // schedule region). if (State->IsLive(Reg)) { - DEBUG(if (State->GetGroup(Reg) != 0) + LLVM_DEBUG(if (State->GetGroup(Reg) != 0) dbgs() << " " << printReg(Reg, TRI) << "=g" << State->GetGroup(Reg) << "->g0(region live-out)"); State->UnionGroups(Reg, 0); @@ -224,7 +224,7 @@ DefIndices[Reg] = Count; } } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); } bool AggressiveAntiDepBreaker::IsImplicitDefUse(MachineInstr &MI, @@ -313,7 +313,7 @@ // subregister definitions). for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI) if (TRI->isSuperRegister(Reg, *AI) && State->IsLive(*AI)) { - DEBUG(if (!header && footer) dbgs() << footer); + LLVM_DEBUG(if (!header && footer) dbgs() << footer); return; } @@ -322,9 +322,9 @@ DefIndices[Reg] = ~0u; RegRefs.erase(Reg); State->LeaveGroup(Reg); - DEBUG(if (header) { + LLVM_DEBUG(if (header) { dbgs() << header << printReg(Reg, TRI); header = nullptr; }); - DEBUG(dbgs() << "->g" << State->GetGroup(Reg) << tag); + LLVM_DEBUG(dbgs() << "->g" << State->GetGroup(Reg) << tag); // Repeat for subregisters. Note that we only do this if the superregister // was not live because otherwise, regardless whether we have an explicit // use of the subregister, the subregister's contents are needed for the @@ -336,15 +336,15 @@ DefIndices[SubregReg] = ~0u; RegRefs.erase(SubregReg); State->LeaveGroup(SubregReg); - DEBUG(if (header) { + LLVM_DEBUG(if (header) { dbgs() << header << printReg(Reg, TRI); header = nullptr; }); - DEBUG(dbgs() << " " << printReg(SubregReg, TRI) << "->g" << + LLVM_DEBUG(dbgs() << " " << printReg(SubregReg, TRI) << "->g" << State->GetGroup(SubregReg) << tag); } } } - DEBUG(if (!header && footer) dbgs() << footer); + LLVM_DEBUG(if (!header && footer) dbgs() << footer); } void AggressiveAntiDepBreaker::PrescanInstruction( @@ -367,14 +367,14 @@ HandleLastUse(Reg, Count + 1, "", "\tDead Def: ", "\n"); } - DEBUG(dbgs() << "\tDef Groups:"); + LLVM_DEBUG(dbgs() << "\tDef Groups:"); for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) { MachineOperand &MO = MI.getOperand(i); if (!MO.isReg() || !MO.isDef()) continue; unsigned Reg = MO.getReg(); if (Reg == 0) continue; - DEBUG(dbgs() << " " << printReg(Reg, TRI) << "=g" << State->GetGroup(Reg)); + LLVM_DEBUG(dbgs() << " " << printReg(Reg, TRI) << "=g" << State->GetGroup(Reg)); // If MI's defs have a special allocation requirement, don't allow // any def registers to be changed. Also assume all registers @@ -383,7 +383,7 @@ // can tell user specified registers from compiler-specified. if (MI.isCall() || MI.hasExtraDefRegAllocReq() || TII->isPredicated(MI) || MI.isInlineAsm()) { - DEBUG(if (State->GetGroup(Reg) != 0) dbgs() << "->g0(alloc-req)"); + LLVM_DEBUG(if (State->GetGroup(Reg) != 0) dbgs() << "->g0(alloc-req)"); State->UnionGroups(Reg, 0); } @@ -393,7 +393,7 @@ unsigned AliasReg = *AI; if (State->IsLive(AliasReg)) { State->UnionGroups(Reg, AliasReg); - DEBUG(dbgs() << "->g" << State->GetGroup(Reg) << "(via " + LLVM_DEBUG(dbgs() << "->g" << State->GetGroup(Reg) << "(via " << printReg(AliasReg, TRI) << ")"); } } @@ -406,7 +406,7 @@ RegRefs.insert(std::make_pair(Reg, RR)); } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); // Scan the register defs for this instruction and update // live-ranges. @@ -437,7 +437,7 @@ void AggressiveAntiDepBreaker::ScanInstruction(MachineInstr &MI, unsigned Count) { - DEBUG(dbgs() << "\tUse Groups:"); + LLVM_DEBUG(dbgs() << "\tUse Groups:"); std::multimap& RegRefs = State->GetRegRefs(); @@ -469,7 +469,7 @@ unsigned Reg = MO.getReg(); if (Reg == 0) continue; - DEBUG(dbgs() << " " << printReg(Reg, TRI) << "=g" << State->GetGroup(Reg)); + LLVM_DEBUG(dbgs() << " " << printReg(Reg, TRI) << "=g" << State->GetGroup(Reg)); // It wasn't previously live but now it is, this is a kill. Forget // the previous live-range information and start a new live-range @@ -477,7 +477,7 @@ HandleLastUse(Reg, Count, "(last-use)"); if (Special) { - DEBUG(if (State->GetGroup(Reg) != 0) dbgs() << "->g0(alloc-req)"); + LLVM_DEBUG(if (State->GetGroup(Reg) != 0) dbgs() << "->g0(alloc-req)"); State->UnionGroups(Reg, 0); } @@ -489,12 +489,12 @@ RegRefs.insert(std::make_pair(Reg, RR)); } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); // Form a group of all defs and uses of a KILL instruction to ensure // that all registers are renamed as a group. if (MI.isKill()) { - DEBUG(dbgs() << "\tKill Group:"); + LLVM_DEBUG(dbgs() << "\tKill Group:"); unsigned FirstReg = 0; for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) { @@ -504,15 +504,15 @@ if (Reg == 0) continue; if (FirstReg != 0) { - DEBUG(dbgs() << "=" << printReg(Reg, TRI)); + LLVM_DEBUG(dbgs() << "=" << printReg(Reg, TRI)); State->UnionGroups(FirstReg, Reg); } else { - DEBUG(dbgs() << " " << printReg(Reg, TRI)); + LLVM_DEBUG(dbgs() << " " << printReg(Reg, TRI)); FirstReg = Reg; } } - DEBUG(dbgs() << "->g" << State->GetGroup(FirstReg) << '\n'); + LLVM_DEBUG(dbgs() << "->g" << State->GetGroup(FirstReg) << '\n'); } } @@ -535,7 +535,7 @@ BV &= RCBV; } - DEBUG(dbgs() << " " << TRI->getRegClassName(RC)); + LLVM_DEBUG(dbgs() << " " << TRI->getRegClassName(RC)); } return BV; @@ -562,7 +562,7 @@ // Find the "superest" register in the group. At the same time, // collect the BitVector of registers that can be used to rename // each register. - DEBUG(dbgs() << "\tRename Candidates for Group g" << AntiDepGroupIndex + LLVM_DEBUG(dbgs() << "\tRename Candidates for Group g" << AntiDepGroupIndex << ":\n"); std::map RenameRegisterMap; unsigned SuperReg = 0; @@ -573,13 +573,13 @@ // If Reg has any references, then collect possible rename regs if (RegRefs.count(Reg) > 0) { - DEBUG(dbgs() << "\t\t" << printReg(Reg, TRI) << ":"); + LLVM_DEBUG(dbgs() << "\t\t" << printReg(Reg, TRI) << ":"); BitVector &BV = RenameRegisterMap[Reg]; assert(BV.empty()); BV = GetRenameRegisters(Reg); - DEBUG({ + LLVM_DEBUG({ dbgs() << " ::"; for (unsigned r : BV.set_bits()) dbgs() << " " << printReg(r, TRI); @@ -625,11 +625,11 @@ ArrayRef Order = RegClassInfo.getOrder(SuperRC); if (Order.empty()) { - DEBUG(dbgs() << "\tEmpty Super Regclass!!\n"); + LLVM_DEBUG(dbgs() << "\tEmpty Super Regclass!!\n"); return false; } - DEBUG(dbgs() << "\tFind Registers:"); + LLVM_DEBUG(dbgs() << "\tFind Registers:"); RenameOrder.insert(RenameOrderType::value_type(SuperRC, Order.size())); @@ -645,7 +645,7 @@ // Don't replace a register with itself. if (NewSuperReg == SuperReg) continue; - DEBUG(dbgs() << " [" << printReg(NewSuperReg, TRI) << ':'); + LLVM_DEBUG(dbgs() << " [" << printReg(NewSuperReg, TRI) << ':'); RenameMap.clear(); // For each referenced group register (which must be a SuperReg or @@ -662,11 +662,11 @@ NewReg = TRI->getSubReg(NewSuperReg, NewSubRegIdx); } - DEBUG(dbgs() << " " << printReg(NewReg, TRI)); + LLVM_DEBUG(dbgs() << " " << printReg(NewReg, TRI)); // Check if Reg can be renamed to NewReg. if (!RenameRegisterMap[Reg].test(NewReg)) { - DEBUG(dbgs() << "(no rename)"); + LLVM_DEBUG(dbgs() << "(no rename)"); goto next_super_reg; } @@ -675,7 +675,7 @@ // must also check all aliases of NewReg, because we can't define a // register when any sub or super is already live. if (State->IsLive(NewReg) || (KillIndices[Reg] > DefIndices[NewReg])) { - DEBUG(dbgs() << "(live)"); + LLVM_DEBUG(dbgs() << "(live)"); goto next_super_reg; } else { bool found = false; @@ -683,7 +683,7 @@ unsigned AliasReg = *AI; if (State->IsLive(AliasReg) || (KillIndices[Reg] > DefIndices[AliasReg])) { - DEBUG(dbgs() << "(alias " << printReg(AliasReg, TRI) << " live)"); + LLVM_DEBUG(dbgs() << "(alias " << printReg(AliasReg, TRI) << " live)"); found = true; break; } @@ -701,7 +701,7 @@ continue; if (UseMI->getOperand(Idx).isEarlyClobber()) { - DEBUG(dbgs() << "(ec)"); + LLVM_DEBUG(dbgs() << "(ec)"); goto next_super_reg; } } @@ -715,7 +715,7 @@ MachineInstr *DefMI = Q.second.Operand->getParent(); if (DefMI->readsRegister(NewReg, TRI)) { - DEBUG(dbgs() << "(ec)"); + LLVM_DEBUG(dbgs() << "(ec)"); goto next_super_reg; } } @@ -728,14 +728,14 @@ // renamed, as recorded in RenameMap. RenameOrder.erase(SuperRC); RenameOrder.insert(RenameOrderType::value_type(SuperRC, R)); - DEBUG(dbgs() << "]\n"); + LLVM_DEBUG(dbgs() << "]\n"); return true; next_super_reg: - DEBUG(dbgs() << ']'); + LLVM_DEBUG(dbgs() << ']'); } while (R != EndR); - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); // No registers are free and available! return false; @@ -788,13 +788,13 @@ } #ifndef NDEBUG - DEBUG(dbgs() << "\n===== Aggressive anti-dependency breaking\n"); - DEBUG(dbgs() << "Available regs:"); + LLVM_DEBUG(dbgs() << "\n===== Aggressive anti-dependency breaking\n"); + LLVM_DEBUG(dbgs() << "Available regs:"); for (unsigned Reg = 0; Reg < TRI->getNumRegs(); ++Reg) { if (!State->IsLive(Reg)) - DEBUG(dbgs() << " " << printReg(Reg, TRI)); + LLVM_DEBUG(dbgs() << " " << printReg(Reg, TRI)); } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); #endif BitVector RegAliases(TRI->getNumRegs()); @@ -811,8 +811,8 @@ if (MI.isDebugValue()) continue; - DEBUG(dbgs() << "Anti: "); - DEBUG(MI.dump()); + LLVM_DEBUG(dbgs() << "Anti: "); + LLVM_DEBUG(MI.dump()); std::set PassthruRegs; GetPassthruRegs(MI, PassthruRegs); @@ -848,30 +848,30 @@ (Edge->getKind() != SDep::Output)) continue; unsigned AntiDepReg = Edge->getReg(); - DEBUG(dbgs() << "\tAntidep reg: " << printReg(AntiDepReg, TRI)); + LLVM_DEBUG(dbgs() << "\tAntidep reg: " << printReg(AntiDepReg, TRI)); assert(AntiDepReg != 0 && "Anti-dependence on reg0?"); if (!MRI.isAllocatable(AntiDepReg)) { // Don't break anti-dependencies on non-allocatable registers. - DEBUG(dbgs() << " (non-allocatable)\n"); + LLVM_DEBUG(dbgs() << " (non-allocatable)\n"); continue; } else if (ExcludeRegs && ExcludeRegs->test(AntiDepReg)) { // Don't break anti-dependencies for critical path registers // if not on the critical path - DEBUG(dbgs() << " (not critical-path)\n"); + LLVM_DEBUG(dbgs() << " (not critical-path)\n"); continue; } else if (PassthruRegs.count(AntiDepReg) != 0) { // If the anti-dep register liveness "passes-thru", then // don't try to change it. It will be changed along with // the use if required to break an earlier antidep. - DEBUG(dbgs() << " (passthru)\n"); + LLVM_DEBUG(dbgs() << " (passthru)\n"); continue; } else { // No anti-dep breaking for implicit deps MachineOperand *AntiDepOp = MI.findRegisterDefOperand(AntiDepReg); assert(AntiDepOp && "Can't find index for defined register operand"); if (!AntiDepOp || AntiDepOp->isImplicit()) { - DEBUG(dbgs() << " (implicit)\n"); + LLVM_DEBUG(dbgs() << " (implicit)\n"); continue; } @@ -897,13 +897,13 @@ PE = PathSU->Preds.end(); P != PE; ++P) { if ((P->getSUnit() == NextSU) && (P->getKind() != SDep::Anti) && (P->getKind() != SDep::Output)) { - DEBUG(dbgs() << " (real dependency)\n"); + LLVM_DEBUG(dbgs() << " (real dependency)\n"); AntiDepReg = 0; break; } else if ((P->getSUnit() != NextSU) && (P->getKind() == SDep::Data) && (P->getReg() == AntiDepReg)) { - DEBUG(dbgs() << " (other dependency)\n"); + LLVM_DEBUG(dbgs() << " (other dependency)\n"); AntiDepReg = 0; break; } @@ -941,16 +941,16 @@ // Determine AntiDepReg's register group. const unsigned GroupIndex = State->GetGroup(AntiDepReg); if (GroupIndex == 0) { - DEBUG(dbgs() << " (zero group)\n"); + LLVM_DEBUG(dbgs() << " (zero group)\n"); continue; } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); // Look for a suitable register to use to break the anti-dependence. std::map RenameMap; if (FindSuitableFreeRegisters(GroupIndex, RenameOrder, RenameMap)) { - DEBUG(dbgs() << "\tBreaking anti-dependence edge on " + LLVM_DEBUG(dbgs() << "\tBreaking anti-dependence edge on " << printReg(AntiDepReg, TRI) << ":"); // Handle each group register... @@ -959,7 +959,7 @@ unsigned CurrReg = S->first; unsigned NewReg = S->second; - DEBUG(dbgs() << " " << printReg(CurrReg, TRI) << "->" + LLVM_DEBUG(dbgs() << " " << printReg(CurrReg, TRI) << "->" << printReg(NewReg, TRI) << "(" << RegRefs.count(CurrReg) << " refs)"); @@ -994,7 +994,7 @@ } ++Broken; - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); } } } Index: lib/CodeGen/AllocationOrder.cpp =================================================================== --- lib/CodeGen/AllocationOrder.cpp +++ lib/CodeGen/AllocationOrder.cpp @@ -39,7 +39,7 @@ HardHints = true; rewind(); - DEBUG({ + LLVM_DEBUG({ if (!Hints.empty()) { dbgs() << "hints:"; for (unsigned I = 0, E = Hints.size(); I != E; ++I) Index: lib/CodeGen/AsmPrinter/DIE.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DIE.cpp +++ lib/CodeGen/AsmPrinter/DIE.cpp @@ -86,7 +86,7 @@ // easily, which helps track down where it came from. if (!dwarf::isValidFormForVersion(AttrData.getForm(), AP->getDwarfVersion())) { - DEBUG(dbgs() << "Invalid form " << format("0x%x", AttrData.getForm()) + LLVM_DEBUG(dbgs() << "Invalid form " << format("0x%x", AttrData.getForm()) << " for DWARF version " << AP->getDwarfVersion() << "\n"); llvm_unreachable("Invalid form for specified DWARF version"); } Index: lib/CodeGen/AsmPrinter/DIEHash.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DIEHash.cpp +++ lib/CodeGen/AsmPrinter/DIEHash.cpp @@ -43,7 +43,7 @@ /// \brief Adds the string in \p Str to the hash. This also hashes /// a trailing NULL with the string. void DIEHash::addString(StringRef Str) { - DEBUG(dbgs() << "Adding string " << Str << " to hash.\n"); + LLVM_DEBUG(dbgs() << "Adding string " << Str << " to hash.\n"); Hash.update(Str); Hash.update(makeArrayRef((uint8_t)'\0')); } @@ -53,7 +53,7 @@ /// \brief Adds the unsigned in \p Value to the hash encoded as a ULEB128. void DIEHash::addULEB128(uint64_t Value) { - DEBUG(dbgs() << "Adding ULEB128 " << Value << " to hash.\n"); + LLVM_DEBUG(dbgs() << "Adding ULEB128 " << Value << " to hash.\n"); do { uint8_t Byte = Value & 0x7f; Value >>= 7; @@ -64,7 +64,7 @@ } void DIEHash::addSLEB128(int64_t Value) { - DEBUG(dbgs() << "Adding ULEB128 " << Value << " to hash.\n"); + LLVM_DEBUG(dbgs() << "Adding ULEB128 " << Value << " to hash.\n"); bool More; do { uint8_t Byte = Value & 0x7f; @@ -80,7 +80,7 @@ /// \brief Including \p Parent adds the context of Parent to the hash.. void DIEHash::addParentContext(const DIE &Parent) { - DEBUG(dbgs() << "Adding parent context to hash...\n"); + LLVM_DEBUG(dbgs() << "Adding parent context to hash...\n"); // [7.27.2] For each surrounding type or namespace beginning with the // outermost such construct... @@ -108,7 +108,7 @@ // ... Then the name, taken from the DW_AT_name attribute. StringRef Name = getDIEStringAttr(Die, dwarf::DW_AT_name); - DEBUG(dbgs() << "... adding context: " << Name << "\n"); + LLVM_DEBUG(dbgs() << "... adding context: " << Name << "\n"); if (!Name.empty()) addString(Name); } @@ -118,7 +118,7 @@ void DIEHash::collectAttributes(const DIE &Die, DIEAttrs &Attrs) { for (const auto &V : Die.values()) { - DEBUG(dbgs() << "Attribute: " + LLVM_DEBUG(dbgs() << "Attribute: " << dwarf::AttributeString(V.getAttribute()) << " added.\n"); switch (V.getAttribute()) { Index: lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp +++ lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp @@ -50,7 +50,7 @@ auto &Ranges = VarInstrRanges[Var]; if (!Ranges.empty() && Ranges.back().second == nullptr && Ranges.back().first->isIdenticalTo(MI)) { - DEBUG(dbgs() << "Coalescing identical DBG_VALUE entries:\n" + LLVM_DEBUG(dbgs() << "Coalescing identical DBG_VALUE entries:\n" << "\t" << Ranges.back().first << "\t" << MI << "\n"); return; } Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -999,7 +999,7 @@ EndLabel = getLabelBeforeInsn(std::next(I)->first); assert(EndLabel && "Forgot label after instruction ending a range!"); - DEBUG(dbgs() << "DotDebugLoc: " << *Begin << "\n"); + LLVM_DEBUG(dbgs() << "DotDebugLoc: " << *Begin << "\n"); auto Value = getDebugLocValue(Begin); DebugLocEntry Loc(StartLabel, EndLabel, Value); @@ -1028,7 +1028,7 @@ // Attempt to coalesce the ranges of two otherwise identical // DebugLocEntries. auto CurEntry = DebugLoc.rbegin(); - DEBUG({ + LLVM_DEBUG({ dbgs() << CurEntry->getValues().size() << " Values:\n"; for (auto &Value : CurEntry->getValues()) Value.dump(); Index: lib/CodeGen/AtomicExpandPass.cpp =================================================================== --- lib/CodeGen/AtomicExpandPass.cpp +++ lib/CodeGen/AtomicExpandPass.cpp @@ -379,7 +379,7 @@ NewLI->setAlignment(LI->getAlignment()); NewLI->setVolatile(LI->isVolatile()); NewLI->setAtomic(LI->getOrdering(), LI->getSyncScopeID()); - DEBUG(dbgs() << "Replaced " << *LI << " with " << *NewLI << "\n"); + LLVM_DEBUG(dbgs() << "Replaced " << *LI << " with " << *NewLI << "\n"); Value *NewVal = Builder.CreateBitCast(NewLI, LI->getType()); LI->replaceAllUsesWith(NewVal); @@ -462,7 +462,7 @@ NewSI->setAlignment(SI->getAlignment()); NewSI->setVolatile(SI->isVolatile()); NewSI->setAtomic(SI->getOrdering(), SI->getSyncScopeID()); - DEBUG(dbgs() << "Replaced " << *SI << " with " << *NewSI << "\n"); + LLVM_DEBUG(dbgs() << "Replaced " << *SI << " with " << *NewSI << "\n"); SI->eraseFromParent(); return NewSI; } @@ -943,7 +943,7 @@ CI->getSyncScopeID()); NewCI->setVolatile(CI->isVolatile()); NewCI->setWeak(CI->isWeak()); - DEBUG(dbgs() << "Replaced " << *CI << " with " << *NewCI << "\n"); + LLVM_DEBUG(dbgs() << "Replaced " << *CI << " with " << *NewCI << "\n"); Value *OldVal = Builder.CreateExtractValue(NewCI, 0); Value *Succ = Builder.CreateExtractValue(NewCI, 1); Index: lib/CodeGen/BranchFolding.cpp =================================================================== --- lib/CodeGen/BranchFolding.cpp +++ lib/CodeGen/BranchFolding.cpp @@ -152,7 +152,7 @@ void BranchFolder::RemoveDeadBlock(MachineBasicBlock *MBB) { assert(MBB->pred_empty() && "MBB must be dead!"); - DEBUG(dbgs() << "\nRemoving MBB: " << *MBB); + LLVM_DEBUG(dbgs() << "\nRemoving MBB: " << *MBB); MachineFunction *MF = MBB->getParent(); // drop all successors. @@ -613,7 +613,7 @@ CommonTailLen = ComputeCommonTailLength(MBB1, MBB2, I1, I2); if (CommonTailLen == 0) return false; - DEBUG(dbgs() << "Common tail length of " << printMBBReference(*MBB1) + LLVM_DEBUG(dbgs() << "Common tail length of " << printMBBReference(*MBB1) << " and " << printMBBReference(*MBB2) << " is " << CommonTailLen << '\n'); @@ -770,7 +770,7 @@ SameTails[commonTailIndex].getTailStartPos(); MachineBasicBlock *MBB = SameTails[commonTailIndex].getBlock(); - DEBUG(dbgs() << "\nSplitting " << printMBBReference(*MBB) << ", size " + LLVM_DEBUG(dbgs() << "\nSplitting " << printMBBReference(*MBB) << ", size " << maxCommonTailLength); // If the split block unconditionally falls-thru to SuccBB, it will be @@ -780,7 +780,7 @@ SuccBB->getBasicBlock() : MBB->getBasicBlock(); MachineBasicBlock *newMBB = SplitMBBAt(*MBB, BBI, BB); if (!newMBB) { - DEBUG(dbgs() << "... failed!"); + LLVM_DEBUG(dbgs() << "... failed!"); return false; } @@ -919,7 +919,7 @@ unsigned MinCommonTailLength) { bool MadeChange = false; - DEBUG(dbgs() << "\nTryTailMergeBlocks: "; + LLVM_DEBUG(dbgs() << "\nTryTailMergeBlocks: "; for (unsigned i = 0, e = MergePotentials.size(); i != e; ++i) dbgs() << printMBBReference(*MergePotentials[i].getBlock()) << (i == e - 1 ? "" : ", "); @@ -1010,19 +1010,19 @@ // MBB is common tail. Adjust all other BB's to jump to this one. // Traversal must be forwards so erases work. - DEBUG(dbgs() << "\nUsing common tail in " << printMBBReference(*MBB) + LLVM_DEBUG(dbgs() << "\nUsing common tail in " << printMBBReference(*MBB) << " for "); for (unsigned int i=0, e = SameTails.size(); i != e; ++i) { if (commonTailIndex == i) continue; - DEBUG(dbgs() << printMBBReference(*SameTails[i].getBlock()) + LLVM_DEBUG(dbgs() << printMBBReference(*SameTails[i].getBlock()) << (i == e - 1 ? "" : ", ")); // Hack the end off BB i, making it jump to BB commonTailIndex instead. replaceTailWithBranchTo(SameTails[i].getTailStartPos(), *MBB); // BB i is no longer a predecessor of SuccBB; remove it from the worklist. MergePotentials.erase(SameTails[i].getMPIter()); } - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n"); // We leave commonTailIndex in the worklist in case there are other blocks // that match it with a smaller number of instructions. MadeChange = true; @@ -1406,7 +1406,7 @@ if (PriorCond.empty() && !PriorTBB && MBB->pred_size() == 1 && PrevBB.succ_size() == 1 && !MBB->hasAddressTaken() && !MBB->isEHPad()) { - DEBUG(dbgs() << "\nMerging into block: " << PrevBB + LLVM_DEBUG(dbgs() << "\nMerging into block: " << PrevBB << "From MBB: " << *MBB); // Remove redundant DBG_VALUEs first. if (PrevBB.begin() != PrevBB.end()) { @@ -1493,7 +1493,7 @@ // Reverse the branch so we will fall through on the previous true cond. SmallVector NewPriorCond(PriorCond); if (!TII->reverseBranchCondition(NewPriorCond)) { - DEBUG(dbgs() << "\nMoving MBB: " << *MBB + LLVM_DEBUG(dbgs() << "\nMoving MBB: " << *MBB << "To make fallthrough to: " << *PriorTBB << "\n"); DebugLoc dl = getBranchDebugLoc(PrevBB); Index: lib/CodeGen/BranchRelaxation.cpp =================================================================== --- lib/CodeGen/BranchRelaxation.cpp +++ lib/CodeGen/BranchRelaxation.cpp @@ -287,7 +287,7 @@ if (TII->isBranchOffsetInRange(MI.getOpcode(), DestOffset - BrOffset)) return true; - DEBUG(dbgs() << "Out of range branch to destination " + LLVM_DEBUG(dbgs() << "Out of range branch to destination " << printMBBReference(DestBB) << " from " << printMBBReference(*MI.getParent()) << " to " << DestOffset << " offset " << DestOffset - BrOffset << '\t' << MI); @@ -359,7 +359,7 @@ // => // bne L2 // b L1 - DEBUG(dbgs() << " Invert condition and swap " + LLVM_DEBUG(dbgs() << " Invert condition and swap " "its destination with " << MBB->back()); removeBranch(MBB); @@ -383,7 +383,7 @@ // just created), so we can use the inverted the condition. MachineBasicBlock &NextBB = *std::next(MachineFunction::iterator(MBB)); - DEBUG(dbgs() << " Insert B to " << printMBBReference(*TBB) + LLVM_DEBUG(dbgs() << " Insert B to " << printMBBReference(*TBB) << ", invert condition and change dest. to " << printMBBReference(NextBB) << '\n'); @@ -396,7 +396,7 @@ } // Branch cond can't be inverted. // In this case we always add a block after the MBB. - DEBUG(dbgs() << " The branch condition can't be inverted. " + LLVM_DEBUG(dbgs() << " The branch condition can't be inverted. " << " Insert a new BB after " << MBB->back()); if (!FBB) @@ -416,7 +416,7 @@ NewBB = createNewBlockAfter(*MBB); insertUncondBranch(NewBB, TBB); - DEBUG(dbgs() << " Insert cond B to the new BB " << printMBBReference(*NewBB) + LLVM_DEBUG(dbgs() << " Insert cond B to the new BB " << printMBBReference(*NewBB) << " Keep the exiting condition.\n" << " Insert B to " << printMBBReference(*FBB) << ".\n" << " In the new BB: Insert B to " @@ -540,7 +540,7 @@ bool BranchRelaxation::runOnMachineFunction(MachineFunction &mf) { MF = &mf; - DEBUG(dbgs() << "***** BranchRelaxation *****\n"); + LLVM_DEBUG(dbgs() << "***** BranchRelaxation *****\n"); const TargetSubtargetInfo &ST = MF->getSubtarget(); TII = ST.getInstrInfo(); @@ -557,7 +557,7 @@ // sizes of each block. scanFunction(); - DEBUG(dbgs() << " Basic blocks before relaxation\n"; dumpBBs();); + LLVM_DEBUG(dbgs() << " Basic blocks before relaxation\n"; dumpBBs();); bool MadeChange = false; while (relaxBranchInstructions()) @@ -566,7 +566,7 @@ // After a while, this might be made debug-only, but it is not expensive. verify(); - DEBUG(dbgs() << " Basic blocks after relaxation\n\n"; dumpBBs()); + LLVM_DEBUG(dbgs() << " Basic blocks after relaxation\n\n"; dumpBBs()); BlockInfo.clear(); Index: lib/CodeGen/BreakFalseDeps.cpp =================================================================== --- lib/CodeGen/BreakFalseDeps.cpp +++ lib/CodeGen/BreakFalseDeps.cpp @@ -165,13 +165,13 @@ unsigned Pref) { unsigned reg = MI->getOperand(OpIdx).getReg(); unsigned Clearance = RDA->getClearance(MI, reg); - DEBUG(dbgs() << "Clearance: " << Clearance << ", want " << Pref); + LLVM_DEBUG(dbgs() << "Clearance: " << Clearance << ", want " << Pref); if (Pref > Clearance) { - DEBUG(dbgs() << ": Break dependency.\n"); + LLVM_DEBUG(dbgs() << ": Break dependency.\n"); return true; } - DEBUG(dbgs() << ": OK .\n"); + LLVM_DEBUG(dbgs() << ": OK .\n"); return false; } @@ -260,7 +260,7 @@ RegClassInfo.runOnMachineFunction(mf); - DEBUG(dbgs() << "********** BREAK FALSE DEPENDENCIES **********\n"); + LLVM_DEBUG(dbgs() << "********** BREAK FALSE DEPENDENCIES **********\n"); // Traverse the basic blocks. for (MachineBasicBlock &MBB : mf) { Index: lib/CodeGen/CalcSpillWeights.cpp =================================================================== --- lib/CodeGen/CalcSpillWeights.cpp +++ lib/CodeGen/CalcSpillWeights.cpp @@ -35,7 +35,7 @@ const MachineLoopInfo &MLI, const MachineBlockFrequencyInfo &MBFI, VirtRegAuxInfo::NormalizingFn norm) { - DEBUG(dbgs() << "********** Compute Spill Weights **********\n" + LLVM_DEBUG(dbgs() << "********** Compute Spill Weights **********\n" << "********** Function: " << MF.getName() << '\n'); MachineRegisterInfo &MRI = MF.getRegInfo(); Index: lib/CodeGen/CodeGenPrepare.cpp =================================================================== --- lib/CodeGen/CodeGenPrepare.cpp +++ lib/CodeGen/CodeGenPrepare.cpp @@ -503,7 +503,7 @@ BranchInst *Term = dyn_cast(SinglePred->getTerminator()); if (Term && !Term->isConditional()) { Changed = true; - DEBUG(dbgs() << "To merge:\n"<< *SinglePred << "\n\n\n"); + LLVM_DEBUG(dbgs() << "To merge:\n"<< *SinglePred << "\n\n\n"); // Remember if SinglePred was the entry block of the function. // If so, we will need to move BB back to the entry position. bool isEntry = SinglePred == &SinglePred->getParent()->getEntryBlock(); @@ -730,7 +730,7 @@ BranchInst *BI = cast(BB->getTerminator()); BasicBlock *DestBB = BI->getSuccessor(0); - DEBUG(dbgs() << "MERGING MOSTLY EMPTY BLOCKS - BEFORE:\n" << *BB << *DestBB); + LLVM_DEBUG(dbgs() << "MERGING MOSTLY EMPTY BLOCKS - BEFORE:\n" << *BB << *DestBB); // If the destination block has a single pred, then this is a trivial edge, // just collapse it. @@ -744,7 +744,7 @@ if (isEntry && BB != &BB->getParent()->getEntryBlock()) BB->moveBefore(&BB->getParent()->getEntryBlock()); - DEBUG(dbgs() << "AFTER:\n" << *DestBB << "\n\n\n"); + LLVM_DEBUG(dbgs() << "AFTER:\n" << *DestBB << "\n\n\n"); return; } } @@ -782,7 +782,7 @@ BB->eraseFromParent(); ++NumBlocksElim; - DEBUG(dbgs() << "AFTER:\n" << *DestBB << "\n\n\n"); + LLVM_DEBUG(dbgs() << "AFTER:\n" << *DestBB << "\n\n\n"); } // Computes a map of base pointer relocation instructions to corresponding @@ -1247,8 +1247,8 @@ if (!TLI.isMaskAndCmp0FoldingBeneficial(*AndI)) return false; - DEBUG(dbgs() << "found 'and' feeding only icmp 0;\n"); - DEBUG(AndI->getParent()->dump()); + LLVM_DEBUG(dbgs() << "found 'and' feeding only icmp 0;\n"); + LLVM_DEBUG(AndI->getParent()->dump()); // Push the 'and' into the same block as the icmp 0. There should only be // one (icmp (and, 0)) in each block, since CSE/GVN should have removed any @@ -1261,7 +1261,7 @@ // Preincrement use iterator so we don't invalidate it. ++UI; - DEBUG(dbgs() << "sinking 'and' use: " << *User << "\n"); + LLVM_DEBUG(dbgs() << "sinking 'and' use: " << *User << "\n"); // Keep the 'and' in the same place if the use is already in the same block. Instruction *InsertPt = @@ -1275,7 +1275,7 @@ // Replace a use of the 'and' with a use of the new 'and'. TheUse = InsertedAnd; ++NumAndUses; - DEBUG(User->getParent()->dump()); + LLVM_DEBUG(User->getParent()->dump()); } // We removed all uses, nuke the and. @@ -2105,13 +2105,13 @@ /// \brief Move \p Inst before \p Before. InstructionMoveBefore(Instruction *Inst, Instruction *Before) : TypePromotionAction(Inst), Position(Inst) { - DEBUG(dbgs() << "Do: move: " << *Inst << "\nbefore: " << *Before << "\n"); + LLVM_DEBUG(dbgs() << "Do: move: " << *Inst << "\nbefore: " << *Before << "\n"); Inst->moveBefore(Before); } /// \brief Move the instruction back to its original position. void undo() override { - DEBUG(dbgs() << "Undo: moveBefore: " << *Inst << "\n"); + LLVM_DEBUG(dbgs() << "Undo: moveBefore: " << *Inst << "\n"); Position.insert(Inst); } }; @@ -2128,7 +2128,7 @@ /// \brief Set \p Idx operand of \p Inst with \p NewVal. OperandSetter(Instruction *Inst, unsigned Idx, Value *NewVal) : TypePromotionAction(Inst), Idx(Idx) { - DEBUG(dbgs() << "Do: setOperand: " << Idx << "\n" + LLVM_DEBUG(dbgs() << "Do: setOperand: " << Idx << "\n" << "for:" << *Inst << "\n" << "with:" << *NewVal << "\n"); Origin = Inst->getOperand(Idx); @@ -2137,7 +2137,7 @@ /// \brief Restore the original value of the instruction. void undo() override { - DEBUG(dbgs() << "Undo: setOperand:" << Idx << "\n" + LLVM_DEBUG(dbgs() << "Undo: setOperand:" << Idx << "\n" << "for: " << *Inst << "\n" << "with: " << *Origin << "\n"); Inst->setOperand(Idx, Origin); @@ -2153,7 +2153,7 @@ public: /// \brief Remove \p Inst from the uses of the operands of \p Inst. OperandsHider(Instruction *Inst) : TypePromotionAction(Inst) { - DEBUG(dbgs() << "Do: OperandsHider: " << *Inst << "\n"); + LLVM_DEBUG(dbgs() << "Do: OperandsHider: " << *Inst << "\n"); unsigned NumOpnds = Inst->getNumOperands(); OriginalValues.reserve(NumOpnds); for (unsigned It = 0; It < NumOpnds; ++It) { @@ -2169,7 +2169,7 @@ /// \brief Restore the original list of uses. void undo() override { - DEBUG(dbgs() << "Undo: OperandsHider: " << *Inst << "\n"); + LLVM_DEBUG(dbgs() << "Undo: OperandsHider: " << *Inst << "\n"); for (unsigned It = 0, EndIt = OriginalValues.size(); It != EndIt; ++It) Inst->setOperand(It, OriginalValues[It]); } @@ -2186,7 +2186,7 @@ TruncBuilder(Instruction *Opnd, Type *Ty) : TypePromotionAction(Opnd) { IRBuilder<> Builder(Opnd); Val = Builder.CreateTrunc(Opnd, Ty, "promoted"); - DEBUG(dbgs() << "Do: TruncBuilder: " << *Val << "\n"); + LLVM_DEBUG(dbgs() << "Do: TruncBuilder: " << *Val << "\n"); } /// \brief Get the built value. @@ -2194,7 +2194,7 @@ /// \brief Remove the built instruction. void undo() override { - DEBUG(dbgs() << "Undo: TruncBuilder: " << *Val << "\n"); + LLVM_DEBUG(dbgs() << "Undo: TruncBuilder: " << *Val << "\n"); if (Instruction *IVal = dyn_cast(Val)) IVal->eraseFromParent(); } @@ -2212,7 +2212,7 @@ : TypePromotionAction(InsertPt) { IRBuilder<> Builder(InsertPt); Val = Builder.CreateSExt(Opnd, Ty, "promoted"); - DEBUG(dbgs() << "Do: SExtBuilder: " << *Val << "\n"); + LLVM_DEBUG(dbgs() << "Do: SExtBuilder: " << *Val << "\n"); } /// \brief Get the built value. @@ -2220,7 +2220,7 @@ /// \brief Remove the built instruction. void undo() override { - DEBUG(dbgs() << "Undo: SExtBuilder: " << *Val << "\n"); + LLVM_DEBUG(dbgs() << "Undo: SExtBuilder: " << *Val << "\n"); if (Instruction *IVal = dyn_cast(Val)) IVal->eraseFromParent(); } @@ -2238,7 +2238,7 @@ : TypePromotionAction(InsertPt) { IRBuilder<> Builder(InsertPt); Val = Builder.CreateZExt(Opnd, Ty, "promoted"); - DEBUG(dbgs() << "Do: ZExtBuilder: " << *Val << "\n"); + LLVM_DEBUG(dbgs() << "Do: ZExtBuilder: " << *Val << "\n"); } /// \brief Get the built value. @@ -2246,7 +2246,7 @@ /// \brief Remove the built instruction. void undo() override { - DEBUG(dbgs() << "Undo: ZExtBuilder: " << *Val << "\n"); + LLVM_DEBUG(dbgs() << "Undo: ZExtBuilder: " << *Val << "\n"); if (Instruction *IVal = dyn_cast(Val)) IVal->eraseFromParent(); } @@ -2261,14 +2261,14 @@ /// \brief Mutate the type of \p Inst into \p NewTy. TypeMutator(Instruction *Inst, Type *NewTy) : TypePromotionAction(Inst), OrigTy(Inst->getType()) { - DEBUG(dbgs() << "Do: MutateType: " << *Inst << " with " << *NewTy + LLVM_DEBUG(dbgs() << "Do: MutateType: " << *Inst << " with " << *NewTy << "\n"); Inst->mutateType(NewTy); } /// \brief Mutate the instruction back to its original type. void undo() override { - DEBUG(dbgs() << "Undo: MutateType: " << *Inst << " with " << *OrigTy + LLVM_DEBUG(dbgs() << "Undo: MutateType: " << *Inst << " with " << *OrigTy << "\n"); Inst->mutateType(OrigTy); } @@ -2296,7 +2296,7 @@ public: /// \brief Replace all the use of \p Inst by \p New. UsesReplacer(Instruction *Inst, Value *New) : TypePromotionAction(Inst) { - DEBUG(dbgs() << "Do: UsersReplacer: " << *Inst << " with " << *New + LLVM_DEBUG(dbgs() << "Do: UsersReplacer: " << *Inst << " with " << *New << "\n"); // Record the original uses. for (Use &U : Inst->uses()) { @@ -2309,7 +2309,7 @@ /// \brief Reassign the original uses of Inst to Inst. void undo() override { - DEBUG(dbgs() << "Undo: UsersReplacer: " << *Inst << "\n"); + LLVM_DEBUG(dbgs() << "Undo: UsersReplacer: " << *Inst << "\n"); for (use_iterator UseIt = OriginalUses.begin(), EndIt = OriginalUses.end(); UseIt != EndIt; ++UseIt) { @@ -2344,7 +2344,7 @@ RemovedInsts(RemovedInsts) { if (New) Replacer = new UsesReplacer(Inst, New); - DEBUG(dbgs() << "Do: InstructionRemover: " << *Inst << "\n"); + LLVM_DEBUG(dbgs() << "Do: InstructionRemover: " << *Inst << "\n"); RemovedInsts.insert(Inst); /// The instructions removed here will be freed after completing /// optimizeBlock() for all blocks as we need to keep track of the @@ -2357,7 +2357,7 @@ /// \brief Resurrect the instruction and reassign it to the proper uses if /// new value was provided when build this action. void undo() override { - DEBUG(dbgs() << "Undo: InstructionRemover: " << *Inst << "\n"); + LLVM_DEBUG(dbgs() << "Undo: InstructionRemover: " << *Inst << "\n"); Inserter.insert(Inst); if (Replacer) Replacer->undo(); @@ -3505,19 +3505,19 @@ // Step #3. Instruction *ExtForOpnd = Ext; - DEBUG(dbgs() << "Propagate Ext to operands\n"); + LLVM_DEBUG(dbgs() << "Propagate Ext to operands\n"); for (int OpIdx = 0, EndOpIdx = ExtOpnd->getNumOperands(); OpIdx != EndOpIdx; ++OpIdx) { - DEBUG(dbgs() << "Operand:\n" << *(ExtOpnd->getOperand(OpIdx)) << '\n'); + LLVM_DEBUG(dbgs() << "Operand:\n" << *(ExtOpnd->getOperand(OpIdx)) << '\n'); if (ExtOpnd->getOperand(OpIdx)->getType() == Ext->getType() || !shouldExtOperand(ExtOpnd, OpIdx)) { - DEBUG(dbgs() << "No need to propagate\n"); + LLVM_DEBUG(dbgs() << "No need to propagate\n"); continue; } // Check if we can statically extend the operand. Value *Opnd = ExtOpnd->getOperand(OpIdx); if (const ConstantInt *Cst = dyn_cast(Opnd)) { - DEBUG(dbgs() << "Statically extend\n"); + LLVM_DEBUG(dbgs() << "Statically extend\n"); unsigned BitWidth = Ext->getType()->getIntegerBitWidth(); APInt CstVal = IsSExt ? Cst->getValue().sext(BitWidth) : Cst->getValue().zext(BitWidth); @@ -3526,7 +3526,7 @@ } // UndefValue are typed, so we have to statically sign extend them. if (isa(Opnd)) { - DEBUG(dbgs() << "Statically extend\n"); + LLVM_DEBUG(dbgs() << "Statically extend\n"); TPT.setOperand(ExtOpnd, OpIdx, UndefValue::get(Ext->getType())); continue; } @@ -3535,7 +3535,7 @@ // Check if Ext was reused to extend an operand. if (!ExtForOpnd) { // If yes, create a new one. - DEBUG(dbgs() << "More operands to ext\n"); + LLVM_DEBUG(dbgs() << "More operands to ext\n"); Value *ValForExtOpnd = IsSExt ? TPT.createSExt(Ext, Opnd, Ext->getType()) : TPT.createZExt(Ext, Opnd, Ext->getType()); if (!isa(ValForExtOpnd)) { @@ -3556,7 +3556,7 @@ ExtForOpnd = nullptr; } if (ExtForOpnd == Ext) { - DEBUG(dbgs() << "Extension is useless now\n"); + LLVM_DEBUG(dbgs() << "Extension is useless now\n"); TPT.eraseInstruction(Ext); } return ExtOpnd; @@ -3572,7 +3572,7 @@ /// \return True if the promotion is profitable, false otherwise. bool AddressingModeMatcher::isPromotionProfitable( unsigned NewCost, unsigned OldCost, Value *PromotedOperand) const { - DEBUG(dbgs() << "OldCost: " << OldCost << "\tNewCost: " << NewCost << '\n'); + LLVM_DEBUG(dbgs() << "OldCost: " << OldCost << "\tNewCost: " << NewCost << '\n'); // The cost of the new extensions is greater than the cost of the // old extension plus what we folded. // This is not profitable. @@ -3819,7 +3819,7 @@ PromotedOperand)) { AddrMode = BackupAddrMode; AddrModeInsts.resize(OldSize); - DEBUG(dbgs() << "Sign extension does not pay off: rollback\n"); + LLVM_DEBUG(dbgs() << "Sign extension does not pay off: rollback\n"); TPT.rollback(LastKnownGood); return false; } @@ -4268,7 +4268,7 @@ if (!PhiOrSelectSeen && none_of(AddrModeInsts, [&](Value *V) { return IsNonLocalValue(V, MemoryInst->getParent()); })) { - DEBUG(dbgs() << "CGP: Found local addrmode: " << AddrMode << "\n"); + LLVM_DEBUG(dbgs() << "CGP: Found local addrmode: " << AddrMode << "\n"); return false; } @@ -4287,7 +4287,7 @@ Value * SunkAddr = SunkAddrVH.pointsToAliveValue() ? SunkAddrVH : nullptr; if (SunkAddr) { - DEBUG(dbgs() << "CGP: Reusing nonlocal addrmode: " << AddrMode << " for " + LLVM_DEBUG(dbgs() << "CGP: Reusing nonlocal addrmode: " << AddrMode << " for " << *MemoryInst << "\n"); if (SunkAddr->getType() != Addr->getType()) SunkAddr = Builder.CreatePointerCast(SunkAddr, Addr->getType()); @@ -4296,7 +4296,7 @@ SubtargetInfo->useAA())) { // By default, we use the GEP-based method when AA is used later. This // prevents new inttoptr/ptrtoint pairs from degrading AA capabilities. - DEBUG(dbgs() << "CGP: SINKING nonlocal addrmode: " << AddrMode << " for " + LLVM_DEBUG(dbgs() << "CGP: SINKING nonlocal addrmode: " << AddrMode << " for " << *MemoryInst << "\n"); Type *IntPtrTy = DL->getIntPtrType(Addr->getType()); Value *ResultPtr = nullptr, *ResultIndex = nullptr; @@ -4436,7 +4436,7 @@ DL->isNonIntegralPointerType(AddrMode.BaseGV->getType()))) return false; - DEBUG(dbgs() << "CGP: SINKING nonlocal addrmode: " << AddrMode << " for " + LLVM_DEBUG(dbgs() << "CGP: SINKING nonlocal addrmode: " << AddrMode << " for " << *MemoryInst << "\n"); Type *IntPtrTy = DL->getIntPtrType(Addr->getType()); Value *Result = nullptr; @@ -5655,7 +5655,7 @@ VectorCost += TTI.getArithmeticInstrCost(Inst->getOpcode(), PromotedType, Arg0OVK, Arg1OVK); } - DEBUG(dbgs() << "Estimated cost of computation to be promoted:\nScalar: " + LLVM_DEBUG(dbgs() << "Estimated cost of computation to be promoted:\nScalar: " << ScalarCost << "\nVector: " << VectorCost << '\n'); return ScalarCost > VectorCost; } @@ -5861,23 +5861,23 @@ // => we would need to check that we are moving it at a cheaper place and // we do not do that for now. BasicBlock *Parent = Inst->getParent(); - DEBUG(dbgs() << "Found an interesting transition: " << *Inst << '\n'); + LLVM_DEBUG(dbgs() << "Found an interesting transition: " << *Inst << '\n'); VectorPromoteHelper VPH(*DL, *TLI, *TTI, Inst, CombineCost); // If the transition has more than one use, assume this is not going to be // beneficial. while (Inst->hasOneUse()) { Instruction *ToBePromoted = cast(*Inst->user_begin()); - DEBUG(dbgs() << "Use: " << *ToBePromoted << '\n'); + LLVM_DEBUG(dbgs() << "Use: " << *ToBePromoted << '\n'); if (ToBePromoted->getParent() != Parent) { - DEBUG(dbgs() << "Instruction to promote is in a different block (" + LLVM_DEBUG(dbgs() << "Instruction to promote is in a different block (" << ToBePromoted->getParent()->getName() << ") than the transition (" << Parent->getName() << ").\n"); return false; } if (VPH.canCombine(ToBePromoted)) { - DEBUG(dbgs() << "Assume " << *Inst << '\n' + LLVM_DEBUG(dbgs() << "Assume " << *Inst << '\n' << "will be combined with: " << *ToBePromoted << '\n'); VPH.recordCombineInstruction(ToBePromoted); bool Changed = VPH.promote(); @@ -5885,11 +5885,11 @@ return Changed; } - DEBUG(dbgs() << "Try promoting.\n"); + LLVM_DEBUG(dbgs() << "Try promoting.\n"); if (!VPH.canPromote(ToBePromoted) || !VPH.shouldPromote(ToBePromoted)) return false; - DEBUG(dbgs() << "Promoting is possible... Enqueue for promotion!\n"); + LLVM_DEBUG(dbgs() << "Promoting is possible... Enqueue for promotion!\n"); VPH.enqueueForPromotion(ToBePromoted); Inst = ToBePromoted; @@ -6383,7 +6383,7 @@ // after it. if (isa(VI) && VI->getParent()->getTerminator()->isEHPad()) continue; - DEBUG(dbgs() << "Moving Debug Value before :\n" << *DVI << ' ' << *VI); + LLVM_DEBUG(dbgs() << "Moving Debug Value before :\n" << *DVI << ' ' << *VI); DVI->removeFromParent(); if (isa(VI)) DVI->insertBefore(&*VI->getParent()->getFirstInsertionPt()); @@ -6462,7 +6462,7 @@ !match(Cond2, m_CombineOr(m_Cmp(), m_BinOp())) ) continue; - DEBUG(dbgs() << "Before branch condition splitting\n"; BB.dump()); + LLVM_DEBUG(dbgs() << "Before branch condition splitting\n"; BB.dump()); // Create a new BB. auto TmpBB = @@ -6590,7 +6590,7 @@ MadeChange = true; - DEBUG(dbgs() << "After branch condition splitting\n"; BB.dump(); + LLVM_DEBUG(dbgs() << "After branch condition splitting\n"; BB.dump(); TmpBB->dump()); } return MadeChange; Index: lib/CodeGen/CriticalAntiDepBreaker.cpp =================================================================== --- lib/CodeGen/CriticalAntiDepBreaker.cpp +++ lib/CodeGen/CriticalAntiDepBreaker.cpp @@ -461,14 +461,14 @@ #ifndef NDEBUG { - DEBUG(dbgs() << "Critical path has total latency " + LLVM_DEBUG(dbgs() << "Critical path has total latency " << (Max->getDepth() + Max->Latency) << "\n"); - DEBUG(dbgs() << "Available regs:"); + LLVM_DEBUG(dbgs() << "Available regs:"); for (unsigned Reg = 0; Reg < TRI->getNumRegs(); ++Reg) { if (KillIndices[Reg] == ~0u) - DEBUG(dbgs() << " " << printReg(Reg, TRI)); + LLVM_DEBUG(dbgs() << " " << printReg(Reg, TRI)); } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); } #endif @@ -645,7 +645,7 @@ AntiDepReg, LastNewReg[AntiDepReg], RC, ForbidRegs)) { - DEBUG(dbgs() << "Breaking anti-dependence edge on " + LLVM_DEBUG(dbgs() << "Breaking anti-dependence edge on " << printReg(AntiDepReg, TRI) << " with " << RegRefs.count(AntiDepReg) << " references" << " using " << printReg(NewReg, TRI) << "!\n"); Index: lib/CodeGen/DFAPacketizer.cpp =================================================================== --- lib/CodeGen/DFAPacketizer.cpp +++ lib/CodeGen/DFAPacketizer.cpp @@ -222,7 +222,7 @@ // End the current packet, bundle packet instructions and reset DFA state. void VLIWPacketizerList::endPacket(MachineBasicBlock *MBB, MachineBasicBlock::iterator MI) { - DEBUG({ + LLVM_DEBUG({ if (!CurrentPacketMIs.empty()) { dbgs() << "Finalizing packet:\n"; for (MachineInstr *MI : CurrentPacketMIs) @@ -235,7 +235,7 @@ } CurrentPacketMIs.clear(); ResourceTracker->clearResources(); - DEBUG(dbgs() << "End packet\n"); + LLVM_DEBUG(dbgs() << "End packet\n"); } // Bundle machine instructions into packets. @@ -248,7 +248,7 @@ std::distance(BeginItr, EndItr)); VLIWScheduler->schedule(); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Scheduling DAG of the packetize region\n"; for (SUnit &SU : VLIWScheduler->SUnits) SU.dumpAll(VLIWScheduler); @@ -287,10 +287,10 @@ assert(SUI && "Missing SUnit Info!"); // Ask DFA if machine resource is available for MI. - DEBUG(dbgs() << "Checking resources for adding MI to packet " << MI); + LLVM_DEBUG(dbgs() << "Checking resources for adding MI to packet " << MI); bool ResourceAvail = ResourceTracker->canReserveResources(MI); - DEBUG({ + LLVM_DEBUG({ if (ResourceAvail) dbgs() << " Resources are available for adding MI to packet\n"; else @@ -302,22 +302,22 @@ SUnit *SUJ = MIToSUnit[MJ]; assert(SUJ && "Missing SUnit Info!"); - DEBUG(dbgs() << " Checking against MJ " << *MJ); + LLVM_DEBUG(dbgs() << " Checking against MJ " << *MJ); // Is it legal to packetize SUI and SUJ together. if (!isLegalToPacketizeTogether(SUI, SUJ)) { - DEBUG(dbgs() << " Not legal to add MI, try to prune\n"); + LLVM_DEBUG(dbgs() << " Not legal to add MI, try to prune\n"); // Allow packetization if dependency can be pruned. if (!isLegalToPruneDependencies(SUI, SUJ)) { // End the packet if dependency cannot be pruned. - DEBUG(dbgs() << " Could not prune dependencies for adding MI\n"); + LLVM_DEBUG(dbgs() << " Could not prune dependencies for adding MI\n"); endPacket(MBB, MI); break; } - DEBUG(dbgs() << " Pruned dependence for adding MI\n"); + LLVM_DEBUG(dbgs() << " Pruned dependence for adding MI\n"); } } } else { - DEBUG(if (ResourceAvail) + LLVM_DEBUG(if (ResourceAvail) dbgs() << "Resources are available, but instruction should not be " "added to packet\n " << MI); // End the packet if resource is not available, or if the instruction @@ -326,7 +326,7 @@ } // Add MI to the current packet. - DEBUG(dbgs() << "* Adding MI to packet " << MI << '\n'); + LLVM_DEBUG(dbgs() << "* Adding MI to packet " << MI << '\n'); BeginItr = addToPacket(MI); } // For all instructions in the packetization range. Index: lib/CodeGen/DeadMachineInstructionElim.cpp =================================================================== --- lib/CodeGen/DeadMachineInstructionElim.cpp +++ lib/CodeGen/DeadMachineInstructionElim.cpp @@ -125,7 +125,7 @@ // If the instruction is dead, delete it! if (isDead(MI)) { - DEBUG(dbgs() << "DeadMachineInstructionElim: DELETING: " << *MI); + LLVM_DEBUG(dbgs() << "DeadMachineInstructionElim: DELETING: " << *MI); // It is possible that some DBG_VALUE instructions refer to this // instruction. They get marked as undef and will be deleted // in the live debug variable analysis. Index: lib/CodeGen/DetectDeadLanes.cpp =================================================================== --- lib/CodeGen/DetectDeadLanes.cpp +++ lib/CodeGen/DetectDeadLanes.cpp @@ -439,7 +439,7 @@ const TargetRegisterClass *DstRC = MRI->getRegClass(DefReg); CrossCopy = isCrossCopy(*MRI, UseMI, DstRC, MO); if (CrossCopy) - DEBUG(dbgs() << "Copy across incompatible classes: " << UseMI); + LLVM_DEBUG(dbgs() << "Copy across incompatible classes: " << UseMI); } if (!CrossCopy) @@ -520,7 +520,7 @@ transferDefinedLanesStep(MO, Info.DefinedLanes); } - DEBUG( + LLVM_DEBUG( dbgs() << "Defined/Used lanes:\n"; for (unsigned RegIdx = 0; RegIdx < NumVirtRegs; ++RegIdx) { unsigned Reg = TargetRegisterInfo::index2VirtReg(RegIdx); @@ -545,17 +545,17 @@ unsigned RegIdx = TargetRegisterInfo::virtReg2Index(Reg); const VRegInfo &RegInfo = VRegInfos[RegIdx]; if (MO.isDef() && !MO.isDead() && RegInfo.UsedLanes.none()) { - DEBUG(dbgs() << "Marking operand '" << MO << "' as dead in " << MI); + LLVM_DEBUG(dbgs() << "Marking operand '" << MO << "' as dead in " << MI); MO.setIsDead(); } if (MO.readsReg()) { bool CrossCopy = false; if (isUndefRegAtInput(MO, RegInfo)) { - DEBUG(dbgs() << "Marking operand '" << MO << "' as undef in " + LLVM_DEBUG(dbgs() << "Marking operand '" << MO << "' as undef in " << MI); MO.setIsUndef(); } else if (isUndefInput(MO, &CrossCopy)) { - DEBUG(dbgs() << "Marking operand '" << MO << "' as undef in " + LLVM_DEBUG(dbgs() << "Marking operand '" << MO << "' as undef in " << MI); MO.setIsUndef(); if (CrossCopy) @@ -577,7 +577,7 @@ // so we safe the compile time. MRI = &MF.getRegInfo(); if (!MRI->subRegLivenessEnabled()) { - DEBUG(dbgs() << "Skipping Detect dead lanes pass\n"); + LLVM_DEBUG(dbgs() << "Skipping Detect dead lanes pass\n"); return false; } Index: lib/CodeGen/EarlyIfConversion.cpp =================================================================== --- lib/CodeGen/EarlyIfConversion.cpp +++ lib/CodeGen/EarlyIfConversion.cpp @@ -185,7 +185,7 @@ // Reject any live-in physregs. It's probably CPSR/EFLAGS, and very hard to // get right. if (!MBB->livein_empty()) { - DEBUG(dbgs() << printMBBReference(*MBB) << " has live-ins.\n"); + LLVM_DEBUG(dbgs() << printMBBReference(*MBB) << " has live-ins.\n"); return false; } @@ -199,14 +199,14 @@ continue; if (++InstrCount > BlockInstrLimit && !Stress) { - DEBUG(dbgs() << printMBBReference(*MBB) << " has more than " + LLVM_DEBUG(dbgs() << printMBBReference(*MBB) << " has more than " << BlockInstrLimit << " instructions.\n"); return false; } // There shouldn't normally be any phis in a single-predecessor block. if (I->isPHI()) { - DEBUG(dbgs() << "Can't hoist: " << *I); + LLVM_DEBUG(dbgs() << "Can't hoist: " << *I); return false; } @@ -214,21 +214,21 @@ // speculate GOT or constant pool loads that are guaranteed not to trap, // but we don't support that for now. if (I->mayLoad()) { - DEBUG(dbgs() << "Won't speculate load: " << *I); + LLVM_DEBUG(dbgs() << "Won't speculate load: " << *I); return false; } // We never speculate stores, so an AA pointer isn't necessary. bool DontMoveAcrossStore = true; if (!I->isSafeToMove(nullptr, DontMoveAcrossStore)) { - DEBUG(dbgs() << "Can't speculate: " << *I); + LLVM_DEBUG(dbgs() << "Can't speculate: " << *I); return false; } // Check for any dependencies on Head instructions. for (const MachineOperand &MO : I->operands()) { if (MO.isRegMask()) { - DEBUG(dbgs() << "Won't speculate regmask: " << *I); + LLVM_DEBUG(dbgs() << "Won't speculate regmask: " << *I); return false; } if (!MO.isReg()) @@ -246,9 +246,9 @@ if (!DefMI || DefMI->getParent() != Head) continue; if (InsertAfter.insert(DefMI).second) - DEBUG(dbgs() << printMBBReference(*MBB) << " depends on " << *DefMI); + LLVM_DEBUG(dbgs() << printMBBReference(*MBB) << " depends on " << *DefMI); if (DefMI->isTerminator()) { - DEBUG(dbgs() << "Can't insert instructions below terminator.\n"); + LLVM_DEBUG(dbgs() << "Can't insert instructions below terminator.\n"); return false; } } @@ -279,7 +279,7 @@ --I; // Some of the conditional code depends in I. if (InsertAfter.count(&*I)) { - DEBUG(dbgs() << "Can't insert code after " << *I); + LLVM_DEBUG(dbgs() << "Can't insert code after " << *I); return false; } @@ -313,7 +313,7 @@ // Some of the clobbered registers are live before I, not a valid insertion // point. if (!LiveRegUnits.empty()) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "Would clobber"; for (SparseSet::const_iterator i = LiveRegUnits.begin(), e = LiveRegUnits.end(); i != e; ++i) @@ -325,10 +325,10 @@ // This is a valid insertion point. InsertionPoint = I; - DEBUG(dbgs() << "Can insert before " << *I); + LLVM_DEBUG(dbgs() << "Can insert before " << *I); return true; } - DEBUG(dbgs() << "No legal insertion point found.\n"); + LLVM_DEBUG(dbgs() << "No legal insertion point found.\n"); return false; } @@ -361,18 +361,18 @@ if (Succ1->pred_size() != 1 || Succ1->succ_size() != 1 || Succ1->succ_begin()[0] != Tail) return false; - DEBUG(dbgs() << "\nDiamond: " << printMBBReference(*Head) << " -> " + LLVM_DEBUG(dbgs() << "\nDiamond: " << printMBBReference(*Head) << " -> " << printMBBReference(*Succ0) << "/" << printMBBReference(*Succ1) << " -> " << printMBBReference(*Tail) << '\n'); // Live-in physregs are tricky to get right when speculating code. if (!Tail->livein_empty()) { - DEBUG(dbgs() << "Tail has live-ins.\n"); + LLVM_DEBUG(dbgs() << "Tail has live-ins.\n"); return false; } } else { - DEBUG(dbgs() << "\nTriangle: " << printMBBReference(*Head) << " -> " + LLVM_DEBUG(dbgs() << "\nTriangle: " << printMBBReference(*Head) << " -> " << printMBBReference(*Succ0) << " -> " << printMBBReference(*Tail) << '\n'); } @@ -380,20 +380,20 @@ // This is a triangle or a diamond. // If Tail doesn't have any phis, there must be side effects. if (Tail->empty() || !Tail->front().isPHI()) { - DEBUG(dbgs() << "No phis in tail.\n"); + LLVM_DEBUG(dbgs() << "No phis in tail.\n"); return false; } // The branch we're looking to eliminate must be analyzable. Cond.clear(); if (TII->analyzeBranch(*Head, TBB, FBB, Cond)) { - DEBUG(dbgs() << "Branch not analyzable.\n"); + LLVM_DEBUG(dbgs() << "Branch not analyzable.\n"); return false; } // This is weird, probably some sort of degenerate CFG. if (!TBB) { - DEBUG(dbgs() << "AnalyzeBranch didn't find conditional branch.\n"); + LLVM_DEBUG(dbgs() << "AnalyzeBranch didn't find conditional branch.\n"); return false; } @@ -422,7 +422,7 @@ // Get target information. if (!TII->canInsertSelect(*Head, Cond, PI.TReg, PI.FReg, PI.CondCycles, PI.TCycles, PI.FCycles)) { - DEBUG(dbgs() << "Can't convert: " << *PI.PHI); + LLVM_DEBUG(dbgs() << "Can't convert: " << *PI.PHI); return false; } } @@ -459,10 +459,10 @@ // Convert all PHIs to select instructions inserted before FirstTerm. for (unsigned i = 0, e = PHIs.size(); i != e; ++i) { PHIInfo &PI = PHIs[i]; - DEBUG(dbgs() << "If-converting " << *PI.PHI); + LLVM_DEBUG(dbgs() << "If-converting " << *PI.PHI); unsigned DstReg = PI.PHI->getOperand(0).getReg(); TII->insertSelect(*Head, FirstTerm, HeadDL, DstReg, Cond, PI.TReg, PI.FReg); - DEBUG(dbgs() << " --> " << *std::prev(FirstTerm)); + LLVM_DEBUG(dbgs() << " --> " << *std::prev(FirstTerm)); PI.PHI->eraseFromParent(); PI.PHI = nullptr; } @@ -481,7 +481,7 @@ PHIInfo &PI = PHIs[i]; unsigned DstReg = 0; - DEBUG(dbgs() << "If-converting " << *PI.PHI); + LLVM_DEBUG(dbgs() << "If-converting " << *PI.PHI); if (PI.TReg == PI.FReg) { // We do not need the select instruction if both incoming values are // equal. @@ -491,7 +491,7 @@ DstReg = MRI->createVirtualRegister(MRI->getRegClass(PHIDst)); TII->insertSelect(*Head, FirstTerm, HeadDL, DstReg, Cond, PI.TReg, PI.FReg); - DEBUG(dbgs() << " --> " << *std::prev(FirstTerm)); + LLVM_DEBUG(dbgs() << " --> " << *std::prev(FirstTerm)); } // Rewrite PHI operands TPred -> (DstReg, Head), remove FPred. @@ -505,7 +505,7 @@ PI.PHI->RemoveOperand(i-2); } } - DEBUG(dbgs() << " --> " << *PI.PHI); + LLVM_DEBUG(dbgs() << " --> " << *PI.PHI); } } @@ -563,7 +563,7 @@ assert(Head->succ_empty() && "Additional head successors?"); if (!ExtraPreds && Head->isLayoutSuccessor(Tail)) { // Splice Tail onto the end of Head. - DEBUG(dbgs() << "Joining tail " << printMBBReference(*Tail) << " into head " + LLVM_DEBUG(dbgs() << "Joining tail " << printMBBReference(*Tail) << " into head " << printMBBReference(*Head) << '\n'); Head->splice(Head->end(), Tail, Tail->begin(), Tail->end()); @@ -572,12 +572,12 @@ Tail->eraseFromParent(); } else { // We need a branch to Tail, let code placement work it out later. - DEBUG(dbgs() << "Converting to unconditional branch.\n"); + LLVM_DEBUG(dbgs() << "Converting to unconditional branch.\n"); SmallVector EmptyCond; TII->insertBranch(*Head, Tail, nullptr, EmptyCond, HeadDL); Head->addSuccessor(Tail); } - DEBUG(dbgs() << *Head); + LLVM_DEBUG(dbgs() << *Head); } @@ -692,7 +692,7 @@ MachineTraceMetrics::Trace TBBTrace = MinInstr->getTrace(IfConv.getTPred()); MachineTraceMetrics::Trace FBBTrace = MinInstr->getTrace(IfConv.getFPred()); - DEBUG(dbgs() << "TBB: " << TBBTrace << "FBB: " << FBBTrace); + LLVM_DEBUG(dbgs() << "TBB: " << TBBTrace << "FBB: " << FBBTrace); unsigned MinCrit = std::min(TBBTrace.getCriticalPath(), FBBTrace.getCriticalPath()); @@ -706,10 +706,10 @@ if (IfConv.TBB != IfConv.Tail) ExtraBlocks.push_back(IfConv.TBB); unsigned ResLength = FBBTrace.getResourceLength(ExtraBlocks); - DEBUG(dbgs() << "Resource length " << ResLength + LLVM_DEBUG(dbgs() << "Resource length " << ResLength << ", minimal critical path " << MinCrit << '\n'); if (ResLength > MinCrit + CritLimit) { - DEBUG(dbgs() << "Not enough available ILP.\n"); + LLVM_DEBUG(dbgs() << "Not enough available ILP.\n"); return false; } @@ -719,7 +719,7 @@ MachineTraceMetrics::Trace HeadTrace = MinInstr->getTrace(IfConv.Head); unsigned BranchDepth = HeadTrace.getInstrCycles(*IfConv.Head->getFirstTerminator()).Depth; - DEBUG(dbgs() << "Branch depth: " << BranchDepth << '\n'); + LLVM_DEBUG(dbgs() << "Branch depth: " << BranchDepth << '\n'); // Look at all the tail phis, and compute the critical path extension caused // by inserting select instructions. @@ -728,15 +728,15 @@ SSAIfConv::PHIInfo &PI = IfConv.PHIs[i]; unsigned Slack = TailTrace.getInstrSlack(*PI.PHI); unsigned MaxDepth = Slack + TailTrace.getInstrCycles(*PI.PHI).Depth; - DEBUG(dbgs() << "Slack " << Slack << ":\t" << *PI.PHI); + LLVM_DEBUG(dbgs() << "Slack " << Slack << ":\t" << *PI.PHI); // The condition is pulled into the critical path. unsigned CondDepth = adjCycles(BranchDepth, PI.CondCycles); if (CondDepth > MaxDepth) { unsigned Extra = CondDepth - MaxDepth; - DEBUG(dbgs() << "Condition adds " << Extra << " cycles.\n"); + LLVM_DEBUG(dbgs() << "Condition adds " << Extra << " cycles.\n"); if (Extra > CritLimit) { - DEBUG(dbgs() << "Exceeds limit of " << CritLimit << '\n'); + LLVM_DEBUG(dbgs() << "Exceeds limit of " << CritLimit << '\n'); return false; } } @@ -745,9 +745,9 @@ unsigned TDepth = adjCycles(TBBTrace.getPHIDepth(*PI.PHI), PI.TCycles); if (TDepth > MaxDepth) { unsigned Extra = TDepth - MaxDepth; - DEBUG(dbgs() << "TBB data adds " << Extra << " cycles.\n"); + LLVM_DEBUG(dbgs() << "TBB data adds " << Extra << " cycles.\n"); if (Extra > CritLimit) { - DEBUG(dbgs() << "Exceeds limit of " << CritLimit << '\n'); + LLVM_DEBUG(dbgs() << "Exceeds limit of " << CritLimit << '\n'); return false; } } @@ -756,9 +756,9 @@ unsigned FDepth = adjCycles(FBBTrace.getPHIDepth(*PI.PHI), PI.FCycles); if (FDepth > MaxDepth) { unsigned Extra = FDepth - MaxDepth; - DEBUG(dbgs() << "FBB data adds " << Extra << " cycles.\n"); + LLVM_DEBUG(dbgs() << "FBB data adds " << Extra << " cycles.\n"); if (Extra > CritLimit) { - DEBUG(dbgs() << "Exceeds limit of " << CritLimit << '\n'); + LLVM_DEBUG(dbgs() << "Exceeds limit of " << CritLimit << '\n'); return false; } } @@ -783,7 +783,7 @@ } bool EarlyIfConverter::runOnMachineFunction(MachineFunction &MF) { - DEBUG(dbgs() << "********** EARLY IF-CONVERSION **********\n" + LLVM_DEBUG(dbgs() << "********** EARLY IF-CONVERSION **********\n" << "********** Function: " << MF.getName() << '\n'); if (skipFunction(MF.getFunction())) return false; Index: lib/CodeGen/ExecutionDomainFix.cpp =================================================================== --- lib/CodeGen/ExecutionDomainFix.cpp +++ lib/CodeGen/ExecutionDomainFix.cpp @@ -161,7 +161,7 @@ // This is the entry block. if (MBB->pred_empty()) { - DEBUG(dbgs() << printMBBReference(*MBB) << ": entry\n"); + LLVM_DEBUG(dbgs() << printMBBReference(*MBB) << ": entry\n"); return; } @@ -200,7 +200,7 @@ force(rx, pdv->getFirstDomain()); } } - DEBUG(dbgs() << printMBBReference(*MBB) + LLVM_DEBUG(dbgs() << printMBBReference(*MBB) << (!TraversedMBB.IsDone ? ": incomplete\n" : ": all preds known\n")); } @@ -245,7 +245,7 @@ continue; for (int rx : regIndices(MO.getReg())) { // This instruction explicitly defines rx. - DEBUG(dbgs() << printReg(RC->getRegister(rx), TRI) << ":\t" << *MI); + LLVM_DEBUG(dbgs() << printReg(RC->getRegister(rx), TRI) << ":\t" << *MI); // Kill off domains redefined by generic instructions. if (Kill) @@ -420,7 +420,7 @@ LiveRegs.clear(); assert(NumRegs == RC->getNumRegs() && "Bad regclass"); - DEBUG(dbgs() << "********** FIX EXECUTION DOMAIN: " + LLVM_DEBUG(dbgs() << "********** FIX EXECUTION DOMAIN: " << TRI->getRegClassName(RC) << " **********\n"); // If no relevant registers are used in the function, we can skip it Index: lib/CodeGen/ExpandPostRAPseudos.cpp =================================================================== --- lib/CodeGen/ExpandPostRAPseudos.cpp +++ lib/CodeGen/ExpandPostRAPseudos.cpp @@ -93,11 +93,11 @@ assert(TargetRegisterInfo::isPhysicalRegister(InsReg) && "Inserted value must be in a physical register"); - DEBUG(dbgs() << "subreg: CONVERTING: " << *MI); + LLVM_DEBUG(dbgs() << "subreg: CONVERTING: " << *MI); if (MI->allDefsAreDead()) { MI->setDesc(TII->get(TargetOpcode::KILL)); - DEBUG(dbgs() << "subreg: replaced by: " << *MI); + LLVM_DEBUG(dbgs() << "subreg: replaced by: " << *MI); return true; } @@ -110,10 +110,10 @@ MI->setDesc(TII->get(TargetOpcode::KILL)); MI->RemoveOperand(3); // SubIdx MI->RemoveOperand(1); // Imm - DEBUG(dbgs() << "subreg: replace by: " << *MI); + LLVM_DEBUG(dbgs() << "subreg: replace by: " << *MI); return true; } - DEBUG(dbgs() << "subreg: eliminated!"); + LLVM_DEBUG(dbgs() << "subreg: eliminated!"); } else { TII->copyPhysReg(*MBB, MI, MI->getDebugLoc(), DstSubReg, InsReg, MI->getOperand(2).isKill()); @@ -122,10 +122,10 @@ MachineBasicBlock::iterator CopyMI = MI; --CopyMI; CopyMI->addRegisterDefined(DstReg); - DEBUG(dbgs() << "subreg: " << *CopyMI); + LLVM_DEBUG(dbgs() << "subreg: " << *CopyMI); } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); MBB->erase(MI); return true; } @@ -133,9 +133,9 @@ bool ExpandPostRA::LowerCopy(MachineInstr *MI) { if (MI->allDefsAreDead()) { - DEBUG(dbgs() << "dead copy: " << *MI); + LLVM_DEBUG(dbgs() << "dead copy: " << *MI); MI->setDesc(TII->get(TargetOpcode::KILL)); - DEBUG(dbgs() << "replaced by: " << *MI); + LLVM_DEBUG(dbgs() << "replaced by: " << *MI); return true; } @@ -144,14 +144,14 @@ bool IdentityCopy = (SrcMO.getReg() == DstMO.getReg()); if (IdentityCopy || SrcMO.isUndef()) { - DEBUG(dbgs() << (IdentityCopy ? "identity copy: " : "undef copy: ") << *MI); + LLVM_DEBUG(dbgs() << (IdentityCopy ? "identity copy: " : "undef copy: ") << *MI); // No need to insert an identity copy instruction, but replace with a KILL // if liveness is changed. if (SrcMO.isUndef() || MI->getNumOperands() > 2) { // We must make sure the super-register gets killed. Replace the // instruction with KILL. MI->setDesc(TII->get(TargetOpcode::KILL)); - DEBUG(dbgs() << "replaced by: " << *MI); + LLVM_DEBUG(dbgs() << "replaced by: " << *MI); return true; } // Vanilla identity copy. @@ -159,13 +159,13 @@ return true; } - DEBUG(dbgs() << "real copy: " << *MI); + LLVM_DEBUG(dbgs() << "real copy: " << *MI); TII->copyPhysReg(*MI->getParent(), MI, MI->getDebugLoc(), DstMO.getReg(), SrcMO.getReg(), SrcMO.isKill()); if (MI->getNumOperands() > 2) TransferImplicitOperands(MI); - DEBUG({ + LLVM_DEBUG({ MachineBasicBlock::iterator dMI = MI; dbgs() << "replaced by: " << *(--dMI); }); @@ -177,7 +177,7 @@ /// copies. /// bool ExpandPostRA::runOnMachineFunction(MachineFunction &MF) { - DEBUG(dbgs() << "Machine Function\n" + LLVM_DEBUG(dbgs() << "Machine Function\n" << "********** EXPANDING POST-RA PSEUDO INSTRS **********\n" << "********** Function: " << MF.getName() << '\n'); TRI = MF.getSubtarget().getRegisterInfo(); Index: lib/CodeGen/FaultMaps.cpp =================================================================== --- lib/CodeGen/FaultMaps.cpp +++ lib/CodeGen/FaultMaps.cpp @@ -62,17 +62,17 @@ // Emit a dummy symbol to force section inclusion. OS.EmitLabel(OutContext.getOrCreateSymbol(Twine("__LLVM_FaultMaps"))); - DEBUG(dbgs() << "********** Fault Map Output **********\n"); + LLVM_DEBUG(dbgs() << "********** Fault Map Output **********\n"); // Header OS.EmitIntValue(FaultMapVersion, 1); // Version. OS.EmitIntValue(0, 1); // Reserved. OS.EmitIntValue(0, 2); // Reserved. - DEBUG(dbgs() << WFMP << "#functions = " << FunctionInfos.size() << "\n"); + LLVM_DEBUG(dbgs() << WFMP << "#functions = " << FunctionInfos.size() << "\n"); OS.EmitIntValue(FunctionInfos.size(), 4); - DEBUG(dbgs() << WFMP << "functions:\n"); + LLVM_DEBUG(dbgs() << WFMP << "functions:\n"); for (const auto &FFI : FunctionInfos) emitFunctionInfo(FFI.first, FFI.second); @@ -82,24 +82,24 @@ const FunctionFaultInfos &FFI) { MCStreamer &OS = *AP.OutStreamer; - DEBUG(dbgs() << WFMP << " function addr: " << *FnLabel << "\n"); + LLVM_DEBUG(dbgs() << WFMP << " function addr: " << *FnLabel << "\n"); OS.EmitSymbolValue(FnLabel, 8); - DEBUG(dbgs() << WFMP << " #faulting PCs: " << FFI.size() << "\n"); + LLVM_DEBUG(dbgs() << WFMP << " #faulting PCs: " << FFI.size() << "\n"); OS.EmitIntValue(FFI.size(), 4); OS.EmitIntValue(0, 4); // Reserved for (auto &Fault : FFI) { - DEBUG(dbgs() << WFMP << " fault type: " + LLVM_DEBUG(dbgs() << WFMP << " fault type: " << faultTypeToString(Fault.Kind) << "\n"); OS.EmitIntValue(Fault.Kind, 4); - DEBUG(dbgs() << WFMP << " faulting PC offset: " + LLVM_DEBUG(dbgs() << WFMP << " faulting PC offset: " << *Fault.FaultingOffsetExpr << "\n"); OS.EmitValue(Fault.FaultingOffsetExpr, 4); - DEBUG(dbgs() << WFMP << " fault handler PC offset: " + LLVM_DEBUG(dbgs() << WFMP << " fault handler PC offset: " << *Fault.HandlerOffsetExpr << "\n"); OS.EmitValue(Fault.HandlerOffsetExpr, 4); } Index: lib/CodeGen/GlobalISel/Combiner.cpp =================================================================== --- lib/CodeGen/GlobalISel/Combiner.cpp +++ lib/CodeGen/GlobalISel/Combiner.cpp @@ -40,7 +40,7 @@ MRI = &MF.getRegInfo(); Builder.setMF(MF); - DEBUG(dbgs() << "Generic MI Combiner for: " << MF.getName() << '\n'); + LLVM_DEBUG(dbgs() << "Generic MI Combiner for: " << MF.getName() << '\n'); MachineOptimizationRemarkEmitter MORE(MF, /*MBFI=*/nullptr); @@ -61,7 +61,7 @@ ++MII; // Erase dead insts before even adding to the list. if (isTriviallyDead(*CurMI, *MRI)) { - DEBUG(dbgs() << *CurMI << "Is dead; erasing.\n"); + LLVM_DEBUG(dbgs() << *CurMI << "Is dead; erasing.\n"); CurMI->eraseFromParentAndMarkDBGValuesForRemoval(); continue; } @@ -71,7 +71,7 @@ // Main Loop. Process the instructions here. while (!WorkList.empty()) { MachineInstr *CurrInst = WorkList.pop_back_val(); - DEBUG(dbgs() << "Try combining " << *CurrInst << "\n";); + LLVM_DEBUG(dbgs() << "Try combining " << *CurrInst << "\n";); Changed |= CInfo.combine(*CurrInst, Builder); } MFChanged |= Changed; Index: lib/CodeGen/GlobalISel/IRTranslator.cpp =================================================================== --- lib/CodeGen/GlobalISel/IRTranslator.cpp +++ lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -652,7 +652,7 @@ const Value *Address = DI.getAddress(); if (!Address || isa(Address)) { - DEBUG(dbgs() << "Dropping debug info for " << DI << "\n"); + LLVM_DEBUG(dbgs() << "Dropping debug info for " << DI << "\n"); return true; } Index: lib/CodeGen/GlobalISel/InstructionSelect.cpp =================================================================== --- lib/CodeGen/GlobalISel/InstructionSelect.cpp +++ lib/CodeGen/GlobalISel/InstructionSelect.cpp @@ -73,7 +73,7 @@ MachineFunctionProperties::Property::FailedISel)) return false; - DEBUG(dbgs() << "Selecting function: " << MF.getName() << '\n'); + LLVM_DEBUG(dbgs() << "Selecting function: " << MF.getName() << '\n'); const TargetPassConfig &TPC = getAnalysis(); const InstructionSelector *ISel = MF.getSubtarget().getInstructionSelector(); @@ -129,12 +129,12 @@ else --MII; - DEBUG(dbgs() << "Selecting: \n " << MI); + LLVM_DEBUG(dbgs() << "Selecting: \n " << MI); // We could have folded this instruction away already, making it dead. // If so, erase it. if (isTriviallyDead(MI, MRI)) { - DEBUG(dbgs() << "Is dead; erasing.\n"); + LLVM_DEBUG(dbgs() << "Is dead; erasing.\n"); MI.eraseFromParentAndMarkDBGValuesForRemoval(); continue; } @@ -147,7 +147,7 @@ } // Dump the range of instructions that MI expanded into. - DEBUG({ + LLVM_DEBUG({ auto InsertedBegin = ReachedBegin ? MBB->begin() : std::next(MII); dbgs() << "Into:\n"; for (auto &InsertedMI : make_range(InsertedBegin, AfterIt)) Index: lib/CodeGen/GlobalISel/Legalizer.cpp =================================================================== --- lib/CodeGen/GlobalISel/Legalizer.cpp +++ lib/CodeGen/GlobalISel/Legalizer.cpp @@ -72,7 +72,7 @@ if (MF.getProperties().hasProperty( MachineFunctionProperties::Property::FailedISel)) return false; - DEBUG(dbgs() << "Legalize Machine IR for: " << MF.getName() << '\n'); + LLVM_DEBUG(dbgs() << "Legalize Machine IR for: " << MF.getName() << '\n'); init(MF); const TargetPassConfig &TPC = getAnalysis(); MachineOptimizationRemarkEmitter MORE(MF, /*MBFI=*/nullptr); @@ -112,7 +112,7 @@ else InstList.insert(MI); } - DEBUG(dbgs() << ".. .. New MI: " << *MI;); + LLVM_DEBUG(dbgs() << ".. .. New MI: " << *MI;); }); const LegalizerInfo &LInfo(Helper.getLegalizerInfo()); LegalizationArtifactCombiner ArtCombiner(Helper.MIRBuilder, MF.getRegInfo(), LInfo); @@ -127,7 +127,7 @@ MachineInstr &MI = *InstList.pop_back_val(); assert(isPreISelGenericOpcode(MI.getOpcode()) && "Expecting generic opcode"); if (isTriviallyDead(MI, MRI)) { - DEBUG(dbgs() << MI << "Is dead; erasing.\n"); + LLVM_DEBUG(dbgs() << MI << "Is dead; erasing.\n"); MI.eraseFromParentAndMarkDBGValuesForRemoval(); continue; } @@ -148,7 +148,7 @@ MachineInstr &MI = *ArtifactList.pop_back_val(); assert(isPreISelGenericOpcode(MI.getOpcode()) && "Expecting generic opcode"); if (isTriviallyDead(MI, MRI)) { - DEBUG(dbgs() << MI << "Is dead; erasing.\n"); + LLVM_DEBUG(dbgs() << MI << "Is dead; erasing.\n"); RemoveDeadInstFromLists(&MI); MI.eraseFromParentAndMarkDBGValuesForRemoval(); continue; @@ -156,7 +156,7 @@ SmallVector DeadInstructions; if (ArtCombiner.tryCombineInstruction(MI, DeadInstructions)) { for (auto *DeadMI : DeadInstructions) { - DEBUG(dbgs() << ".. Erasing Dead Instruction " << *DeadMI); + LLVM_DEBUG(dbgs() << ".. Erasing Dead Instruction " << *DeadMI); RemoveDeadInstFromLists(DeadMI); DeadMI->eraseFromParentAndMarkDBGValuesForRemoval(); } Index: lib/CodeGen/GlobalISel/LegalizerHelper.cpp =================================================================== --- lib/CodeGen/GlobalISel/LegalizerHelper.cpp +++ lib/CodeGen/GlobalISel/LegalizerHelper.cpp @@ -35,34 +35,34 @@ LegalizerHelper::LegalizeResult LegalizerHelper::legalizeInstrStep(MachineInstr &MI) { - DEBUG(dbgs() << "Legalizing: "; MI.print(dbgs())); + LLVM_DEBUG(dbgs() << "Legalizing: "; MI.print(dbgs())); auto Step = LI.getAction(MI, MRI); switch (Step.Action) { case Legal: - DEBUG(dbgs() << ".. Already legal\n"); + LLVM_DEBUG(dbgs() << ".. Already legal\n"); return AlreadyLegal; case Libcall: - DEBUG(dbgs() << ".. Convert to libcall\n"); + LLVM_DEBUG(dbgs() << ".. Convert to libcall\n"); return libcall(MI); case NarrowScalar: - DEBUG(dbgs() << ".. Narrow scalar\n"); + LLVM_DEBUG(dbgs() << ".. Narrow scalar\n"); return narrowScalar(MI, Step.TypeIdx, Step.NewType); case WidenScalar: - DEBUG(dbgs() << ".. Widen scalar\n"); + LLVM_DEBUG(dbgs() << ".. Widen scalar\n"); return widenScalar(MI, Step.TypeIdx, Step.NewType); case Lower: - DEBUG(dbgs() << ".. Lower\n"); + LLVM_DEBUG(dbgs() << ".. Lower\n"); return lower(MI, Step.TypeIdx, Step.NewType); case FewerElements: - DEBUG(dbgs() << ".. Reduce number of elements\n"); + LLVM_DEBUG(dbgs() << ".. Reduce number of elements\n"); return fewerElementsVector(MI, Step.TypeIdx, Step.NewType); case Custom: - DEBUG(dbgs() << ".. Custom legalization\n"); + LLVM_DEBUG(dbgs() << ".. Custom legalization\n"); return LI.legalizeCustom(MI, MRI, MIRBuilder) ? Legalized : UnableToLegalize; default: - DEBUG(dbgs() << ".. Unable to legalize\n"); + LLVM_DEBUG(dbgs() << ".. Unable to legalize\n"); return UnableToLegalize; } } Index: lib/CodeGen/GlobalISel/LegalizerInfo.cpp =================================================================== --- lib/CodeGen/GlobalISel/LegalizerInfo.cpp +++ lib/CodeGen/GlobalISel/LegalizerInfo.cpp @@ -46,17 +46,17 @@ } LegalizeActionStep LegalizeRuleSet::apply(const LegalityQuery &Query) const { - DEBUG(dbgs() << "Applying legalizer ruleset to: "; Query.print(dbgs()); + LLVM_DEBUG(dbgs() << "Applying legalizer ruleset to: "; Query.print(dbgs()); dbgs() << "\n"); if (Rules.empty()) { - DEBUG(dbgs() << ".. fallback to legacy rules (no rules defined)\n"); + LLVM_DEBUG(dbgs() << ".. fallback to legacy rules (no rules defined)\n"); return {LegalizeAction::UseLegacyRules, 0, LLT{}}; } for (const auto &Rule : Rules) { if (Rule.match(Query)) { - DEBUG(dbgs() << ".. match\n"); + LLVM_DEBUG(dbgs() << ".. match\n"); std::pair Mutation = Rule.determineMutation(Query); - DEBUG(dbgs() << ".. .. " << (unsigned)Rule.getAction() << ", " + LLVM_DEBUG(dbgs() << ".. .. " << (unsigned)Rule.getAction() << ", " << Mutation.first << ", " << Mutation.second << "\n"); assert((Query.Types[Mutation.first] != Mutation.second || Rule.getAction() == MoreElements || @@ -64,9 +64,9 @@ "Simple loop detected"); return {Rule.getAction(), Mutation.first, Mutation.second}; } else - DEBUG(dbgs() << ".. no match\n"); + LLVM_DEBUG(dbgs() << ".. no match\n"); } - DEBUG(dbgs() << ".. unsupported\n"); + LLVM_DEBUG(dbgs() << ".. unsupported\n"); return {LegalizeAction::Unsupported, 0, LLT{}}; } @@ -233,10 +233,10 @@ unsigned LegalizerInfo::getActionDefinitionsIdx(unsigned Opcode) const { unsigned OpcodeIdx = getOpcodeIdxForOpcode(Opcode); if (unsigned Alias = RulesForOpcode[OpcodeIdx].getAlias()) { - DEBUG(dbgs() << ".. opcode " << Opcode << " is aliased to " << Alias + LLVM_DEBUG(dbgs() << ".. opcode " << Opcode << " is aliased to " << Alias << "\n"); OpcodeIdx = getOpcodeIdxForOpcode(Alias); - DEBUG(dbgs() << ".. opcode " << Alias << " is aliased to " + LLVM_DEBUG(dbgs() << ".. opcode " << Alias << " is aliased to " << RulesForOpcode[OpcodeIdx].getAlias() << "\n"); assert(RulesForOpcode[OpcodeIdx].getAlias() == 0 && "Cannot chain aliases"); } @@ -291,13 +291,13 @@ for (unsigned i = 0; i < Query.Types.size(); ++i) { auto Action = getAspectAction({Query.Opcode, i, Query.Types[i]}); if (Action.first != Legal) { - DEBUG(dbgs() << ".. (legacy) Type " << i << " Action=" + LLVM_DEBUG(dbgs() << ".. (legacy) Type " << i << " Action=" << (unsigned)Action.first << ", " << Action.second << "\n"); return {Action.first, i, Action.second}; } else - DEBUG(dbgs() << ".. (legacy) Type " << i << " Legal\n"); + LLVM_DEBUG(dbgs() << ".. (legacy) Type " << i << " Legal\n"); } - DEBUG(dbgs() << ".. (legacy) Legal\n"); + LLVM_DEBUG(dbgs() << ".. (legacy) Legal\n"); return {Legal, 0, LLT{}}; } Index: lib/CodeGen/GlobalISel/Localizer.cpp =================================================================== --- lib/CodeGen/GlobalISel/Localizer.cpp +++ lib/CodeGen/GlobalISel/Localizer.cpp @@ -59,7 +59,7 @@ MachineFunctionProperties::Property::FailedISel)) return false; - DEBUG(dbgs() << "Localize instructions for: " << MF.getName() << '\n'); + LLVM_DEBUG(dbgs() << "Localize instructions for: " << MF.getName() << '\n'); init(MF); @@ -73,7 +73,7 @@ for (MachineInstr &MI : MBB) { if (LocalizedInstrs.count(&MI) || !shouldLocalize(MI)) continue; - DEBUG(dbgs() << "Should localize: " << MI); + LLVM_DEBUG(dbgs() << "Should localize: " << MI); assert(MI.getDesc().getNumDefs() == 1 && "More than one definition not supported yet"); unsigned Reg = MI.getOperand(0).getReg(); @@ -85,12 +85,12 @@ MachineOperand &MOUse = *MOIt++; // Check if the use is already local. MachineBasicBlock *InsertMBB; - DEBUG(MachineInstr &MIUse = *MOUse.getParent(); + LLVM_DEBUG(MachineInstr &MIUse = *MOUse.getParent(); dbgs() << "Checking use: " << MIUse << " #Opd: " << MIUse.getOperandNo(&MOUse) << '\n'); if (isLocalUse(MOUse, MI, InsertMBB)) continue; - DEBUG(dbgs() << "Fixing non-local use\n"); + LLVM_DEBUG(dbgs() << "Fixing non-local use\n"); Changed = true; auto MBBAndReg = std::make_pair(InsertMBB, Reg); auto NewVRegIt = MBBWithLocalDef.find(MBBAndReg); @@ -111,9 +111,9 @@ LocalizedMI->getOperand(0).setReg(NewReg); NewVRegIt = MBBWithLocalDef.insert(std::make_pair(MBBAndReg, NewReg)).first; - DEBUG(dbgs() << "Inserted: " << *LocalizedMI); + LLVM_DEBUG(dbgs() << "Inserted: " << *LocalizedMI); } - DEBUG(dbgs() << "Update use with: " << printReg(NewVRegIt->second) + LLVM_DEBUG(dbgs() << "Update use with: " << printReg(NewVRegIt->second) << '\n'); // Update the user reg. MOUse.setReg(NewVRegIt->second); Index: lib/CodeGen/GlobalISel/RegBankSelect.cpp =================================================================== --- lib/CodeGen/GlobalISel/RegBankSelect.cpp +++ lib/CodeGen/GlobalISel/RegBankSelect.cpp @@ -75,7 +75,7 @@ if (RegBankSelectMode.getNumOccurrences() != 0) { OptMode = RegBankSelectMode; if (RegBankSelectMode != RunningMode) - DEBUG(dbgs() << "RegBankSelect mode overrided by command line\n"); + LLVM_DEBUG(dbgs() << "RegBankSelect mode overrided by command line\n"); } } @@ -122,7 +122,7 @@ // Reg is free of assignment, a simple assignment will make the // register bank to match. OnlyAssign = CurRegBank == nullptr; - DEBUG(dbgs() << "Does assignment already match: "; + LLVM_DEBUG(dbgs() << "Does assignment already match: "; if (CurRegBank) dbgs() << *CurRegBank; else dbgs() << "none"; dbgs() << " against "; assert(DesiredRegBrank && "The mapping must be valid"); @@ -159,7 +159,7 @@ // same types because the type is a placeholder when this function is called. MachineInstr *MI = MIRBuilder.buildInstrNoInsert(TargetOpcode::COPY).addDef(Dst).addUse(Src); - DEBUG(dbgs() << "Copy: " << printReg(Src) << " to: " << printReg(Dst) + LLVM_DEBUG(dbgs() << "Copy: " << printReg(Src) << " to: " << printReg(Dst) << '\n'); // TODO: // Check if MI is legal. if not, we need to legalize all the @@ -245,7 +245,7 @@ MappingCost CurCost = computeMapping(MI, *CurMapping, LocalRepairPts, &Cost); if (CurCost < Cost) { - DEBUG(dbgs() << "New best: " << CurCost << '\n'); + LLVM_DEBUG(dbgs() << "New best: " << CurCost << '\n'); Cost = CurCost; BestMapping = CurMapping; RepairPts.clear(); @@ -397,11 +397,11 @@ MappingCost Cost(MBFI ? MBFI->getBlockFreq(MI.getParent()) : 1); bool Saturated = Cost.addLocalCost(InstrMapping.getCost()); assert(!Saturated && "Possible mapping saturated the cost"); - DEBUG(dbgs() << "Evaluating mapping cost for: " << MI); - DEBUG(dbgs() << "With: " << InstrMapping << '\n'); + LLVM_DEBUG(dbgs() << "Evaluating mapping cost for: " << MI); + LLVM_DEBUG(dbgs() << "With: " << InstrMapping << '\n'); RepairPts.clear(); if (BestCost && Cost > *BestCost) { - DEBUG(dbgs() << "Mapping is too expensive from the start\n"); + LLVM_DEBUG(dbgs() << "Mapping is too expensive from the start\n"); return Cost; } @@ -417,17 +417,17 @@ unsigned Reg = MO.getReg(); if (!Reg) continue; - DEBUG(dbgs() << "Opd" << OpIdx << '\n'); + LLVM_DEBUG(dbgs() << "Opd" << OpIdx << '\n'); const RegisterBankInfo::ValueMapping &ValMapping = InstrMapping.getOperandMapping(OpIdx); // If Reg is already properly mapped, this is free. bool Assign; if (assignmentMatch(Reg, ValMapping, Assign)) { - DEBUG(dbgs() << "=> is free (match).\n"); + LLVM_DEBUG(dbgs() << "=> is free (match).\n"); continue; } if (Assign) { - DEBUG(dbgs() << "=> is free (simple assignment).\n"); + LLVM_DEBUG(dbgs() << "=> is free (simple assignment).\n"); RepairPts.emplace_back(RepairingPlacement(MI, OpIdx, *TRI, *this, RepairingPlacement::Reassign)); continue; @@ -446,7 +446,7 @@ // Check that the materialization of the repairing is possible. if (!RepairPt.canMaterialize()) { - DEBUG(dbgs() << "Mapping involves impossible repairing\n"); + LLVM_DEBUG(dbgs() << "Mapping involves impossible repairing\n"); return MappingCost::ImpossibleCost(); } @@ -509,7 +509,7 @@ // Stop looking into what it takes to repair, this is already // too expensive. if (BestCost && Cost > *BestCost) { - DEBUG(dbgs() << "Mapping is too expensive, stop processing\n"); + LLVM_DEBUG(dbgs() << "Mapping is too expensive, stop processing\n"); return Cost; } @@ -519,7 +519,7 @@ break; } } - DEBUG(dbgs() << "Total cost is: " << Cost << "\n"); + LLVM_DEBUG(dbgs() << "Total cost is: " << Cost << "\n"); return Cost; } @@ -559,14 +559,14 @@ } // Second, rewrite the instruction. - DEBUG(dbgs() << "Actual mapping of the operands: " << OpdMapper << '\n'); + LLVM_DEBUG(dbgs() << "Actual mapping of the operands: " << OpdMapper << '\n'); RBI->applyMapping(OpdMapper); return true; } bool RegBankSelect::assignInstr(MachineInstr &MI) { - DEBUG(dbgs() << "Assign: " << MI); + LLVM_DEBUG(dbgs() << "Assign: " << MI); // Remember the repairing placement for all the operands. SmallVector RepairPts; @@ -587,7 +587,7 @@ // Make sure the mapping is valid for MI. assert(BestMapping->verify(MI) && "Invalid instruction mapping"); - DEBUG(dbgs() << "Best Mapping: " << *BestMapping << '\n'); + LLVM_DEBUG(dbgs() << "Best Mapping: " << *BestMapping << '\n'); // After this call, MI may not be valid anymore. // Do not use it. @@ -600,7 +600,7 @@ MachineFunctionProperties::Property::FailedISel)) return false; - DEBUG(dbgs() << "Assign register banks for: " << MF.getName() << '\n'); + LLVM_DEBUG(dbgs() << "Assign register banks for: " << MF.getName() << '\n'); const Function &F = MF.getFunction(); Mode SaveOptMode = OptMode; if (F.hasFnAttribute(Attribute::OptimizeNone)) Index: lib/CodeGen/GlobalISel/RegisterBankInfo.cpp =================================================================== --- lib/CodeGen/GlobalISel/RegisterBankInfo.cpp +++ lib/CodeGen/GlobalISel/RegisterBankInfo.cpp @@ -72,7 +72,7 @@ const RegisterBank &RegBank = getRegBank(Idx); assert(Idx == RegBank.getID() && "ID does not match the index in the array"); - DEBUG(dbgs() << "Verify " << RegBank << '\n'); + LLVM_DEBUG(dbgs() << "Verify " << RegBank << '\n'); assert(RegBank.verify(TRI) && "RegBank is invalid"); } #endif // NDEBUG @@ -403,18 +403,18 @@ void RegisterBankInfo::applyDefaultMapping(const OperandsMapper &OpdMapper) { MachineInstr &MI = OpdMapper.getMI(); MachineRegisterInfo &MRI = OpdMapper.getMRI(); - DEBUG(dbgs() << "Applying default-like mapping\n"); + LLVM_DEBUG(dbgs() << "Applying default-like mapping\n"); for (unsigned OpIdx = 0, EndIdx = OpdMapper.getInstrMapping().getNumOperands(); OpIdx != EndIdx; ++OpIdx) { - DEBUG(dbgs() << "OpIdx " << OpIdx); + LLVM_DEBUG(dbgs() << "OpIdx " << OpIdx); MachineOperand &MO = MI.getOperand(OpIdx); if (!MO.isReg()) { - DEBUG(dbgs() << " is not a register, nothing to be done\n"); + LLVM_DEBUG(dbgs() << " is not a register, nothing to be done\n"); continue; } if (!MO.getReg()) { - DEBUG(dbgs() << " is %%noreg, nothing to be done\n"); + LLVM_DEBUG(dbgs() << " is %%noreg, nothing to be done\n"); continue; } assert(OpdMapper.getInstrMapping().getOperandMapping(OpIdx).NumBreakDowns != @@ -426,14 +426,14 @@ iterator_range::const_iterator> NewRegs = OpdMapper.getVRegs(OpIdx); if (NewRegs.begin() == NewRegs.end()) { - DEBUG(dbgs() << " has not been repaired, nothing to be done\n"); + LLVM_DEBUG(dbgs() << " has not been repaired, nothing to be done\n"); continue; } unsigned OrigReg = MO.getReg(); unsigned NewReg = *NewRegs.begin(); - DEBUG(dbgs() << " changed, replace " << printReg(OrigReg, nullptr)); + LLVM_DEBUG(dbgs() << " changed, replace " << printReg(OrigReg, nullptr)); MO.setReg(NewReg); - DEBUG(dbgs() << " with " << printReg(NewReg, nullptr)); + LLVM_DEBUG(dbgs() << " with " << printReg(NewReg, nullptr)); // The OperandsMapper creates plain scalar, we may have to fix that. // Check if the types match and if not, fix that. @@ -447,11 +447,11 @@ assert(OrigTy.getSizeInBits() <= NewTy.getSizeInBits() && "Types with difference size cannot be handled by the default " "mapping"); - DEBUG(dbgs() << "\nChange type of new opd from " << NewTy << " to " + LLVM_DEBUG(dbgs() << "\nChange type of new opd from " << NewTy << " to " << OrigTy); MRI.setType(NewReg, OrigTy); } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); } } Index: lib/CodeGen/GlobalISel/Utils.cpp =================================================================== --- lib/CodeGen/GlobalISel/Utils.cpp +++ lib/CodeGen/GlobalISel/Utils.cpp @@ -91,7 +91,7 @@ if (!MO.isReg()) continue; - DEBUG(dbgs() << "Converting operand: " << MO << '\n'); + LLVM_DEBUG(dbgs() << "Converting operand: " << MO << '\n'); assert(MO.isReg() && "Unsupported non-reg operand"); unsigned Reg = MO.getReg(); Index: lib/CodeGen/GlobalMerge.cpp =================================================================== --- lib/CodeGen/GlobalMerge.cpp +++ lib/CodeGen/GlobalMerge.cpp @@ -442,7 +442,7 @@ Type *Int32Ty = Type::getInt32Ty(M.getContext()); auto &DL = M.getDataLayout(); - DEBUG(dbgs() << " Trying to merge set, starts with #" + LLVM_DEBUG(dbgs() << " Trying to merge set, starts with #" << GlobalSet.find_first() << "\n"); ssize_t i = GlobalSet.find_first(); Index: lib/CodeGen/IfConversion.cpp =================================================================== --- lib/CodeGen/IfConversion.cpp +++ lib/CodeGen/IfConversion.cpp @@ -361,14 +361,14 @@ getAnalysisIfAvailable()); } - DEBUG(dbgs() << "\nIfcvt: function (" << ++FnNum << ") \'" + LLVM_DEBUG(dbgs() << "\nIfcvt: function (" << ++FnNum << ") \'" << MF.getName() << "\'"); if (FnNum < IfCvtFnStart || (IfCvtFnStop != -1 && FnNum > IfCvtFnStop)) { - DEBUG(dbgs() << " skipped\n"); + LLVM_DEBUG(dbgs() << " skipped\n"); return false; } - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n"); MF.RenumberBlocks(); BBAnalysis.resize(MF.getNumBlockIDs()); @@ -406,14 +406,14 @@ case ICSimpleFalse: { bool isFalse = Kind == ICSimpleFalse; if ((isFalse && DisableSimpleF) || (!isFalse && DisableSimple)) break; - DEBUG(dbgs() << "Ifcvt (Simple" + LLVM_DEBUG(dbgs() << "Ifcvt (Simple" << (Kind == ICSimpleFalse ? " false" : "") << "): " << printMBBReference(*BBI.BB) << " (" << ((Kind == ICSimpleFalse) ? BBI.FalseBB->getNumber() : BBI.TrueBB->getNumber()) << ") "); RetVal = IfConvertSimple(BBI, Kind); - DEBUG(dbgs() << (RetVal ? "succeeded!" : "failed!") << "\n"); + LLVM_DEBUG(dbgs() << (RetVal ? "succeeded!" : "failed!") << "\n"); if (RetVal) { if (isFalse) ++NumSimpleFalse; else ++NumSimple; @@ -430,16 +430,16 @@ if (DisableTriangleR && !isFalse && isRev) break; if (DisableTriangleF && isFalse && !isRev) break; if (DisableTriangleFR && isFalse && isRev) break; - DEBUG(dbgs() << "Ifcvt (Triangle"); + LLVM_DEBUG(dbgs() << "Ifcvt (Triangle"); if (isFalse) - DEBUG(dbgs() << " false"); + LLVM_DEBUG(dbgs() << " false"); if (isRev) - DEBUG(dbgs() << " rev"); - DEBUG(dbgs() << "): " << printMBBReference(*BBI.BB) + LLVM_DEBUG(dbgs() << " rev"); + LLVM_DEBUG(dbgs() << "): " << printMBBReference(*BBI.BB) << " (T:" << BBI.TrueBB->getNumber() << ",F:" << BBI.FalseBB->getNumber() << ") "); RetVal = IfConvertTriangle(BBI, Kind); - DEBUG(dbgs() << (RetVal ? "succeeded!" : "failed!") << "\n"); + LLVM_DEBUG(dbgs() << (RetVal ? "succeeded!" : "failed!") << "\n"); if (RetVal) { if (isFalse) { if (isRev) ++NumTriangleFRev; @@ -453,24 +453,24 @@ } case ICDiamond: if (DisableDiamond) break; - DEBUG(dbgs() << "Ifcvt (Diamond): " << printMBBReference(*BBI.BB) + LLVM_DEBUG(dbgs() << "Ifcvt (Diamond): " << printMBBReference(*BBI.BB) << " (T:" << BBI.TrueBB->getNumber() << ",F:" << BBI.FalseBB->getNumber() << ") "); RetVal = IfConvertDiamond(BBI, Kind, NumDups, NumDups2, Token->TClobbersPred, Token->FClobbersPred); - DEBUG(dbgs() << (RetVal ? "succeeded!" : "failed!") << "\n"); + LLVM_DEBUG(dbgs() << (RetVal ? "succeeded!" : "failed!") << "\n"); if (RetVal) ++NumDiamonds; break; case ICForkedDiamond: if (DisableForkedDiamond) break; - DEBUG(dbgs() << "Ifcvt (Forked Diamond): " << printMBBReference(*BBI.BB) + LLVM_DEBUG(dbgs() << "Ifcvt (Forked Diamond): " << printMBBReference(*BBI.BB) << " (T:" << BBI.TrueBB->getNumber() << ",F:" << BBI.FalseBB->getNumber() << ") "); RetVal = IfConvertForkedDiamond(BBI, Kind, NumDups, NumDups2, Token->TClobbersPred, Token->FClobbersPred); - DEBUG(dbgs() << (RetVal ? "succeeded!" : "failed!") << "\n"); + LLVM_DEBUG(dbgs() << (RetVal ? "succeeded!" : "failed!") << "\n"); if (RetVal) ++NumForkedDiamonds; break; } Index: lib/CodeGen/InlineSpiller.cpp =================================================================== --- lib/CodeGen/InlineSpiller.cpp +++ lib/CodeGen/InlineSpiller.cpp @@ -335,7 +335,7 @@ if (isRegToSpill(SnipReg)) continue; RegsToSpill.push_back(SnipReg); - DEBUG(dbgs() << "\talso spill snippet " << SnipLI << '\n'); + LLVM_DEBUG(dbgs() << "\talso spill snippet " << SnipLI << '\n'); ++NumSnippets; } } @@ -387,7 +387,7 @@ LiveInterval &OrigLI = LIS.getInterval(Original); VNInfo *OrigVNI = OrigLI.getVNInfoAt(Idx); StackInt->MergeValueInAsValue(OrigLI, OrigVNI, StackInt->getValNumInfo(0)); - DEBUG(dbgs() << "\tmerged orig valno " << OrigVNI->id << ": " + LLVM_DEBUG(dbgs() << "\tmerged orig valno " << OrigVNI->id << ": " << *StackInt << '\n'); // We are going to spill SrcVNI immediately after its def, so clear out @@ -409,7 +409,7 @@ MRI.getRegClass(SrcReg), &TRI); --MII; // Point to store instruction. LIS.InsertMachineInstrInMaps(*MII); - DEBUG(dbgs() << "\thoisted: " << SrcVNI->def << '\t' << *MII); + LLVM_DEBUG(dbgs() << "\thoisted: " << SrcVNI->def << '\t' << *MII); HSpiller.addToMergeableSpills(*MII, StackSlot, Original); ++NumSpills; @@ -428,7 +428,7 @@ LiveInterval *LI; std::tie(LI, VNI) = WorkList.pop_back_val(); unsigned Reg = LI->reg; - DEBUG(dbgs() << "Checking redundant spills for " + LLVM_DEBUG(dbgs() << "Checking redundant spills for " << VNI->id << '@' << VNI->def << " in " << *LI << '\n'); // Regs to spill are taken care of. @@ -437,7 +437,7 @@ // Add all of VNI's live range to StackInt. StackInt->MergeValueInAsValue(*LI, VNI, StackInt->getValNumInfo(0)); - DEBUG(dbgs() << "Merged to stack int: " << *StackInt << '\n'); + LLVM_DEBUG(dbgs() << "Merged to stack int: " << *StackInt << '\n'); // Find all spills and copies of VNI. for (MachineRegisterInfo::use_instr_nodbg_iterator @@ -465,7 +465,7 @@ // Erase spills. int FI; if (Reg == TII.isStoreToStackSlot(MI, FI) && FI == StackSlot) { - DEBUG(dbgs() << "Redundant spill " << Idx << '\t' << MI); + LLVM_DEBUG(dbgs() << "Redundant spill " << Idx << '\t' << MI); // eliminateDeadDefs won't normally remove stores, so switch opcode. MI.setDesc(TII.get(TargetOpcode::KILL)); DeadDefs.push_back(&MI); @@ -527,13 +527,13 @@ VNInfo *ParentVNI = VirtReg.getVNInfoAt(UseIdx.getBaseIndex()); if (!ParentVNI) { - DEBUG(dbgs() << "\tadding flags: "); + LLVM_DEBUG(dbgs() << "\tadding flags: "); for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) { MachineOperand &MO = MI.getOperand(i); if (MO.isReg() && MO.isUse() && MO.getReg() == VirtReg.reg) MO.setIsUndef(); } - DEBUG(dbgs() << UseIdx << '\t' << MI); + LLVM_DEBUG(dbgs() << UseIdx << '\t' << MI); return true; } @@ -547,7 +547,7 @@ if (!Edit->canRematerializeAt(RM, OrigVNI, UseIdx, false)) { markValueUsed(&VirtReg, ParentVNI); - DEBUG(dbgs() << "\tcannot remat for " << UseIdx << '\t' << MI); + LLVM_DEBUG(dbgs() << "\tcannot remat for " << UseIdx << '\t' << MI); return false; } @@ -555,7 +555,7 @@ // same register for uses and defs. if (RI.Tied) { markValueUsed(&VirtReg, ParentVNI); - DEBUG(dbgs() << "\tcannot remat tied reg: " << UseIdx << '\t' << MI); + LLVM_DEBUG(dbgs() << "\tcannot remat tied reg: " << UseIdx << '\t' << MI); return false; } @@ -581,7 +581,7 @@ NewMI->setDebugLoc(MI.getDebugLoc()); (void)DefIdx; - DEBUG(dbgs() << "\tremat: " << DefIdx << '\t' + LLVM_DEBUG(dbgs() << "\tremat: " << DefIdx << '\t' << *LIS.getInstructionFromIndex(DefIdx)); // Replace operands @@ -592,7 +592,7 @@ MO.setIsKill(); } } - DEBUG(dbgs() << "\t " << UseIdx << '\t' << MI << '\n'); + LLVM_DEBUG(dbgs() << "\t " << UseIdx << '\t' << MI << '\n'); ++NumRemats; return true; @@ -637,7 +637,7 @@ MI->addRegisterDead(Reg, &TRI); if (!MI->allDefsAreDead()) continue; - DEBUG(dbgs() << "All defs dead: " << *MI); + LLVM_DEBUG(dbgs() << "All defs dead: " << *MI); DeadDefs.push_back(MI); } } @@ -646,7 +646,7 @@ // deleted here. if (DeadDefs.empty()) return; - DEBUG(dbgs() << "Remat created " << DeadDefs.size() << " dead defs.\n"); + LLVM_DEBUG(dbgs() << "Remat created " << DeadDefs.size() << " dead defs.\n"); Edit->eliminateDeadDefs(DeadDefs, RegsToSpill, AA); // LiveRangeEdit::eliminateDeadDef is used to remove dead define instructions @@ -669,7 +669,7 @@ RegsToSpill[ResultPos++] = Reg; } RegsToSpill.erase(RegsToSpill.begin() + ResultPos, RegsToSpill.end()); - DEBUG(dbgs() << RegsToSpill.size() << " registers to spill after remat.\n"); + LLVM_DEBUG(dbgs() << RegsToSpill.size() << " registers to spill after remat.\n"); } //===----------------------------------------------------------------------===// @@ -691,7 +691,7 @@ if (!IsLoad) HSpiller.rmFromMergeableSpills(*MI, StackSlot); - DEBUG(dbgs() << "Coalescing stack access: " << *MI); + LLVM_DEBUG(dbgs() << "Coalescing stack access: " << *MI); LIS.RemoveMachineInstrFromMaps(*MI); MI->eraseFromParent(); @@ -848,7 +848,7 @@ FoldMI->RemoveOperand(i - 1); } - DEBUG(dumpMachineInstrRangeWithSlotIndex(MIS.begin(), MIS.end(), LIS, + LLVM_DEBUG(dumpMachineInstrRangeWithSlotIndex(MIS.begin(), MIS.end(), LIS, "folded")); if (!WasCopy) @@ -872,7 +872,7 @@ LIS.InsertMachineInstrRangeInMaps(MIS.begin(), MI); - DEBUG(dumpMachineInstrRangeWithSlotIndex(MIS.begin(), MI, LIS, "reload", + LLVM_DEBUG(dumpMachineInstrRangeWithSlotIndex(MIS.begin(), MI, LIS, "reload", NewVReg)); ++NumReloads; } @@ -912,7 +912,7 @@ LIS.InsertMachineInstrRangeInMaps(std::next(MI), MIS.end()); - DEBUG(dumpMachineInstrRangeWithSlotIndex(std::next(MI), MIS.end(), LIS, + LLVM_DEBUG(dumpMachineInstrRangeWithSlotIndex(std::next(MI), MIS.end(), LIS, "spill")); ++NumSpills; if (IsRealSpill) @@ -921,7 +921,7 @@ /// spillAroundUses - insert spill code around each use of Reg. void InlineSpiller::spillAroundUses(unsigned Reg) { - DEBUG(dbgs() << "spillAroundUses " << printReg(Reg) << '\n'); + LLVM_DEBUG(dbgs() << "spillAroundUses " << printReg(Reg) << '\n'); LiveInterval &OldLI = LIS.getInterval(Reg); // Iterate over instructions using Reg. @@ -934,7 +934,7 @@ if (MI->isDebugValue()) { // Modify DBG_VALUE now that the value is in a spill slot. MachineBasicBlock *MBB = MI->getParent(); - DEBUG(dbgs() << "Modifying debug info due to spill:\t" << *MI); + LLVM_DEBUG(dbgs() << "Modifying debug info due to spill:\t" << *MI); buildDbgValueForSpill(*MBB, MI, *MI, StackSlot); MBB->erase(MI); continue; @@ -965,7 +965,7 @@ if (SibReg && isSibling(SibReg)) { // This may actually be a copy between snippets. if (isRegToSpill(SibReg)) { - DEBUG(dbgs() << "Found new snippet copy: " << *MI); + LLVM_DEBUG(dbgs() << "Found new snippet copy: " << *MI); SnippetCopies.insert(MI); continue; } @@ -1008,7 +1008,7 @@ hasLiveDef = true; } } - DEBUG(dbgs() << "\trewrite: " << Idx << '\t' << *MI << '\n'); + LLVM_DEBUG(dbgs() << "\trewrite: " << Idx << '\t' << *MI << '\n'); // FIXME: Use a second vreg if instruction has no tied ops. if (RI.Writes) @@ -1034,7 +1034,7 @@ for (unsigned Reg : RegsToSpill) StackInt->MergeSegmentsInAsValue(LIS.getInterval(Reg), StackInt->getValNumInfo(0)); - DEBUG(dbgs() << "Merged spilled regs: " << *StackInt << '\n'); + LLVM_DEBUG(dbgs() << "Merged spilled regs: " << *StackInt << '\n'); // Spill around uses of all RegsToSpill. for (unsigned Reg : RegsToSpill) @@ -1042,7 +1042,7 @@ // Hoisted spills may cause dead code. if (!DeadDefs.empty()) { - DEBUG(dbgs() << "Eliminating " << DeadDefs.size() << " dead defs\n"); + LLVM_DEBUG(dbgs() << "Eliminating " << DeadDefs.size() << " dead defs\n"); Edit->eliminateDeadDefs(DeadDefs, RegsToSpill, AA); } @@ -1074,7 +1074,7 @@ StackSlot = VRM.getStackSlot(Original); StackInt = nullptr; - DEBUG(dbgs() << "Inline spilling " + LLVM_DEBUG(dbgs() << "Inline spilling " << TRI.getRegClassName(MRI.getRegClass(edit.getReg())) << ':' << edit.getParent() << "\nFrom original " << printReg(Original) << '\n'); @@ -1261,11 +1261,11 @@ "Orders have different size with WorkSet"); #ifndef NDEBUG - DEBUG(dbgs() << "Orders size is " << Orders.size() << "\n"); + LLVM_DEBUG(dbgs() << "Orders size is " << Orders.size() << "\n"); SmallVector::reverse_iterator RIt = Orders.rbegin(); for (; RIt != Orders.rend(); RIt++) - DEBUG(dbgs() << "BB" << (*RIt)->getBlock()->getNumber() << ","); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "BB" << (*RIt)->getBlock()->getNumber() << ","); + LLVM_DEBUG(dbgs() << "\n"); #endif } @@ -1374,7 +1374,7 @@ // Current Block is the BB containing the new hoisted spill. Add it to // SpillsToKeep. LiveReg is the source of the new spill. SpillsToKeep[*RIt] = LiveReg; - DEBUG({ + LLVM_DEBUG({ dbgs() << "spills in BB: "; for (const auto Rspill : SpillsInSubTree) dbgs() << Rspill->getBlock()->getNumber() << " "; @@ -1430,7 +1430,7 @@ if (Ent.second.empty()) continue; - DEBUG({ + LLVM_DEBUG({ dbgs() << "\nFor Slot" << Slot << " and VN" << OrigVNI->id << ":\n" << "Equal spills in BB: "; for (const auto spill : EqValSpills) @@ -1445,7 +1445,7 @@ runHoistSpills(OrigLI, *OrigVNI, EqValSpills, SpillsToRm, SpillsToIns); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Finally inserted spills in BB: "; for (const auto Ispill : SpillsToIns) dbgs() << Ispill.first->getNumber() << " "; Index: lib/CodeGen/InterleavedAccessPass.cpp =================================================================== --- lib/CodeGen/InterleavedAccessPass.cpp +++ lib/CodeGen/InterleavedAccessPass.cpp @@ -332,7 +332,7 @@ if (!tryReplaceExtracts(Extracts, Shuffles)) return false; - DEBUG(dbgs() << "IA: Found an interleaved load: " << *LI << "\n"); + LLVM_DEBUG(dbgs() << "IA: Found an interleaved load: " << *LI << "\n"); // Try to create target specific intrinsics to replace the load and shuffles. if (!TLI->lowerInterleavedLoad(LI, Shuffles, Indices, Factor)) @@ -424,7 +424,7 @@ if (!isReInterleaveMask(SVI->getShuffleMask(), Factor, MaxFactor, OpNumElts)) return false; - DEBUG(dbgs() << "IA: Found an interleaved store: " << *SI << "\n"); + LLVM_DEBUG(dbgs() << "IA: Found an interleaved store: " << *SI << "\n"); // Try to create target specific intrinsics to replace the store and shuffle. if (!TLI->lowerInterleavedStore(SI, SVI, Factor)) @@ -441,7 +441,7 @@ if (!TPC || !LowerInterleavedAccesses) return false; - DEBUG(dbgs() << "*** " << getPassName() << ": " << F.getName() << "\n"); + LLVM_DEBUG(dbgs() << "*** " << getPassName() << ": " << F.getName() << "\n"); DT = &getAnalysis().getDomTree(); auto &TM = TPC->getTM(); Index: lib/CodeGen/LazyMachineBlockFrequencyInfo.cpp =================================================================== --- lib/CodeGen/LazyMachineBlockFrequencyInfo.cpp +++ lib/CodeGen/LazyMachineBlockFrequencyInfo.cpp @@ -57,23 +57,23 @@ LazyMachineBlockFrequencyInfoPass::calculateIfNotAvailable() const { auto *MBFI = getAnalysisIfAvailable(); if (MBFI) { - DEBUG(dbgs() << "MachineBlockFrequencyInfo is available\n"); + LLVM_DEBUG(dbgs() << "MachineBlockFrequencyInfo is available\n"); return *MBFI; } auto &MBPI = getAnalysis(); auto *MLI = getAnalysisIfAvailable(); auto *MDT = getAnalysisIfAvailable(); - DEBUG(dbgs() << "Building MachineBlockFrequencyInfo on the fly\n"); - DEBUG(if (MLI) dbgs() << "LoopInfo is available\n"); + LLVM_DEBUG(dbgs() << "Building MachineBlockFrequencyInfo on the fly\n"); + LLVM_DEBUG(if (MLI) dbgs() << "LoopInfo is available\n"); if (!MLI) { - DEBUG(dbgs() << "Building LoopInfo on the fly\n"); + LLVM_DEBUG(dbgs() << "Building LoopInfo on the fly\n"); // First create a dominator tree. - DEBUG(if (MDT) dbgs() << "DominatorTree is available\n"); + LLVM_DEBUG(if (MDT) dbgs() << "DominatorTree is available\n"); if (!MDT) { - DEBUG(dbgs() << "Building DominatorTree on the fly\n"); + LLVM_DEBUG(dbgs() << "Building DominatorTree on the fly\n"); OwnedMDT = make_unique(); OwnedMDT->getBase().recalculate(*MF); MDT = OwnedMDT.get(); Index: lib/CodeGen/LiveDebugValues.cpp =================================================================== --- lib/CodeGen/LiveDebugValues.cpp +++ lib/CodeGen/LiveDebugValues.cpp @@ -479,7 +479,7 @@ // Check if the register is the location of a debug value. for (unsigned ID : OpenRanges.getVarLocs()) { if (VarLocIDs[ID].isDescribedByReg() == Reg) { - DEBUG(dbgs() << "Spilling Register " << printReg(Reg, TRI) << '(' + LLVM_DEBUG(dbgs() << "Spilling Register " << printReg(Reg, TRI) << '(' << VarLocIDs[ID].Var.getVar()->getName() << ")\n"); // Create a DBG_VALUE instruction to describe the Var in its spilled @@ -493,7 +493,7 @@ MachineInstr *SpDMI = BuildMI(*MF, DMI->getDebugLoc(), DMI->getDesc(), true, SpillBase, DMI->getDebugVariable(), SpillExpr); - DEBUG(dbgs() << "Creating DBG_VALUE inst for spill: "; + LLVM_DEBUG(dbgs() << "Creating DBG_VALUE inst for spill: "; SpDMI->print(dbgs(), false, TII)); // The newly created DBG_VALUE instruction SpDMI must be inserted after @@ -526,7 +526,7 @@ if (OpenRanges.empty()) return false; - DEBUG(for (unsigned ID : OpenRanges.getVarLocs()) { + LLVM_DEBUG(for (unsigned ID : OpenRanges.getVarLocs()) { // Copy OpenRanges to OutLocs, if not already present. dbgs() << "Add to OutLocs: "; VarLocIDs[ID].dump(); }); @@ -555,7 +555,7 @@ bool LiveDebugValues::join(MachineBasicBlock &MBB, VarLocInMBB &OutLocs, VarLocInMBB &InLocs, const VarLocMap &VarLocIDs, SmallPtrSet &Visited) { - DEBUG(dbgs() << "join MBB: " << MBB.getName() << "\n"); + LLVM_DEBUG(dbgs() << "join MBB: " << MBB.getName() << "\n"); bool Changed = false; VarLocSet InLocsT; // Temporary incoming locations. @@ -615,7 +615,7 @@ DMI->getDebugVariable(), DMI->getDebugExpression()); if (DMI->isIndirectDebugValue()) MI->getOperand(1).setImm(DMI->getOperand(1).getImm()); - DEBUG(dbgs() << "Inserted: "; MI->dump();); + LLVM_DEBUG(dbgs() << "Inserted: "; MI->dump();); ILS.set(ID); ++NumInserted; Changed = true; @@ -626,7 +626,7 @@ /// Calculate the liveness information for the given machine function and /// extend ranges across basic blocks. bool LiveDebugValues::ExtendRanges(MachineFunction &MF) { - DEBUG(dbgs() << "\nDebug Range Extension\n"); + LLVM_DEBUG(dbgs() << "\nDebug Range Extension\n"); bool Changed = false; bool OLChanged = false; @@ -657,7 +657,7 @@ transfer(MI, OpenRanges, OutLocs, VarLocIDs, Spills, /*transferSpills=*/false); - DEBUG(printVarLocInMBB(MF, OutLocs, VarLocIDs, "OutLocs after initialization", + LLVM_DEBUG(printVarLocInMBB(MF, OutLocs, VarLocIDs, "OutLocs after initialization", dbgs())); ReversePostOrderTraversal RPOT(&MF); @@ -678,7 +678,7 @@ // thing twice. We could avoid this with a custom priority queue, but this // is probably not worth it. SmallPtrSet OnPending; - DEBUG(dbgs() << "Processing Worklist\n"); + LLVM_DEBUG(dbgs() << "Processing Worklist\n"); while (!Worklist.empty()) { MachineBasicBlock *MBB = OrderToBB[Worklist.top()]; Worklist.pop(); @@ -700,9 +700,9 @@ SP.DebugInst); Spills.clear(); - DEBUG(printVarLocInMBB(MF, OutLocs, VarLocIDs, + LLVM_DEBUG(printVarLocInMBB(MF, OutLocs, VarLocIDs, "OutLocs after propagating", dbgs())); - DEBUG(printVarLocInMBB(MF, InLocs, VarLocIDs, + LLVM_DEBUG(printVarLocInMBB(MF, InLocs, VarLocIDs, "InLocs after propagating", dbgs())); if (OLChanged) { @@ -720,8 +720,8 @@ assert(Pending.empty() && "Pending should be empty"); } - DEBUG(printVarLocInMBB(MF, OutLocs, VarLocIDs, "Final OutLocs", dbgs())); - DEBUG(printVarLocInMBB(MF, InLocs, VarLocIDs, "Final InLocs", dbgs())); + LLVM_DEBUG(printVarLocInMBB(MF, OutLocs, VarLocIDs, "Final OutLocs", dbgs())); + LLVM_DEBUG(printVarLocInMBB(MF, InLocs, VarLocIDs, "Final InLocs", dbgs())); return Changed; } Index: lib/CodeGen/LiveDebugVariables.cpp =================================================================== --- lib/CodeGen/LiveDebugVariables.cpp +++ lib/CodeGen/LiveDebugVariables.cpp @@ -510,7 +510,7 @@ if (MI.getNumOperands() != 4 || !(MI.getOperand(1).isReg() || MI.getOperand(1).isImm()) || !MI.getOperand(2).isMetadata()) { - DEBUG(dbgs() << "Can't handle " << MI); + LLVM_DEBUG(dbgs() << "Can't handle " << MI); return false; } @@ -648,7 +648,7 @@ if (CopyValues.empty()) return; - DEBUG(dbgs() << "Got " << CopyValues.size() << " copies of " << *LI << '\n'); + LLVM_DEBUG(dbgs() << "Got " << CopyValues.size() << " copies of " << *LI << '\n'); // Try to add defs of the copied values for each kill point. for (unsigned i = 0, e = Kills.size(); i != e; ++i) { @@ -662,7 +662,7 @@ LocMap::iterator I = locInts.find(Idx); if (I.valid() && I.start() <= Idx) continue; - DEBUG(dbgs() << "Kill at " << Idx << " covered by valno #" + LLVM_DEBUG(dbgs() << "Kill at " << Idx << " covered by valno #" << DstVNI->id << " in " << *DstLI << '\n'); MachineInstr *CopyMI = LIS.getInstructionFromIndex(DstVNI->def); assert(CopyMI && CopyMI->isCopy() && "Bad copy value"); @@ -811,12 +811,12 @@ MF = &mf; LIS = &pass.getAnalysis(); TRI = mf.getSubtarget().getRegisterInfo(); - DEBUG(dbgs() << "********** COMPUTING LIVE DEBUG VARIABLES: " + LLVM_DEBUG(dbgs() << "********** COMPUTING LIVE DEBUG VARIABLES: " << mf.getName() << " **********\n"); bool Changed = collectDebugValues(mf); computeIntervals(); - DEBUG(print(dbgs())); + LLVM_DEBUG(print(dbgs())); ModifiedMF = Changed; return Changed; } @@ -862,7 +862,7 @@ bool UserValue::splitLocation(unsigned OldLocNo, ArrayRef NewRegs, LiveIntervals& LIS) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "Splitting Loc" << OldLocNo << '\t'; print(dbgs(), nullptr); }); @@ -945,7 +945,7 @@ while (LocMapI.valid()) { DbgValueLocation v = LocMapI.value(); if (v.locNo() == OldLocNo) { - DEBUG(dbgs() << "Erasing [" << LocMapI.start() << ';' + LLVM_DEBUG(dbgs() << "Erasing [" << LocMapI.start() << ';' << LocMapI.stop() << ")\n"); LocMapI.erase(); } else { @@ -955,7 +955,7 @@ } } - DEBUG({dbgs() << "Split result: \t"; print(dbgs(), nullptr);}); + LLVM_DEBUG({dbgs() << "Split result: \t"; print(dbgs(), nullptr);}); return DidChange; } @@ -1173,11 +1173,11 @@ if (trimmedDefs.count(Start)) Start = Start.getPrevIndex(); - DEBUG(dbgs() << "\t[" << Start << ';' << Stop << "):" << Loc.locNo()); + LLVM_DEBUG(dbgs() << "\t[" << Start << ';' << Stop << "):" << Loc.locNo()); MachineFunction::iterator MBB = LIS.getMBBFromIndex(Start)->getIterator(); SlotIndex MBBEnd = LIS.getMBBEndIdx(&*MBB); - DEBUG(dbgs() << ' ' << printMBBReference(*MBB) << '-' << MBBEnd); + LLVM_DEBUG(dbgs() << ' ' << printMBBReference(*MBB) << '-' << MBBEnd); insertDebugValue(&*MBB, Start, Stop, Loc, Spilled, LIS, TII, TRI); // This interval may span multiple basic blocks. // Insert a DBG_VALUE into each one. @@ -1187,10 +1187,10 @@ if (++MBB == MFEnd) break; MBBEnd = LIS.getMBBEndIdx(&*MBB); - DEBUG(dbgs() << ' ' << printMBBReference(*MBB) << '-' << MBBEnd); + LLVM_DEBUG(dbgs() << ' ' << printMBBReference(*MBB) << '-' << MBBEnd); insertDebugValue(&*MBB, Start, Stop, Loc, Spilled, LIS, TII, TRI); } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); if (MBB == MFEnd) break; @@ -1199,13 +1199,13 @@ } void LDVImpl::emitDebugValues(VirtRegMap *VRM) { - DEBUG(dbgs() << "********** EMITTING LIVE DEBUG VARIABLES **********\n"); + LLVM_DEBUG(dbgs() << "********** EMITTING LIVE DEBUG VARIABLES **********\n"); if (!MF) return; const TargetInstrInfo *TII = MF->getSubtarget().getInstrInfo(); BitVector SpilledLocations; for (unsigned i = 0, e = userValues.size(); i != e; ++i) { - DEBUG(userValues[i]->print(dbgs(), TRI)); + LLVM_DEBUG(userValues[i]->print(dbgs(), TRI)); userValues[i]->rewriteLocations(*VRM, *TRI, SpilledLocations); userValues[i]->emitDebugValues(VRM, *LIS, *TII, *TRI, SpilledLocations); } Index: lib/CodeGen/LiveIntervals.cpp =================================================================== --- lib/CodeGen/LiveIntervals.cpp +++ lib/CodeGen/LiveIntervals.cpp @@ -147,7 +147,7 @@ for (unsigned i = 0, e = TRI->getNumRegUnits(); i != e; ++i) getRegUnit(i); } - DEBUG(dump()); + LLVM_DEBUG(dump()); return true; } @@ -310,7 +310,7 @@ /// entering the entry block or a landing pad. void LiveIntervals::computeLiveInRegUnits() { RegUnitRanges.resize(TRI->getNumRegUnits()); - DEBUG(dbgs() << "Computing live-in reg-units in ABI blocks.\n"); + LLVM_DEBUG(dbgs() << "Computing live-in reg-units in ABI blocks.\n"); // Keep track of the live range sets allocated. SmallVector NewRanges; @@ -323,7 +323,7 @@ // Create phi-defs at Begin for all live-in registers. SlotIndex Begin = Indexes->getMBBStartIdx(&MBB); - DEBUG(dbgs() << Begin << "\t" << printMBBReference(MBB)); + LLVM_DEBUG(dbgs() << Begin << "\t" << printMBBReference(MBB)); for (const auto &LI : MBB.liveins()) { for (MCRegUnitIterator Units(LI.PhysReg, TRI); Units.isValid(); ++Units) { unsigned Unit = *Units; @@ -335,12 +335,12 @@ } VNInfo *VNI = LR->createDeadDef(Begin, getVNInfoAllocator()); (void)VNI; - DEBUG(dbgs() << ' ' << printRegUnit(Unit, TRI) << '#' << VNI->id); + LLVM_DEBUG(dbgs() << ' ' << printRegUnit(Unit, TRI) << '#' << VNI->id); } } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); } - DEBUG(dbgs() << "Created " << NewRanges.size() << " new intervals.\n"); + LLVM_DEBUG(dbgs() << "Created " << NewRanges.size() << " new intervals.\n"); // Compute the 'normal' part of the ranges. for (unsigned Unit : NewRanges) @@ -396,7 +396,7 @@ } // VNI is live-in to MBB. - DEBUG(dbgs() << " live-in at " << BlockStart << '\n'); + LLVM_DEBUG(dbgs() << " live-in at " << BlockStart << '\n'); LR.addSegment(LiveRange::Segment(BlockStart, Idx, VNI)); // Make sure VNI is live-out from the predecessors. @@ -413,7 +413,7 @@ bool LiveIntervals::shrinkToUses(LiveInterval *li, SmallVectorImpl *dead) { - DEBUG(dbgs() << "Shrink: " << *li << '\n'); + LLVM_DEBUG(dbgs() << "Shrink: " << *li << '\n'); assert(TargetRegisterInfo::isVirtualRegister(li->reg) && "Can only shrink virtual registers"); @@ -442,7 +442,7 @@ // This shouldn't happen: readsVirtualRegister returns true, but there is // no live value. It is likely caused by a target getting flags // wrong. - DEBUG(dbgs() << Idx << '\t' << UseMI + LLVM_DEBUG(dbgs() << Idx << '\t' << UseMI << "Warning: Instr claims to read non-existent value in " << *li << '\n'); continue; @@ -465,7 +465,7 @@ // Handle dead values. bool CanSeparate = computeDeadValues(*li, dead); - DEBUG(dbgs() << "Shrunk: " << *li << '\n'); + LLVM_DEBUG(dbgs() << "Shrunk: " << *li << '\n'); return CanSeparate; } @@ -495,7 +495,7 @@ // This is a dead PHI. Remove it. VNI->markUnused(); LI.removeSegment(I); - DEBUG(dbgs() << "Dead PHI at " << Def << " may separate interval\n"); + LLVM_DEBUG(dbgs() << "Dead PHI at " << Def << " may separate interval\n"); MayHaveSplitComponents = true; } else { // This is a dead def. Make sure the instruction knows. @@ -503,7 +503,7 @@ assert(MI && "No instruction defining live value"); MI->addRegisterDead(LI.reg, TRI); if (dead && MI->allDefsAreDead()) { - DEBUG(dbgs() << "All defs dead: " << Def << '\t' << *MI); + LLVM_DEBUG(dbgs() << "All defs dead: " << Def << '\t' << *MI); dead->push_back(MI); } } @@ -512,7 +512,7 @@ } void LiveIntervals::shrinkToUses(LiveInterval::SubRange &SR, unsigned Reg) { - DEBUG(dbgs() << "Shrink: " << SR << '\n'); + LLVM_DEBUG(dbgs() << "Shrink: " << SR << '\n'); assert(TargetRegisterInfo::isVirtualRegister(Reg) && "Can only shrink virtual registers"); // Find all the values used, including PHI kills. @@ -571,13 +571,13 @@ continue; if (VNI->isPHIDef()) { // This is a dead PHI. Remove it. - DEBUG(dbgs() << "Dead PHI at " << VNI->def << " may separate interval\n"); + LLVM_DEBUG(dbgs() << "Dead PHI at " << VNI->def << " may separate interval\n"); VNI->markUnused(); SR.removeSegment(*Segment); } } - DEBUG(dbgs() << "Shrunk: " << SR << '\n'); + LLVM_DEBUG(dbgs() << "Shrunk: " << SR << '\n'); } void LiveIntervals::extendToIndices(LiveRange &LR, @@ -942,7 +942,7 @@ /// Update all live ranges touched by MI, assuming a move from OldIdx to /// NewIdx. void updateAllRanges(MachineInstr *MI) { - DEBUG(dbgs() << "handleMove " << OldIdx << " -> " << NewIdx << ": " << *MI); + LLVM_DEBUG(dbgs() << "handleMove " << OldIdx << " -> " << NewIdx << ": " << *MI); bool hasRegMask = false; for (MachineOperand &MO : MI->operands()) { if (MO.isRegMask()) @@ -992,7 +992,7 @@ void updateRange(LiveRange &LR, unsigned Reg, LaneBitmask LaneMask) { if (!Updated.insert(&LR).second) return; - DEBUG({ + LLVM_DEBUG({ dbgs() << " "; if (TargetRegisterInfo::isVirtualRegister(Reg)) { dbgs() << printReg(Reg); @@ -1007,7 +1007,7 @@ handleMoveDown(LR); else handleMoveUp(LR, Reg, LaneMask); - DEBUG(dbgs() << " -->\t" << LR << '\n'); + LLVM_DEBUG(dbgs() << " -->\t" << LR << '\n'); LR.verify(); } @@ -1580,7 +1580,7 @@ unsigned NumComp = ConEQ.Classify(LI); if (NumComp <= 1) return; - DEBUG(dbgs() << " Split " << NumComp << " components: " << LI << '\n'); + LLVM_DEBUG(dbgs() << " Split " << NumComp << " components: " << LI << '\n'); unsigned Reg = LI.reg; const TargetRegisterClass *RegClass = MRI->getRegClass(Reg); for (unsigned I = 1; I < NumComp; ++I) { Index: lib/CodeGen/LiveRangeEdit.cpp =================================================================== --- lib/CodeGen/LiveRangeEdit.cpp +++ lib/CodeGen/LiveRangeEdit.cpp @@ -220,7 +220,7 @@ if (!DefMI->isSafeToMove(nullptr, SawStore)) return false; - DEBUG(dbgs() << "Try to fold single def: " << *DefMI + LLVM_DEBUG(dbgs() << "Try to fold single def: " << *DefMI << " into single use: " << *UseMI); SmallVector Ops; @@ -230,7 +230,7 @@ MachineInstr *FoldMI = TII.foldMemoryOperand(*UseMI, Ops, *DefMI, &LIS); if (!FoldMI) return false; - DEBUG(dbgs() << " folded: " << *FoldMI); + LLVM_DEBUG(dbgs() << " folded: " << *FoldMI); LIS.ReplaceMachineInstrInMaps(*UseMI, *FoldMI); UseMI->eraseFromParent(); DefMI->addRegisterDead(LI->reg, nullptr); @@ -267,18 +267,18 @@ } // Never delete inline asm. if (MI->isInlineAsm()) { - DEBUG(dbgs() << "Won't delete: " << Idx << '\t' << *MI); + LLVM_DEBUG(dbgs() << "Won't delete: " << Idx << '\t' << *MI); return; } // Use the same criteria as DeadMachineInstructionElim. bool SawStore = false; if (!MI->isSafeToMove(nullptr, SawStore)) { - DEBUG(dbgs() << "Can't delete: " << Idx << '\t' << *MI); + LLVM_DEBUG(dbgs() << "Can't delete: " << Idx << '\t' << *MI); return; } - DEBUG(dbgs() << "Deleting dead def " << Idx << '\t' << *MI); + LLVM_DEBUG(dbgs() << "Deleting dead def " << Idx << '\t' << *MI); // Collect virtual registers to be erased after MI is gone. SmallVector RegsToErase; @@ -352,7 +352,7 @@ continue; MI->RemoveOperand(i-1); } - DEBUG(dbgs() << "Converted physregs to:\t" << *MI); + LLVM_DEBUG(dbgs() << "Converted physregs to:\t" << *MI); } else { // If the dest of MI is an original reg and MI is reMaterializable, // don't delete the inst. Replace the dest with a new reg, and keep @@ -465,7 +465,7 @@ for (unsigned I = 0, Size = size(); I < Size; ++I) { LiveInterval &LI = LIS.getInterval(get(I)); if (MRI.recomputeRegClass(LI.reg)) - DEBUG({ + LLVM_DEBUG({ const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo(); dbgs() << "Inflated " << printReg(LI.reg) << " to " << TRI->getRegClassName(MRI.getRegClass(LI.reg)) << '\n'; Index: lib/CodeGen/LiveRangeShrink.cpp =================================================================== --- lib/CodeGen/LiveRangeShrink.cpp +++ lib/CodeGen/LiveRangeShrink.cpp @@ -111,7 +111,7 @@ MachineRegisterInfo &MRI = MF.getRegInfo(); - DEBUG(dbgs() << "**** Analysing " << MF.getName() << '\n'); + LLVM_DEBUG(dbgs() << "**** Analysing " << MF.getName() << '\n'); InstOrderMap IOM; // Map from register to instruction order (value of IOM) where the Index: lib/CodeGen/LiveRegMatrix.cpp =================================================================== --- lib/CodeGen/LiveRegMatrix.cpp +++ lib/CodeGen/LiveRegMatrix.cpp @@ -102,37 +102,37 @@ } void LiveRegMatrix::assign(LiveInterval &VirtReg, unsigned PhysReg) { - DEBUG(dbgs() << "assigning " << printReg(VirtReg.reg, TRI) + LLVM_DEBUG(dbgs() << "assigning " << printReg(VirtReg.reg, TRI) << " to " << printReg(PhysReg, TRI) << ':'); assert(!VRM->hasPhys(VirtReg.reg) && "Duplicate VirtReg assignment"); VRM->assignVirt2Phys(VirtReg.reg, PhysReg); foreachUnit(TRI, VirtReg, PhysReg, [&](unsigned Unit, const LiveRange &Range) { - DEBUG(dbgs() << ' ' << printRegUnit(Unit, TRI) << ' ' << Range); + LLVM_DEBUG(dbgs() << ' ' << printRegUnit(Unit, TRI) << ' ' << Range); Matrix[Unit].unify(VirtReg, Range); return false; }); ++NumAssigned; - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); } void LiveRegMatrix::unassign(LiveInterval &VirtReg) { unsigned PhysReg = VRM->getPhys(VirtReg.reg); - DEBUG(dbgs() << "unassigning " << printReg(VirtReg.reg, TRI) + LLVM_DEBUG(dbgs() << "unassigning " << printReg(VirtReg.reg, TRI) << " from " << printReg(PhysReg, TRI) << ':'); VRM->clearVirt(VirtReg.reg); foreachUnit(TRI, VirtReg, PhysReg, [&](unsigned Unit, const LiveRange &Range) { - DEBUG(dbgs() << ' ' << printRegUnit(Unit, TRI)); + LLVM_DEBUG(dbgs() << ' ' << printRegUnit(Unit, TRI)); Matrix[Unit].extract(VirtReg, Range); return false; }); ++NumUnassigned; - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); } bool LiveRegMatrix::isPhysRegUsed(unsigned PhysReg) const { Index: lib/CodeGen/LocalStackSlotAllocation.cpp =================================================================== --- lib/CodeGen/LocalStackSlotAllocation.cpp +++ lib/CodeGen/LocalStackSlotAllocation.cpp @@ -164,7 +164,7 @@ Offset = (Offset + Align - 1) / Align * Align; int64_t LocalOffset = StackGrowsDown ? -Offset : Offset; - DEBUG(dbgs() << "Allocate FI(" << FrameIdx << ") to local offset " + LLVM_DEBUG(dbgs() << "Allocate FI(" << FrameIdx << ") to local offset " << LocalOffset << "\n"); // Keep the offset available for base register allocation LocalOffsets[FrameIdx] = LocalOffset; @@ -351,7 +351,7 @@ assert(MFI.isObjectPreAllocated(FrameIdx) && "Only pre-allocated locals expected!"); - DEBUG(dbgs() << "Considering: " << MI); + LLVM_DEBUG(dbgs() << "Considering: " << MI); unsigned idx = 0; for (unsigned f = MI.getNumOperands(); idx != f; ++idx) { @@ -367,7 +367,7 @@ int64_t Offset = 0; int64_t FrameSizeAdjust = StackGrowsDown ? MFI.getLocalFrameSize() : 0; - DEBUG(dbgs() << " Replacing FI in: " << MI); + LLVM_DEBUG(dbgs() << " Replacing FI in: " << MI); // If we have a suitable base register available, use it; otherwise // create a new one. Note that any offset encoded in the @@ -377,7 +377,7 @@ if (UsedBaseReg && lookupCandidateBaseReg(BaseReg, BaseOffset, FrameSizeAdjust, LocalOffset, MI, TRI)) { - DEBUG(dbgs() << " Reusing base register " << BaseReg << "\n"); + LLVM_DEBUG(dbgs() << " Reusing base register " << BaseReg << "\n"); // We found a register to reuse. Offset = FrameSizeAdjust + LocalOffset - BaseOffset; } else { @@ -405,7 +405,7 @@ const TargetRegisterClass *RC = TRI->getPointerRegClass(*MF); BaseReg = Fn.getRegInfo().createVirtualRegister(RC); - DEBUG(dbgs() << " Materializing base register " << BaseReg << + LLVM_DEBUG(dbgs() << " Materializing base register " << BaseReg << " at frame local offset " << LocalOffset + InstrOffset << "\n"); // Tell the target to insert the instruction to initialize @@ -427,7 +427,7 @@ // Modify the instruction to use the new base register rather // than the frame index operand. TRI->resolveFrameIndex(MI, BaseReg, Offset); - DEBUG(dbgs() << "Resolved: " << MI); + LLVM_DEBUG(dbgs() << "Resolved: " << MI); ++NumReplacements; } Index: lib/CodeGen/MIRCanonicalizerPass.cpp =================================================================== --- lib/CodeGen/MIRCanonicalizerPass.cpp +++ lib/CodeGen/MIRCanonicalizerPass.cpp @@ -161,7 +161,7 @@ if (!MO.isReg() || !TargetRegisterInfo::isVirtualRegister(MO.getReg())) continue; - DEBUG(dbgs() << "Operand " << 0 << " of "; II->dump(); MO.dump();); + LLVM_DEBUG(dbgs() << "Operand " << 0 << " of "; II->dump(); MO.dump();); MachineInstr *Def = II; unsigned Distance = ~0U; @@ -211,7 +211,7 @@ if (DefI == BBE || UseI == BBE) continue; - DEBUG({ + LLVM_DEBUG({ dbgs() << "Splicing "; DefI->dump(); dbgs() << " right before: "; @@ -253,7 +253,7 @@ if (!MI->mayStore() && !MI->isBranch() && !DoesMISideEffect) continue; - DEBUG(dbgs() << "Found Candidate: "; MI->dump();); + LLVM_DEBUG(dbgs() << "Found Candidate: "; MI->dump();); Candidates.push_back(MI); } @@ -274,7 +274,7 @@ RegQueue.pop(); if (TReg.isFrameIndex()) { - DEBUG(dbgs() << "Popping frame index.\n";); + LLVM_DEBUG(dbgs() << "Popping frame index.\n";); VRegs.push_back(TypedVReg(RSE_FrameIndex)); continue; } @@ -283,7 +283,7 @@ unsigned Reg = TReg.getReg(); if (TargetRegisterInfo::isVirtualRegister(Reg)) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "Popping vreg "; MRI.def_begin(Reg)->dump(); dbgs() << "\n"; @@ -295,7 +295,7 @@ VRegs.push_back(TypedVReg(Reg)); } } else { - DEBUG(dbgs() << "Popping physreg.\n";); + LLVM_DEBUG(dbgs() << "Popping physreg.\n";); VRegs.push_back(TypedVReg(Reg)); continue; } @@ -311,7 +311,7 @@ break; } - DEBUG({ + LLVM_DEBUG({ dbgs() << "\n========================\n"; dbgs() << "Visited MI: "; Def->dump(); @@ -323,7 +323,7 @@ MachineOperand &MO = Def->getOperand(I); if (MO.isFI()) { - DEBUG(dbgs() << "Pushing frame index.\n";); + LLVM_DEBUG(dbgs() << "Pushing frame index.\n";); RegQueue.push(TypedVReg(RSE_FrameIndex)); } @@ -343,7 +343,7 @@ const TargetRegisterClass *RC) { const unsigned VR_GAP = (++VRegGapIndex * 1000); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Adjusting per-BB VR_GAP for BB" << VRegGapIndex << " to " << VR_GAP << "\n"; }); @@ -371,7 +371,7 @@ // that in the other file we are just getting an incoming vreg that comes // from a copy from a frame index. So it's safe to skip by one. LastRenameReg = MRI.createVirtualRegister(RC); - DEBUG(dbgs() << "Skipping rename for FI " << LastRenameReg << "\n";); + LLVM_DEBUG(dbgs() << "Skipping rename for FI " << LastRenameReg << "\n";); continue; } else if (vreg.isCandidate()) { @@ -384,7 +384,7 @@ if (!FirstCandidate) break; LastRenameReg = MRI.createVirtualRegister(RC); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Skipping rename for new candidate " << LastRenameReg << "\n"; }); @@ -393,7 +393,7 @@ continue; } else if (!TargetRegisterInfo::isVirtualRegister(vreg.getReg())) { LastRenameReg = MRI.createVirtualRegister(RC); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Skipping rename for Phys Reg " << LastRenameReg << "\n"; }); continue; @@ -401,7 +401,7 @@ auto Reg = vreg.getReg(); if (llvm::find(renamedInOtherBB, Reg) != renamedInOtherBB.end()) { - DEBUG(dbgs() << "Vreg " << Reg << " already renamed in other BB.\n";); + LLVM_DEBUG(dbgs() << "Vreg " << Reg << " already renamed in other BB.\n";); continue; } @@ -409,19 +409,19 @@ LastRenameReg = Rename; if (VRegRenameMap.find(Reg) == VRegRenameMap.end()) { - DEBUG(dbgs() << "Mapping vreg ";); + LLVM_DEBUG(dbgs() << "Mapping vreg ";); if (MRI.reg_begin(Reg) != MRI.reg_end()) { - DEBUG(auto foo = &*MRI.reg_begin(Reg); foo->dump();); + LLVM_DEBUG(auto foo = &*MRI.reg_begin(Reg); foo->dump();); } else { - DEBUG(dbgs() << Reg;); + LLVM_DEBUG(dbgs() << Reg;); } - DEBUG(dbgs() << " to ";); + LLVM_DEBUG(dbgs() << " to ";); if (MRI.reg_begin(Rename) != MRI.reg_end()) { - DEBUG(auto foo = &*MRI.reg_begin(Rename); foo->dump();); + LLVM_DEBUG(auto foo = &*MRI.reg_begin(Rename); foo->dump();); } else { - DEBUG(dbgs() << Rename;); + LLVM_DEBUG(dbgs() << Rename;); } - DEBUG(dbgs() << "\n";); + LLVM_DEBUG(dbgs() << "\n";); VRegRenameMap.insert(std::pair(Reg, Rename)); } @@ -488,18 +488,18 @@ if (CanonicalizeBasicBlockNumber != ~0U) { if (CanonicalizeBasicBlockNumber != basicBlockNum++) return false; - DEBUG(dbgs() << "\n Canonicalizing BasicBlock " << MBB->getName() << "\n";); + LLVM_DEBUG(dbgs() << "\n Canonicalizing BasicBlock " << MBB->getName() << "\n";); } if (llvm::find(bbNames, MBB->getName()) != bbNames.end()) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "Found potentially duplicate BasicBlocks: " << MBB->getName() << "\n"; }); return false; } - DEBUG({ + LLVM_DEBUG({ dbgs() << "\n\n NEW BASIC BLOCK: " << MBB->getName() << " \n\n"; dbgs() << "\n\n================================================\n\n"; }); @@ -514,11 +514,11 @@ if (!DummyRC) return false; bbNames.push_back(MBB->getName()); - DEBUG(dbgs() << "\n\n NEW BASIC BLOCK: " << MBB->getName() << "\n\n";); + LLVM_DEBUG(dbgs() << "\n\n NEW BASIC BLOCK: " << MBB->getName() << "\n\n";); - DEBUG(dbgs() << "MBB Before Scheduling:\n"; MBB->dump();); + LLVM_DEBUG(dbgs() << "MBB Before Scheduling:\n"; MBB->dump();); Changed |= rescheduleCanonically(MBB); - DEBUG(dbgs() << "MBB After Scheduling:\n"; MBB->dump();); + LLVM_DEBUG(dbgs() << "MBB After Scheduling:\n"; MBB->dump();); std::vector Candidates = populateCandidates(MBB); std::vector VisitedMIs; @@ -543,7 +543,7 @@ if (!(MO.isReg() && TargetRegisterInfo::isVirtualRegister(MO.getReg()))) continue; - DEBUG(dbgs() << "Enqueue register"; MO.dump(); dbgs() << "\n";); + LLVM_DEBUG(dbgs() << "Enqueue register"; MO.dump(); dbgs() << "\n";); RegQueue.push(TypedVReg(MO.getReg())); } @@ -560,7 +560,7 @@ if (!MO.isReg() && !MO.isFI()) continue; - DEBUG(dbgs() << "Enqueue Reg/FI"; MO.dump(); dbgs() << "\n";); + LLVM_DEBUG(dbgs() << "Enqueue Reg/FI"; MO.dump(); dbgs() << "\n";); RegQueue.push(MO.isReg() ? TypedVReg(MO.getReg()) : TypedVReg(RSE_FrameIndex)); @@ -581,8 +581,8 @@ Changed |= doVRegRenaming(renamedInOtherBB, VRegRenameMap, MRI); Changed |= doDefKillClear(MBB); - DEBUG(dbgs() << "Updated MachineBasicBlock:\n"; MBB->dump(); dbgs() << "\n";); - DEBUG(dbgs() << "\n\n================================================\n\n"); + LLVM_DEBUG(dbgs() << "Updated MachineBasicBlock:\n"; MBB->dump(); dbgs() << "\n";); + LLVM_DEBUG(dbgs() << "\n\n================================================\n\n"); return Changed; } @@ -592,14 +592,14 @@ if (CanonicalizeFunctionNumber != ~0U) { if (CanonicalizeFunctionNumber != functionNum++) return false; - DEBUG(dbgs() << "\n Canonicalizing Function " << MF.getName() << "\n";); + LLVM_DEBUG(dbgs() << "\n Canonicalizing Function " << MF.getName() << "\n";); } // we need a valid vreg to create a vreg type for skipping all those // stray vreg numbers so reach alignment/canonical vreg values. std::vector RPOList = GetRPOList(MF); - DEBUG( + LLVM_DEBUG( dbgs() << "\n\n NEW MACHINE FUNCTION: " << MF.getName() << " \n\n"; dbgs() << "\n\n================================================\n\n"; dbgs() << "Total Basic Blocks: " << RPOList.size() << "\n"; Index: lib/CodeGen/MachineBasicBlock.cpp =================================================================== --- lib/CodeGen/MachineBasicBlock.cpp +++ lib/CodeGen/MachineBasicBlock.cpp @@ -845,7 +845,7 @@ MachineBasicBlock *NMBB = MF->CreateMachineBasicBlock(); MF->insert(std::next(MachineFunction::iterator(this)), NMBB); - DEBUG(dbgs() << "Splitting critical edge: " << printMBBReference(*this) + LLVM_DEBUG(dbgs() << "Splitting critical edge: " << printMBBReference(*this) << " -- " << printMBBReference(*NMBB) << " -- " << printMBBReference(*Succ) << '\n'); @@ -876,7 +876,7 @@ if (TargetRegisterInfo::isPhysicalRegister(Reg) || LV->getVarInfo(Reg).removeKill(*MI)) { KilledRegs.push_back(Reg); - DEBUG(dbgs() << "Removing terminator kill: " << *MI); + LLVM_DEBUG(dbgs() << "Removing terminator kill: " << *MI); OI->setIsKill(false); } } @@ -967,7 +967,7 @@ continue; if (TargetRegisterInfo::isVirtualRegister(Reg)) LV->getVarInfo(Reg).Kills.push_back(&*I); - DEBUG(dbgs() << "Restored terminator kill: " << *I); + LLVM_DEBUG(dbgs() << "Restored terminator kill: " << *I); break; } } @@ -1100,7 +1100,7 @@ // case that we can't handle. Since this never happens in properly optimized // code, just skip those edges. if (TBB && TBB == FBB) { - DEBUG(dbgs() << "Won't split critical edge after degenerate " + LLVM_DEBUG(dbgs() << "Won't split critical edge after degenerate " << printMBBReference(*this) << '\n'); return false; } Index: lib/CodeGen/MachineBlockPlacement.cpp =================================================================== --- lib/CodeGen/MachineBlockPlacement.cpp +++ lib/CodeGen/MachineBlockPlacement.cpp @@ -638,7 +638,7 @@ if (SuccChain == &Chain) { SkipSucc = true; } else if (Succ != *SuccChain->begin()) { - DEBUG(dbgs() << " " << getBlockName(Succ) << " -> Mid chain!\n"); + LLVM_DEBUG(dbgs() << " " << getBlockName(Succ) << " -> Mid chain!\n"); continue; } } @@ -1005,7 +1005,7 @@ // If we have a trellis, and BB doesn't have the best fallthrough edges, // we shouldn't choose any successor. We've already looked and there's a // better fallthrough edge for all the successors. - DEBUG(dbgs() << "Trellis, but not one of the chosen edges.\n"); + LLVM_DEBUG(dbgs() << "Trellis, but not one of the chosen edges.\n"); return Result; } @@ -1022,7 +1022,7 @@ canTailDuplicateUnplacedPreds(BB, Succ2, Chain, BlockFilter) && isProfitableToTailDup(BB, Succ2, MBPI->getEdgeProbability(BB, Succ1), Chain, BlockFilter)) { - DEBUG(BranchProbability Succ2Prob = getAdjustedProbability( + LLVM_DEBUG(BranchProbability Succ2Prob = getAdjustedProbability( MBPI->getEdgeProbability(BB, Succ2), AdjustedSumProb); dbgs() << " Selected: " << getBlockName(Succ2) << ", probability: " << Succ2Prob << " (Tail Duplicate)\n"); @@ -1036,7 +1036,7 @@ ComputedEdges[BestB.Src] = { BestB.Dest, false }; auto TrellisSucc = BestA.Dest; - DEBUG(BranchProbability SuccProb = getAdjustedProbability( + LLVM_DEBUG(BranchProbability SuccProb = getAdjustedProbability( MBPI->getEdgeProbability(BB, TrellisSucc), AdjustedSumProb); dbgs() << " Selected: " << getBlockName(TrellisSucc) << ", probability: " << SuccProb << " (Trellis)\n"); @@ -1145,7 +1145,7 @@ if (TriangleChainCount == 0) return; - DEBUG(dbgs() << "Pre-computing triangle chains.\n"); + LLVM_DEBUG(dbgs() << "Pre-computing triangle chains.\n"); // Map from last block to the chain that contains it. This allows us to extend // chains as we find new triangles. DenseMap TriangleChainMap; @@ -1219,7 +1219,7 @@ MachineBasicBlock *dst = Chain.Edges.back(); Chain.Edges.pop_back(); for (MachineBasicBlock *src : reverse(Chain.Edges)) { - DEBUG(dbgs() << "Marking edge: " << getBlockName(src) << "->" << + LLVM_DEBUG(dbgs() << "Marking edge: " << getBlockName(src) << "->" << getBlockName(dst) << " as pre-computed based on triangles.\n"); auto InsertResult = ComputedEdges.insert({src, {dst, true}}); @@ -1426,7 +1426,7 @@ } if (BadCFGConflict) { - DEBUG(dbgs() << " Not a candidate: " << getBlockName(Succ) << " -> " << SuccProb + LLVM_DEBUG(dbgs() << " Not a candidate: " << getBlockName(Succ) << " -> " << SuccProb << " (prob) (non-cold CFG conflict)\n"); return true; } @@ -1457,7 +1457,7 @@ auto AdjustedSumProb = collectViableSuccessors(BB, Chain, BlockFilter, Successors); - DEBUG(dbgs() << "Selecting best successor for: " << getBlockName(BB) << "\n"); + LLVM_DEBUG(dbgs() << "Selecting best successor for: " << getBlockName(BB) << "\n"); // if we already precomputed the best successor for BB, return that if still // applicable. @@ -1498,18 +1498,18 @@ continue; } - DEBUG( + LLVM_DEBUG( dbgs() << " Candidate: " << getBlockName(Succ) << ", probability: " << SuccProb << (SuccChain.UnscheduledPredecessors != 0 ? " (CFG break)" : "") << "\n"); if (BestSucc.BB && BestProb >= SuccProb) { - DEBUG(dbgs() << " Not the best candidate, continuing\n"); + LLVM_DEBUG(dbgs() << " Not the best candidate, continuing\n"); continue; } - DEBUG(dbgs() << " Setting it as best candidate\n"); + LLVM_DEBUG(dbgs() << " Setting it as best candidate\n"); BestSucc.BB = Succ; BestProb = SuccProb; } @@ -1534,7 +1534,7 @@ break; if (canTailDuplicateUnplacedPreds(BB, Succ, Chain, BlockFilter) && (isProfitableToTailDup(BB, Succ, BestProb, Chain, BlockFilter))) { - DEBUG( + LLVM_DEBUG( dbgs() << " Candidate: " << getBlockName(Succ) << ", probability: " << DupProb << " (Tail Duplicate)\n"); @@ -1545,7 +1545,7 @@ } if (BestSucc.BB) - DEBUG(dbgs() << " Selected: " << getBlockName(BestSucc.BB) << "\n"); + LLVM_DEBUG(dbgs() << " Selected: " << getBlockName(BestSucc.BB) << "\n"); return BestSucc; } @@ -1591,7 +1591,7 @@ "Found CFG-violating block"); BlockFrequency CandidateFreq = MBFI->getBlockFreq(MBB); - DEBUG(dbgs() << " " << getBlockName(MBB) << " -> "; + LLVM_DEBUG(dbgs() << " " << getBlockName(MBB) << " -> "; MBFI->printBlockFreq(dbgs(), CandidateFreq) << " (freq)\n"); // For ehpad, we layout the least probable first as to avoid jumping back @@ -1718,7 +1718,7 @@ if (!BestSucc) break; - DEBUG(dbgs() << "Unnatural loop CFG detected, forcibly merging the " + LLVM_DEBUG(dbgs() << "Unnatural loop CFG detected, forcibly merging the " "layout successor until the CFG reduces\n"); } @@ -1738,14 +1738,14 @@ // Zero out UnscheduledPredecessors for the successor we're about to merge in case // we selected a successor that didn't fit naturally into the CFG. SuccChain.UnscheduledPredecessors = 0; - DEBUG(dbgs() << "Merging from " << getBlockName(BB) << " to " + LLVM_DEBUG(dbgs() << "Merging from " << getBlockName(BB) << " to " << getBlockName(BestSucc) << "\n"); markChainSuccessors(SuccChain, LoopHeaderBB, BlockFilter); Chain.merge(BestSucc, &SuccChain); BB = *std::prev(Chain.end()); } - DEBUG(dbgs() << "Finished forming chain for header block " + LLVM_DEBUG(dbgs() << "Finished forming chain for header block " << getBlockName(*Chain.begin()) << "\n"); } @@ -1779,7 +1779,7 @@ if (!LoopBlockSet.count(*HeaderChain.begin())) return L.getHeader(); - DEBUG(dbgs() << "Finding best loop top for: " << getBlockName(L.getHeader()) + LLVM_DEBUG(dbgs() << "Finding best loop top for: " << getBlockName(L.getHeader()) << "\n"); BlockFrequency BestPredFreq; @@ -1787,7 +1787,7 @@ for (MachineBasicBlock *Pred : L.getHeader()->predecessors()) { if (!LoopBlockSet.count(Pred)) continue; - DEBUG(dbgs() << " header pred: " << getBlockName(Pred) << ", has " + LLVM_DEBUG(dbgs() << " header pred: " << getBlockName(Pred) << ", has " << Pred->succ_size() << " successors, "; MBFI->printBlockFreq(dbgs(), Pred) << " freq\n"); if (Pred->succ_size() > 1) @@ -1804,7 +1804,7 @@ // If no direct predecessor is fine, just use the loop header. if (!BestPred) { - DEBUG(dbgs() << " final top unchanged\n"); + LLVM_DEBUG(dbgs() << " final top unchanged\n"); return L.getHeader(); } @@ -1814,7 +1814,7 @@ *BestPred->pred_begin() != L.getHeader()) BestPred = *BestPred->pred_begin(); - DEBUG(dbgs() << " final top: " << getBlockName(BestPred) << "\n"); + LLVM_DEBUG(dbgs() << " final top: " << getBlockName(BestPred) << "\n"); return BestPred; } @@ -1846,7 +1846,7 @@ // blocks where rotating to exit with that block will reach an outer loop. SmallPtrSet BlocksExitingToOuterLoop; - DEBUG(dbgs() << "Finding best loop exit for: " << getBlockName(L.getHeader()) + LLVM_DEBUG(dbgs() << "Finding best loop exit for: " << getBlockName(L.getHeader()) << "\n"); for (MachineBasicBlock *MBB : L.getBlocks()) { BlockChain &Chain = *BlockToChain[MBB]; @@ -1870,14 +1870,14 @@ BlockChain &SuccChain = *BlockToChain[Succ]; // Don't split chains, either this chain or the successor's chain. if (&Chain == &SuccChain) { - DEBUG(dbgs() << " exiting: " << getBlockName(MBB) << " -> " + LLVM_DEBUG(dbgs() << " exiting: " << getBlockName(MBB) << " -> " << getBlockName(Succ) << " (chain conflict)\n"); continue; } auto SuccProb = MBPI->getEdgeProbability(MBB, Succ); if (LoopBlockSet.count(Succ)) { - DEBUG(dbgs() << " looping: " << getBlockName(MBB) << " -> " + LLVM_DEBUG(dbgs() << " looping: " << getBlockName(MBB) << " -> " << getBlockName(Succ) << " (" << SuccProb << ")\n"); HasLoopingSucc = true; continue; @@ -1891,7 +1891,7 @@ } BlockFrequency ExitEdgeFreq = MBFI->getBlockFreq(MBB) * SuccProb; - DEBUG(dbgs() << " exiting: " << getBlockName(MBB) << " -> " + LLVM_DEBUG(dbgs() << " exiting: " << getBlockName(MBB) << " -> " << getBlockName(Succ) << " [L:" << SuccLoopDepth << "] ("; MBFI->printBlockFreq(dbgs(), ExitEdgeFreq) << ")\n"); // Note that we bias this toward an existing layout successor to retain @@ -1917,11 +1917,11 @@ // Without a candidate exiting block or with only a single block in the // loop, just use the loop header to layout the loop. if (!ExitingBB) { - DEBUG(dbgs() << " No other candidate exit blocks, using loop header\n"); + LLVM_DEBUG(dbgs() << " No other candidate exit blocks, using loop header\n"); return nullptr; } if (L.getNumBlocks() == 1) { - DEBUG(dbgs() << " Loop has 1 block, using loop header as exit\n"); + LLVM_DEBUG(dbgs() << " Loop has 1 block, using loop header as exit\n"); return nullptr; } @@ -1932,7 +1932,7 @@ !BlocksExitingToOuterLoop.count(ExitingBB)) return nullptr; - DEBUG(dbgs() << " Best exiting block: " << getBlockName(ExitingBB) << "\n"); + LLVM_DEBUG(dbgs() << " Best exiting block: " << getBlockName(ExitingBB) << "\n"); return ExitingBB; } @@ -2009,7 +2009,7 @@ return; } - DEBUG(dbgs() << "Rotating loop to put exit " << getBlockName(ExitingBB) + LLVM_DEBUG(dbgs() << "Rotating loop to put exit " << getBlockName(ExitingBB) << " at bottom\n"); std::rotate(LoopChain.begin(), std::next(ExitIt), LoopChain.end()); } @@ -2145,7 +2145,7 @@ } } - DEBUG(dbgs() << "The cost of loop rotation by making " << getBlockName(*Iter) + LLVM_DEBUG(dbgs() << "The cost of loop rotation by making " << getBlockName(*Iter) << " to the top: " << Cost.getFrequency() << "\n"); if (Cost < SmallestRotationCost) { @@ -2155,7 +2155,7 @@ } if (RotationPos != LoopChain.end()) { - DEBUG(dbgs() << "Rotate loop by making " << getBlockName(*RotationPos) + LLVM_DEBUG(dbgs() << "Rotate loop by making " << getBlockName(*RotationPos) << " to the top\n"); std::rotate(LoopChain.begin(), RotationPos, LoopChain.end()); } @@ -2260,7 +2260,7 @@ else rotateLoop(LoopChain, PreferredLoopExit, LoopBlockSet); - DEBUG({ + LLVM_DEBUG({ // Crash at the end so we get all of the debugging output first. bool BadLoop = false; if (LoopChain.UnscheduledPredecessors) { @@ -2319,7 +2319,7 @@ // Ensure that the layout successor is a viable block, as we know that // fallthrough is a possibility. assert(NextFI != FE && "Can't fallthrough past the last block."); - DEBUG(dbgs() << "Pre-merging due to unanalyzable fallthrough: " + LLVM_DEBUG(dbgs() << "Pre-merging due to unanalyzable fallthrough: " << getBlockName(BB) << " -> " << getBlockName(NextBB) << "\n"); Chain->merge(NextBB, nullptr); @@ -2351,7 +2351,7 @@ #ifndef NDEBUG using FunctionBlockSetType = SmallPtrSet; #endif - DEBUG({ + LLVM_DEBUG({ // Crash at the end so we get all of the debugging output first. bool BadFunc = false; FunctionBlockSetType FunctionBlockSet; @@ -2376,9 +2376,9 @@ // Splice the blocks into place. MachineFunction::iterator InsertPos = F->begin(); - DEBUG(dbgs() << "[MBP] Function: "<< F->getName() << "\n"); + LLVM_DEBUG(dbgs() << "[MBP] Function: "<< F->getName() << "\n"); for (MachineBasicBlock *ChainBB : FunctionChain) { - DEBUG(dbgs() << (ChainBB == *FunctionChain.begin() ? "Placing chain " + LLVM_DEBUG(dbgs() << (ChainBB == *FunctionChain.begin() ? "Placing chain " : " ... ") << getBlockName(ChainBB) << "\n"); if (InsertPos != MachineFunction::iterator(ChainBB)) @@ -2465,9 +2465,9 @@ MBPI->getEdgeProbability(ChainBB, FBB) > MBPI->getEdgeProbability(ChainBB, TBB) && !TII->reverseBranchCondition(Cond)) { - DEBUG(dbgs() << "Reverse order of the two branches: " + LLVM_DEBUG(dbgs() << "Reverse order of the two branches: " << getBlockName(ChainBB) << "\n"); - DEBUG(dbgs() << " Edge probability: " + LLVM_DEBUG(dbgs() << " Edge probability: " << MBPI->getEdgeProbability(ChainBB, FBB) << " vs " << MBPI->getEdgeProbability(ChainBB, TBB) << "\n"); DebugLoc dl; // FIXME: this is nowhere @@ -2633,7 +2633,7 @@ if (!shouldTailDuplicate(BB)) return false; - DEBUG(dbgs() << "Redoing tail duplication for Succ#" + LLVM_DEBUG(dbgs() << "Redoing tail duplication for Succ#" << BB->getNumber() << "\n"); // This has to be a callback because none of it can be done after @@ -2682,7 +2682,7 @@ if (RemBB == PreferredLoopExit) PreferredLoopExit = nullptr; - DEBUG(dbgs() << "TailDuplicator deleted block: " + LLVM_DEBUG(dbgs() << "TailDuplicator deleted block: " << getBlockName(RemBB) << "\n"); }; auto RemovalCallbackRef = Index: lib/CodeGen/MachineCSE.cpp =================================================================== --- lib/CodeGen/MachineCSE.cpp +++ lib/CodeGen/MachineCSE.cpp @@ -178,8 +178,8 @@ continue; if (!MRI->constrainRegAttrs(SrcReg, Reg)) continue; - DEBUG(dbgs() << "Coalescing: " << *DefMI); - DEBUG(dbgs() << "*** to: " << *MI); + LLVM_DEBUG(dbgs() << "Coalescing: " << *DefMI); + LLVM_DEBUG(dbgs() << "*** to: " << *MI); // Propagate SrcReg of copies to MI. MO.setReg(SrcReg); MRI->clearKillFlags(SrcReg); @@ -457,13 +457,13 @@ } void MachineCSE::EnterScope(MachineBasicBlock *MBB) { - DEBUG(dbgs() << "Entering: " << MBB->getName() << '\n'); + LLVM_DEBUG(dbgs() << "Entering: " << MBB->getName() << '\n'); ScopeType *Scope = new ScopeType(VNT); ScopeMap[MBB] = Scope; } void MachineCSE::ExitScope(MachineBasicBlock *MBB) { - DEBUG(dbgs() << "Exiting: " << MBB->getName() << '\n'); + LLVM_DEBUG(dbgs() << "Exiting: " << MBB->getName() << '\n'); DenseMap::iterator SI = ScopeMap.find(MBB); assert(SI != ScopeMap.end()); delete SI->second; @@ -547,8 +547,8 @@ // Found a common subexpression, eliminate it. unsigned CSVN = VNT.lookup(MI); MachineInstr *CSMI = Exps[CSVN]; - DEBUG(dbgs() << "Examining: " << *MI); - DEBUG(dbgs() << "*** Found a common subexpression: " << *CSMI); + LLVM_DEBUG(dbgs() << "Examining: " << *MI); + LLVM_DEBUG(dbgs() << "*** Found a common subexpression: " << *CSMI); // Check if it's profitable to perform this CSE. bool DoCSE = true; @@ -582,7 +582,7 @@ "Do not CSE physical register defs!"); if (!isProfitableToCSE(NewReg, OldReg, CSMI, MI)) { - DEBUG(dbgs() << "*** Not profitable, avoid CSE!\n"); + LLVM_DEBUG(dbgs() << "*** Not profitable, avoid CSE!\n"); DoCSE = false; break; } @@ -591,7 +591,7 @@ // within the constraints (register class, bank, or low-level type) of // the old instruction. if (!MRI->constrainRegAttrs(NewReg, OldReg)) { - DEBUG(dbgs() << "*** Not the same register constraints, avoid CSE!\n"); + LLVM_DEBUG(dbgs() << "*** Not the same register constraints, avoid CSE!\n"); DoCSE = false; break; } Index: lib/CodeGen/MachineCombiner.cpp =================================================================== --- lib/CodeGen/MachineCombiner.cpp +++ lib/CodeGen/MachineCombiner.cpp @@ -308,7 +308,7 @@ unsigned NewRootDepth = getDepth(InsInstrs, InstrIdxForVirtReg, BlockTrace); unsigned RootDepth = BlockTrace.getInstrCycles(*Root).Depth; - DEBUG(dbgs() << " Dependence data for " << *Root << "\tNewRootDepth: " + LLVM_DEBUG(dbgs() << " Dependence data for " << *Root << "\tNewRootDepth: " << NewRootDepth << "\tRootDepth: " << RootDepth); // For a transform such as reassociation, the cost equation is @@ -317,8 +317,8 @@ // Being conservative also protects against inaccuracies in the underlying // machine trace metrics and CPU models. if (getCombinerObjective(Pattern) == CombinerObjective::MustReduceDepth) { - DEBUG(dbgs() << "\tIt MustReduceDepth "); - DEBUG(NewRootDepth < RootDepth ? dbgs() << "\t and it does it\n" + LLVM_DEBUG(dbgs() << "\tIt MustReduceDepth "); + LLVM_DEBUG(NewRootDepth < RootDepth ? dbgs() << "\t and it does it\n" : dbgs() << "\t but it does NOT do it\n"); return NewRootDepth < RootDepth; } @@ -336,16 +336,16 @@ unsigned NewCycleCount = NewRootDepth + NewRootLatency; unsigned OldCycleCount = RootDepth + RootLatency + (SlackIsAccurate ? RootSlack : 0); - DEBUG(dbgs() << "\n\tNewRootLatency: " << NewRootLatency << "\tRootLatency: " + LLVM_DEBUG(dbgs() << "\n\tNewRootLatency: " << NewRootLatency << "\tRootLatency: " << RootLatency << "\n\tRootSlack: " << RootSlack << " SlackIsAccurate=" << SlackIsAccurate << "\n\tNewRootDepth + NewRootLatency = " << NewCycleCount << "\n\tRootDepth + RootLatency + RootSlack = " << OldCycleCount;); - DEBUG(NewCycleCount <= OldCycleCount + LLVM_DEBUG(NewCycleCount <= OldCycleCount ? dbgs() << "\n\t It IMPROVES PathLen because" : dbgs() << "\n\t It DOES NOT improve PathLen because"); - DEBUG(dbgs() << "\n\t\tNewCycleCount = " << NewCycleCount + LLVM_DEBUG(dbgs() << "\n\t\tNewCycleCount = " << NewCycleCount << ", OldCycleCount = " << OldCycleCount << "\n"); return NewCycleCount <= OldCycleCount; @@ -392,10 +392,10 @@ unsigned ResLenAfterCombine = BlockTrace.getResourceLength(MBBarr, MSCInsArr, MSCDelArr); - DEBUG(dbgs() << "\t\tResource length before replacement: " + LLVM_DEBUG(dbgs() << "\t\tResource length before replacement: " << ResLenBeforeCombine << " and after: " << ResLenAfterCombine << "\n";); - DEBUG( + LLVM_DEBUG( ResLenAfterCombine <= ResLenBeforeCombine ? dbgs() << "\t\t As result it IMPROVES/PRESERVES Resource Length\n" : dbgs() << "\t\t As result it DOES NOT improve/preserve Resource " @@ -492,7 +492,7 @@ /// sequence is shorter. bool MachineCombiner::combineInstructions(MachineBasicBlock *MBB) { bool Changed = false; - DEBUG(dbgs() << "Combining MBB " << MBB->getName() << "\n"); + LLVM_DEBUG(dbgs() << "Combining MBB " << MBB->getName() << "\n"); bool IncrementalUpdate = false; auto BlockIter = MBB->begin(); @@ -555,7 +555,7 @@ if (!NewInstCount) continue; - DEBUG(if (dump_intrs) { + LLVM_DEBUG(if (dump_intrs) { dbgs() << "\tFor the Pattern (" << (int)P << ") these instructions could be removed\n"; for (auto const *InstrPtr : DelInstrs) { dbgs() << "\t\t" << STI->getSchedInfoStr(*InstrPtr) << ": "; @@ -642,9 +642,9 @@ MinInstr = nullptr; OptSize = MF.getFunction().optForSize(); - DEBUG(dbgs() << getPassName() << ": " << MF.getName() << '\n'); + LLVM_DEBUG(dbgs() << getPassName() << ": " << MF.getName() << '\n'); if (!TII->useMachineCombiner()) { - DEBUG(dbgs() << " Skipping pass: Target does not support machine combiner\n"); + LLVM_DEBUG(dbgs() << " Skipping pass: Target does not support machine combiner\n"); return false; } Index: lib/CodeGen/MachineCopyPropagation.cpp =================================================================== --- lib/CodeGen/MachineCopyPropagation.cpp +++ lib/CodeGen/MachineCopyPropagation.cpp @@ -143,7 +143,7 @@ for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI) { Reg2MIMap::iterator CI = CopyMap.find(*AI); if (CI != CopyMap.end()) { - DEBUG(dbgs() << "MCP: Copy is used - not dead: "; CI->second->dump()); + LLVM_DEBUG(dbgs() << "MCP: Copy is used - not dead: "; CI->second->dump()); MaybeDeadCopies.remove(CI->second); } } @@ -191,7 +191,7 @@ if (!isNopCopy(PrevCopy, Src, Def, TRI)) return false; - DEBUG(dbgs() << "MCP: copy is a NOP, removing: "; Copy.dump()); + LLVM_DEBUG(dbgs() << "MCP: copy is a NOP, removing: "; Copy.dump()); // Copy was redundantly redefining either Src or Def. Remove earlier kill // flags between Copy and PrevCopy because the value will be reused now. @@ -209,7 +209,7 @@ } void MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) { - DEBUG(dbgs() << "MCP: CopyPropagateBlock " << MBB.getName() << "\n"); + LLVM_DEBUG(dbgs() << "MCP: CopyPropagateBlock " << MBB.getName() << "\n"); for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E; ) { MachineInstr *MI = &*I; @@ -253,7 +253,7 @@ ReadRegister(Reg); } - DEBUG(dbgs() << "MCP: Copy is a deletion candidate: "; MI->dump()); + LLVM_DEBUG(dbgs() << "MCP: Copy is a deletion candidate: "; MI->dump()); // Copy is now a candidate for deletion. if (!MRI->isReserved(Def)) @@ -331,7 +331,7 @@ continue; } - DEBUG(dbgs() << "MCP: Removing copy due to regmask clobbering: "; + LLVM_DEBUG(dbgs() << "MCP: Removing copy due to regmask clobbering: "; MaybeDead->dump()); // erase() will return the next valid iterator pointing to the next Index: lib/CodeGen/MachineFrameInfo.cpp =================================================================== --- lib/CodeGen/MachineFrameInfo.cpp +++ lib/CodeGen/MachineFrameInfo.cpp @@ -40,7 +40,7 @@ unsigned StackAlign) { if (!ShouldClamp || Align <= StackAlign) return Align; - DEBUG(dbgs() << "Warning: requested alignment " << Align + LLVM_DEBUG(dbgs() << "Warning: requested alignment " << Align << " exceeds the stack alignment " << StackAlign << " when stack realignment is off" << '\n'); return StackAlign; Index: lib/CodeGen/MachineLICM.cpp =================================================================== --- lib/CodeGen/MachineLICM.cpp +++ lib/CodeGen/MachineLICM.cpp @@ -313,10 +313,10 @@ PreRegAlloc = MRI->isSSA(); if (PreRegAlloc) - DEBUG(dbgs() << "******** Pre-regalloc Machine LICM: "); + LLVM_DEBUG(dbgs() << "******** Pre-regalloc Machine LICM: "); else - DEBUG(dbgs() << "******** Post-regalloc Machine LICM: "); - DEBUG(dbgs() << MF.getName() << " ********\n"); + LLVM_DEBUG(dbgs() << "******** Post-regalloc Machine LICM: "); + LLVM_DEBUG(dbgs() << MF.getName() << " ********\n"); if (PreRegAlloc) { // Estimate register pressure during pre-regalloc pass. @@ -581,7 +581,7 @@ // Now move the instructions to the predecessor, inserting it before any // terminator instructions. - DEBUG(dbgs() << "Hoisting to " << printMBBReference(*Preheader) << " from " + LLVM_DEBUG(dbgs() << "Hoisting to " << printMBBReference(*Preheader) << " from " << printMBBReference(*MI->getParent()) << ": " << *MI); // Splice the instruction to the preheader. @@ -619,14 +619,14 @@ } void MachineLICMBase::EnterScope(MachineBasicBlock *MBB) { - DEBUG(dbgs() << "Entering " << printMBBReference(*MBB) << '\n'); + LLVM_DEBUG(dbgs() << "Entering " << printMBBReference(*MBB) << '\n'); // Remember livein register pressure. BackTrace.push_back(RegPressure); } void MachineLICMBase::ExitScope(MachineBasicBlock *MBB) { - DEBUG(dbgs() << "Exiting " << printMBBReference(*MBB) << '\n'); + LLVM_DEBUG(dbgs() << "Exiting " << printMBBReference(*MBB) << '\n'); BackTrace.pop_back(); } @@ -1120,7 +1120,7 @@ // Don't hoist a cheap instruction if it would create a copy in the loop. if (CheapInstr && CreatesCopy) { - DEBUG(dbgs() << "Won't hoist cheap instr with loop PHI use: " << MI); + LLVM_DEBUG(dbgs() << "Won't hoist cheap instr with loop PHI use: " << MI); return false; } @@ -1139,7 +1139,7 @@ if (!TargetRegisterInfo::isVirtualRegister(Reg)) continue; if (MO.isDef() && HasHighOperandLatency(MI, i, Reg)) { - DEBUG(dbgs() << "Hoist High Latency: " << MI); + LLVM_DEBUG(dbgs() << "Hoist High Latency: " << MI); ++NumHighLatency; return true; } @@ -1157,14 +1157,14 @@ // Visit BBs from header to current BB, if hoisting this doesn't cause // high register pressure, then it's safe to proceed. if (!CanCauseHighRegPressure(Cost, CheapInstr)) { - DEBUG(dbgs() << "Hoist non-reg-pressure: " << MI); + LLVM_DEBUG(dbgs() << "Hoist non-reg-pressure: " << MI); ++NumLowRP; return true; } // Don't risk increasing register pressure if it would create copies. if (CreatesCopy) { - DEBUG(dbgs() << "Won't hoist instr with loop PHI use: " << MI); + LLVM_DEBUG(dbgs() << "Won't hoist instr with loop PHI use: " << MI); return false; } @@ -1173,7 +1173,7 @@ // conservative. if (AvoidSpeculation && (!IsGuaranteedToExecute(MI.getParent()) && !MayCSE(&MI))) { - DEBUG(dbgs() << "Won't speculate: " << MI); + LLVM_DEBUG(dbgs() << "Won't speculate: " << MI); return false; } @@ -1181,7 +1181,7 @@ // to be remat'ed. if (!TII->isTriviallyReMaterializable(MI, AA) && !MI.isDereferenceableInvariantLoad(AA)) { - DEBUG(dbgs() << "Can't remat / high reg-pressure: " << MI); + LLVM_DEBUG(dbgs() << "Can't remat / high reg-pressure: " << MI); return false; } @@ -1278,7 +1278,7 @@ return false; if (const MachineInstr *Dup = LookForDuplicate(MI, CI->second)) { - DEBUG(dbgs() << "CSEing " << *MI << " with " << *Dup); + LLVM_DEBUG(dbgs() << "CSEing " << *MI << " with " << *Dup); // Replace virtual registers defined by MI by their counterparts defined // by Dup. @@ -1353,7 +1353,7 @@ // Now move the instructions to the predecessor, inserting it before any // terminator instructions. - DEBUG({ + LLVM_DEBUG({ dbgs() << "Hoisting " << *MI; if (MI->getParent()->getBasicBlock()) dbgs() << " from " << printMBBReference(*MI->getParent()); Index: lib/CodeGen/MachineOutliner.cpp =================================================================== --- lib/CodeGen/MachineOutliner.cpp +++ lib/CodeGen/MachineOutliner.cpp @@ -1101,7 +1101,7 @@ // Remove C from the CandidateList. C.InCandidateList = false; - DEBUG(dbgs() << "- Removed a Candidate \n"; + LLVM_DEBUG(dbgs() << "- Removed a Candidate \n"; dbgs() << "--- Num fns left for candidate: " << F.getOccurrenceCount() << "\n"; dbgs() << "--- Candidate's functions's benefit: " << F.getBenefit() @@ -1400,7 +1400,7 @@ NumOutlined++; } - DEBUG(dbgs() << "OutlinedSomething = " << OutlinedSomething << "\n";); + LLVM_DEBUG(dbgs() << "OutlinedSomething = " << OutlinedSomething << "\n";); return OutlinedSomething; } Index: lib/CodeGen/MachinePipeliner.cpp =================================================================== --- lib/CodeGen/MachinePipeliner.cpp +++ lib/CodeGen/MachinePipeliner.cpp @@ -856,7 +856,7 @@ Topo.InitDAGTopologicalSorting(); postprocessDAG(); changeDependences(); - DEBUG({ + LLVM_DEBUG({ for (unsigned su = 0, e = SUnits.size(); su != e; ++su) SUnits[su].dumpAll(this); }); @@ -875,7 +875,7 @@ RecMII = 0; MII = std::max(ResMII, RecMII); - DEBUG(dbgs() << "MII = " << MII << " (rec=" << RecMII << ", res=" << ResMII + LLVM_DEBUG(dbgs() << "MII = " << MII << " (rec=" << RecMII << ", res=" << ResMII << ")\n"); // Can't schedule a loop without a valid MII. @@ -894,7 +894,7 @@ checkNodeSets(NodeSets); - DEBUG({ + LLVM_DEBUG({ for (auto &I : NodeSets) { dbgs() << " Rec NodeSet "; I.dump(); @@ -907,7 +907,7 @@ removeDuplicateNodes(NodeSets); - DEBUG({ + LLVM_DEBUG({ for (auto &I : NodeSets) { dbgs() << " NodeSet "; I.dump(); @@ -1558,7 +1558,7 @@ void SwingSchedulerDAG::computeNodeFunctions(NodeSetType &NodeSets) { ScheduleInfo.resize(SUnits.size()); - DEBUG({ + LLVM_DEBUG({ for (ScheduleDAGTopologicalSort::const_iterator I = Topo.begin(), E = Topo.end(); I != E; ++I) { @@ -1610,7 +1610,7 @@ for (NodeSet &I : NodeSets) I.computeNodeSetInfo(this); - DEBUG({ + LLVM_DEBUG({ for (unsigned i = 0; i < SUnits.size(); i++) { dbgs() << "\tNode " << i << ":\n"; dbgs() << "\t ASAP = " << getASAP(&SUnits[i]) << "\n"; @@ -1794,7 +1794,7 @@ CriticalPSets, RecRegPressure.MaxSetPressure); if (RPDelta.Excess.isValid()) { - DEBUG(dbgs() << "Excess register pressure: SU(" << SU->NodeNum << ") " + LLVM_DEBUG(dbgs() << "Excess register pressure: SU(" << SU->NodeNum << ") " << TRI->getRegPressureSetName(RPDelta.Excess.getPSet()) << ":" << RPDelta.Excess.getUnitInc()); NS.setExceedPressure(SU); @@ -1848,7 +1848,7 @@ for (auto &SU : SUnits) if (SU.getDepth() > MII * 1.5) { NodeSets.clear(); - DEBUG(dbgs() << "Clear recurrence node-sets\n"); + LLVM_DEBUG(dbgs() << "Clear recurrence node-sets\n"); return; } } @@ -2003,28 +2003,28 @@ NodeOrder.clear(); for (auto &Nodes : NodeSets) { - DEBUG(dbgs() << "NodeSet size " << Nodes.size() << "\n"); + LLVM_DEBUG(dbgs() << "NodeSet size " << Nodes.size() << "\n"); OrderKind Order; SmallSetVector N; if (pred_L(NodeOrder, N) && isSubset(N, Nodes)) { R.insert(N.begin(), N.end()); Order = BottomUp; - DEBUG(dbgs() << " Bottom up (preds) "); + LLVM_DEBUG(dbgs() << " Bottom up (preds) "); } else if (succ_L(NodeOrder, N) && isSubset(N, Nodes)) { R.insert(N.begin(), N.end()); Order = TopDown; - DEBUG(dbgs() << " Top down (succs) "); + LLVM_DEBUG(dbgs() << " Top down (succs) "); } else if (isIntersect(N, Nodes, R)) { // If some of the successors are in the existing node-set, then use the // top-down ordering. Order = TopDown; - DEBUG(dbgs() << " Top down (intersect) "); + LLVM_DEBUG(dbgs() << " Top down (intersect) "); } else if (NodeSets.size() == 1) { for (auto &N : Nodes) if (N->Succs.size() == 0) R.insert(N); Order = BottomUp; - DEBUG(dbgs() << " Bottom up (all) "); + LLVM_DEBUG(dbgs() << " Bottom up (all) "); } else { // Find the node with the highest ASAP. SUnit *maxASAP = nullptr; @@ -2034,7 +2034,7 @@ } R.insert(maxASAP); Order = BottomUp; - DEBUG(dbgs() << " Bottom up (default) "); + LLVM_DEBUG(dbgs() << " Bottom up (default) "); } while (!R.empty()) { @@ -2055,7 +2055,7 @@ maxHeight = I; } NodeOrder.insert(maxHeight); - DEBUG(dbgs() << maxHeight->NodeNum << " "); + LLVM_DEBUG(dbgs() << maxHeight->NodeNum << " "); R.remove(maxHeight); for (const auto &I : maxHeight->Succs) { if (Nodes.count(I.getSUnit()) == 0) @@ -2078,7 +2078,7 @@ } } Order = BottomUp; - DEBUG(dbgs() << "\n Switching order to bottom up "); + LLVM_DEBUG(dbgs() << "\n Switching order to bottom up "); SmallSetVector N; if (pred_L(NodeOrder, N, &Nodes)) R.insert(N.begin(), N.end()); @@ -2099,7 +2099,7 @@ maxDepth = I; } NodeOrder.insert(maxDepth); - DEBUG(dbgs() << maxDepth->NodeNum << " "); + LLVM_DEBUG(dbgs() << maxDepth->NodeNum << " "); R.remove(maxDepth); if (Nodes.isExceedSU(maxDepth)) { Order = TopDown; @@ -2128,16 +2128,16 @@ } } Order = TopDown; - DEBUG(dbgs() << "\n Switching order to top down "); + LLVM_DEBUG(dbgs() << "\n Switching order to top down "); SmallSetVector N; if (succ_L(NodeOrder, N, &Nodes)) R.insert(N.begin(), N.end()); } } - DEBUG(dbgs() << "\nDone with Nodeset\n"); + LLVM_DEBUG(dbgs() << "\nDone with Nodeset\n"); } - DEBUG({ + LLVM_DEBUG({ dbgs() << "Node order: "; for (SUnit *I : NodeOrder) dbgs() << " " << I->NodeNum << " "; @@ -2156,7 +2156,7 @@ for (unsigned II = MII; II < MII + 10 && !scheduleFound; ++II) { Schedule.reset(); Schedule.setInitiationInterval(II); - DEBUG(dbgs() << "Try to schedule with " << II << "\n"); + LLVM_DEBUG(dbgs() << "Try to schedule with " << II << "\n"); SetVector::iterator NI = NodeOrder.begin(); SetVector::iterator NE = NodeOrder.end(); @@ -2173,12 +2173,12 @@ int SchedStart = INT_MIN; Schedule.computeStart(SU, &EarlyStart, &LateStart, &SchedEnd, &SchedStart, II, this); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Inst (" << SU->NodeNum << ") "; SU->getInstr()->dump(); dbgs() << "\n"; }); - DEBUG({ + LLVM_DEBUG({ dbgs() << "\tes: " << EarlyStart << " ls: " << LateStart << " me: " << SchedEnd << " ms: " << SchedStart << "\n"; }); @@ -2214,7 +2214,7 @@ Schedule.getMaxStageCount() > (unsigned)SwpMaxStages) scheduleFound = false; - DEBUG({ + LLVM_DEBUG({ if (!scheduleFound) dbgs() << "\tCan't schedule\n"; }); @@ -2225,7 +2225,7 @@ scheduleFound = Schedule.isValidSchedule(this); } - DEBUG(dbgs() << "Schedule Found? " << scheduleFound << "\n"); + LLVM_DEBUG(dbgs() << "Schedule Found? " << scheduleFound << "\n"); if (scheduleFound) Schedule.finalizeSchedule(this); @@ -2295,7 +2295,7 @@ generatePhis(KernelBB, PrologBBs.back(), KernelBB, KernelBB, Schedule, VRMap, InstrMap, MaxStageCount, MaxStageCount, false); - DEBUG(dbgs() << "New block\n"; KernelBB->dump();); + LLVM_DEBUG(dbgs() << "New block\n"; KernelBB->dump();); SmallVector EpilogBBs; // Generate the epilog instructions to complete the pipeline. @@ -2362,7 +2362,7 @@ } } rewritePhiValues(NewBB, i, Schedule, VRMap, InstrMap); - DEBUG({ + LLVM_DEBUG({ dbgs() << "prolog:\n"; NewBB->dump(); }); @@ -2442,7 +2442,7 @@ InstrMap, LastStage, EpilogStage, i == 1); PredBB = NewBB; - DEBUG({ + LLVM_DEBUG({ dbgs() << "epilog:\n"; NewBB->dump(); }); @@ -3510,7 +3510,7 @@ } if (ST.getInstrInfo()->isZeroCost(SU->getInstr()->getOpcode()) || Resources->canReserveResources(*SU->getInstr())) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "\tinsert at cycle " << curCycle << " "; SU->getInstr()->dump(); }); @@ -3523,7 +3523,7 @@ FirstCycle = curCycle; return true; } - DEBUG({ + LLVM_DEBUG({ dbgs() << "\tfailed to insert at cycle " << curCycle << " "; SU->getInstr()->dump(); }); @@ -4001,7 +4001,7 @@ SSD->fixupRegisterOverlaps(cycleInstrs); } - DEBUG(dump();); + LLVM_DEBUG(dump();); } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) Index: lib/CodeGen/MachineRegionInfo.cpp =================================================================== --- lib/CodeGen/MachineRegionInfo.cpp +++ lib/CodeGen/MachineRegionInfo.cpp @@ -89,7 +89,7 @@ RI.recalculate(F, DT, PDT, DF); - DEBUG(RI.dump()); + LLVM_DEBUG(RI.dump()); return false; } Index: lib/CodeGen/MachineSSAUpdater.cpp =================================================================== --- lib/CodeGen/MachineSSAUpdater.cpp +++ lib/CodeGen/MachineSSAUpdater.cpp @@ -204,7 +204,7 @@ // If the client wants to know about all new instructions, tell it. if (InsertedPHIs) InsertedPHIs->push_back(InsertedPHI); - DEBUG(dbgs() << " Inserted PHI: " << *InsertedPHI << "\n"); + LLVM_DEBUG(dbgs() << " Inserted PHI: " << *InsertedPHI << "\n"); return InsertedPHI->getOperand(0).getReg(); } Index: lib/CodeGen/MachineScheduler.cpp =================================================================== --- lib/CodeGen/MachineScheduler.cpp +++ lib/CodeGen/MachineScheduler.cpp @@ -360,7 +360,7 @@ } else if (!mf.getSubtarget().enableMachineScheduler()) return false; - DEBUG(dbgs() << "Before MISched:\n"; mf.print(dbgs())); + LLVM_DEBUG(dbgs() << "Before MISched:\n"; mf.print(dbgs())); // Initialize the context of the pass. MF = &mf; @@ -372,7 +372,7 @@ LIS = &getAnalysis(); if (VerifyScheduling) { - DEBUG(LIS->dump()); + LLVM_DEBUG(LIS->dump()); MF->verify(this, "Before machine scheduling."); } RegClassInfo->runOnMachineFunction(*MF); @@ -382,7 +382,7 @@ std::unique_ptr Scheduler(createMachineScheduler()); scheduleRegions(*Scheduler, false); - DEBUG(LIS->dump()); + LLVM_DEBUG(LIS->dump()); if (VerifyScheduling) MF->verify(this, "After machine scheduling."); return true; @@ -396,10 +396,10 @@ if (!EnablePostRAMachineSched) return false; } else if (!mf.getSubtarget().enablePostRAScheduler()) { - DEBUG(dbgs() << "Subtarget disables post-MI-sched.\n"); + LLVM_DEBUG(dbgs() << "Subtarget disables post-MI-sched.\n"); return false; } - DEBUG(dbgs() << "Before post-MI-sched:\n"; mf.print(dbgs())); + LLVM_DEBUG(dbgs() << "Before post-MI-sched:\n"; mf.print(dbgs())); // Initialize the context of the pass. MF = &mf; @@ -547,8 +547,8 @@ Scheduler.exitRegion(); continue; } - DEBUG(dbgs() << "********** MI Scheduling **********\n"); - DEBUG(dbgs() << MF->getName() << ":" << printMBBReference(*MBB) << " " + LLVM_DEBUG(dbgs() << "********** MI Scheduling **********\n"); + LLVM_DEBUG(dbgs() << MF->getName() << ":" << printMBBReference(*MBB) << " " << MBB->getName() << "\n From: " << *I << " To: "; if (RegionEnd != MBB->end()) dbgs() << *RegionEnd; else dbgs() << "End"; @@ -749,8 +749,8 @@ /// does not consider liveness or register pressure. It is useful for PostRA /// scheduling and potentially other custom schedulers. void ScheduleDAGMI::schedule() { - DEBUG(dbgs() << "ScheduleDAGMI::schedule starting\n"); - DEBUG(SchedImpl->dumpPolicy()); + LLVM_DEBUG(dbgs() << "ScheduleDAGMI::schedule starting\n"); + LLVM_DEBUG(SchedImpl->dumpPolicy()); // Build the DAG. buildSchedGraph(AA); @@ -766,7 +766,7 @@ // This may initialize a DFSResult to be used for queue priority. SchedImpl->initialize(this); - DEBUG( + LLVM_DEBUG( if (EntrySU.getInstr() != nullptr) EntrySU.dumpAll(this); for (const SUnit &SU : SUnits) @@ -781,7 +781,7 @@ bool IsTopNode = false; while (true) { - DEBUG(dbgs() << "** ScheduleDAGMI::schedule picking next node\n"); + LLVM_DEBUG(dbgs() << "** ScheduleDAGMI::schedule picking next node\n"); SUnit *SU = SchedImpl->pickNode(IsTopNode); if (!SU) break; @@ -821,7 +821,7 @@ placeDebugValues(); - DEBUG({ + LLVM_DEBUG({ dbgs() << "*** Final schedule for " << printMBBReference(*begin()->getParent()) << " ***\n"; dumpSchedule(); @@ -1016,7 +1016,7 @@ // Close the RPTracker to finalize live ins. RPTracker.closeRegion(); - DEBUG(RPTracker.dump()); + LLVM_DEBUG(RPTracker.dump()); // Initialize the live ins and live outs. TopRPTracker.addLiveRegs(RPTracker.getPressure().LiveInRegs); @@ -1031,7 +1031,7 @@ BotRPTracker.initLiveThru(RPTracker); if (!BotRPTracker.getLiveThru().empty()) { TopRPTracker.initLiveThru(BotRPTracker.getLiveThru()); - DEBUG(dbgs() << "Live Thru: "; + LLVM_DEBUG(dbgs() << "Live Thru: "; dumpRegSetPressure(BotRPTracker.getLiveThru(), TRI)); }; @@ -1046,7 +1046,7 @@ updatePressureDiffs(LiveUses); } - DEBUG( + LLVM_DEBUG( dbgs() << "Top Pressure:\n"; dumpRegSetPressure(TopRPTracker.getRegSetPressureAtPos(), TRI); dbgs() << "Bottom Pressure:\n"; @@ -1066,13 +1066,13 @@ for (unsigned i = 0, e = RegionPressure.size(); i < e; ++i) { unsigned Limit = RegClassInfo->getRegPressureSetLimit(i); if (RegionPressure[i] > Limit) { - DEBUG(dbgs() << TRI->getRegPressureSetName(i) + LLVM_DEBUG(dbgs() << TRI->getRegPressureSetName(i) << " Limit " << Limit << " Actual " << RegionPressure[i] << "\n"); RegionCriticalPSets.push_back(PressureChange(i)); } } - DEBUG(dbgs() << "Excess PSets: "; + LLVM_DEBUG(dbgs() << "Excess PSets: "; for (const PressureChange &RCPS : RegionCriticalPSets) dbgs() << TRI->getRegPressureSetName( RCPS.getPSet()) << " "; @@ -1097,7 +1097,7 @@ } unsigned Limit = RegClassInfo->getRegPressureSetLimit(ID); if (NewMaxPressure[ID] >= Limit - 2) { - DEBUG(dbgs() << " " << TRI->getRegPressureSetName(ID) << ": " + LLVM_DEBUG(dbgs() << " " << TRI->getRegPressureSetName(ID) << ": " << NewMaxPressure[ID] << ((NewMaxPressure[ID] > Limit) ? " > " : " <= ") << Limit << "(+ " << BotRPTracker.getLiveThru()[ID] << " livethru)\n"); @@ -1130,7 +1130,7 @@ PressureDiff &PDiff = getPressureDiff(&SU); PDiff.addPressureChange(Reg, Decrement, &MRI); - DEBUG( + LLVM_DEBUG( dbgs() << " UpdateRegP: SU(" << SU.NodeNum << ") " << printReg(Reg, TRI) << ':' << PrintLaneMask(P.LaneMask) << ' ' << *SU.getInstr(); @@ -1140,7 +1140,7 @@ } } else { assert(P.LaneMask.any()); - DEBUG(dbgs() << " LiveReg: " << printVRegOrUnit(Reg, TRI) << "\n"); + LLVM_DEBUG(dbgs() << " LiveReg: " << printVRegOrUnit(Reg, TRI) << "\n"); // This may be called before CurrentBottom has been initialized. However, // BotRPTracker must have a valid position. We want the value live into the // instruction or live out of the block, so ask for the previous @@ -1168,7 +1168,7 @@ if (LRQ.valueIn() == VNI) { PressureDiff &PDiff = getPressureDiff(SU); PDiff.addPressureChange(Reg, true, &MRI); - DEBUG( + LLVM_DEBUG( dbgs() << " UpdateRegP: SU(" << SU->NodeNum << ") " << *SU->getInstr(); dbgs() << " to "; @@ -1192,8 +1192,8 @@ /// ScheduleDAGMILive then it will want to override this virtual method in order /// to update any specialized state. void ScheduleDAGMILive::schedule() { - DEBUG(dbgs() << "ScheduleDAGMILive::schedule starting\n"); - DEBUG(SchedImpl->dumpPolicy()); + LLVM_DEBUG(dbgs() << "ScheduleDAGMILive::schedule starting\n"); + LLVM_DEBUG(SchedImpl->dumpPolicy()); buildDAGWithRegPressure(); Topo.InitDAGTopologicalSorting(); @@ -1207,7 +1207,7 @@ // This may initialize a DFSResult to be used for queue priority. SchedImpl->initialize(this); - DEBUG( + LLVM_DEBUG( if (EntrySU.getInstr() != nullptr) EntrySU.dumpAll(this); for (const SUnit &SU : SUnits) { @@ -1234,7 +1234,7 @@ bool IsTopNode = false; while (true) { - DEBUG(dbgs() << "** ScheduleDAGMILive::schedule picking next node\n"); + LLVM_DEBUG(dbgs() << "** ScheduleDAGMILive::schedule picking next node\n"); SUnit *SU = SchedImpl->pickNode(IsTopNode); if (!SU) break; @@ -1262,7 +1262,7 @@ placeDebugValues(); - DEBUG({ + LLVM_DEBUG({ dbgs() << "*** Final schedule for " << printMBBReference(*begin()->getParent()) << " ***\n"; dumpSchedule(); @@ -1379,13 +1379,13 @@ } else CyclicLatency = 0; - DEBUG(dbgs() << "Cyclic Path: SU(" << DefSU->NodeNum << ") -> SU(" + LLVM_DEBUG(dbgs() << "Cyclic Path: SU(" << DefSU->NodeNum << ") -> SU(" << SU->NodeNum << ") = " << CyclicLatency << "c\n"); if (CyclicLatency > MaxCyclicLatency) MaxCyclicLatency = CyclicLatency; } } - DEBUG(dbgs() << "Cyclic Critical Path: " << MaxCyclicLatency << "c\n"); + LLVM_DEBUG(dbgs() << "Cyclic Critical Path: " << MaxCyclicLatency << "c\n"); return MaxCyclicLatency; } @@ -1429,7 +1429,7 @@ TopRPTracker.advance(RegOpers); assert(TopRPTracker.getPos() == CurrentTop && "out of sync"); - DEBUG( + LLVM_DEBUG( dbgs() << "Top Pressure:\n"; dumpRegSetPressure(TopRPTracker.getRegSetPressureAtPos(), TRI); ); @@ -1468,7 +1468,7 @@ SmallVector LiveUses; BotRPTracker.recede(RegOpers, &LiveUses); assert(BotRPTracker.getPos() == CurrentBottom && "out of sync"); - DEBUG( + LLVM_DEBUG( dbgs() << "Bottom Pressure:\n"; dumpRegSetPressure(BotRPTracker.getRegSetPressureAtPos(), TRI); ); @@ -1571,7 +1571,7 @@ *SUb->getInstr(), MemOpRecords[Idx+1].BaseReg, ClusterLength) && DAG->addEdge(SUb, SDep(SUa, SDep::Cluster))) { - DEBUG(dbgs() << "Cluster ld/st SU(" << SUa->NodeNum << ") - SU(" + LLVM_DEBUG(dbgs() << "Cluster ld/st SU(" << SUa->NodeNum << ") - SU(" << SUb->NodeNum << ")\n"); // Copy successor edges from SUa to SUb. Interleaving computation // dependent on SUa can prevent load combining due to register reuse. @@ -1580,7 +1580,7 @@ for (const SDep &Succ : SUa->Succs) { if (Succ.getSUnit() == SUb) continue; - DEBUG(dbgs() << " Copy Succ SU(" << Succ.getSUnit()->NodeNum << ")\n"); + LLVM_DEBUG(dbgs() << " Copy Succ SU(" << Succ.getSUnit()->NodeNum << ")\n"); DAG->addEdge(Succ.getSUnit(), SDep(SUb, SDep::Artificial)); } ++ClusterLength; @@ -1789,17 +1789,17 @@ return; GlobalUses.push_back(Pred.getSUnit()); } - DEBUG(dbgs() << "Constraining copy SU(" << CopySU->NodeNum << ")\n"); + LLVM_DEBUG(dbgs() << "Constraining copy SU(" << CopySU->NodeNum << ")\n"); // Add the weak edges. for (SmallVectorImpl::const_iterator I = LocalUses.begin(), E = LocalUses.end(); I != E; ++I) { - DEBUG(dbgs() << " Local use SU(" << (*I)->NodeNum << ") -> SU(" + LLVM_DEBUG(dbgs() << " Local use SU(" << (*I)->NodeNum << ") -> SU(" << GlobalSU->NodeNum << ")\n"); DAG->addEdge(GlobalSU, SDep(*I, SDep::Weak)); } for (SmallVectorImpl::const_iterator I = GlobalUses.begin(), E = GlobalUses.end(); I != E; ++I) { - DEBUG(dbgs() << " Global use SU(" << (*I)->NodeNum << ") -> SU(" + LLVM_DEBUG(dbgs() << " Global use SU(" << (*I)->NodeNum << ") -> SU(" << FirstLocalSU->NodeNum << ")\n"); DAG->addEdge(FirstLocalSU, SDep(*I, SDep::Weak)); } @@ -1958,7 +1958,7 @@ unsigned uops = SchedModel->getNumMicroOps(SU->getInstr()); if ((CurrMOps > 0) && (CurrMOps + uops > SchedModel->getIssueWidth())) { - DEBUG(dbgs() << " SU(" << SU->NodeNum << ") uops=" + LLVM_DEBUG(dbgs() << " SU(" << SU->NodeNum << ") uops=" << SchedModel->getNumMicroOps(SU->getInstr()) << '\n'); return true; } @@ -1966,7 +1966,7 @@ if (CurrMOps > 0 && ((isTop() && SchedModel->mustBeginGroup(SU->getInstr())) || (!isTop() && SchedModel->mustEndGroup(SU->getInstr())))) { - DEBUG(dbgs() << " hazard: SU(" << SU->NodeNum << ") must " + LLVM_DEBUG(dbgs() << " hazard: SU(" << SU->NodeNum << ") must " << (isTop()? "begin" : "end") << " group\n"); return true; } @@ -1983,7 +1983,7 @@ #ifndef NDEBUG MaxObservedStall = std::max(Cycles, MaxObservedStall); #endif - DEBUG(dbgs() << " SU(" << SU->NodeNum << ") " + LLVM_DEBUG(dbgs() << " SU(" << SU->NodeNum << ") " << SchedModel->getResourceName(ResIdx) << "=" << NRCycle << "c\n"); return true; @@ -2006,7 +2006,7 @@ } } if (LateSU) { - DEBUG(dbgs() << Available.getName() << " RemLatency SU(" + LLVM_DEBUG(dbgs() << Available.getName() << " RemLatency SU(" << LateSU->NodeNum << ") " << RemLatency << "c\n"); } return RemLatency; @@ -2023,7 +2023,7 @@ unsigned OtherCritCount = Rem->RemIssueCount + (RetiredMOps * SchedModel->getMicroOpFactor()); - DEBUG(dbgs() << " " << Available.getName() << " + Remain MOps: " + LLVM_DEBUG(dbgs() << " " << Available.getName() << " + Remain MOps: " << OtherCritCount / SchedModel->getMicroOpFactor() << '\n'); for (unsigned PIdx = 1, PEnd = SchedModel->getNumProcResourceKinds(); PIdx != PEnd; ++PIdx) { @@ -2034,7 +2034,7 @@ } } if (OtherCritIdx) { - DEBUG(dbgs() << " " << Available.getName() << " + Remain CritRes: " + LLVM_DEBUG(dbgs() << " " << Available.getName() << " + Remain CritRes: " << OtherCritCount / SchedModel->getResourceFactor(OtherCritIdx) << " " << SchedModel->getResourceName(OtherCritIdx) << "\n"); } @@ -2100,7 +2100,7 @@ checkResourceLimit(SchedModel->getLatencyFactor(), getCriticalCount(), getScheduledLatency()); - DEBUG(dbgs() << "Cycle: " << CurrCycle << ' ' << Available.getName() << '\n'); + LLVM_DEBUG(dbgs() << "Cycle: " << CurrCycle << ' ' << Available.getName() << '\n'); } void SchedBoundary::incExecutedResources(unsigned PIdx, unsigned Count) { @@ -2120,7 +2120,7 @@ countResource(unsigned PIdx, unsigned Cycles, unsigned NextCycle) { unsigned Factor = SchedModel->getResourceFactor(PIdx); unsigned Count = Factor * Cycles; - DEBUG(dbgs() << " " << SchedModel->getResourceName(PIdx) + LLVM_DEBUG(dbgs() << " " << SchedModel->getResourceName(PIdx) << " +" << Cycles << "x" << Factor << "u\n"); // Update Executed resources counts. @@ -2132,14 +2132,14 @@ // becomes the critical resource. if (ZoneCritResIdx != PIdx && (getResourceCount(PIdx) > getCriticalCount())) { ZoneCritResIdx = PIdx; - DEBUG(dbgs() << " *** Critical resource " + LLVM_DEBUG(dbgs() << " *** Critical resource " << SchedModel->getResourceName(PIdx) << ": " << getResourceCount(PIdx) / SchedModel->getLatencyFactor() << "c\n"); } // For reserved resources, record the highest cycle using the resource. unsigned NextAvailable = getNextResourceCycle(PIdx, Cycles); if (NextAvailable > CurrCycle) { - DEBUG(dbgs() << " Resource conflict: " + LLVM_DEBUG(dbgs() << " Resource conflict: " << SchedModel->getProcResource(PIdx)->Name << " reserved until @" << NextAvailable << "\n"); } @@ -2166,7 +2166,7 @@ "Cannot schedule this instruction's MicroOps in the current cycle."); unsigned ReadyCycle = (isTop() ? SU->TopReadyCycle : SU->BotReadyCycle); - DEBUG(dbgs() << " Ready @" << ReadyCycle << "c\n"); + LLVM_DEBUG(dbgs() << " Ready @" << ReadyCycle << "c\n"); unsigned NextCycle = CurrCycle; switch (SchedModel->getMicroOpBufferSize()) { @@ -2176,7 +2176,7 @@ case 1: if (ReadyCycle > NextCycle) { NextCycle = ReadyCycle; - DEBUG(dbgs() << " *** Stall until: " << ReadyCycle << "\n"); + LLVM_DEBUG(dbgs() << " *** Stall until: " << ReadyCycle << "\n"); } break; default: @@ -2205,7 +2205,7 @@ if ((int)(ScaledMOps - getResourceCount(ZoneCritResIdx)) >= (int)SchedModel->getLatencyFactor()) { ZoneCritResIdx = 0; - DEBUG(dbgs() << " *** Critical resource NumMicroOps: " + LLVM_DEBUG(dbgs() << " *** Critical resource NumMicroOps: " << ScaledMOps / SchedModel->getLatencyFactor() << "c\n"); } } @@ -2242,12 +2242,12 @@ unsigned &BotLatency = isTop() ? DependentLatency : ExpectedLatency; if (SU->getDepth() > TopLatency) { TopLatency = SU->getDepth(); - DEBUG(dbgs() << " " << Available.getName() + LLVM_DEBUG(dbgs() << " " << Available.getName() << " TopLatency SU(" << SU->NodeNum << ") " << TopLatency << "c\n"); } if (SU->getHeight() > BotLatency) { BotLatency = SU->getHeight(); - DEBUG(dbgs() << " " << Available.getName() + LLVM_DEBUG(dbgs() << " " << Available.getName() << " BotLatency SU(" << SU->NodeNum << ") " << BotLatency << "c\n"); } // If we stall for any reason, bump the cycle. @@ -2272,17 +2272,17 @@ // currCycle to X. if ((isTop() && SchedModel->mustEndGroup(SU->getInstr())) || (!isTop() && SchedModel->mustBeginGroup(SU->getInstr()))) { - DEBUG(dbgs() << " Bump cycle to " + LLVM_DEBUG(dbgs() << " Bump cycle to " << (isTop() ? "end" : "begin") << " group\n"); bumpCycle(++NextCycle); } while (CurrMOps >= SchedModel->getIssueWidth()) { - DEBUG(dbgs() << " *** Max MOps " << CurrMOps + LLVM_DEBUG(dbgs() << " *** Max MOps " << CurrMOps << " at cycle " << CurrCycle << '\n'); bumpCycle(++NextCycle); } - DEBUG(dumpScheduledState()); + LLVM_DEBUG(dumpScheduledState()); } /// Release pending ready nodes in to the available queue. This makes them @@ -2355,8 +2355,8 @@ releasePending(); } - DEBUG(Pending.dump()); - DEBUG(Available.dump()); + LLVM_DEBUG(Pending.dump()); + LLVM_DEBUG(Available.dump()); if (Available.size() == 1) return *Available.begin(); @@ -2454,7 +2454,7 @@ if (!OtherResLimited) { if (IsPostRA || (RemLatency + CurrZone.getCurrCycle() > Rem.CriticalPath)) { Policy.ReduceLatency |= true; - DEBUG(dbgs() << " " << CurrZone.Available.getName() + LLVM_DEBUG(dbgs() << " " << CurrZone.Available.getName() << " RemainingLatency " << RemLatency << " + " << CurrZone.getCurrCycle() << "c > CritPath " << Rem.CriticalPath << "\n"); @@ -2464,7 +2464,7 @@ if (CurrZone.getZoneCritResIdx() == OtherCritIdx) return; - DEBUG( + LLVM_DEBUG( if (CurrZone.isResourceLimited()) { dbgs() << " " << CurrZone.Available.getName() << " ResourceLimited: " << SchedModel->getResourceName(CurrZone.getZoneCritResIdx()) @@ -2620,7 +2620,7 @@ } static void tracePick(GenericSchedulerBase::CandReason Reason, bool IsTop) { - DEBUG(dbgs() << "Pick " << (IsTop ? "Top " : "Bot ") + LLVM_DEBUG(dbgs() << "Pick " << (IsTop ? "Top " : "Bot ") << GenericSchedulerBase::getReasonStr(Reason) << '\n'); } @@ -2743,7 +2743,7 @@ Rem.IsAcyclicLatencyLimited = InFlightCount > BufferLimit; - DEBUG(dbgs() << "IssueCycles=" + LLVM_DEBUG(dbgs() << "IssueCycles=" << Rem.RemIssueCount / SchedModel->getLatencyFactor() << "c " << "IterCycles=" << IterCount / SchedModel->getLatencyFactor() << "c NumIters=" << (AcyclicCount + IterCount-1) / IterCount @@ -2761,7 +2761,7 @@ if (SU->getDepth() > Rem.CriticalPath) Rem.CriticalPath = SU->getDepth(); } - DEBUG(dbgs() << "Critical Path(GS-RR ): " << Rem.CriticalPath << '\n'); + LLVM_DEBUG(dbgs() << "Critical Path(GS-RR ): " << Rem.CriticalPath << '\n'); if (DumpCriticalPathLength) { errs() << "Critical Path(GS-RR ): " << Rem.CriticalPath << " \n"; } @@ -2874,7 +2874,7 @@ } } } - DEBUG(if (Cand.RPDelta.Excess.isValid()) + LLVM_DEBUG(if (Cand.RPDelta.Excess.isValid()) dbgs() << " Try SU(" << Cand.SU->NodeNum << ") " << TRI->getRegPressureSetName(Cand.RPDelta.Excess.getPSet()) << ":" << Cand.RPDelta.Excess.getUnitInc() << "\n"); @@ -3018,7 +3018,7 @@ if (TryCand.ResDelta == SchedResourceDelta()) TryCand.initResourceDelta(DAG, SchedModel); Cand.setBest(TryCand); - DEBUG(traceCandidate(Cand)); + LLVM_DEBUG(traceCandidate(Cand)); } } } @@ -3047,14 +3047,14 @@ setPolicy(TopPolicy, /*IsPostRA=*/false, Top, &Bot); // See if BotCand is still valid (because we previously scheduled from Top). - DEBUG(dbgs() << "Picking from Bot:\n"); + LLVM_DEBUG(dbgs() << "Picking from Bot:\n"); if (!BotCand.isValid() || BotCand.SU->isScheduled || BotCand.Policy != BotPolicy) { BotCand.reset(CandPolicy()); pickNodeFromQueue(Bot, BotPolicy, DAG->getBotRPTracker(), BotCand); assert(BotCand.Reason != NoCand && "failed to find the first candidate"); } else { - DEBUG(traceCandidate(BotCand)); + LLVM_DEBUG(traceCandidate(BotCand)); #ifndef NDEBUG if (VerifyScheduling) { SchedCandidate TCand; @@ -3067,14 +3067,14 @@ } // Check if the top Q has a better candidate. - DEBUG(dbgs() << "Picking from Top:\n"); + LLVM_DEBUG(dbgs() << "Picking from Top:\n"); if (!TopCand.isValid() || TopCand.SU->isScheduled || TopCand.Policy != TopPolicy) { TopCand.reset(CandPolicy()); pickNodeFromQueue(Top, TopPolicy, DAG->getTopRPTracker(), TopCand); assert(TopCand.Reason != NoCand && "failed to find the first candidate"); } else { - DEBUG(traceCandidate(TopCand)); + LLVM_DEBUG(traceCandidate(TopCand)); #ifndef NDEBUG if (VerifyScheduling) { SchedCandidate TCand; @@ -3094,7 +3094,7 @@ tryCandidate(Cand, TopCand, nullptr); if (TopCand.Reason != NoCand) { Cand.setBest(TopCand); - DEBUG(traceCandidate(Cand)); + LLVM_DEBUG(traceCandidate(Cand)); } IsTopNode = Cand.AtTop; @@ -3143,7 +3143,7 @@ if (SU->isBottomReady()) Bot.removeReady(SU); - DEBUG(dbgs() << "Scheduling SU(" << SU->NodeNum << ") " << *SU->getInstr()); + LLVM_DEBUG(dbgs() << "Scheduling SU(" << SU->NodeNum << ") " << *SU->getInstr()); return SU; } @@ -3164,7 +3164,7 @@ MachineInstr *Copy = DepSU->getInstr(); if (!Copy->isCopy()) continue; - DEBUG(dbgs() << " Rescheduling physreg copy "; + LLVM_DEBUG(dbgs() << " Rescheduling physreg copy "; Dep.getSUnit()->dump(DAG)); DAG->moveInstruction(Copy, InsertPos); } @@ -3244,7 +3244,7 @@ if (SU->getDepth() > Rem.CriticalPath) Rem.CriticalPath = SU->getDepth(); } - DEBUG(dbgs() << "Critical Path: (PGS-RR) " << Rem.CriticalPath << '\n'); + LLVM_DEBUG(dbgs() << "Critical Path: (PGS-RR) " << Rem.CriticalPath << '\n'); if (DumpCriticalPathLength) { errs() << "Critical Path(PGS-RR ): " << Rem.CriticalPath << " \n"; } @@ -3302,7 +3302,7 @@ tryCandidate(Cand, TryCand); if (TryCand.Reason != NoCand) { Cand.setBest(TryCand); - DEBUG(traceCandidate(Cand)); + LLVM_DEBUG(traceCandidate(Cand)); } } } @@ -3334,7 +3334,7 @@ IsTopNode = true; Top.removeReady(SU); - DEBUG(dbgs() << "Scheduling SU(" << SU->NodeNum << ") " << *SU->getInstr()); + LLVM_DEBUG(dbgs() << "Scheduling SU(" << SU->NodeNum << ") " << *SU->getInstr()); return SU; } @@ -3423,7 +3423,7 @@ SUnit *SU = ReadyQ.back(); ReadyQ.pop_back(); IsTopNode = false; - DEBUG(dbgs() << "Pick node " << "SU(" << SU->NodeNum << ") " + LLVM_DEBUG(dbgs() << "Pick node " << "SU(" << SU->NodeNum << ") " << " ILP: " << DAG->getDFSResult()->getILP(SU) << " Tree: " << DAG->getDFSResult()->getSubtreeID(SU) << " @" << DAG->getDFSResult()->getSubtreeLevel( Index: lib/CodeGen/MachineSink.cpp =================================================================== --- lib/CodeGen/MachineSink.cpp +++ lib/CodeGen/MachineSink.cpp @@ -210,8 +210,8 @@ MachineInstr *DefMI = MRI->getVRegDef(SrcReg); if (DefMI->isCopyLike()) return false; - DEBUG(dbgs() << "Coalescing: " << *DefMI); - DEBUG(dbgs() << "*** to: " << MI); + LLVM_DEBUG(dbgs() << "Coalescing: " << *DefMI); + LLVM_DEBUG(dbgs() << "*** to: " << MI); MRI->replaceRegWith(DstReg, SrcReg); MI.eraseFromParent(); @@ -295,7 +295,7 @@ if (skipFunction(MF.getFunction())) return false; - DEBUG(dbgs() << "******** Machine Sinking ********\n"); + LLVM_DEBUG(dbgs() << "******** Machine Sinking ********\n"); TII = MF.getSubtarget().getInstrInfo(); TRI = MF.getSubtarget().getRegisterInfo(); @@ -322,14 +322,14 @@ for (auto &Pair : ToSplit) { auto NewSucc = Pair.first->SplitCriticalEdge(Pair.second, *this); if (NewSucc != nullptr) { - DEBUG(dbgs() << " *** Splitting critical edge: " + LLVM_DEBUG(dbgs() << " *** Splitting critical edge: " << printMBBReference(*Pair.first) << " -- " << printMBBReference(*NewSucc) << " -- " << printMBBReference(*Pair.second) << '\n'); MadeChange = true; ++NumSplit; } else - DEBUG(dbgs() << " *** Not legal to break critical edge\n"); + LLVM_DEBUG(dbgs() << " *** Not legal to break critical edge\n"); } // If this iteration over the code changed anything, keep iterating. if (!MadeChange) break; @@ -803,7 +803,7 @@ return false; } - DEBUG(dbgs() << "Sink instr " << MI << "\tinto block " << *SuccToSinkTo); + LLVM_DEBUG(dbgs() << "Sink instr " << MI << "\tinto block " << *SuccToSinkTo); // If the block has multiple predecessors, this is a critical edge. // Decide if we can sink along it or need to break the edge. @@ -813,26 +813,26 @@ bool TryBreak = false; bool store = true; if (!MI.isSafeToMove(AA, store)) { - DEBUG(dbgs() << " *** NOTE: Won't sink load along critical edge.\n"); + LLVM_DEBUG(dbgs() << " *** NOTE: Won't sink load along critical edge.\n"); TryBreak = true; } // We don't want to sink across a critical edge if we don't dominate the // successor. We could be introducing calculations to new code paths. if (!TryBreak && !DT->dominates(ParentBlock, SuccToSinkTo)) { - DEBUG(dbgs() << " *** NOTE: Critical edge found\n"); + LLVM_DEBUG(dbgs() << " *** NOTE: Critical edge found\n"); TryBreak = true; } // Don't sink instructions into a loop. if (!TryBreak && LI->isLoopHeader(SuccToSinkTo)) { - DEBUG(dbgs() << " *** NOTE: Loop header found\n"); + LLVM_DEBUG(dbgs() << " *** NOTE: Loop header found\n"); TryBreak = true; } // Otherwise we are OK with sinking along a critical edge. if (!TryBreak) - DEBUG(dbgs() << "Sinking along critical edge.\n"); + LLVM_DEBUG(dbgs() << "Sinking along critical edge.\n"); else { // Mark this edge as to be split. // If the edge can actually be split, the next iteration of the main loop @@ -840,7 +840,7 @@ bool Status = PostponeSplitCriticalEdge(MI, ParentBlock, SuccToSinkTo, BreakPHIEdge); if (!Status) - DEBUG(dbgs() << " *** PUNTING: Not legal or profitable to " + LLVM_DEBUG(dbgs() << " *** PUNTING: Not legal or profitable to " "break critical edge\n"); // The instruction will not be sunk this time. return false; @@ -854,7 +854,7 @@ bool Status = PostponeSplitCriticalEdge(MI, ParentBlock, SuccToSinkTo, BreakPHIEdge); if (!Status) - DEBUG(dbgs() << " *** PUNTING: Not legal or profitable to " + LLVM_DEBUG(dbgs() << " *** PUNTING: Not legal or profitable to " "break critical edge\n"); // The instruction will not be sunk this time. return false; Index: lib/CodeGen/MachineTraceMetrics.cpp =================================================================== --- lib/CodeGen/MachineTraceMetrics.cpp +++ lib/CodeGen/MachineTraceMetrics.cpp @@ -396,7 +396,7 @@ } void MachineTraceMetrics::invalidate(const MachineBasicBlock *MBB) { - DEBUG(dbgs() << "Invalidate traces through " << printMBBReference(*MBB) + LLVM_DEBUG(dbgs() << "Invalidate traces through " << printMBBReference(*MBB) << '\n'); BlockInfo[MBB->getNumber()].invalidate(); for (unsigned i = 0; i != TS_NumStrategies; ++i) @@ -477,7 +477,7 @@ /// Compute the trace through MBB. void MachineTraceMetrics::Ensemble::computeTrace(const MachineBasicBlock *MBB) { - DEBUG(dbgs() << "Computing " << getName() << " trace through " + LLVM_DEBUG(dbgs() << "Computing " << getName() << " trace through " << printMBBReference(*MBB) << '\n'); // Set up loop bounds for the backwards post-order traversal. LoopBounds Bounds(BlockInfo, MTM.Loops); @@ -486,11 +486,11 @@ Bounds.Downward = false; Bounds.Visited.clear(); for (auto I : inverse_post_order_ext(MBB, Bounds)) { - DEBUG(dbgs() << " pred for " << printMBBReference(*I) << ": "); + LLVM_DEBUG(dbgs() << " pred for " << printMBBReference(*I) << ": "); TraceBlockInfo &TBI = BlockInfo[I->getNumber()]; // All the predecessors have been visited, pick the preferred one. TBI.Pred = pickTracePred(I); - DEBUG({ + LLVM_DEBUG({ if (TBI.Pred) dbgs() << printMBBReference(*TBI.Pred) << '\n'; else @@ -504,11 +504,11 @@ Bounds.Downward = true; Bounds.Visited.clear(); for (auto I : post_order_ext(MBB, Bounds)) { - DEBUG(dbgs() << " succ for " << printMBBReference(*I) << ": "); + LLVM_DEBUG(dbgs() << " succ for " << printMBBReference(*I) << ": "); TraceBlockInfo &TBI = BlockInfo[I->getNumber()]; // All the successors have been visited, pick the preferred one. TBI.Succ = pickTraceSucc(I); - DEBUG({ + LLVM_DEBUG({ if (TBI.Succ) dbgs() << printMBBReference(*TBI.Succ) << '\n'; else @@ -531,7 +531,7 @@ WorkList.push_back(BadMBB); do { const MachineBasicBlock *MBB = WorkList.pop_back_val(); - DEBUG(dbgs() << "Invalidate " << printMBBReference(*MBB) << ' ' + LLVM_DEBUG(dbgs() << "Invalidate " << printMBBReference(*MBB) << ' ' << getName() << " height.\n"); // Find any MBB predecessors that have MBB as their preferred successor. // They are the only ones that need to be invalidated. @@ -556,7 +556,7 @@ WorkList.push_back(BadMBB); do { const MachineBasicBlock *MBB = WorkList.pop_back_val(); - DEBUG(dbgs() << "Invalidate " << printMBBReference(*MBB) << ' ' + LLVM_DEBUG(dbgs() << "Invalidate " << printMBBReference(*MBB) << ' ' << getName() << " depth.\n"); // Find any MBB successors that have MBB as their preferred predecessor. // They are the only ones that need to be invalidated. @@ -813,9 +813,9 @@ if (TBI.HasValidInstrHeights) { // Update critical path length. TBI.CriticalPath = std::max(TBI.CriticalPath, Cycle + MICycles.Height); - DEBUG(dbgs() << TBI.CriticalPath << '\t' << Cycle << '\t' << UseMI); + LLVM_DEBUG(dbgs() << TBI.CriticalPath << '\t' << Cycle << '\t' << UseMI); } else { - DEBUG(dbgs() << Cycle << '\t' << UseMI); + LLVM_DEBUG(dbgs() << Cycle << '\t' << UseMI); } } @@ -860,13 +860,13 @@ // Go through trace blocks in top-down order, stopping after the center block. while (!Stack.empty()) { MBB = Stack.pop_back_val(); - DEBUG(dbgs() << "\nDepths for " << printMBBReference(*MBB) << ":\n"); + LLVM_DEBUG(dbgs() << "\nDepths for " << printMBBReference(*MBB) << ":\n"); TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()]; TBI.HasValidInstrDepths = true; TBI.CriticalPath = 0; // Print out resource depths here as well. - DEBUG({ + LLVM_DEBUG({ dbgs() << format("%7u Instructions\n", TBI.InstrDepth); ArrayRef PRDepths = getProcResourceDepths(MBB->getNumber()); for (unsigned K = 0; K != PRDepths.size(); ++K) @@ -1045,12 +1045,12 @@ SmallVector Deps; for (;!Stack.empty(); Stack.pop_back()) { MBB = Stack.back(); - DEBUG(dbgs() << "Heights for " << printMBBReference(*MBB) << ":\n"); + LLVM_DEBUG(dbgs() << "Heights for " << printMBBReference(*MBB) << ":\n"); TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()]; TBI.HasValidInstrHeights = true; TBI.CriticalPath = 0; - DEBUG({ + LLVM_DEBUG({ dbgs() << format("%7u Instructions\n", TBI.InstrHeight); ArrayRef PRHeights = getProcResourceHeights(MBB->getNumber()); for (unsigned K = 0; K != PRHeights.size(); ++K) @@ -1081,7 +1081,7 @@ if (!Deps.empty()) { // Loop header PHI heights are all 0. unsigned Height = TBI.Succ ? Cycles.lookup(&PHI).Height : 0; - DEBUG(dbgs() << "pred\t" << Height << '\t' << PHI); + LLVM_DEBUG(dbgs() << "pred\t" << Height << '\t' << PHI); if (pushDepHeight(Deps.front(), PHI, Height, Heights, MTM.SchedModel, MTM.TII)) addLiveIns(Deps.front().DefMI, Deps.front().DefOp, Stack); @@ -1122,38 +1122,38 @@ InstrCycles &MICycles = Cycles[&MI]; MICycles.Height = Cycle; if (!TBI.HasValidInstrDepths) { - DEBUG(dbgs() << Cycle << '\t' << MI); + LLVM_DEBUG(dbgs() << Cycle << '\t' << MI); continue; } // Update critical path length. TBI.CriticalPath = std::max(TBI.CriticalPath, Cycle + MICycles.Depth); - DEBUG(dbgs() << TBI.CriticalPath << '\t' << Cycle << '\t' << MI); + LLVM_DEBUG(dbgs() << TBI.CriticalPath << '\t' << Cycle << '\t' << MI); } // Update virtual live-in heights. They were added by addLiveIns() with a 0 // height because the final height isn't known until now. - DEBUG(dbgs() << printMBBReference(*MBB) << " Live-ins:"); + LLVM_DEBUG(dbgs() << printMBBReference(*MBB) << " Live-ins:"); for (LiveInReg &LIR : TBI.LiveIns) { const MachineInstr *DefMI = MTM.MRI->getVRegDef(LIR.Reg); LIR.Height = Heights.lookup(DefMI); - DEBUG(dbgs() << ' ' << printReg(LIR.Reg) << '@' << LIR.Height); + LLVM_DEBUG(dbgs() << ' ' << printReg(LIR.Reg) << '@' << LIR.Height); } // Transfer the live regunits to the live-in list. for (SparseSet::const_iterator RI = RegUnits.begin(), RE = RegUnits.end(); RI != RE; ++RI) { TBI.LiveIns.push_back(LiveInReg(RI->RegUnit, RI->Cycle)); - DEBUG(dbgs() << ' ' << printRegUnit(RI->RegUnit, MTM.TRI) + LLVM_DEBUG(dbgs() << ' ' << printRegUnit(RI->RegUnit, MTM.TRI) << '@' << RI->Cycle); } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); if (!TBI.HasValidInstrDepths) continue; // Add live-ins to the critical path length. TBI.CriticalPath = std::max(TBI.CriticalPath, computeCrossBlockCriticalPath(TBI)); - DEBUG(dbgs() << "Critical path: " << TBI.CriticalPath << '\n'); + LLVM_DEBUG(dbgs() << "Critical path: " << TBI.CriticalPath << '\n'); } } Index: lib/CodeGen/MacroFusion.cpp =================================================================== --- lib/CodeGen/MacroFusion.cpp +++ lib/CodeGen/MacroFusion.cpp @@ -66,7 +66,7 @@ if (SI.getSUnit() == &FirstSU) SI.setLatency(0); - DEBUG(dbgs() << "Macro fuse: "; + LLVM_DEBUG(dbgs() << "Macro fuse: "; FirstSU.print(dbgs(), &DAG); dbgs() << " - "; SecondSU.print(dbgs(), &DAG); dbgs() << " / "; dbgs() << DAG.TII->getName(FirstSU.getInstr()->getOpcode()) << " - " << @@ -80,7 +80,7 @@ if (SI.isWeak() || isHazard(SI) || SU == &DAG.ExitSU || SU == &SecondSU || SU->isPred(&SecondSU)) continue; - DEBUG(dbgs() << " Bind "; + LLVM_DEBUG(dbgs() << " Bind "; SecondSU.print(dbgs(), &DAG); dbgs() << " - "; SU->print(dbgs(), &DAG); dbgs() << '\n';); DAG.addEdge(SU, SDep(&SecondSU, SDep::Artificial)); @@ -93,7 +93,7 @@ SUnit *SU = SI.getSUnit(); if (SI.isWeak() || isHazard(SI) || &FirstSU == SU || FirstSU.isSucc(SU)) continue; - DEBUG(dbgs() << " Bind "; + LLVM_DEBUG(dbgs() << " Bind "; SU->print(dbgs(), &DAG); dbgs() << " - "; FirstSU.print(dbgs(), &DAG); dbgs() << '\n';); DAG.addEdge(&FirstSU, SDep(SU, SDep::Artificial)); Index: lib/CodeGen/PHIElimination.cpp =================================================================== --- lib/CodeGen/PHIElimination.cpp +++ lib/CodeGen/PHIElimination.cpp @@ -270,7 +270,7 @@ IncomingReg = entry; reusedIncoming = true; ++NumReused; - DEBUG(dbgs() << "Reusing " << printReg(IncomingReg) << " for " << *MPhi); + LLVM_DEBUG(dbgs() << "Reusing " << printReg(IncomingReg) << " for " << *MPhi); } else { const TargetRegisterClass *RC = MF.getRegInfo().getRegClass(DestReg); entry = IncomingReg = MF.getRegInfo().createVirtualRegister(RC); @@ -295,9 +295,9 @@ // AfterPHIsIt, so it appears before the current PHICopy. if (reusedIncoming) if (MachineInstr *OldKill = VI.findKill(&MBB)) { - DEBUG(dbgs() << "Remove old kill from " << *OldKill); + LLVM_DEBUG(dbgs() << "Remove old kill from " << *OldKill); LV->removeVirtualRegisterKilled(IncomingReg, *OldKill); - DEBUG(MBB.dump()); + LLVM_DEBUG(MBB.dump()); } // Add information to LiveVariables to know that the incoming value is @@ -593,7 +593,7 @@ if (!ShouldSplit && !NoPhiElimLiveOutEarlyExit) continue; if (ShouldSplit) { - DEBUG(dbgs() << printReg(Reg) << " live-out before critical edge " + LLVM_DEBUG(dbgs() << printReg(Reg) << " live-out before critical edge " << printMBBReference(*PreMBB) << " -> " << printMBBReference(MBB) << ": " << *BBI); } @@ -610,7 +610,7 @@ // Check for a loop exiting edge. if (!ShouldSplit && CurLoop != PreLoop) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "Split wouldn't help, maybe avoid loop copies?\n"; if (PreLoop) dbgs() << "PreLoop: " << *PreLoop; if (CurLoop) dbgs() << "CurLoop: " << *CurLoop; @@ -624,7 +624,7 @@ if (!ShouldSplit && !SplitAllCriticalEdges) continue; if (!PreMBB->SplitCriticalEdge(&MBB, *this)) { - DEBUG(dbgs() << "Failed to split critical edge.\n"); + LLVM_DEBUG(dbgs() << "Failed to split critical edge.\n"); continue; } Changed = true; Index: lib/CodeGen/PeepholeOptimizer.cpp =================================================================== --- lib/CodeGen/PeepholeOptimizer.cpp +++ lib/CodeGen/PeepholeOptimizer.cpp @@ -696,7 +696,7 @@ // An existent entry with multiple sources is a PHI cycle we must avoid. // Otherwise it's an entry with a valid next source we already found. if (CurSrcRes.getNumSources() > 1) { - DEBUG(dbgs() << "findNextSource: found PHI cycle, aborting...\n"); + LLVM_DEBUG(dbgs() << "findNextSource: found PHI cycle, aborting...\n"); return false; } break; @@ -709,7 +709,7 @@ if (NumSrcs > 1) { PHICount++; if (PHICount >= RewritePHILimit) { - DEBUG(dbgs() << "findNextSource: PHI limit reached\n"); + LLVM_DEBUG(dbgs() << "findNextSource: PHI limit reached\n"); return false; } @@ -1143,9 +1143,9 @@ // Build the new PHI node and return its def register as the new source. MachineInstr &OrigPHI = const_cast(*Res.getInst()); MachineInstr &NewPHI = insertPHI(*MRI, *TII, NewPHISrcs, OrigPHI); - DEBUG(dbgs() << "-- getNewSource\n"); - DEBUG(dbgs() << " Replacing: " << OrigPHI); - DEBUG(dbgs() << " With: " << NewPHI); + LLVM_DEBUG(dbgs() << "-- getNewSource\n"); + LLVM_DEBUG(dbgs() << " Replacing: " << OrigPHI); + LLVM_DEBUG(dbgs() << " With: " << NewPHI); const MachineOperand &MODef = NewPHI.getOperand(0); return RegSubRegPair(MODef.getReg(), MODef.getSubReg()); } @@ -1241,9 +1241,9 @@ NewCopy->getOperand(0).setIsUndef(); } - DEBUG(dbgs() << "-- RewriteSource\n"); - DEBUG(dbgs() << " Replacing: " << CopyLike); - DEBUG(dbgs() << " With: " << *NewCopy); + LLVM_DEBUG(dbgs() << "-- RewriteSource\n"); + LLVM_DEBUG(dbgs() << " Replacing: " << CopyLike); + LLVM_DEBUG(dbgs() << " With: " << *NewCopy); MRI->replaceRegWith(Def.Reg, NewVReg); MRI->clearKillFlags(NewVReg); @@ -1462,7 +1462,7 @@ if (PrevCopy == NAPhysToVirtMIs.end()) { // We can't remove the copy: there was an intervening clobber of the // non-allocatable physical register after the copy to virtual. - DEBUG(dbgs() << "NAPhysCopy: intervening clobber forbids erasing " << MI); + LLVM_DEBUG(dbgs() << "NAPhysCopy: intervening clobber forbids erasing " << MI); return false; } @@ -1470,7 +1470,7 @@ if (PrevDstReg == SrcReg) { // Remove the virt->phys copy: we saw the virtual register definition, and // the non-allocatable physical register's state hasn't changed since then. - DEBUG(dbgs() << "NAPhysCopy: erasing " << MI); + LLVM_DEBUG(dbgs() << "NAPhysCopy: erasing " << MI); ++NumNAPhysCopies; return true; } @@ -1479,7 +1479,7 @@ // register get a copy of the non-allocatable physical register, and we only // track one such copy. Avoid getting confused by this new non-allocatable // physical register definition, and remove it from the tracked copies. - DEBUG(dbgs() << "NAPhysCopy: missed opportunity " << MI); + LLVM_DEBUG(dbgs() << "NAPhysCopy: missed opportunity " << MI); NAPhysToVirtMIs.erase(PrevCopy); return false; } @@ -1575,15 +1575,15 @@ if (findTargetRecurrence(PHI.getOperand(0).getReg(), TargetRegs, RC)) { // Commutes operands of instructions in RC if necessary so that the copy to // be generated from PHI can be coalesced. - DEBUG(dbgs() << "Optimize recurrence chain from " << PHI); + LLVM_DEBUG(dbgs() << "Optimize recurrence chain from " << PHI); for (auto &RI : RC) { - DEBUG(dbgs() << "\tInst: " << *(RI.getMI())); + LLVM_DEBUG(dbgs() << "\tInst: " << *(RI.getMI())); auto CP = RI.getCommutePair(); if (CP) { Changed = true; TII->commuteInstruction(*(RI.getMI()), false, (*CP).first, (*CP).second); - DEBUG(dbgs() << "\t\tCommuted: " << *(RI.getMI())); + LLVM_DEBUG(dbgs() << "\t\tCommuted: " << *(RI.getMI())); } } } @@ -1595,8 +1595,8 @@ if (skipFunction(MF.getFunction())) return false; - DEBUG(dbgs() << "********** PEEPHOLE OPTIMIZER **********\n"); - DEBUG(dbgs() << "********** Function: " << MF.getName() << '\n'); + LLVM_DEBUG(dbgs() << "********** PEEPHOLE OPTIMIZER **********\n"); + LLVM_DEBUG(dbgs() << "********** Function: " << MF.getName() << '\n'); if (DisablePeephole) return false; @@ -1667,7 +1667,7 @@ if (Def != NAPhysToVirtMIs.end()) { // A new definition of the non-allocatable physical register // invalidates previous copies. - DEBUG(dbgs() << "NAPhysCopy: invalidating because of " << *MI); + LLVM_DEBUG(dbgs() << "NAPhysCopy: invalidating because of " << *MI); NAPhysToVirtMIs.erase(Def); } } @@ -1676,7 +1676,7 @@ for (auto &RegMI : NAPhysToVirtMIs) { unsigned Def = RegMI.first; if (MachineOperand::clobbersPhysReg(RegMask, Def)) { - DEBUG(dbgs() << "NAPhysCopy: invalidating because of " << *MI); + LLVM_DEBUG(dbgs() << "NAPhysCopy: invalidating because of " << *MI); NAPhysToVirtMIs.erase(Def); } } @@ -1692,7 +1692,7 @@ // don't know what's correct anymore. // // FIXME: handle explicit asm clobbers. - DEBUG(dbgs() << "NAPhysCopy: blowing away all info due to " << *MI); + LLVM_DEBUG(dbgs() << "NAPhysCopy: blowing away all info due to " << *MI); NAPhysToVirtMIs.clear(); } @@ -1768,8 +1768,8 @@ TII->optimizeLoadInstr(*MI, MRI, FoldAsLoadDefReg, DefMI)) { // Update LocalMIs since we replaced MI with FoldMI and deleted // DefMI. - DEBUG(dbgs() << "Replacing: " << *MI); - DEBUG(dbgs() << " With: " << *FoldMI); + LLVM_DEBUG(dbgs() << "Replacing: " << *MI); + LLVM_DEBUG(dbgs() << " With: " << *FoldMI); LocalMIs.erase(MI); LocalMIs.erase(DefMI); LocalMIs.insert(FoldMI); @@ -1791,7 +1791,7 @@ // the load candidates. Note: We might be able to fold *into* this // instruction, so this needs to be after the folding logic. if (MI->isLoadFoldBarrier()) { - DEBUG(dbgs() << "Encountered load fold barrier on " << *MI); + LLVM_DEBUG(dbgs() << "Encountered load fold barrier on " << *MI); FoldAsLoadDefCandidates.clear(); } } Index: lib/CodeGen/PostRASchedulerList.cpp =================================================================== --- lib/CodeGen/PostRASchedulerList.cpp +++ lib/CodeGen/PostRASchedulerList.cpp @@ -242,7 +242,7 @@ /// Print the schedule before exiting the region. void SchedulePostRATDList::exitRegion() { - DEBUG({ + LLVM_DEBUG({ dbgs() << "*** Final schedule ***\n"; dumpSchedule(); dbgs() << '\n'; @@ -308,7 +308,7 @@ : TargetSubtargetInfo::ANTIDEP_NONE); } - DEBUG(dbgs() << "PostRAScheduler\n"); + LLVM_DEBUG(dbgs() << "PostRAScheduler\n"); SchedulePostRATDList Scheduler(Fn, MLI, AA, RegClassInfo, AntiDepMode, CriticalPathRCs); @@ -412,8 +412,8 @@ postprocessDAG(); - DEBUG(dbgs() << "********** List Scheduling **********\n"); - DEBUG( + LLVM_DEBUG(dbgs() << "********** List Scheduling **********\n"); + LLVM_DEBUG( for (const SUnit &SU : SUnits) { SU.dumpAll(this); dbgs() << '\n'; @@ -501,8 +501,8 @@ /// count of its successors. If a successor pending count is zero, add it to /// the Available queue. void SchedulePostRATDList::ScheduleNodeTopDown(SUnit *SU, unsigned CurCycle) { - DEBUG(dbgs() << "*** Scheduling [" << CurCycle << "]: "); - DEBUG(SU->dump(this)); + LLVM_DEBUG(dbgs() << "*** Scheduling [" << CurCycle << "]: "); + LLVM_DEBUG(SU->dump(this)); Sequence.push_back(SU); assert(CurCycle >= SU->getDepth() && @@ -516,7 +516,7 @@ /// emitNoop - Add a noop to the current instruction sequence. void SchedulePostRATDList::emitNoop(unsigned CurCycle) { - DEBUG(dbgs() << "*** Emitting noop in cycle " << CurCycle << '\n'); + LLVM_DEBUG(dbgs() << "*** Emitting noop in cycle " << CurCycle << '\n'); HazardRec->EmitNoop(); Sequence.push_back(nullptr); // NULL here means noop ++NumNoops; @@ -568,7 +568,7 @@ MinDepth = PendingQueue[i]->getDepth(); } - DEBUG(dbgs() << "\n*** Examining Available\n"; AvailableQueue.dump(this)); + LLVM_DEBUG(dbgs() << "\n*** Examining Available\n"; AvailableQueue.dump(this)); SUnit *FoundSUnit = nullptr, *NotPreferredSUnit = nullptr; bool HasNoopHazards = false; @@ -604,7 +604,7 @@ // non-preferred node. if (NotPreferredSUnit) { if (!FoundSUnit) { - DEBUG(dbgs() << "*** Will schedule a non-preferred instruction...\n"); + LLVM_DEBUG(dbgs() << "*** Will schedule a non-preferred instruction...\n"); FoundSUnit = NotPreferredSUnit; } else { AvailableQueue.push(NotPreferredSUnit); @@ -631,19 +631,19 @@ HazardRec->EmitInstruction(FoundSUnit); CycleHasInsts = true; if (HazardRec->atIssueLimit()) { - DEBUG(dbgs() << "*** Max instructions per cycle " << CurCycle << '\n'); + LLVM_DEBUG(dbgs() << "*** Max instructions per cycle " << CurCycle << '\n'); HazardRec->AdvanceCycle(); ++CurCycle; CycleHasInsts = false; } } else { if (CycleHasInsts) { - DEBUG(dbgs() << "*** Finished cycle " << CurCycle << '\n'); + LLVM_DEBUG(dbgs() << "*** Finished cycle " << CurCycle << '\n'); HazardRec->AdvanceCycle(); } else if (!HasNoopHazards) { // Otherwise, we have a pipeline stall, but no other problem, // just advance the current cycle and try again. - DEBUG(dbgs() << "*** Stall in cycle " << CurCycle << '\n'); + LLVM_DEBUG(dbgs() << "*** Stall in cycle " << CurCycle << '\n'); HazardRec->AdvanceCycle(); ++NumStalls; } else { Index: lib/CodeGen/ProcessImplicitDefs.cpp =================================================================== --- lib/CodeGen/ProcessImplicitDefs.cpp +++ lib/CodeGen/ProcessImplicitDefs.cpp @@ -73,7 +73,7 @@ } void ProcessImplicitDefs::processImplicitDef(MachineInstr *MI) { - DEBUG(dbgs() << "Processing " << *MI); + LLVM_DEBUG(dbgs() << "Processing " << *MI); unsigned Reg = MI->getOperand(0).getReg(); if (TargetRegisterInfo::isVirtualRegister(Reg)) { @@ -84,7 +84,7 @@ MachineInstr *UserMI = MO.getParent(); if (!canTurnIntoImplicitDef(UserMI)) continue; - DEBUG(dbgs() << "Converting to IMPLICIT_DEF: " << *UserMI); + LLVM_DEBUG(dbgs() << "Converting to IMPLICIT_DEF: " << *UserMI); UserMI->setDesc(TII->get(TargetOpcode::IMPLICIT_DEF)); WorkList.insert(UserMI); } @@ -116,7 +116,7 @@ // If we found the using MI, we can erase the IMPLICIT_DEF. if (Found) { - DEBUG(dbgs() << "Physreg user: " << *UserMI); + LLVM_DEBUG(dbgs() << "Physreg user: " << *UserMI); MI->eraseFromParent(); return; } @@ -125,14 +125,14 @@ // Leave the physreg IMPLICIT_DEF, but trim any extra operands. for (unsigned i = MI->getNumOperands() - 1; i; --i) MI->RemoveOperand(i); - DEBUG(dbgs() << "Keeping physreg: " << *MI); + LLVM_DEBUG(dbgs() << "Keeping physreg: " << *MI); } /// processImplicitDefs - Process IMPLICIT_DEF instructions and turn them into /// operands. bool ProcessImplicitDefs::runOnMachineFunction(MachineFunction &MF) { - DEBUG(dbgs() << "********** PROCESS IMPLICIT DEFS **********\n" + LLVM_DEBUG(dbgs() << "********** PROCESS IMPLICIT DEFS **********\n" << "********** Function: " << MF.getName() << '\n'); bool Changed = false; @@ -154,7 +154,7 @@ if (WorkList.empty()) continue; - DEBUG(dbgs() << printMBBReference(*MFI) << " has " << WorkList.size() + LLVM_DEBUG(dbgs() << printMBBReference(*MFI) << " has " << WorkList.size() << " implicit defs.\n"); Changed = true; Index: lib/CodeGen/PrologEpilogInserter.cpp =================================================================== --- lib/CodeGen/PrologEpilogInserter.cpp +++ lib/CodeGen/PrologEpilogInserter.cpp @@ -564,10 +564,10 @@ Offset = alignTo(Offset, Align, Skew); if (StackGrowsDown) { - DEBUG(dbgs() << "alloc FI(" << FrameIdx << ") at SP[" << -Offset << "]\n"); + LLVM_DEBUG(dbgs() << "alloc FI(" << FrameIdx << ") at SP[" << -Offset << "]\n"); MFI.setObjectOffset(FrameIdx, -Offset); // Set the computed offset } else { - DEBUG(dbgs() << "alloc FI(" << FrameIdx << ") at SP[" << Offset << "]\n"); + LLVM_DEBUG(dbgs() << "alloc FI(" << FrameIdx << ") at SP[" << Offset << "]\n"); MFI.setObjectOffset(FrameIdx, Offset); Offset += MFI.getObjectSize(FrameIdx); } @@ -660,11 +660,11 @@ if (StackGrowsDown) { int ObjStart = -(FreeStart + ObjSize); - DEBUG(dbgs() << "alloc FI(" << FrameIdx << ") scavenged at SP[" << ObjStart + LLVM_DEBUG(dbgs() << "alloc FI(" << FrameIdx << ") scavenged at SP[" << ObjStart << "]\n"); MFI.setObjectOffset(FrameIdx, ObjStart); } else { - DEBUG(dbgs() << "alloc FI(" << FrameIdx << ") scavenged at SP[" << FreeStart + LLVM_DEBUG(dbgs() << "alloc FI(" << FrameIdx << ") scavenged at SP[" << FreeStart << "]\n"); MFI.setObjectOffset(FrameIdx, FreeStart); } @@ -745,7 +745,7 @@ // Adjust to alignment boundary Offset = alignTo(Offset, Align, Skew); - DEBUG(dbgs() << "alloc FI(" << i << ") at SP[" << -Offset << "]\n"); + LLVM_DEBUG(dbgs() << "alloc FI(" << i << ") at SP[" << -Offset << "]\n"); MFI.setObjectOffset(i, -Offset); // Set the computed offset } } else if (MaxCSFrameIndex >= MinCSFrameIndex) { @@ -758,7 +758,7 @@ // Adjust to alignment boundary Offset = alignTo(Offset, Align, Skew); - DEBUG(dbgs() << "alloc FI(" << i << ") at SP[" << Offset << "]\n"); + LLVM_DEBUG(dbgs() << "alloc FI(" << i << ") at SP[" << Offset << "]\n"); MFI.setObjectOffset(i, Offset); Offset += MFI.getObjectSize(i); } @@ -795,13 +795,13 @@ // Adjust to alignment boundary. Offset = alignTo(Offset, Align, Skew); - DEBUG(dbgs() << "Local frame base offset: " << Offset << "\n"); + LLVM_DEBUG(dbgs() << "Local frame base offset: " << Offset << "\n"); // Resolve offsets for objects in the local block. for (unsigned i = 0, e = MFI.getLocalFrameObjectCount(); i != e; ++i) { std::pair Entry = MFI.getLocalFrameObjectMap(i); int64_t FIOffset = (StackGrowsDown ? -Offset : Offset) + Entry.second; - DEBUG(dbgs() << "alloc FI(" << Entry.first << ") at SP[" << + LLVM_DEBUG(dbgs() << "alloc FI(" << Entry.first << ") at SP[" << FIOffset << "]\n"); MFI.setObjectOffset(Entry.first, FIOffset); } Index: lib/CodeGen/ReachingDefAnalysis.cpp =================================================================== --- lib/CodeGen/ReachingDefAnalysis.cpp +++ lib/CodeGen/ReachingDefAnalysis.cpp @@ -47,7 +47,7 @@ MBBReachingDefs[MBBNumber][*Unit].push_back(LiveRegs[*Unit]); } } - DEBUG(dbgs() << printMBBReference(*MBB) << ": entry\n"); + LLVM_DEBUG(dbgs() << printMBBReference(*MBB) << ": entry\n"); return; } @@ -69,7 +69,7 @@ } } - DEBUG(dbgs() << printMBBReference(*MBB) + LLVM_DEBUG(dbgs() << printMBBReference(*MBB) << (!TraversedMBB.IsDone ? ": incomplete\n" : ": all preds known\n")); } @@ -109,7 +109,7 @@ continue; for (MCRegUnitIterator Unit(MO.getReg(), TRI); Unit.isValid(); ++Unit) { // This instruction explicitly defines the current reg unit. - DEBUG(dbgs() << printReg(MO.getReg(), TRI) << ":\t" << CurInstr << '\t' + LLVM_DEBUG(dbgs() << printReg(MO.getReg(), TRI) << ":\t" << CurInstr << '\t' << *MI); // How many instructions since this reg unit was last written? @@ -142,7 +142,7 @@ MBBReachingDefs.resize(mf.getNumBlockIDs()); - DEBUG(dbgs() << "********** REACHING DEFINITION ANALYSIS **********\n"); + LLVM_DEBUG(dbgs() << "********** REACHING DEFINITION ANALYSIS **********\n"); // Initialize the MBBOutRegsInfos MBBOutRegsInfos.resize(mf.getNumBlockIDs()); Index: lib/CodeGen/RegAllocBase.cpp =================================================================== --- lib/CodeGen/RegAllocBase.cpp +++ lib/CodeGen/RegAllocBase.cpp @@ -91,7 +91,7 @@ // Unused registers can appear when the spiller coalesces snippets. if (MRI->reg_nodbg_empty(VirtReg->reg)) { - DEBUG(dbgs() << "Dropping unused " << *VirtReg << '\n'); + LLVM_DEBUG(dbgs() << "Dropping unused " << *VirtReg << '\n'); aboutToRemoveInterval(*VirtReg); LIS->removeInterval(VirtReg->reg); continue; @@ -103,7 +103,7 @@ // selectOrSplit requests the allocator to return an available physical // register if possible and populate a list of new live intervals that // result from splitting. - DEBUG(dbgs() << "\nselectOrSplit " + LLVM_DEBUG(dbgs() << "\nselectOrSplit " << TRI->getRegClassName(MRI->getRegClass(VirtReg->reg)) << ':' << *VirtReg << " w=" << VirtReg->weight << '\n'); @@ -145,12 +145,12 @@ assert(!VRM->hasPhys(SplitVirtReg->reg) && "Register already assigned"); if (MRI->reg_nodbg_empty(SplitVirtReg->reg)) { assert(SplitVirtReg->empty() && "Non-empty but used interval"); - DEBUG(dbgs() << "not queueing unused " << *SplitVirtReg << '\n'); + LLVM_DEBUG(dbgs() << "not queueing unused " << *SplitVirtReg << '\n'); aboutToRemoveInterval(*SplitVirtReg); LIS->removeInterval(SplitVirtReg->reg); continue; } - DEBUG(dbgs() << "queuing new interval: " << *SplitVirtReg << "\n"); + LLVM_DEBUG(dbgs() << "queuing new interval: " << *SplitVirtReg << "\n"); assert(TargetRegisterInfo::isVirtualRegister(SplitVirtReg->reg) && "expect split value in virtual register"); enqueue(SplitVirtReg); Index: lib/CodeGen/RegAllocBasic.cpp =================================================================== --- lib/CodeGen/RegAllocBasic.cpp +++ lib/CodeGen/RegAllocBasic.cpp @@ -219,7 +219,7 @@ Intfs.push_back(Intf); } } - DEBUG(dbgs() << "spilling " << printReg(PhysReg, TRI) + LLVM_DEBUG(dbgs() << "spilling " << printReg(PhysReg, TRI) << " interferences with " << VirtReg << "\n"); assert(!Intfs.empty() && "expected interference"); @@ -292,7 +292,7 @@ } // No other spill candidates were found, so spill the current VirtReg. - DEBUG(dbgs() << "spilling: " << VirtReg << '\n'); + LLVM_DEBUG(dbgs() << "spilling: " << VirtReg << '\n'); if (!VirtReg.isSpillable()) return ~0u; LiveRangeEdit LRE(&VirtReg, SplitVRegs, *MF, *LIS, VRM, this, &DeadRemats); @@ -304,7 +304,7 @@ } bool RABasic::runOnMachineFunction(MachineFunction &mf) { - DEBUG(dbgs() << "********** BASIC REGISTER ALLOCATION **********\n" + LLVM_DEBUG(dbgs() << "********** BASIC REGISTER ALLOCATION **********\n" << "********** Function: " << mf.getName() << '\n'); @@ -323,7 +323,7 @@ postOptimization(); // Diagnostic output before rewriting - DEBUG(dbgs() << "Post alloc VirtRegMap:\n" << *VRM << "\n"); + LLVM_DEBUG(dbgs() << "Post alloc VirtRegMap:\n" << *VRM << "\n"); releaseMemory(); return true; Index: lib/CodeGen/RegAllocFast.cpp =================================================================== --- lib/CodeGen/RegAllocFast.cpp +++ lib/CodeGen/RegAllocFast.cpp @@ -322,11 +322,11 @@ // instruction, not on the spill. bool SpillKill = MachineBasicBlock::iterator(LR.LastUse) != MI; LR.Dirty = false; - DEBUG(dbgs() << "Spilling " << printReg(LRI->VirtReg, TRI) + LLVM_DEBUG(dbgs() << "Spilling " << printReg(LRI->VirtReg, TRI) << " in " << printReg(LR.PhysReg, TRI)); const TargetRegisterClass &RC = *MRI->getRegClass(LRI->VirtReg); int FI = getStackSpaceFor(LRI->VirtReg, RC); - DEBUG(dbgs() << " to stack slot #" << FI << "\n"); + LLVM_DEBUG(dbgs() << " to stack slot #" << FI << "\n"); TII->storeRegToStackSlot(*MBB, MI, LR.PhysReg, SpillKill, FI, &RC, TRI); ++NumStores; // Update statistics @@ -339,7 +339,7 @@ MachineInstr *NewDV = buildDbgValueForSpill(*MBB, MI, *DBG, FI); assert(NewDV->getParent() == MBB && "dangling parent pointer"); (void)NewDV; - DEBUG(dbgs() << "Inserting debug info due to spill:" << "\n" << *NewDV); + LLVM_DEBUG(dbgs() << "Inserting debug info due to spill:" << "\n" << *NewDV); } // Now this register is spilled there is should not be any DBG_VALUE // pointing to this register because they are all pointing to spilled value @@ -476,7 +476,7 @@ /// \returns spillImpossible when PhysReg or an alias can't be spilled. unsigned RegAllocFast::calcSpillCost(MCPhysReg PhysReg) const { if (isRegUsedInInstr(PhysReg)) { - DEBUG(dbgs() << printReg(PhysReg, TRI) << " is already used in instr.\n"); + LLVM_DEBUG(dbgs() << printReg(PhysReg, TRI) << " is already used in instr.\n"); return spillImpossible; } switch (unsigned VirtReg = PhysRegState[PhysReg]) { @@ -485,7 +485,7 @@ case regFree: return 0; case regReserved: - DEBUG(dbgs() << printReg(VirtReg, TRI) << " corresponding " + LLVM_DEBUG(dbgs() << printReg(VirtReg, TRI) << " corresponding " << printReg(PhysReg, TRI) << " is reserved already.\n"); return spillImpossible; default: { @@ -496,7 +496,7 @@ } // This is a disabled register, add up cost of aliases. - DEBUG(dbgs() << printReg(PhysReg, TRI) << " is disabled.\n"); + LLVM_DEBUG(dbgs() << printReg(PhysReg, TRI) << " is disabled.\n"); unsigned Cost = 0; for (MCRegAliasIterator AI(PhysReg, TRI, false); AI.isValid(); ++AI) { MCPhysReg Alias = *AI; @@ -523,7 +523,7 @@ /// proper container for VirtReg now. The physical register must not be used /// for anything else when this is called. void RegAllocFast::assignVirtToPhysReg(LiveReg &LR, MCPhysReg PhysReg) { - DEBUG(dbgs() << "Assigning " << printReg(LR.VirtReg, TRI) << " to " + LLVM_DEBUG(dbgs() << "Assigning " << printReg(LR.VirtReg, TRI) << " to " << printReg(PhysReg, TRI) << "\n"); PhysRegState[PhysReg] = LR.VirtReg; assert(!LR.PhysReg && "Already assigned a physreg"); @@ -570,16 +570,16 @@ } } - DEBUG(dbgs() << "Allocating " << printReg(VirtReg) << " from " + LLVM_DEBUG(dbgs() << "Allocating " << printReg(VirtReg) << " from " << TRI->getRegClassName(&RC) << "\n"); unsigned BestReg = 0; unsigned BestCost = spillImpossible; for (MCPhysReg PhysReg : AO) { unsigned Cost = calcSpillCost(PhysReg); - DEBUG(dbgs() << "\tRegister: " << printReg(PhysReg, TRI) << "\n"); - DEBUG(dbgs() << "\tCost: " << Cost << "\n"); - DEBUG(dbgs() << "\tBestCost: " << BestCost << "\n"); + LLVM_DEBUG(dbgs() << "\tRegister: " << printReg(PhysReg, TRI) << "\n"); + LLVM_DEBUG(dbgs() << "\tCost: " << Cost << "\n"); + LLVM_DEBUG(dbgs() << "\tBestCost: " << BestCost << "\n"); // Cost is 0 when all aliases are already disabled. if (Cost == 0) { assignVirtToPhysReg(*LRI, PhysReg); @@ -654,22 +654,22 @@ LRI = allocVirtReg(MI, LRI, Hint); const TargetRegisterClass &RC = *MRI->getRegClass(VirtReg); int FrameIndex = getStackSpaceFor(VirtReg, RC); - DEBUG(dbgs() << "Reloading " << printReg(VirtReg, TRI) << " into " + LLVM_DEBUG(dbgs() << "Reloading " << printReg(VirtReg, TRI) << " into " << printReg(LRI->PhysReg, TRI) << "\n"); TII->loadRegFromStackSlot(*MBB, MI, LRI->PhysReg, FrameIndex, &RC, TRI); ++NumLoads; } else if (LRI->Dirty) { if (isLastUseOfLocalReg(MO)) { - DEBUG(dbgs() << "Killing last use: " << MO << "\n"); + LLVM_DEBUG(dbgs() << "Killing last use: " << MO << "\n"); if (MO.isUse()) MO.setIsKill(); else MO.setIsDead(); } else if (MO.isKill()) { - DEBUG(dbgs() << "Clearing dubious kill: " << MO << "\n"); + LLVM_DEBUG(dbgs() << "Clearing dubious kill: " << MO << "\n"); MO.setIsKill(false); } else if (MO.isDead()) { - DEBUG(dbgs() << "Clearing dubious dead: " << MO << "\n"); + LLVM_DEBUG(dbgs() << "Clearing dubious dead: " << MO << "\n"); MO.setIsDead(false); } } else if (MO.isKill()) { @@ -677,10 +677,10 @@ // register would be killed immediately, and there might be a second use: // %foo = OR killed %x, %x // This would cause a second reload of %x into a different register. - DEBUG(dbgs() << "Clearing clean kill: " << MO << "\n"); + LLVM_DEBUG(dbgs() << "Clearing clean kill: " << MO << "\n"); MO.setIsKill(false); } else if (MO.isDead()) { - DEBUG(dbgs() << "Clearing clean dead: " << MO << "\n"); + LLVM_DEBUG(dbgs() << "Clearing clean dead: " << MO << "\n"); MO.setIsDead(false); } assert(LRI->PhysReg && "Register not assigned"); @@ -727,7 +727,7 @@ // there are additional physreg defines. void RegAllocFast::handleThroughOperands(MachineInstr &MI, SmallVectorImpl &VirtDead) { - DEBUG(dbgs() << "Scanning for through registers:"); + LLVM_DEBUG(dbgs() << "Scanning for through registers:"); SmallSet ThroughRegs; for (const MachineOperand &MO : MI.operands()) { if (!MO.isReg()) continue; @@ -737,13 +737,13 @@ if (MO.isEarlyClobber() || (MO.isUse() && MO.isTied()) || (MO.getSubReg() && MI.readsVirtualRegister(Reg))) { if (ThroughRegs.insert(Reg).second) - DEBUG(dbgs() << ' ' << printReg(Reg)); + LLVM_DEBUG(dbgs() << ' ' << printReg(Reg)); } } // If any physreg defines collide with preallocated through registers, // we must spill and reallocate. - DEBUG(dbgs() << "\nChecking for physdef collisions.\n"); + LLVM_DEBUG(dbgs() << "\nChecking for physdef collisions.\n"); for (const MachineOperand &MO : MI.operands()) { if (!MO.isReg() || !MO.isDef()) continue; unsigned Reg = MO.getReg(); @@ -756,7 +756,7 @@ } SmallVector PartialDefs; - DEBUG(dbgs() << "Allocating tied uses.\n"); + LLVM_DEBUG(dbgs() << "Allocating tied uses.\n"); for (unsigned I = 0, E = MI.getNumOperands(); I != E; ++I) { const MachineOperand &MO = MI.getOperand(I); if (!MO.isReg()) continue; @@ -764,7 +764,7 @@ if (!TargetRegisterInfo::isVirtualRegister(Reg)) continue; if (MO.isUse()) { if (!MO.isTied()) continue; - DEBUG(dbgs() << "Operand " << I << "("<< MO << ") is tied to operand " + LLVM_DEBUG(dbgs() << "Operand " << I << "("<< MO << ") is tied to operand " << MI.findTiedOperandIdx(I) << ".\n"); LiveRegMap::iterator LRI = reloadVirtReg(MI, I, Reg, 0); MCPhysReg PhysReg = LRI->PhysReg; @@ -772,7 +772,7 @@ // Note: we don't update the def operand yet. That would cause the normal // def-scan to attempt spilling. } else if (MO.getSubReg() && MI.readsVirtualRegister(Reg)) { - DEBUG(dbgs() << "Partial redefine: " << MO << "\n"); + LLVM_DEBUG(dbgs() << "Partial redefine: " << MO << "\n"); // Reload the register, but don't assign to the operand just yet. // That would confuse the later phys-def processing pass. LiveRegMap::iterator LRI = reloadVirtReg(MI, I, Reg, 0); @@ -780,7 +780,7 @@ } } - DEBUG(dbgs() << "Allocating early clobbers.\n"); + LLVM_DEBUG(dbgs() << "Allocating early clobbers.\n"); for (unsigned I = 0, E = MI.getNumOperands(); I != E; ++I) { const MachineOperand &MO = MI.getOperand(I); if (!MO.isReg()) continue; @@ -801,7 +801,7 @@ if (!MO.isReg() || (MO.isDef() && !MO.isEarlyClobber())) continue; unsigned Reg = MO.getReg(); if (!Reg || !TargetRegisterInfo::isPhysicalRegister(Reg)) continue; - DEBUG(dbgs() << "\tSetting " << printReg(Reg, TRI) + LLVM_DEBUG(dbgs() << "\tSetting " << printReg(Reg, TRI) << " as used in instr\n"); markRegUsedInInstr(Reg); } @@ -848,7 +848,7 @@ void RegAllocFast::allocateBasicBlock(MachineBasicBlock &MBB) { this->MBB = &MBB; - DEBUG(dbgs() << "\nAllocating " << MBB); + LLVM_DEBUG(dbgs() << "\nAllocating " << MBB); PhysRegState.assign(TRI->getNumRegs(), regDisabled); assert(LiveVirtRegs.empty() && "Mapping not cleared from last block?"); @@ -866,7 +866,7 @@ // Otherwise, sequentially allocate each instruction in the MBB. for (MachineInstr &MI : MBB) { const MCInstrDesc &MCID = MI.getDesc(); - DEBUG( + LLVM_DEBUG( dbgs() << "\n>> " << MI << "Regs:"; dumpState() ); @@ -894,13 +894,13 @@ if (SS != -1) { // Modify DBG_VALUE now that the value is in a spill slot. updateDbgValueForSpill(*DebugMI, SS); - DEBUG(dbgs() << "Modifying debug info due to spill:" + LLVM_DEBUG(dbgs() << "Modifying debug info due to spill:" << "\t" << *DebugMI); continue; } // We can't allocate a physreg for a DebugValue, sorry! - DEBUG(dbgs() << "Unable to allocate vreg used by DBG_VALUE"); + LLVM_DEBUG(dbgs() << "Unable to allocate vreg used by DBG_VALUE"); MO.setReg(0); } @@ -1025,7 +1025,7 @@ // as call-clobbered, this is not correct because some of those // definitions may be used later on and we do not want to reuse // those for virtual registers in between. - DEBUG(dbgs() << " Spilling remaining registers before call.\n"); + LLVM_DEBUG(dbgs() << " Spilling remaining registers before call.\n"); spillAll(MI); } @@ -1060,15 +1060,15 @@ VirtDead.clear(); if (CopyDstReg && CopyDstReg == CopySrcReg && CopyDstSub == CopySrcSub) { - DEBUG(dbgs() << "-- coalescing: " << MI); + LLVM_DEBUG(dbgs() << "-- coalescing: " << MI); Coalesced.push_back(&MI); } else { - DEBUG(dbgs() << "<< " << MI); + LLVM_DEBUG(dbgs() << "<< " << MI); } } // Spill all physical registers holding virtual registers now. - DEBUG(dbgs() << "Spilling live registers at end of block.\n"); + LLVM_DEBUG(dbgs() << "Spilling live registers at end of block.\n"); spillAll(MBB.getFirstTerminator()); // Erase all the coalesced copies. We are delaying it until now because @@ -1077,12 +1077,12 @@ MBB.erase(MI); NumCopies += Coalesced.size(); - DEBUG(MBB.dump()); + LLVM_DEBUG(MBB.dump()); } /// Allocates registers for a function. bool RegAllocFast::runOnMachineFunction(MachineFunction &MF) { - DEBUG(dbgs() << "********** FAST REGISTER ALLOCATION **********\n" + LLVM_DEBUG(dbgs() << "********** FAST REGISTER ALLOCATION **********\n" << "********** Function: " << MF.getName() << '\n'); MRI = &MF.getRegInfo(); const TargetSubtargetInfo &STI = MF.getSubtarget(); Index: lib/CodeGen/RegAllocGreedy.cpp =================================================================== --- lib/CodeGen/RegAllocGreedy.cpp +++ lib/CodeGen/RegAllocGreedy.cpp @@ -766,7 +766,7 @@ // preferred register. if (unsigned Hint = MRI->getSimpleHint(VirtReg.reg)) if (Order.isHint(Hint)) { - DEBUG(dbgs() << "missed hint " << printReg(Hint, TRI) << '\n'); + LLVM_DEBUG(dbgs() << "missed hint " << printReg(Hint, TRI) << '\n'); EvictionCost MaxCost; MaxCost.setBrokenHints(1); if (canEvictInterference(VirtReg, Hint, true, MaxCost)) { @@ -785,7 +785,7 @@ if (!Cost) return PhysReg; - DEBUG(dbgs() << printReg(PhysReg, TRI) << " is available at cost " << Cost + LLVM_DEBUG(dbgs() << printReg(PhysReg, TRI) << " is available at cost " << Cost << '\n'); unsigned CheapReg = tryEvict(VirtReg, Order, NewVRegs, Cost); return CheapReg ? CheapReg : PhysReg; @@ -814,7 +814,7 @@ break; } if (PhysReg) - DEBUG(dbgs() << "can reassign: " << VirtReg << " from " + LLVM_DEBUG(dbgs() << "can reassign: " << VirtReg << " from " << printReg(PrevReg, TRI) << " to " << printReg(PhysReg, TRI) << '\n'); return PhysReg; @@ -843,7 +843,7 @@ return true; if (A.weight > B.weight) { - DEBUG(dbgs() << "should evict: " << B << " w= " << B.weight << '\n'); + LLVM_DEBUG(dbgs() << "should evict: " << B << " w= " << B.weight << '\n'); return true; } return false; @@ -1035,7 +1035,7 @@ if (!Cascade) Cascade = ExtraRegInfo[VirtReg.reg].Cascade = NextCascade++; - DEBUG(dbgs() << "evicting " << printReg(PhysReg, TRI) + LLVM_DEBUG(dbgs() << "evicting " << printReg(PhysReg, TRI) << " interference: Cascade " << Cascade << '\n'); // Collect all interfering virtregs first. @@ -1107,7 +1107,7 @@ const TargetRegisterClass *RC = MRI->getRegClass(VirtReg.reg); unsigned MinCost = RegClassInfo.getMinCost(RC); if (MinCost >= CostPerUseLimit) { - DEBUG(dbgs() << TRI->getRegClassName(RC) << " minimum cost = " << MinCost + LLVM_DEBUG(dbgs() << TRI->getRegClassName(RC) << " minimum cost = " << MinCost << ", no cheaper registers to be found.\n"); return 0; } @@ -1116,7 +1116,7 @@ // the same cost. We don't need to look at them if they're too expensive. if (TRI->getCostPerUse(Order.getOrder().back()) >= CostPerUseLimit) { OrderLimit = RegClassInfo.getLastCostChange(RC); - DEBUG(dbgs() << "Only trying the first " << OrderLimit << " regs.\n"); + LLVM_DEBUG(dbgs() << "Only trying the first " << OrderLimit << " regs.\n"); } } @@ -1127,7 +1127,7 @@ // The first use of a callee-saved register in a function has cost 1. // Don't start using a CSR when the CostPerUseLimit is low. if (CostPerUseLimit == 1 && isUnusedCalleeSavedReg(PhysReg)) { - DEBUG(dbgs() << printReg(PhysReg, TRI) << " would clobber CSR " + LLVM_DEBUG(dbgs() << printReg(PhysReg, TRI) << " would clobber CSR " << printReg(RegClassInfo.getLastCalleeSavedAlias(PhysReg), TRI) << '\n'); continue; @@ -1316,7 +1316,7 @@ // Perhaps iterating can enable more bundles? SpillPlacer->iterate(); } - DEBUG(dbgs() << ", v=" << Visited); + LLVM_DEBUG(dbgs() << ", v=" << Visited); } /// calcCompactRegion - Compute the set of edge bundles that should be live @@ -1334,7 +1334,7 @@ // Compact regions don't correspond to any physreg. Cand.reset(IntfCache, 0); - DEBUG(dbgs() << "Compact region bundles"); + LLVM_DEBUG(dbgs() << "Compact region bundles"); // Use the spill placer to determine the live bundles. GrowRegion pretends // that all the through blocks have interference when PhysReg is unset. @@ -1343,7 +1343,7 @@ // The static split cost will be zero since Cand.Intf reports no interference. BlockFrequency Cost; if (!addSplitConstraints(Cand.Intf, Cost)) { - DEBUG(dbgs() << ", none.\n"); + LLVM_DEBUG(dbgs() << ", none.\n"); return false; } @@ -1351,11 +1351,11 @@ SpillPlacer->finish(); if (!Cand.LiveBundles.any()) { - DEBUG(dbgs() << ", none.\n"); + LLVM_DEBUG(dbgs() << ", none.\n"); return false; } - DEBUG({ + LLVM_DEBUG({ for (int i : Cand.LiveBundles.set_bits()) dbgs() << " EB#" << i; dbgs() << ".\n"; @@ -1633,7 +1633,7 @@ // These are the intervals created for new global ranges. We may create more // intervals for local ranges. const unsigned NumGlobalIntvs = LREdit.size(); - DEBUG(dbgs() << "splitAroundRegion with " << NumGlobalIntvs << " globals.\n"); + LLVM_DEBUG(dbgs() << "splitAroundRegion with " << NumGlobalIntvs << " globals.\n"); assert(NumGlobalIntvs && "No global intervals configured"); // Isolate even single instructions when dealing with a proper sub-class. @@ -1670,7 +1670,7 @@ // Create separate intervals for isolated blocks with multiple uses. if (!IntvIn && !IntvOut) { - DEBUG(dbgs() << printMBBReference(*BI.MBB) << " isolated.\n"); + LLVM_DEBUG(dbgs() << printMBBReference(*BI.MBB) << " isolated.\n"); if (SA->shouldSplitSingleBlock(BI, SingleInstrs)) SE->splitSingleBlock(BI); continue; @@ -1752,7 +1752,7 @@ // blocks is strictly decreasing. if (IntvMap[i] < NumGlobalIntvs) { if (SA->countLiveBlocks(&Reg) >= OrigBlocks) { - DEBUG(dbgs() << "Main interval covers the same " << OrigBlocks + LLVM_DEBUG(dbgs() << "Main interval covers the same " << OrigBlocks << " blocks as original.\n"); // Don't allow repeated splitting as a safe guard against looping. setStage(Reg, RS_Split2); @@ -1784,7 +1784,7 @@ // No benefit from the compact region, our fallback will be per-block // splitting. Make sure we find a solution that is cheaper than spilling. BestCost = SpillCost; - DEBUG(dbgs() << "Cost of isolating all blocks = "; + LLVM_DEBUG(dbgs() << "Cost of isolating all blocks = "; MBFI->printBlockFreq(dbgs(), BestCost) << '\n'); } @@ -1848,13 +1848,13 @@ SpillPlacer->prepare(Cand.LiveBundles); BlockFrequency Cost; if (!addSplitConstraints(Cand.Intf, Cost)) { - DEBUG(dbgs() << printReg(PhysReg, TRI) << "\tno positive bundles\n"); + LLVM_DEBUG(dbgs() << printReg(PhysReg, TRI) << "\tno positive bundles\n"); continue; } - DEBUG(dbgs() << printReg(PhysReg, TRI) << "\tstatic = "; + LLVM_DEBUG(dbgs() << printReg(PhysReg, TRI) << "\tstatic = "; MBFI->printBlockFreq(dbgs(), Cost)); if (Cost >= BestCost) { - DEBUG({ + LLVM_DEBUG({ if (BestCand == NoCand) dbgs() << " worse than no bundles\n"; else @@ -1869,13 +1869,13 @@ // No live bundles, defer to splitSingleBlocks(). if (!Cand.LiveBundles.any()) { - DEBUG(dbgs() << " no bundles.\n"); + LLVM_DEBUG(dbgs() << " no bundles.\n"); continue; } bool HasEvictionChain = false; Cost += calcGlobalSplitCost(Cand, Order, &HasEvictionChain); - DEBUG({ + LLVM_DEBUG({ dbgs() << ", total = "; MBFI->printBlockFreq(dbgs(), Cost) << " with bundles"; for (int i : Cand.LiveBundles.set_bits()) @@ -1896,11 +1896,11 @@ if (CanCauseEvictionChain && BestCand != NoCand) { // See splitCanCauseEvictionChain for detailed description of bad // eviction chain scenarios. - DEBUG(dbgs() << "Best split candidate of vreg " + LLVM_DEBUG(dbgs() << "Best split candidate of vreg " << printReg(VirtReg.reg, TRI) << " may "); if (!(*CanCauseEvictionChain)) - DEBUG(dbgs() << "not "); - DEBUG(dbgs() << "cause bad eviction chain\n"); + LLVM_DEBUG(dbgs() << "not "); + LLVM_DEBUG(dbgs() << "cause bad eviction chain\n"); } return BestCand; @@ -1923,7 +1923,7 @@ if (unsigned B = Cand.getBundles(BundleCand, BestCand)) { UsedCands.push_back(BestCand); Cand.IntvIdx = SE->openIntv(); - DEBUG(dbgs() << "Split for " << printReg(Cand.PhysReg, TRI) << " in " + LLVM_DEBUG(dbgs() << "Split for " << printReg(Cand.PhysReg, TRI) << " in " << B << " bundles, intv " << Cand.IntvIdx << ".\n"); (void)B; } @@ -1936,7 +1936,7 @@ if (unsigned B = Cand.getBundles(BundleCand, 0)) { UsedCands.push_back(0); Cand.IntvIdx = SE->openIntv(); - DEBUG(dbgs() << "Split for compact region in " << B << " bundles, intv " + LLVM_DEBUG(dbgs() << "Split for compact region in " << B << " bundles, intv " << Cand.IntvIdx << ".\n"); (void)B; } @@ -2036,7 +2036,7 @@ if (Uses.size() <= 1) return 0; - DEBUG(dbgs() << "Split around " << Uses.size() << " individual instrs.\n"); + LLVM_DEBUG(dbgs() << "Split around " << Uses.size() << " individual instrs.\n"); const TargetRegisterClass *SuperRC = TRI->getLargestLegalSuperClass(CurRC, *MF); @@ -2051,7 +2051,7 @@ SuperRCNumAllocatableRegs == getNumAllocatableRegsForConstraints(MI, VirtReg.reg, SuperRC, TII, TRI, RCI)) { - DEBUG(dbgs() << " skip:\t" << Uses[i] << '\t' << *MI); + LLVM_DEBUG(dbgs() << " skip:\t" << Uses[i] << '\t' << *MI); continue; } SE->openIntv(); @@ -2061,7 +2061,7 @@ } if (LREdit.empty()) { - DEBUG(dbgs() << "All uses were copies.\n"); + LLVM_DEBUG(dbgs() << "All uses were copies.\n"); return 0; } @@ -2179,7 +2179,7 @@ return 0; const unsigned NumGaps = Uses.size()-1; - DEBUG({ + LLVM_DEBUG({ dbgs() << "tryLocalSplit: "; for (unsigned i = 0, e = Uses.size(); i != e; ++i) dbgs() << ' ' << Uses[i]; @@ -2192,7 +2192,7 @@ if (Matrix->checkRegMaskInterference(VirtReg)) { // Get regmask slots for the whole block. ArrayRef RMS = LIS->getRegMaskSlotsInBlock(BI.MBB->getNumber()); - DEBUG(dbgs() << RMS.size() << " regmasks in block:"); + LLVM_DEBUG(dbgs() << RMS.size() << " regmasks in block:"); // Constrain to VirtReg's live range. unsigned ri = std::lower_bound(RMS.begin(), RMS.end(), Uses.front().getRegSlot()) - RMS.begin(); @@ -2206,14 +2206,14 @@ // overlap the live range. if (SlotIndex::isSameInstr(Uses[i+1], RMS[ri]) && i+1 == NumGaps) break; - DEBUG(dbgs() << ' ' << RMS[ri] << ':' << Uses[i] << '-' << Uses[i+1]); + LLVM_DEBUG(dbgs() << ' ' << RMS[ri] << ':' << Uses[i] << '-' << Uses[i+1]); RegMaskGaps.push_back(i); // Advance ri to the next gap. A regmask on one of the uses counts in // both gaps. while (ri != re && SlotIndex::isEarlierInstr(RMS[ri], Uses[i+1])) ++ri; } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); } // Since we allow local split results to be split again, there is a risk of @@ -2272,13 +2272,13 @@ const bool LiveBefore = SplitBefore != 0 || BI.LiveIn; const bool LiveAfter = SplitAfter != NumGaps || BI.LiveOut; - DEBUG(dbgs() << printReg(PhysReg, TRI) << ' ' + LLVM_DEBUG(dbgs() << printReg(PhysReg, TRI) << ' ' << Uses[SplitBefore] << '-' << Uses[SplitAfter] << " i=" << MaxGap); // Stop before the interval gets so big we wouldn't be making progress. if (!LiveBefore && !LiveAfter) { - DEBUG(dbgs() << " all\n"); + LLVM_DEBUG(dbgs() << " all\n"); break; } // Should the interval be extended or shrunk? @@ -2303,12 +2303,12 @@ 1); // Would this split be possible to allocate? // Never allocate all gaps, we wouldn't be making progress. - DEBUG(dbgs() << " w=" << EstWeight); + LLVM_DEBUG(dbgs() << " w=" << EstWeight); if (EstWeight * Hysteresis >= MaxGap) { Shrink = false; float Diff = EstWeight - MaxGap; if (Diff > BestDiff) { - DEBUG(dbgs() << " (best)"); + LLVM_DEBUG(dbgs() << " (best)"); BestDiff = Hysteresis * Diff; BestBefore = SplitBefore; BestAfter = SplitAfter; @@ -2319,7 +2319,7 @@ // Try to shrink. if (Shrink) { if (++SplitBefore < SplitAfter) { - DEBUG(dbgs() << " shrink\n"); + LLVM_DEBUG(dbgs() << " shrink\n"); // Recompute the max when necessary. if (GapWeight[SplitBefore - 1] >= MaxGap) { MaxGap = GapWeight[SplitBefore]; @@ -2333,11 +2333,11 @@ // Try to extend the interval. if (SplitAfter >= NumGaps) { - DEBUG(dbgs() << " end\n"); + LLVM_DEBUG(dbgs() << " end\n"); break; } - DEBUG(dbgs() << " extend\n"); + LLVM_DEBUG(dbgs() << " extend\n"); MaxGap = std::max(MaxGap, GapWeight[SplitAfter++]); } } @@ -2346,7 +2346,7 @@ if (BestBefore == NumGaps) return 0; - DEBUG(dbgs() << "Best local split range: " << Uses[BestBefore] + LLVM_DEBUG(dbgs() << "Best local split range: " << Uses[BestBefore] << '-' << Uses[BestAfter] << ", " << BestDiff << ", " << (BestAfter - BestBefore + 1) << " instrs\n"); @@ -2368,14 +2368,14 @@ bool LiveAfter = BestAfter != NumGaps || BI.LiveOut; unsigned NewGaps = LiveBefore + BestAfter - BestBefore + LiveAfter; if (NewGaps >= NumGaps) { - DEBUG(dbgs() << "Tagging non-progress ranges: "); + LLVM_DEBUG(dbgs() << "Tagging non-progress ranges: "); assert(!ProgressRequired && "Didn't make progress when it was required."); for (unsigned i = 0, e = IntvMap.size(); i != e; ++i) if (IntvMap[i] == 1) { setStage(LIS->getInterval(LREdit.get(i)), RS_Split2); - DEBUG(dbgs() << printReg(LREdit.get(i))); + LLVM_DEBUG(dbgs() << printReg(LREdit.get(i))); } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); } ++NumLocalSplits; @@ -2468,7 +2468,7 @@ // chances are one would not be recolorable. if (Q.collectInterferingVRegs(LastChanceRecoloringMaxInterference) >= LastChanceRecoloringMaxInterference && !ExhaustiveSearch) { - DEBUG(dbgs() << "Early abort: too many interferences.\n"); + LLVM_DEBUG(dbgs() << "Early abort: too many interferences.\n"); CutOffInfo |= CO_Interf; return false; } @@ -2482,7 +2482,7 @@ MRI->getRegClass(Intf->reg) == CurRC) && !(hasTiedDef(MRI, VirtReg.reg) && !hasTiedDef(MRI, Intf->reg))) || FixedRegisters.count(Intf->reg)) { - DEBUG(dbgs() << "Early abort: the interference is not recolorable.\n"); + LLVM_DEBUG(dbgs() << "Early abort: the interference is not recolorable.\n"); return false; } RecoloringCandidates.insert(Intf); @@ -2535,7 +2535,7 @@ SmallVectorImpl &NewVRegs, SmallVirtRegSet &FixedRegisters, unsigned Depth) { - DEBUG(dbgs() << "Try last chance recoloring for " << VirtReg << '\n'); + LLVM_DEBUG(dbgs() << "Try last chance recoloring for " << VirtReg << '\n'); // Ranges must be Done. assert((getStage(VirtReg) >= RS_Done || !VirtReg.isSpillable()) && "Last chance recoloring should really be last chance"); @@ -2544,7 +2544,7 @@ // for target with hundreds of registers. // Indeed, in that case we may want to cut the search space earlier. if (Depth >= LastChanceRecoloringMaxDepth && !ExhaustiveSearch) { - DEBUG(dbgs() << "Abort because max depth has been reached.\n"); + LLVM_DEBUG(dbgs() << "Abort because max depth has been reached.\n"); CutOffInfo |= CO_Depth; return ~0u; } @@ -2561,7 +2561,7 @@ Order.rewind(); while (unsigned PhysReg = Order.next()) { - DEBUG(dbgs() << "Try to assign: " << VirtReg << " to " + LLVM_DEBUG(dbgs() << "Try to assign: " << VirtReg << " to " << printReg(PhysReg, TRI) << '\n'); RecoloringCandidates.clear(); VirtRegToPhysReg.clear(); @@ -2570,7 +2570,7 @@ // It is only possible to recolor virtual register interference. if (Matrix->checkInterference(VirtReg, PhysReg) > LiveRegMatrix::IK_VirtReg) { - DEBUG(dbgs() << "Some interferences are not with virtual registers.\n"); + LLVM_DEBUG(dbgs() << "Some interferences are not with virtual registers.\n"); continue; } @@ -2579,7 +2579,7 @@ // the interferences. if (!mayRecolorAllInterferences(PhysReg, VirtReg, RecoloringCandidates, FixedRegisters)) { - DEBUG(dbgs() << "Some interferences cannot be recolored.\n"); + LLVM_DEBUG(dbgs() << "Some interferences cannot be recolored.\n"); continue; } @@ -2621,7 +2621,7 @@ return PhysReg; } - DEBUG(dbgs() << "Fail to assign: " << VirtReg << " to " + LLVM_DEBUG(dbgs() << "Fail to assign: " << VirtReg << " to " << printReg(PhysReg, TRI) << '\n'); // The recoloring attempt failed, undo the changes. @@ -2669,7 +2669,7 @@ unsigned Depth) { while (!RecoloringQueue.empty()) { LiveInterval *LI = dequeue(RecoloringQueue); - DEBUG(dbgs() << "Try to recolor: " << *LI << '\n'); + LLVM_DEBUG(dbgs() << "Try to recolor: " << *LI << '\n'); unsigned PhysReg; PhysReg = selectOrSplitImpl(*LI, NewVRegs, FixedRegisters, Depth + 1); // When splitting happens, the live-range may actually be empty. @@ -2681,10 +2681,10 @@ if (!PhysReg) { assert(LI->empty() && "Only empty live-range do not require a register"); - DEBUG(dbgs() << "Recoloring of " << *LI << " succeeded. Empty LI.\n"); + LLVM_DEBUG(dbgs() << "Recoloring of " << *LI << " succeeded. Empty LI.\n"); continue; } - DEBUG(dbgs() << "Recoloring of " << *LI + LLVM_DEBUG(dbgs() << "Recoloring of " << *LI << " succeeded with: " << printReg(PhysReg, TRI) << '\n'); Matrix->assign(*LI, PhysReg); @@ -2852,7 +2852,7 @@ Visited.insert(Reg); RecoloringCandidates.push_back(Reg); - DEBUG(dbgs() << "Trying to reconcile hints for: " << printReg(Reg, TRI) << '(' + LLVM_DEBUG(dbgs() << "Trying to reconcile hints for: " << printReg(Reg, TRI) << '(' << printReg(PhysReg, TRI) << ")\n"); do { @@ -2874,7 +2874,7 @@ Matrix->checkInterference(LI, PhysReg))) continue; - DEBUG(dbgs() << printReg(Reg, TRI) << '(' << printReg(CurrPhys, TRI) + LLVM_DEBUG(dbgs() << printReg(Reg, TRI) << '(' << printReg(CurrPhys, TRI) << ") is recolorable.\n"); // Gather the hint info. @@ -2883,19 +2883,19 @@ // Check if recoloring the live-range will increase the cost of the // non-identity copies. if (CurrPhys != PhysReg) { - DEBUG(dbgs() << "Checking profitability:\n"); + LLVM_DEBUG(dbgs() << "Checking profitability:\n"); BlockFrequency OldCopiesCost = getBrokenHintFreq(Info, CurrPhys); BlockFrequency NewCopiesCost = getBrokenHintFreq(Info, PhysReg); - DEBUG(dbgs() << "Old Cost: " << OldCopiesCost.getFrequency() + LLVM_DEBUG(dbgs() << "Old Cost: " << OldCopiesCost.getFrequency() << "\nNew Cost: " << NewCopiesCost.getFrequency() << '\n'); if (OldCopiesCost < NewCopiesCost) { - DEBUG(dbgs() << "=> Not profitable.\n"); + LLVM_DEBUG(dbgs() << "=> Not profitable.\n"); continue; } // At this point, the cost is either cheaper or equal. If it is // equal, we consider this is profitable because it may expose // more recoloring opportunities. - DEBUG(dbgs() << "=> Profitable.\n"); + LLVM_DEBUG(dbgs() << "=> Profitable.\n"); // Recolor the live-range. Matrix->unassign(LI); Matrix->assign(LI, PhysReg); @@ -2983,7 +2983,7 @@ } LiveRangeStage Stage = getStage(VirtReg); - DEBUG(dbgs() << StageName[Stage] + LLVM_DEBUG(dbgs() << StageName[Stage] << " Cascade " << ExtraRegInfo[VirtReg.reg].Cascade << '\n'); // Try to evict a less worthy live range, but only for ranges from the primary @@ -3013,7 +3013,7 @@ // This gives a better picture of the interference to split around. if (Stage < RS_Split) { setStage(VirtReg, RS_Split); - DEBUG(dbgs() << "wait for second round\n"); + LLVM_DEBUG(dbgs() << "wait for second round\n"); NewVRegs.push_back(VirtReg.reg); return 0; } @@ -3042,7 +3042,7 @@ // We would need a deep integration with the spiller to do the // right thing here. Anyway, that is still good for early testing. setStage(VirtReg, RS_Memory); - DEBUG(dbgs() << "Do as if this register is in memory\n"); + LLVM_DEBUG(dbgs() << "Do as if this register is in memory\n"); NewVRegs.push_back(VirtReg.reg); } else { NamedRegionTimer T("spill", "Spiller", TimerGroupName, @@ -3128,7 +3128,7 @@ } bool RAGreedy::runOnMachineFunction(MachineFunction &mf) { - DEBUG(dbgs() << "********** GREEDY REGISTER ALLOCATION **********\n" + LLVM_DEBUG(dbgs() << "********** GREEDY REGISTER ALLOCATION **********\n" << "********** Function: " << mf.getName() << '\n'); MF = &mf; @@ -3164,7 +3164,7 @@ calculateSpillWeightsAndHints(*LIS, mf, VRM, *Loops, *MBFI); - DEBUG(LIS->dump()); + LLVM_DEBUG(LIS->dump()); SA.reset(new SplitAnalysis(*VRM, *LIS, *Loops)); SE.reset(new SplitEditor(*SA, *AA, *LIS, *VRM, *DomTree, *MBFI)); Index: lib/CodeGen/RegAllocPBQP.cpp =================================================================== --- lib/CodeGen/RegAllocPBQP.cpp +++ lib/CodeGen/RegAllocPBQP.cpp @@ -684,7 +684,7 @@ const TargetRegisterInfo &TRI = *MF.getSubtarget().getRegisterInfo(); (void)TRI; - DEBUG(dbgs() << "VREG " << printReg(VReg, &TRI) << " -> SPILLED (Cost: " + LLVM_DEBUG(dbgs() << "VREG " << printReg(VReg, &TRI) << " -> SPILLED (Cost: " << LRE.getParent().weight << ", New vregs: "); // Copy any newly inserted live intervals into the list of regs to @@ -693,11 +693,11 @@ I != E; ++I) { const LiveInterval &LI = LIS.getInterval(*I); assert(!LI.empty() && "Empty spill range."); - DEBUG(dbgs() << printReg(LI.reg, &TRI) << " "); + LLVM_DEBUG(dbgs() << printReg(LI.reg, &TRI) << " "); VRegsToAlloc.insert(LI.reg); } - DEBUG(dbgs() << ")\n"); + LLVM_DEBUG(dbgs() << ")\n"); } bool RegAllocPBQP::mapPBQPToRegAlloc(const PBQPRAGraph &G, @@ -723,7 +723,7 @@ if (AllocOption != PBQP::RegAlloc::getSpillOptionIdx()) { unsigned PReg = G.getNodeMetadata(NId).getAllowedRegs()[AllocOption - 1]; - DEBUG(dbgs() << "VREG " << printReg(VReg, &TRI) << " -> " + LLVM_DEBUG(dbgs() << "VREG " << printReg(VReg, &TRI) << " -> " << TRI.getName(PReg) << "\n"); assert(PReg != 0 && "Invalid preg selected."); VRM.assignVirt2Phys(VReg, PReg); @@ -800,7 +800,7 @@ MF.getRegInfo().freezeReservedRegs(MF); - DEBUG(dbgs() << "PBQP Register Allocating for " << MF.getName() << "\n"); + LLVM_DEBUG(dbgs() << "PBQP Register Allocating for " << MF.getName() << "\n"); // Allocator main loop: // @@ -835,7 +835,7 @@ unsigned Round = 0; while (!PBQPAllocComplete) { - DEBUG(dbgs() << " PBQP Regalloc round " << Round << ":\n"); + LLVM_DEBUG(dbgs() << " PBQP Regalloc round " << Round << ":\n"); PBQPRAGraph G(PBQPRAGraph::GraphMetadata(MF, LIS, MBFI)); initializeGraph(G, VRM, *VRegSpiller); @@ -849,7 +849,7 @@ ".pbqpgraph"; std::error_code EC; raw_fd_ostream OS(GraphFileName, EC, sys::fs::F_Text); - DEBUG(dbgs() << "Dumping graph for round " << Round << " to \"" + LLVM_DEBUG(dbgs() << "Dumping graph for round " << Round << " to \"" << GraphFileName << "\"\n"); G.dump(OS); } @@ -867,7 +867,7 @@ VRegsToAlloc.clear(); EmptyIntervalVRegs.clear(); - DEBUG(dbgs() << "Post alloc VirtRegMap:\n" << VRM << "\n"); + LLVM_DEBUG(dbgs() << "Post alloc VirtRegMap:\n" << VRM << "\n"); return true; } Index: lib/CodeGen/RegUsageInfoCollector.cpp =================================================================== --- lib/CodeGen/RegUsageInfoCollector.cpp +++ lib/CodeGen/RegUsageInfoCollector.cpp @@ -83,9 +83,9 @@ const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo(); const TargetMachine &TM = MF.getTarget(); - DEBUG(dbgs() << " -------------------- " << getPassName() + LLVM_DEBUG(dbgs() << " -------------------- " << getPassName() << " -------------------- \n"); - DEBUG(dbgs() << "Function Name : " << MF.getName() << "\n"); + LLVM_DEBUG(dbgs() << "Function Name : " << MF.getName() << "\n"); std::vector RegMask; @@ -101,7 +101,7 @@ PRUI->setTargetMachine(&TM); - DEBUG(dbgs() << "Clobbered Registers: "); + LLVM_DEBUG(dbgs() << "Clobbered Registers: "); const BitVector &UsedPhysRegsMask = MRI->getUsedPhysRegsMask(); auto SetRegAsDefined = [&RegMask] (unsigned Reg) { @@ -135,15 +135,15 @@ } } else { ++NumCSROpt; - DEBUG(dbgs() << MF.getName() + LLVM_DEBUG(dbgs() << MF.getName() << " function optimized for not having CSR.\n"); } for (unsigned PReg = 1, PRegE = TRI->getNumRegs(); PReg < PRegE; ++PReg) if (MachineOperand::clobbersPhysReg(&(RegMask[0]), PReg)) - DEBUG(dbgs() << printReg(PReg, TRI) << " "); + LLVM_DEBUG(dbgs() << printReg(PReg, TRI) << " "); - DEBUG(dbgs() << " \n----------------------------------------\n"); + LLVM_DEBUG(dbgs() << " \n----------------------------------------\n"); PRUI->storeUpdateRegUsageInfo(&F, std::move(RegMask)); Index: lib/CodeGen/RegUsageInfoPropagate.cpp =================================================================== --- lib/CodeGen/RegUsageInfoPropagate.cpp +++ lib/CodeGen/RegUsageInfoPropagate.cpp @@ -105,9 +105,9 @@ const Module *M = MF.getFunction().getParent(); PhysicalRegisterUsageInfo *PRUI = &getAnalysis(); - DEBUG(dbgs() << " ++++++++++++++++++++ " << getPassName() + LLVM_DEBUG(dbgs() << " ++++++++++++++++++++ " << getPassName() << " ++++++++++++++++++++ \n"); - DEBUG(dbgs() << "MachineFunction : " << MF.getName() << "\n"); + LLVM_DEBUG(dbgs() << "MachineFunction : " << MF.getName() << "\n"); const MachineFrameInfo &MFI = MF.getFrameInfo(); if (!MFI.hasCalls() && !MFI.hasTailCall()) @@ -119,9 +119,9 @@ for (MachineInstr &MI : MBB) { if (!MI.isCall()) continue; - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "Call Instruction Before Register Usage Info Propagation : \n"); - DEBUG(dbgs() << MI << "\n"); + LLVM_DEBUG(dbgs() << MI << "\n"); auto UpdateRegMask = [&](const Function *F) { const auto *RegMask = PRUI->getRegUsageInfo(F); @@ -134,15 +134,15 @@ if (const Function *F = findCalledFunction(*M, MI)) { UpdateRegMask(F); } else { - DEBUG(dbgs() << "Failed to find call target function\n"); + LLVM_DEBUG(dbgs() << "Failed to find call target function\n"); } - DEBUG(dbgs() << "Call Instruction After Register Usage Info Propagation : " + LLVM_DEBUG(dbgs() << "Call Instruction After Register Usage Info Propagation : " << MI << '\n'); } } - DEBUG(dbgs() << " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" + LLVM_DEBUG(dbgs() << " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" "++++++ \n"); return Changed; } Index: lib/CodeGen/RegisterClassInfo.cpp =================================================================== --- lib/CodeGen/RegisterClassInfo.cpp +++ lib/CodeGen/RegisterClassInfo.cpp @@ -151,7 +151,7 @@ RCI.MinCost = uint8_t(MinCost); RCI.LastCostChange = LastCostChange; - DEBUG({ + LLVM_DEBUG({ dbgs() << "AllocationOrder(" << TRI->getRegClassName(RC) << ") = ["; for (unsigned I = 0; I != RCI.NumRegs; ++I) dbgs() << ' ' << printReg(RCI.Order[I], TRI); Index: lib/CodeGen/RegisterCoalescer.cpp =================================================================== --- lib/CodeGen/RegisterCoalescer.cpp +++ lib/CodeGen/RegisterCoalescer.cpp @@ -568,7 +568,7 @@ // in IntB, we can merge them. if (ValS+1 != BS) return false; - DEBUG(dbgs() << "Extending: " << printReg(IntB.reg, TRI)); + LLVM_DEBUG(dbgs() << "Extending: " << printReg(IntB.reg, TRI)); SlotIndex FillerStart = ValS->end, FillerEnd = BS->start; // We are about to delete CopyMI, so need to remove it as the 'instruction @@ -594,7 +594,7 @@ S.MergeValueNumberInto(SubBValNo, SubValSNo); } - DEBUG(dbgs() << " result = " << IntB << '\n'); + LLVM_DEBUG(dbgs() << " result = " << IntB << '\n'); // If the source instruction was killing the source register before the // merge, unset the isKill marker given the live range has been extended. @@ -742,7 +742,7 @@ return false; } - DEBUG(dbgs() << "\tremoveCopyByCommutingDef: " << AValNo->def << '\t' + LLVM_DEBUG(dbgs() << "\tremoveCopyByCommutingDef: " << AValNo->def << '\t' << *DefMI); // At this point we have decided that it is legal to do this @@ -812,7 +812,7 @@ VNInfo *DVNI = IntB.getVNInfoAt(DefIdx); if (!DVNI) continue; - DEBUG(dbgs() << "\t\tnoop: " << DefIdx << '\t' << *UseMI); + LLVM_DEBUG(dbgs() << "\t\tnoop: " << DefIdx << '\t' << *UseMI); assert(DVNI->def == DefIdx); BValNo = IntB.MergeValueNumberInto(DVNI, BValNo); for (LiveInterval::SubRange &S : IntB.subranges()) { @@ -853,11 +853,11 @@ BValNo->def = AValNo->def; addSegmentsWithValNo(IntB, BValNo, IntA, AValNo); - DEBUG(dbgs() << "\t\textended: " << IntB << '\n'); + LLVM_DEBUG(dbgs() << "\t\textended: " << IntB << '\n'); LIS->removeVRegDefAt(IntA, AValNo->def); - DEBUG(dbgs() << "\t\ttrimmed: " << IntA << '\n'); + LLVM_DEBUG(dbgs() << "\t\ttrimmed: " << IntA << '\n'); ++numCommutes; return true; } @@ -991,7 +991,7 @@ // Now ok to move copy. if (CopyLeftBB) { - DEBUG(dbgs() << "\tremovePartialRedundancy: Move the copy to " + LLVM_DEBUG(dbgs() << "\tremovePartialRedundancy: Move the copy to " << printMBBReference(*CopyLeftBB) << '\t' << CopyMI); // Insert new copy to CopyLeftBB. @@ -1010,7 +1010,7 @@ // the deleted list. ErasedInstrs.erase(NewCopyMI); } else { - DEBUG(dbgs() << "\tremovePartialRedundancy: Remove the copy from " + LLVM_DEBUG(dbgs() << "\tremovePartialRedundancy: Remove the copy from " << printMBBReference(MBB) << '\t' << CopyMI); } @@ -1266,7 +1266,7 @@ bool UpdatedSubRanges = false; for (LiveInterval::SubRange &SR : DstInt.subranges()) { if ((SR.LaneMask & DstMask).none()) { - DEBUG(dbgs() << "Removing undefined SubRange " + LLVM_DEBUG(dbgs() << "Removing undefined SubRange " << PrintLaneMask(SR.LaneMask) << " : " << SR << "\n"); // VNI is in ValNo - remove any segments in this SubRange that have this ValNo if (VNInfo *RmValNo = SR.getVNInfoAt(CurrIdx.getRegSlot())) { @@ -1324,7 +1324,7 @@ LR->createDeadDef(NewMIIdx.getRegSlot(), LIS->getVNInfoAllocator()); } - DEBUG(dbgs() << "Remat: " << NewMI); + LLVM_DEBUG(dbgs() << "Remat: " << NewMI); ++NumReMats; // The source interval can become smaller because we removed a use. @@ -1339,7 +1339,7 @@ // Move the debug value directly after the def of the rematerialized // value in DstReg. MBB->splice(std::next(NewMI.getIterator()), UseMI->getParent(), UseMI); - DEBUG(dbgs() << "\t\tupdated: " << *UseMI); + LLVM_DEBUG(dbgs() << "\t\tupdated: " << *UseMI); } } eliminateDeadDefs(); @@ -1377,7 +1377,7 @@ } else if (SrcLI.liveAt(Idx)) return false; - DEBUG(dbgs() << "\tEliminating copy of value\n"); + LLVM_DEBUG(dbgs() << "\tEliminating copy of value\n"); // Remove any DstReg segments starting at the instruction. LiveInterval &DstLI = LIS->getInterval(DstReg); @@ -1424,7 +1424,7 @@ if (isLive) continue; MO.setIsUndef(true); - DEBUG(dbgs() << "\tnew undef: " << UseIdx << '\t' << MI); + LLVM_DEBUG(dbgs() << "\tnew undef: " << UseIdx << '\t' << MI); } // A def of a subregister may be a use of the other subregisters, so @@ -1539,7 +1539,7 @@ MO.substVirtReg(DstReg, SubIdx, *TRI); } - DEBUG({ + LLVM_DEBUG({ dbgs() << "\t\tupdated: "; if (!UseMI->isDebugValue()) dbgs() << LIS->getInstructionIndex(*UseMI) << "\t"; @@ -1553,7 +1553,7 @@ // reserved register. This doesn't increase register pressure, so it is // always beneficial. if (!MRI->isReserved(CP.getDstReg())) { - DEBUG(dbgs() << "\tCan only merge into reserved registers.\n"); + LLVM_DEBUG(dbgs() << "\tCan only merge into reserved registers.\n"); return false; } @@ -1561,17 +1561,17 @@ if (JoinVInt.containsOneValue()) return true; - DEBUG(dbgs() << "\tCannot join complex intervals into reserved register.\n"); + LLVM_DEBUG(dbgs() << "\tCannot join complex intervals into reserved register.\n"); return false; } bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, bool &Again) { Again = false; - DEBUG(dbgs() << LIS->getInstructionIndex(*CopyMI) << '\t' << *CopyMI); + LLVM_DEBUG(dbgs() << LIS->getInstructionIndex(*CopyMI) << '\t' << *CopyMI); CoalescerPair CP(*TRI); if (!CP.setRegisters(CopyMI)) { - DEBUG(dbgs() << "\tNot coalescable.\n"); + LLVM_DEBUG(dbgs() << "\tNot coalescable.\n"); return false; } @@ -1586,7 +1586,7 @@ } if (!TRI->shouldCoalesce(CopyMI, SrcRC, SrcIdx, DstRC, DstIdx, CP.getNewRC(), *LIS)) { - DEBUG(dbgs() << "\tSubtarget bailed on coalescing.\n"); + LLVM_DEBUG(dbgs() << "\tSubtarget bailed on coalescing.\n"); return false; } } @@ -1595,7 +1595,7 @@ // sometimes dead copies slip through, and we can't generate invalid live // ranges. if (!CP.isPhys() && CopyMI->allDefsAreDead()) { - DEBUG(dbgs() << "\tCopy is dead.\n"); + LLVM_DEBUG(dbgs() << "\tCopy is dead.\n"); DeadDefs.push_back(CopyMI); eliminateDeadDefs(); return true; @@ -1612,7 +1612,7 @@ // When that happens, just join the values and remove the copy. if (CP.getSrcReg() == CP.getDstReg()) { LiveInterval &LI = LIS->getInterval(CP.getSrcReg()); - DEBUG(dbgs() << "\tCopy already coalesced: " << LI << '\n'); + LLVM_DEBUG(dbgs() << "\tCopy already coalesced: " << LI << '\n'); const SlotIndex CopyIdx = LIS->getInstructionIndex(*CopyMI); LiveQueryResult LRQ = LI.Query(CopyIdx); if (VNInfo *DefVNI = LRQ.valueDefined()) { @@ -1629,7 +1629,7 @@ S.MergeValueNumberInto(SDefVNI, SReadVNI); } } - DEBUG(dbgs() << "\tMerged values: " << LI << '\n'); + LLVM_DEBUG(dbgs() << "\tMerged values: " << LI << '\n'); } deleteInstr(CopyMI); return true; @@ -1637,7 +1637,7 @@ // Enforce policies. if (CP.isPhys()) { - DEBUG(dbgs() << "\tConsidering merging " << printReg(CP.getSrcReg(), TRI) + LLVM_DEBUG(dbgs() << "\tConsidering merging " << printReg(CP.getSrcReg(), TRI) << " with " << printReg(CP.getDstReg(), TRI, CP.getSrcIdx()) << '\n'); if (!canJoinPhys(CP)) { @@ -1656,7 +1656,7 @@ LIS->getInterval(CP.getDstReg()).size()) CP.flip(); - DEBUG({ + LLVM_DEBUG({ dbgs() << "\tConsidering merging to " << TRI->getRegClassName(CP.getNewRC()) << " with "; if (CP.getDstIdx() && CP.getSrcIdx()) @@ -1692,7 +1692,7 @@ if (adjustCopiesBackFrom(CP, CopyMI) || removeCopyByCommutingDef(CP, CopyMI)) { deleteInstr(CopyMI); - DEBUG(dbgs() << "\tTrivial!\n"); + LLVM_DEBUG(dbgs() << "\tTrivial!\n"); return true; } } @@ -1704,7 +1704,7 @@ return true; // Otherwise, we are unable to join the intervals. - DEBUG(dbgs() << "\tInterference!\n"); + LLVM_DEBUG(dbgs() << "\tInterference!\n"); Again = true; // May be possible to coalesce later. return false; } @@ -1738,7 +1738,7 @@ for (LiveInterval::SubRange &S : LI.subranges()) { if ((S.LaneMask & ShrinkMask).none()) continue; - DEBUG(dbgs() << "Shrink LaneUses (Lane " << PrintLaneMask(S.LaneMask) + LLVM_DEBUG(dbgs() << "Shrink LaneUses (Lane " << PrintLaneMask(S.LaneMask) << ")\n"); LIS->shrinkToUses(S, LI.reg); } @@ -1756,7 +1756,7 @@ // Update regalloc hint. TRI->updateRegAllocHint(CP.getSrcReg(), CP.getDstReg(), *MF); - DEBUG({ + LLVM_DEBUG({ dbgs() << "\tSuccess: " << printReg(CP.getSrcReg(), TRI, CP.getSrcIdx()) << " -> " << printReg(CP.getDstReg(), TRI, CP.getDstIdx()) << '\n'; dbgs() << "\tResult = "; @@ -1777,7 +1777,7 @@ assert(CP.isPhys() && "Must be a physreg copy"); assert(MRI->isReserved(DstReg) && "Not a reserved register"); LiveInterval &RHS = LIS->getInterval(SrcReg); - DEBUG(dbgs() << "\t\tRHS = " << RHS << '\n'); + LLVM_DEBUG(dbgs() << "\t\tRHS = " << RHS << '\n'); assert(RHS.containsOneValue() && "Invalid join with reserved register"); @@ -1796,7 +1796,7 @@ return false; } if (RHS.overlaps(LIS->getRegUnit(*UI))) { - DEBUG(dbgs() << "\t\tInterference: " << printRegUnit(*UI, TRI) << '\n'); + LLVM_DEBUG(dbgs() << "\t\tInterference: " << printRegUnit(*UI, TRI) << '\n'); return false; } } @@ -1805,7 +1805,7 @@ BitVector RegMaskUsable; if (LIS->checkRegMaskInterference(RHS, RegMaskUsable) && !RegMaskUsable.test(DstReg)) { - DEBUG(dbgs() << "\t\tRegMask interference\n"); + LLVM_DEBUG(dbgs() << "\t\tRegMask interference\n"); return false; } } @@ -1835,12 +1835,12 @@ // %y = def // ... if (!MRI->hasOneNonDBGUse(SrcReg)) { - DEBUG(dbgs() << "\t\tMultiple vreg uses!\n"); + LLVM_DEBUG(dbgs() << "\t\tMultiple vreg uses!\n"); return false; } if (!LIS->intervalIsInOneMBB(RHS)) { - DEBUG(dbgs() << "\t\tComplex control flow!\n"); + LLVM_DEBUG(dbgs() << "\t\tComplex control flow!\n"); return false; } @@ -1858,7 +1858,7 @@ SI != CopyRegIdx; SI = Indexes->getNextNonNullIndex(SI)) { MachineInstr *MI = LIS->getInstructionFromIndex(SI); if (MI->readsRegister(DstReg, TRI)) { - DEBUG(dbgs() << "\t\tInterference (read): " << *MI); + LLVM_DEBUG(dbgs() << "\t\tInterference (read): " << *MI); return false; } } @@ -1866,7 +1866,7 @@ // We're going to remove the copy which defines a physical reserved // register, so remove its valno, etc. - DEBUG(dbgs() << "\t\tRemoving phys reg def of " << printReg(DstReg, TRI) + LLVM_DEBUG(dbgs() << "\t\tRemoving phys reg def of " << printReg(DstReg, TRI) << " at " << CopyRegIdx << "\n"); LIS->removePhysRegDefAt(DstReg, CopyRegIdx); @@ -2375,7 +2375,7 @@ // to erase the IMPLICIT_DEF instruction. if (OtherV.ErasableImplicitDef && DefMI && DefMI->getParent() != Indexes->getMBBFromIndex(V.OtherVNI->def)) { - DEBUG(dbgs() << "IMPLICIT_DEF defined at " << V.OtherVNI->def + LLVM_DEBUG(dbgs() << "IMPLICIT_DEF defined at " << V.OtherVNI->def << " extends into " << printMBBReference(*DefMI->getParent()) << ", keeping it.\n"); OtherV.ErasableImplicitDef = false; @@ -2487,7 +2487,7 @@ assert(V.OtherVNI && "OtherVNI not assigned, can't merge."); assert(Other.Vals[V.OtherVNI->id].isAnalyzed() && "Missing recursion"); Assignments[ValNo] = Other.Assignments[V.OtherVNI->id]; - DEBUG(dbgs() << "\t\tmerge " << printReg(Reg) << ':' << ValNo << '@' + LLVM_DEBUG(dbgs() << "\t\tmerge " << printReg(Reg) << ':' << ValNo << '@' << LR.getValNumInfo(ValNo)->def << " into " << printReg(Other.Reg) << ':' << V.OtherVNI->id << '@' << V.OtherVNI->def << " --> @" @@ -2517,7 +2517,7 @@ for (unsigned i = 0, e = LR.getNumValNums(); i != e; ++i) { computeAssignment(i, Other); if (Vals[i].Resolution == CR_Impossible) { - DEBUG(dbgs() << "\t\tinterference at " << printReg(Reg) << ':' << i + LLVM_DEBUG(dbgs() << "\t\tinterference at " << printReg(Reg) << ':' << i << '@' << LR.getValNumInfo(i)->def << '\n'); return false; } @@ -2540,11 +2540,11 @@ // lanes escape the block. SlotIndex End = OtherI->end; if (End >= MBBEnd) { - DEBUG(dbgs() << "\t\ttaints global " << printReg(Other.Reg) << ':' + LLVM_DEBUG(dbgs() << "\t\ttaints global " << printReg(Other.Reg) << ':' << OtherI->valno->id << '@' << OtherI->start << '\n'); return false; } - DEBUG(dbgs() << "\t\ttaints local " << printReg(Other.Reg) << ':' + LLVM_DEBUG(dbgs() << "\t\ttaints local " << printReg(Other.Reg) << ':' << OtherI->valno->id << '@' << OtherI->start << " to " << End << '\n'); // A dead def is not a problem. @@ -2587,7 +2587,7 @@ assert(V.Resolution != CR_Impossible && "Unresolvable conflict"); if (V.Resolution != CR_Unresolved) continue; - DEBUG(dbgs() << "\t\tconflict at " << printReg(Reg) << ':' << i + LLVM_DEBUG(dbgs() << "\t\tconflict at " << printReg(Reg) << ':' << i << '@' << LR.getValNumInfo(i)->def << '\n'); if (SubRangeJoin) return false; @@ -2625,7 +2625,7 @@ while (true) { assert(MI != MBB->end() && "Bad LastMI"); if (usesLanes(*MI, Other.Reg, Other.SubIdx, TaintedLanes)) { - DEBUG(dbgs() << "\t\ttainted lanes used by: " << *MI); + LLVM_DEBUG(dbgs() << "\t\ttainted lanes used by: " << *MI); return false; } // LastMI is the last instruction to use the current value. @@ -2698,7 +2698,7 @@ if (!EraseImpDef) EndPoints.push_back(Def); } - DEBUG(dbgs() << "\t\tpruned " << printReg(Other.Reg) << " at " << Def + LLVM_DEBUG(dbgs() << "\t\tpruned " << printReg(Other.Reg) << " at " << Def << ": " << Other.LR << '\n'); break; } @@ -2710,7 +2710,7 @@ // computeAssignment(), the value that was originally copied could have // been replaced. LIS->pruneValue(LR, Def, &EndPoints); - DEBUG(dbgs() << "\t\tpruned all of " << printReg(Reg) << " at " + LLVM_DEBUG(dbgs() << "\t\tpruned all of " << printReg(Reg) << " at " << Def << ": " << LR << '\n'); } break; @@ -2735,7 +2735,7 @@ // Check subranges at the point where the copy will be removed. SlotIndex Def = LR.getValNumInfo(i)->def; // Print message so mismatches with eraseInstrs() can be diagnosed. - DEBUG(dbgs() << "\t\tExpecting instruction removal at " << Def << '\n'); + LLVM_DEBUG(dbgs() << "\t\tExpecting instruction removal at " << Def << '\n'); for (LiveInterval::SubRange &S : LI.subranges()) { LiveQueryResult Q = S.Query(Def); @@ -2743,7 +2743,7 @@ // copied and we must remove that subrange value as well. VNInfo *ValueOut = Q.valueOutOrDead(); if (ValueOut != nullptr && Q.valueIn() == nullptr) { - DEBUG(dbgs() << "\t\tPrune sublane " << PrintLaneMask(S.LaneMask) + LLVM_DEBUG(dbgs() << "\t\tPrune sublane " << PrintLaneMask(S.LaneMask) << " at " << Def << "\n"); LIS->pruneValue(S, Def, nullptr); DidPrune = true; @@ -2754,7 +2754,7 @@ // If a subrange ends at the copy, then a value was copied but only // partially used later. Shrink the subregister range appropriately. if (Q.valueIn() != nullptr && Q.valueOut() == nullptr) { - DEBUG(dbgs() << "\t\tDead uses at sublane " << PrintLaneMask(S.LaneMask) + LLVM_DEBUG(dbgs() << "\t\tDead uses at sublane " << PrintLaneMask(S.LaneMask) << " at " << Def << "\n"); ShrinkMask |= S.LaneMask; } @@ -2867,7 +2867,7 @@ std::prev(S)->end = NewEnd; } } - DEBUG({ + LLVM_DEBUG({ dbgs() << "\t\tremoved " << i << '@' << Def << ": " << LR << '\n'; if (LI != nullptr) dbgs() << "\t\t LHS = " << *LI << '\n'; @@ -2885,7 +2885,7 @@ ShrinkRegs.push_back(Reg); } ErasedInstrs.insert(MI); - DEBUG(dbgs() << "\t\terased:\t" << Def << '\t' << *MI); + LLVM_DEBUG(dbgs() << "\t\terased:\t" << Def << '\t' << *MI); LIS->RemoveMachineInstrFromMaps(*MI); MI->eraseFromParent(); break; @@ -2940,13 +2940,13 @@ LRange.join(RRange, LHSVals.getAssignments(), RHSVals.getAssignments(), NewVNInfo); - DEBUG(dbgs() << "\t\tjoined lanes: " << LRange << "\n"); + LLVM_DEBUG(dbgs() << "\t\tjoined lanes: " << LRange << "\n"); if (EndPoints.empty()) return; // Recompute the parts of the live range we had to remove because of // CR_Replace conflicts. - DEBUG({ + LLVM_DEBUG({ dbgs() << "\t\trestoring liveness to " << EndPoints.size() << " points: "; for (unsigned i = 0, n = EndPoints.size(); i != n; ++i) { dbgs() << EndPoints[i]; @@ -2985,7 +2985,7 @@ JoinVals LHSVals(LHS, CP.getDstReg(), CP.getDstIdx(), LaneBitmask::getNone(), NewVNInfo, CP, LIS, TRI, false, TrackSubRegLiveness); - DEBUG(dbgs() << "\t\tRHS = " << RHS + LLVM_DEBUG(dbgs() << "\t\tRHS = " << RHS << "\n\t\tLHS = " << LHS << '\n'); @@ -3018,7 +3018,7 @@ R.LaneMask = Mask; } } - DEBUG(dbgs() << "\t\tLHST = " << printReg(CP.getDstReg()) + LLVM_DEBUG(dbgs() << "\t\tLHST = " << printReg(CP.getDstReg()) << ' ' << LHS << '\n'); // Determine lanemasks of RHS in the coalesced register and merge subranges. @@ -3034,7 +3034,7 @@ mergeSubRangeInto(LHS, R, Mask, CP); } } - DEBUG(dbgs() << "\tJoined SubRanges " << LHS << "\n"); + LLVM_DEBUG(dbgs() << "\tJoined SubRanges " << LHS << "\n"); // Pruning implicit defs from subranges may result in the main range // having stale segments. @@ -3072,7 +3072,7 @@ if (!EndPoints.empty()) { // Recompute the parts of the live range we had to remove because of // CR_Replace conflicts. - DEBUG({ + LLVM_DEBUG({ dbgs() << "\t\trestoring liveness to " << EndPoints.size() << " points: "; for (unsigned i = 0, n = EndPoints.size(); i != n; ++i) { dbgs() << EndPoints[i]; @@ -3220,7 +3220,7 @@ continue; // Check that OtherReg interfere with DstReg. if (LIS->getInterval(OtherReg).overlaps(DstLI)) { - DEBUG(dbgs() << "Apply terminal rule for: " << printReg(DstReg) << '\n'); + LLVM_DEBUG(dbgs() << "Apply terminal rule for: " << printReg(DstReg) << '\n'); return true; } } @@ -3229,7 +3229,7 @@ void RegisterCoalescer::copyCoalesceInMBB(MachineBasicBlock *MBB) { - DEBUG(dbgs() << MBB->getName() << ":\n"); + LLVM_DEBUG(dbgs() << MBB->getName() << ":\n"); // Collect all copy-like instructions in MBB. Don't start coalescing anything // yet, it might invalidate the iterator. @@ -3294,7 +3294,7 @@ } void RegisterCoalescer::joinAllIntervals() { - DEBUG(dbgs() << "********** JOINING INTERVALS ***********\n"); + LLVM_DEBUG(dbgs() << "********** JOINING INTERVALS ***********\n"); assert(WorkList.empty() && LocalWorkList.empty() && "Old data still around."); std::vector MBBs; @@ -3350,7 +3350,7 @@ // splitting optimization. JoinSplitEdges = EnableJoinSplits; - DEBUG(dbgs() << "********** SIMPLE REGISTER COALESCING **********\n" + LLVM_DEBUG(dbgs() << "********** SIMPLE REGISTER COALESCING **********\n" << "********** Function: " << MF->getName() << '\n'); if (VerifyCoalescing) @@ -3368,13 +3368,13 @@ array_pod_sort(InflateRegs.begin(), InflateRegs.end()); InflateRegs.erase(std::unique(InflateRegs.begin(), InflateRegs.end()), InflateRegs.end()); - DEBUG(dbgs() << "Trying to inflate " << InflateRegs.size() << " regs.\n"); + LLVM_DEBUG(dbgs() << "Trying to inflate " << InflateRegs.size() << " regs.\n"); for (unsigned i = 0, e = InflateRegs.size(); i != e; ++i) { unsigned Reg = InflateRegs[i]; if (MRI->reg_nodbg_empty(Reg)) continue; if (MRI->recomputeRegClass(Reg)) { - DEBUG(dbgs() << printReg(Reg) << " inflated to " + LLVM_DEBUG(dbgs() << printReg(Reg) << " inflated to " << TRI->getRegClassName(MRI->getRegClass(Reg)) << '\n'); ++NumInflated; @@ -3398,7 +3398,7 @@ } } - DEBUG(dump()); + LLVM_DEBUG(dump()); if (VerifyCoalescing) MF->verify(this, "After register coalescing"); return true; Index: lib/CodeGen/RegisterScavenging.cpp =================================================================== --- lib/CodeGen/RegisterScavenging.cpp +++ lib/CodeGen/RegisterScavenging.cpp @@ -288,7 +288,7 @@ unsigned RegScavenger::FindUnusedReg(const TargetRegisterClass *RC) const { for (unsigned Reg : *RC) { if (!isRegUsed(Reg)) { - DEBUG(dbgs() << "Scavenger found unused reg: " << printReg(Reg, TRI) + LLVM_DEBUG(dbgs() << "Scavenger found unused reg: " << printReg(Reg, TRI) << "\n"); return Reg; } @@ -561,14 +561,14 @@ // If we found an unused register there is no reason to spill it. if (!isRegUsed(SReg)) { - DEBUG(dbgs() << "Scavenged register: " << printReg(SReg, TRI) << "\n"); + LLVM_DEBUG(dbgs() << "Scavenged register: " << printReg(SReg, TRI) << "\n"); return SReg; } ScavengedInfo &Scavenged = spill(SReg, *RC, SPAdj, I, UseMI); Scavenged.Restore = &*std::prev(UseMI); - DEBUG(dbgs() << "Scavenged register (with spill): " << printReg(SReg, TRI) + LLVM_DEBUG(dbgs() << "Scavenged register (with spill): " << printReg(SReg, TRI) << "\n"); return SReg; @@ -594,14 +594,14 @@ MachineBasicBlock::iterator ReloadAfter = RestoreAfter ? std::next(MBBI) : MBBI; MachineBasicBlock::iterator ReloadBefore = std::next(ReloadAfter); - DEBUG(dbgs() << "Reload before: " << *ReloadBefore << '\n'); + LLVM_DEBUG(dbgs() << "Reload before: " << *ReloadBefore << '\n'); ScavengedInfo &Scavenged = spill(Reg, RC, SPAdj, SpillBefore, ReloadBefore); Scavenged.Restore = &*std::prev(SpillBefore); LiveUnits.removeReg(Reg); - DEBUG(dbgs() << "Scavenged register with spill: " << printReg(Reg, TRI) + LLVM_DEBUG(dbgs() << "Scavenged register with spill: " << printReg(Reg, TRI) << " until " << *SpillBefore); } else { - DEBUG(dbgs() << "Scavenged free register: " << printReg(Reg, TRI) << '\n'); + LLVM_DEBUG(dbgs() << "Scavenged free register: " << printReg(Reg, TRI) << '\n'); } return Reg; } @@ -757,7 +757,7 @@ bool Again = scavengeFrameVirtualRegsInBlock(MRI, RS, MBB); if (Again) { - DEBUG(dbgs() << "Warning: Required two scavenging passes for block " + LLVM_DEBUG(dbgs() << "Warning: Required two scavenging passes for block " << MBB.getName() << '\n'); Again = scavengeFrameVirtualRegsInBlock(MRI, RS, MBB); // The target required a 2nd run (because it created new vregs while Index: lib/CodeGen/RenameIndependentSubregs.cpp =================================================================== --- lib/CodeGen/RenameIndependentSubregs.cpp +++ lib/CodeGen/RenameIndependentSubregs.cpp @@ -134,17 +134,17 @@ const TargetRegisterClass *RegClass = MRI->getRegClass(Reg); SmallVector Intervals; Intervals.push_back(&LI); - DEBUG(dbgs() << printReg(Reg) << ": Found " << Classes.getNumClasses() + LLVM_DEBUG(dbgs() << printReg(Reg) << ": Found " << Classes.getNumClasses() << " equivalence classes.\n"); - DEBUG(dbgs() << printReg(Reg) << ": Splitting into newly created:"); + LLVM_DEBUG(dbgs() << printReg(Reg) << ": Splitting into newly created:"); for (unsigned I = 1, NumClasses = Classes.getNumClasses(); I < NumClasses; ++I) { unsigned NewVReg = MRI->createVirtualRegister(RegClass); LiveInterval &NewLI = LIS->createEmptyInterval(NewVReg); Intervals.push_back(&NewLI); - DEBUG(dbgs() << ' ' << printReg(NewVReg)); + LLVM_DEBUG(dbgs() << ' ' << printReg(NewVReg)); } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); rewriteOperands(Classes, SubRangeInfos, Intervals); distribute(Classes, SubRangeInfos, Intervals); @@ -376,7 +376,7 @@ if (!MRI->subRegLivenessEnabled()) return false; - DEBUG(dbgs() << "Renaming independent subregister live ranges in " + LLVM_DEBUG(dbgs() << "Renaming independent subregister live ranges in " << MF.getName() << '\n'); LIS = &getAnalysis(); Index: lib/CodeGen/ResetMachineFunctionPass.cpp =================================================================== --- lib/CodeGen/ResetMachineFunctionPass.cpp +++ lib/CodeGen/ResetMachineFunctionPass.cpp @@ -47,7 +47,7 @@ MachineFunctionProperties::Property::FailedISel)) { if (AbortOnFailedISel) report_fatal_error("Instruction selection failed"); - DEBUG(dbgs() << "Resetting: " << MF.getName() << '\n'); + LLVM_DEBUG(dbgs() << "Resetting: " << MF.getName() << '\n'); ++NumFunctionsReset; MF.reset(); if (EmitFallbackDiag) { Index: lib/CodeGen/SafeStack.cpp =================================================================== --- lib/CodeGen/SafeStack.cpp +++ lib/CodeGen/SafeStack.cpp @@ -242,7 +242,7 @@ ConstantRange(APInt(BitWidth, 0), APInt(BitWidth, AllocaSize)); bool Safe = AllocaRange.contains(AccessRange); - DEBUG(dbgs() << "[SafeStack] " + LLVM_DEBUG(dbgs() << "[SafeStack] " << (isa(AllocaPtr) ? "Alloca " : "ByValArgument ") << *AllocaPtr << "\n" << " Access " << *Addr << "\n" @@ -298,7 +298,7 @@ case Instruction::Store: if (V == I->getOperand(0)) { // Stored the pointer - conservatively assume it may be unsafe. - DEBUG(dbgs() << "[SafeStack] Unsafe alloca: " << *AllocaPtr + LLVM_DEBUG(dbgs() << "[SafeStack] Unsafe alloca: " << *AllocaPtr << "\n store of address: " << *I << "\n"); return false; } @@ -324,7 +324,7 @@ if (const MemIntrinsic *MI = dyn_cast(I)) { if (!IsMemIntrinsicSafe(MI, UI, AllocaPtr, AllocaSize)) { - DEBUG(dbgs() << "[SafeStack] Unsafe alloca: " << *AllocaPtr + LLVM_DEBUG(dbgs() << "[SafeStack] Unsafe alloca: " << *AllocaPtr << "\n unsafe memintrinsic: " << *I << "\n"); return false; @@ -344,7 +344,7 @@ if (A->get() == V) if (!(CS.doesNotCapture(A - B) && (CS.doesNotAccessMemory(A - B) || CS.doesNotAccessMemory()))) { - DEBUG(dbgs() << "[SafeStack] Unsafe alloca: " << *AllocaPtr + LLVM_DEBUG(dbgs() << "[SafeStack] Unsafe alloca: " << *AllocaPtr << "\n unsafe call: " << *I << "\n"); return false; } @@ -829,7 +829,7 @@ TryInlinePointerAddress(); - DEBUG(dbgs() << "[SafeStack] safestack applied\n"); + LLVM_DEBUG(dbgs() << "[SafeStack] safestack applied\n"); return true; } @@ -850,16 +850,16 @@ } bool runOnFunction(Function &F) override { - DEBUG(dbgs() << "[SafeStack] Function: " << F.getName() << "\n"); + LLVM_DEBUG(dbgs() << "[SafeStack] Function: " << F.getName() << "\n"); if (!F.hasFnAttribute(Attribute::SafeStack)) { - DEBUG(dbgs() << "[SafeStack] safestack is not requested" + LLVM_DEBUG(dbgs() << "[SafeStack] safestack is not requested" " for this function\n"); return false; } if (F.isDeclaration()) { - DEBUG(dbgs() << "[SafeStack] function definition" + LLVM_DEBUG(dbgs() << "[SafeStack] function definition" " is not available\n"); return false; } Index: lib/CodeGen/SafeStackColoring.cpp =================================================================== --- lib/CodeGen/SafeStackColoring.cpp +++ lib/CodeGen/SafeStackColoring.cpp @@ -101,10 +101,10 @@ // For each basic block, compute // * the list of markers in the instruction order // * the sets of allocas whose lifetime starts or ends in this BB - DEBUG(dbgs() << "Instructions:\n"); + LLVM_DEBUG(dbgs() << "Instructions:\n"); unsigned InstNo = 0; for (BasicBlock *BB : depth_first(&F)) { - DEBUG(dbgs() << " " << InstNo << ": BB " << BB->getName() << "\n"); + LLVM_DEBUG(dbgs() << " " << InstNo << ": BB " << BB->getName() << "\n"); unsigned BBStart = InstNo++; BlockLifetimeInfo &BlockInfo = BlockLiveness[BB]; @@ -121,7 +121,7 @@ } auto ProcessMarker = [&](Instruction *I, const Marker &M) { - DEBUG(dbgs() << " " << InstNo << ": " + LLVM_DEBUG(dbgs() << " " << InstNo << ": " << (M.IsStart ? "start " : "end ") << M.AllocaNo << ", " << *I << "\n"); @@ -280,7 +280,7 @@ #endif void StackColoring::run() { - DEBUG(dumpAllocas()); + LLVM_DEBUG(dumpAllocas()); for (unsigned I = 0; I < NumAllocas; ++I) AllocaNumbering[Allocas[I]] = I; @@ -303,7 +303,7 @@ LiveRanges[I] = getFullLiveRange(); calculateLocalLiveness(); - DEBUG(dumpBlockLiveness()); + LLVM_DEBUG(dumpBlockLiveness()); calculateLiveIntervals(); - DEBUG(dumpLiveRanges()); + LLVM_DEBUG(dumpLiveRanges()); } Index: lib/CodeGen/SafeStackLayout.cpp =================================================================== --- lib/CodeGen/SafeStackLayout.cpp +++ lib/CodeGen/SafeStackLayout.cpp @@ -63,30 +63,30 @@ return; } - DEBUG(dbgs() << "Layout: size " << Obj.Size << ", align " << Obj.Alignment + LLVM_DEBUG(dbgs() << "Layout: size " << Obj.Size << ", align " << Obj.Alignment << ", range " << Obj.Range << "\n"); assert(Obj.Alignment <= MaxAlignment); unsigned Start = AdjustStackOffset(0, Obj.Size, Obj.Alignment); unsigned End = Start + Obj.Size; - DEBUG(dbgs() << " First candidate: " << Start << " .. " << End << "\n"); + LLVM_DEBUG(dbgs() << " First candidate: " << Start << " .. " << End << "\n"); for (const StackRegion &R : Regions) { - DEBUG(dbgs() << " Examining region: " << R.Start << " .. " << R.End + LLVM_DEBUG(dbgs() << " Examining region: " << R.Start << " .. " << R.End << ", range " << R.Range << "\n"); assert(End >= R.Start); if (Start >= R.End) { - DEBUG(dbgs() << " Does not intersect, skip.\n"); + LLVM_DEBUG(dbgs() << " Does not intersect, skip.\n"); continue; } if (Obj.Range.Overlaps(R.Range)) { // Find the next appropriate location. Start = AdjustStackOffset(R.End, Obj.Size, Obj.Alignment); End = Start + Obj.Size; - DEBUG(dbgs() << " Overlaps. Next candidate: " << Start << " .. " << End + LLVM_DEBUG(dbgs() << " Overlaps. Next candidate: " << Start << " .. " << End << "\n"); continue; } if (End <= R.End) { - DEBUG(dbgs() << " Reusing region(s).\n"); + LLVM_DEBUG(dbgs() << " Reusing region(s).\n"); break; } } @@ -95,12 +95,12 @@ if (End > LastRegionEnd) { // Insert a new region at the end. Maybe two. if (Start > LastRegionEnd) { - DEBUG(dbgs() << " Creating gap region: " << LastRegionEnd << " .. " + LLVM_DEBUG(dbgs() << " Creating gap region: " << LastRegionEnd << " .. " << Start << "\n"); Regions.emplace_back(LastRegionEnd, Start, StackColoring::LiveRange()); LastRegionEnd = Start; } - DEBUG(dbgs() << " Creating new region: " << LastRegionEnd << " .. " << End + LLVM_DEBUG(dbgs() << " Creating new region: " << LastRegionEnd << " .. " << End << ", range " << Obj.Range << "\n"); Regions.emplace_back(LastRegionEnd, End, Obj.Range); LastRegionEnd = End; @@ -150,5 +150,5 @@ for (auto &Obj : StackObjects) layoutObject(Obj); - DEBUG(print(dbgs())); + LLVM_DEBUG(print(dbgs())); } Index: lib/CodeGen/ScheduleDAGInstrs.cpp =================================================================== --- lib/CodeGen/ScheduleDAGInstrs.cpp +++ lib/CodeGen/ScheduleDAGInstrs.cpp @@ -845,7 +845,7 @@ BarrierChain->addPredBarrier(SU); BarrierChain = SU; - DEBUG(dbgs() << "Global memory object and new barrier chain: SU(" + LLVM_DEBUG(dbgs() << "Global memory object and new barrier chain: SU(" << BarrierChain->NodeNum << ").\n";); // Add dependencies against everything below it and clear maps. @@ -934,11 +934,11 @@ // Reduce maps if they grow huge. if (Stores.size() + Loads.size() >= HugeRegion) { - DEBUG(dbgs() << "Reducing Stores and Loads maps.\n";); + LLVM_DEBUG(dbgs() << "Reducing Stores and Loads maps.\n";); reduceHugeMemNodeMaps(Stores, Loads, getReductionSize()); } if (NonAliasStores.size() + NonAliasLoads.size() >= HugeRegion) { - DEBUG(dbgs() << "Reducing NonAliasStores and NonAliasLoads maps.\n";); + LLVM_DEBUG(dbgs() << "Reducing NonAliasStores and NonAliasLoads maps.\n";); reduceHugeMemNodeMaps(NonAliasStores, NonAliasLoads, getReductionSize()); } } @@ -978,7 +978,7 @@ void ScheduleDAGInstrs::reduceHugeMemNodeMaps(Value2SUsMap &stores, Value2SUsMap &loads, unsigned N) { - DEBUG(dbgs() << "Before reduction:\nStoring SUnits:\n"; + LLVM_DEBUG(dbgs() << "Before reduction:\nStoring SUnits:\n"; stores.dump(); dbgs() << "Loading SUnits:\n"; loads.dump()); @@ -1007,11 +1007,11 @@ if (newBarrierChain->NodeNum < BarrierChain->NodeNum) { BarrierChain->addPredBarrier(newBarrierChain); BarrierChain = newBarrierChain; - DEBUG(dbgs() << "Inserting new barrier chain: SU(" + LLVM_DEBUG(dbgs() << "Inserting new barrier chain: SU(" << BarrierChain->NodeNum << ").\n";); } else - DEBUG(dbgs() << "Keeping old barrier chain: SU(" + LLVM_DEBUG(dbgs() << "Keeping old barrier chain: SU(" << BarrierChain->NodeNum << ").\n";); } else @@ -1020,7 +1020,7 @@ insertBarrierChain(stores); insertBarrierChain(loads); - DEBUG(dbgs() << "After reduction:\nStoring SUnits:\n"; + LLVM_DEBUG(dbgs() << "After reduction:\nStoring SUnits:\n"; stores.dump(); dbgs() << "Loading SUnits:\n"; loads.dump()); @@ -1044,7 +1044,7 @@ } void ScheduleDAGInstrs::fixupKills(MachineBasicBlock &MBB) { - DEBUG(dbgs() << "Fixup kills for " << printMBBReference(MBB) << '\n'); + LLVM_DEBUG(dbgs() << "Fixup kills for " << printMBBReference(MBB) << '\n'); LiveRegs.init(*TRI); LiveRegs.addLiveOuts(MBB); @@ -1245,10 +1245,10 @@ } R.SubtreeConnections.resize(SubtreeClasses.getNumClasses()); R.SubtreeConnectLevels.resize(SubtreeClasses.getNumClasses()); - DEBUG(dbgs() << R.getNumSubtrees() << " subtrees:\n"); + LLVM_DEBUG(dbgs() << R.getNumSubtrees() << " subtrees:\n"); for (unsigned Idx = 0, End = R.DFSNodeData.size(); Idx != End; ++Idx) { R.DFSNodeData[Idx].SubtreeID = SubtreeClasses[Idx]; - DEBUG(dbgs() << " SU(" << Idx << ") in tree " + LLVM_DEBUG(dbgs() << " SU(" << Idx << ") in tree " << R.DFSNodeData[Idx].SubtreeID << '\n'); } for (const std::pair &P : ConnectionPairs) { @@ -1404,7 +1404,7 @@ for (const Connection &C : SubtreeConnections[SubtreeID]) { SubtreeConnectLevels[C.TreeID] = std::max(SubtreeConnectLevels[C.TreeID], C.Level); - DEBUG(dbgs() << " Tree: " << C.TreeID + LLVM_DEBUG(dbgs() << " Tree: " << C.TreeID << " @" << SubtreeConnectLevels[C.TreeID] << '\n'); } } Index: lib/CodeGen/ScoreboardHazardRecognizer.cpp =================================================================== --- lib/CodeGen/ScoreboardHazardRecognizer.cpp +++ lib/CodeGen/ScoreboardHazardRecognizer.cpp @@ -68,11 +68,11 @@ // If MaxLookAhead is not set above, then we are not enabled. if (!isEnabled()) - DEBUG(dbgs() << "Disabled scoreboard hazard recognizer\n"); + LLVM_DEBUG(dbgs() << "Disabled scoreboard hazard recognizer\n"); else { // A nonempty itinerary must have a SchedModel. IssueWidth = ItinData->SchedModel.IssueWidth; - DEBUG(dbgs() << "Using scoreboard hazard recognizer: Depth = " + LLVM_DEBUG(dbgs() << "Using scoreboard hazard recognizer: Depth = " << ScoreboardDepth << '\n'); } } @@ -155,9 +155,9 @@ } if (!freeUnits) { - DEBUG(dbgs() << "*** Hazard in cycle +" << StageCycle << ", "); - DEBUG(dbgs() << "SU(" << SU->NodeNum << "): "); - DEBUG(DAG->dumpNode(SU)); + LLVM_DEBUG(dbgs() << "*** Hazard in cycle +" << StageCycle << ", "); + LLVM_DEBUG(dbgs() << "SU(" << SU->NodeNum << "): "); + LLVM_DEBUG(DAG->dumpNode(SU)); return Hazard; } } @@ -223,8 +223,8 @@ cycle += IS->getNextCycles(); } - DEBUG(ReservedScoreboard.dump()); - DEBUG(RequiredScoreboard.dump()); + LLVM_DEBUG(ReservedScoreboard.dump()); + LLVM_DEBUG(RequiredScoreboard.dump()); } void ScoreboardHazardRecognizer::AdvanceCycle() { Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp =================================================================== --- lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -1020,7 +1020,7 @@ bool AddTo) { assert(N->getNumValues() == NumTo && "Broken CombineTo call!"); ++NodesCombined; - DEBUG(dbgs() << "\nReplacing.1 "; + LLVM_DEBUG(dbgs() << "\nReplacing.1 "; N->dump(&DAG); dbgs() << "\nWith: "; To[0].getNode()->dump(&DAG); @@ -1081,7 +1081,7 @@ // Replace the old value with the new one. ++NodesCombined; - DEBUG(dbgs() << "\nReplacing.2 "; + LLVM_DEBUG(dbgs() << "\nReplacing.2 "; TLO.Old.getNode()->dump(&DAG); dbgs() << "\nWith: "; TLO.New.getNode()->dump(&DAG); @@ -1106,7 +1106,7 @@ // Replace the old value with the new one. ++NodesCombined; - DEBUG(dbgs() << "\nReplacing.2 "; TLO.Old.getNode()->dump(&DAG); + LLVM_DEBUG(dbgs() << "\nReplacing.2 "; TLO.Old.getNode()->dump(&DAG); dbgs() << "\nWith: "; TLO.New.getNode()->dump(&DAG); dbgs() << '\n'); CommitTargetLoweringOpt(TLO); @@ -1118,7 +1118,7 @@ EVT VT = Load->getValueType(0); SDValue Trunc = DAG.getNode(ISD::TRUNCATE, DL, VT, SDValue(ExtLoad, 0)); - DEBUG(dbgs() << "\nReplacing.9 "; + LLVM_DEBUG(dbgs() << "\nReplacing.9 "; Load->dump(&DAG); dbgs() << "\nWith: "; Trunc.getNode()->dump(&DAG); @@ -1223,7 +1223,7 @@ if (TLI.IsDesirableToPromoteOp(Op, PVT)) { assert(PVT != VT && "Don't know what type to promote to!"); - DEBUG(dbgs() << "\nPromoting "; Op.getNode()->dump(&DAG)); + LLVM_DEBUG(dbgs() << "\nPromoting "; Op.getNode()->dump(&DAG)); bool Replace0 = false; SDValue N0 = Op.getOperand(0); @@ -1288,7 +1288,7 @@ if (TLI.IsDesirableToPromoteOp(Op, PVT)) { assert(PVT != VT && "Don't know what type to promote to!"); - DEBUG(dbgs() << "\nPromoting "; Op.getNode()->dump(&DAG)); + LLVM_DEBUG(dbgs() << "\nPromoting "; Op.getNode()->dump(&DAG)); bool Replace = false; SDValue N0 = Op.getOperand(0); @@ -1340,7 +1340,7 @@ // fold (aext (aext x)) -> (aext x) // fold (aext (zext x)) -> (zext x) // fold (aext (sext x)) -> (sext x) - DEBUG(dbgs() << "\nPromoting "; + LLVM_DEBUG(dbgs() << "\nPromoting "; Op.getNode()->dump(&DAG)); return DAG.getNode(Op.getOpcode(), SDLoc(Op), VT, Op.getOperand(0)); } @@ -1383,7 +1383,7 @@ MemVT, LD->getMemOperand()); SDValue Result = DAG.getNode(ISD::TRUNCATE, DL, VT, NewLD); - DEBUG(dbgs() << "\nPromoting "; + LLVM_DEBUG(dbgs() << "\nPromoting "; N->dump(&DAG); dbgs() << "\nTo: "; Result.getNode()->dump(&DAG); @@ -1482,7 +1482,7 @@ continue; } - DEBUG(dbgs() << "\nCombining: "; N->dump(&DAG)); + LLVM_DEBUG(dbgs() << "\nCombining: "; N->dump(&DAG)); // Add any operands of the new node which have not yet been combined to the // worklist as well. Because the worklist uniques things already, this @@ -1510,7 +1510,7 @@ RV.getOpcode() != ISD::DELETED_NODE && "Node was deleted but visit returned new node!"); - DEBUG(dbgs() << " ... into: "; + LLVM_DEBUG(dbgs() << " ... into: "; RV.getNode()->dump(&DAG)); if (N->getNumValues() == RV.getNode()->getNumValues()) @@ -3954,13 +3954,13 @@ if (Loads.size() == 0) return false; - DEBUG(dbgs() << "Backwards propagate AND: "; N->dump()); + LLVM_DEBUG(dbgs() << "Backwards propagate AND: "; N->dump()); SDValue MaskOp = N->getOperand(1); // If it exists, fixup the single node we allow in the tree that needs // masking. if (FixupNode) { - DEBUG(dbgs() << "First, need to fix up: "; FixupNode->dump()); + LLVM_DEBUG(dbgs() << "First, need to fix up: "; FixupNode->dump()); SDValue And = DAG.getNode(ISD::AND, SDLoc(FixupNode), FixupNode->getValueType(0), SDValue(FixupNode, 0), MaskOp); @@ -3985,7 +3985,7 @@ // Create narrow loads. for (auto *Load : Loads) { - DEBUG(dbgs() << "Propagate AND back to: "; Load->dump()); + LLVM_DEBUG(dbgs() << "Propagate AND back to: "; Load->dump()); SDValue And = DAG.getNode(ISD::AND, SDLoc(Load), Load->getValueType(0), SDValue(Load, 0), MaskOp); DAG.ReplaceAllUsesOfValueWith(SDValue(Load, 0), And); @@ -11280,7 +11280,7 @@ // Avoid missing important xor optimizations. if (SDValue Tmp = visitXOR(TheXor)) { if (Tmp.getNode() != TheXor) { - DEBUG(dbgs() << "\nReplacing.8 "; + LLVM_DEBUG(dbgs() << "\nReplacing.8 "; TheXor->dump(&DAG); dbgs() << "\nWith: "; Tmp.getNode()->dump(&DAG); @@ -11550,7 +11550,7 @@ BasePtr, Offset, AM); ++PreIndexedNodes; ++NodesCombined; - DEBUG(dbgs() << "\nReplacing.4 "; + LLVM_DEBUG(dbgs() << "\nReplacing.4 "; N->dump(&DAG); dbgs() << "\nWith: "; Result.getNode()->dump(&DAG); @@ -11719,7 +11719,7 @@ BasePtr, Offset, AM); ++PostIndexedNodes; ++NodesCombined; - DEBUG(dbgs() << "\nReplacing.5 "; + LLVM_DEBUG(dbgs() << "\nReplacing.5 "; N->dump(&DAG); dbgs() << "\nWith: "; Result.getNode()->dump(&DAG); @@ -11789,7 +11789,7 @@ // v3 = add v2, c // Now we replace use of chain2 with chain1. This makes the second load // isomorphic to the one we are deleting, and thus makes this load live. - DEBUG(dbgs() << "\nReplacing.6 "; + LLVM_DEBUG(dbgs() << "\nReplacing.6 "; N->dump(&DAG); dbgs() << "\nWith chain: "; Chain.getNode()->dump(&DAG); @@ -11824,7 +11824,7 @@ AddUsersToWorklist(N); } else Index = DAG.getUNDEF(N->getValueType(1)); - DEBUG(dbgs() << "\nReplacing.7 "; + LLVM_DEBUG(dbgs() << "\nReplacing.7 "; N->dump(&DAG); dbgs() << "\nWith: "; Undef.getNode()->dump(&DAG); Index: lib/CodeGen/SelectionDAG/FastISel.cpp =================================================================== --- lib/CodeGen/SelectionDAG/FastISel.cpp +++ lib/CodeGen/SelectionDAG/FastISel.cpp @@ -1142,13 +1142,13 @@ const DbgDeclareInst *DI = cast(II); assert(DI->getVariable() && "Missing variable"); if (!FuncInfo.MF->getMMI().hasDebugInfo()) { - DEBUG(dbgs() << "Dropping debug info for " << *DI << "\n"); + LLVM_DEBUG(dbgs() << "Dropping debug info for " << *DI << "\n"); return true; } const Value *Address = DI->getAddress(); if (!Address || isa(Address)) { - DEBUG(dbgs() << "Dropping debug info for " << *DI << "\n"); + LLVM_DEBUG(dbgs() << "Dropping debug info for " << *DI << "\n"); return true; } @@ -1200,7 +1200,7 @@ } else { // We can't yet handle anything else here because it would require // generating code, thus altering codegen because of debug info. - DEBUG(dbgs() << "Dropping debug info for " << *DI << "\n"); + LLVM_DEBUG(dbgs() << "Dropping debug info for " << *DI << "\n"); } return true; } @@ -1243,7 +1243,7 @@ } else { // We can't yet handle anything else here because it would require // generating code, thus altering codegen because of debug info. - DEBUG(dbgs() << "Dropping debug info for " << *DI << "\n"); + LLVM_DEBUG(dbgs() << "Dropping debug info for " << *DI << "\n"); } return true; } Index: lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp =================================================================== --- lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp +++ lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp @@ -483,7 +483,7 @@ auto I = ByValArgFrameIndexMap.find(A); if (I != ByValArgFrameIndexMap.end()) return I->second; - DEBUG(dbgs() << "Argument does not have assigned frame index!\n"); + LLVM_DEBUG(dbgs() << "Argument does not have assigned frame index!\n"); return INT_MAX; } Index: lib/CodeGen/SelectionDAG/LegalizeDAG.cpp =================================================================== --- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -200,7 +200,7 @@ } void ReplaceNode(SDNode *Old, SDNode *New) { - DEBUG(dbgs() << " ... replacing: "; Old->dump(&DAG); + LLVM_DEBUG(dbgs() << " ... replacing: "; Old->dump(&DAG); dbgs() << " with: "; New->dump(&DAG)); assert(Old->getNumValues() == New->getNumValues() && @@ -213,7 +213,7 @@ } void ReplaceNode(SDValue Old, SDValue New) { - DEBUG(dbgs() << " ... replacing: "; Old->dump(&DAG); + LLVM_DEBUG(dbgs() << " ... replacing: "; Old->dump(&DAG); dbgs() << " with: "; New->dump(&DAG)); DAG.ReplaceAllUsesWith(Old, New); @@ -223,11 +223,11 @@ } void ReplaceNode(SDNode *Old, const SDValue *New) { - DEBUG(dbgs() << " ... replacing: "; Old->dump(&DAG)); + LLVM_DEBUG(dbgs() << " ... replacing: "; Old->dump(&DAG)); DAG.ReplaceAllUsesWith(Old, New); for (unsigned i = 0, e = Old->getNumValues(); i != e; ++i) { - DEBUG(dbgs() << (i == 0 ? " with: " + LLVM_DEBUG(dbgs() << (i == 0 ? " with: " : " and: "); New[i]->dump(&DAG)); if (UpdatedNodes) @@ -408,7 +408,7 @@ } SDValue SelectionDAGLegalize::OptimizeFloatStore(StoreSDNode* ST) { - DEBUG(dbgs() << "Optimizing float store operations\n"); + LLVM_DEBUG(dbgs() << "Optimizing float store operations\n"); // Turn 'store float 1.0, Ptr' -> 'store int 0x12345678, Ptr' // FIXME: We shouldn't do this for TargetConstantFP's. // FIXME: move this to the DAG Combiner! Note that we can't regress due @@ -477,7 +477,7 @@ AAMDNodes AAInfo = ST->getAAInfo(); if (!ST->isTruncatingStore()) { - DEBUG(dbgs() << "Legalizing store operation\n"); + LLVM_DEBUG(dbgs() << "Legalizing store operation\n"); if (SDNode *OptStore = OptimizeFloatStore(ST).getNode()) { ReplaceNode(ST, OptStore); return; @@ -495,15 +495,15 @@ unsigned Align = ST->getAlignment(); const DataLayout &DL = DAG.getDataLayout(); if (!TLI.allowsMemoryAccess(*DAG.getContext(), DL, MemVT, AS, Align)) { - DEBUG(dbgs() << "Expanding unsupported unaligned store\n"); + LLVM_DEBUG(dbgs() << "Expanding unsupported unaligned store\n"); SDValue Result = TLI.expandUnalignedStore(ST, DAG); ReplaceNode(SDValue(ST, 0), Result); } else - DEBUG(dbgs() << "Legal store\n"); + LLVM_DEBUG(dbgs() << "Legal store\n"); break; } case TargetLowering::Custom: { - DEBUG(dbgs() << "Trying custom lowering\n"); + LLVM_DEBUG(dbgs() << "Trying custom lowering\n"); SDValue Res = TLI.LowerOperation(SDValue(Node, 0), DAG); if (Res && Res != SDValue(Node, 0)) ReplaceNode(SDValue(Node, 0), Res); @@ -524,7 +524,7 @@ return; } - DEBUG(dbgs() << "Legalizing truncating store operations\n"); + LLVM_DEBUG(dbgs() << "Legalizing truncating store operations\n"); SDValue Value = ST->getValue(); EVT StVT = ST->getMemoryVT(); unsigned StWidth = StVT.getSizeInBits(); @@ -656,7 +656,7 @@ ISD::LoadExtType ExtType = LD->getExtensionType(); if (ExtType == ISD::NON_EXTLOAD) { - DEBUG(dbgs() << "Legalizing non-extending load operation\n"); + LLVM_DEBUG(dbgs() << "Legalizing non-extending load operation\n"); MVT VT = Node->getSimpleValueType(0); SDValue RVal = SDValue(Node, 0); SDValue RChain = SDValue(Node, 1); @@ -706,7 +706,7 @@ return; } - DEBUG(dbgs() << "Legalizing extending load operation\n"); + LLVM_DEBUG(dbgs() << "Legalizing extending load operation\n"); EVT SrcVT = LD->getMemoryVT(); unsigned SrcWidth = SrcVT.getSizeInBits(); unsigned Alignment = LD->getAlignment(); @@ -979,7 +979,7 @@ /// Return a legal replacement for the given operation, with all legal operands. void SelectionDAGLegalize::LegalizeOp(SDNode *Node) { - DEBUG(dbgs() << "\nLegalizing: "; Node->dump(&DAG)); + LLVM_DEBUG(dbgs() << "\nLegalizing: "; Node->dump(&DAG)); // Allow illegal target nodes and illegal registers. if (Node->getOpcode() == ISD::TargetConstant || @@ -1202,10 +1202,10 @@ } switch (Action) { case TargetLowering::Legal: - DEBUG(dbgs() << "Legal node: nothing to do\n"); + LLVM_DEBUG(dbgs() << "Legal node: nothing to do\n"); return; case TargetLowering::Custom: - DEBUG(dbgs() << "Trying custom legalization\n"); + LLVM_DEBUG(dbgs() << "Trying custom legalization\n"); // FIXME: The handling for custom lowering with multiple results is // a complete mess. if (SDValue Res = TLI.LowerOperation(SDValue(Node, 0), DAG)) { @@ -1213,7 +1213,7 @@ return; if (Node->getNumValues() == 1) { - DEBUG(dbgs() << "Successfully custom legalized node\n"); + LLVM_DEBUG(dbgs() << "Successfully custom legalized node\n"); // We can just directly replace this node with the lowered value. ReplaceNode(SDValue(Node, 0), Res); return; @@ -1222,11 +1222,11 @@ SmallVector ResultVals; for (unsigned i = 0, e = Node->getNumValues(); i != e; ++i) ResultVals.push_back(Res.getValue(i)); - DEBUG(dbgs() << "Successfully custom legalized node\n"); + LLVM_DEBUG(dbgs() << "Successfully custom legalized node\n"); ReplaceNode(Node, ResultVals.data()); return; } - DEBUG(dbgs() << "Could not custom legalize node\n"); + LLVM_DEBUG(dbgs() << "Could not custom legalize node\n"); LLVM_FALLTHROUGH; case TargetLowering::Expand: if (ExpandNode(Node)) @@ -2043,12 +2043,12 @@ std::pair CallInfo = TLI.LowerCallTo(CLI); if (!CallInfo.second.getNode()) { - DEBUG(dbgs() << "Created tailcall: "; DAG.getRoot().dump()); + LLVM_DEBUG(dbgs() << "Created tailcall: "; DAG.getRoot().dump()); // It's a tailcall, return the chain (which is the DAG root). return DAG.getRoot(); } - DEBUG(dbgs() << "Created libcall: "; CallInfo.first.dump()); + LLVM_DEBUG(dbgs() << "Created libcall: "; CallInfo.first.dump()); return CallInfo.first; } @@ -2334,9 +2334,9 @@ EVT DestVT, const SDLoc &dl) { // TODO: Should any fast-math-flags be set for the created nodes? - DEBUG(dbgs() << "Legalizing INT_TO_FP\n"); + LLVM_DEBUG(dbgs() << "Legalizing INT_TO_FP\n"); if (Op0.getValueType() == MVT::i32 && TLI.isTypeLegal(MVT::f64)) { - DEBUG(dbgs() << "32-bit [signed|unsigned] integer to float/double " + LLVM_DEBUG(dbgs() << "32-bit [signed|unsigned] integer to float/double " "expansion\n"); // Get the stack frame index of a 8 byte buffer. @@ -2402,7 +2402,7 @@ // and in all alternate rounding modes. // TODO: Generalize this for use with other types. if (Op0.getValueType() == MVT::i64 && DestVT == MVT::f64) { - DEBUG(dbgs() << "Converting unsigned i64 to f64\n"); + LLVM_DEBUG(dbgs() << "Converting unsigned i64 to f64\n"); SDValue TwoP52 = DAG.getConstant(UINT64_C(0x4330000000000000), dl, MVT::i64); SDValue TwoP84PlusTwoP52 = @@ -2425,7 +2425,7 @@ // TODO: Generalize this for use with other types. if (Op0.getValueType() == MVT::i64 && DestVT == MVT::f32) { - DEBUG(dbgs() << "Converting unsigned i64 to f32\n"); + LLVM_DEBUG(dbgs() << "Converting unsigned i64 to f32\n"); // For unsigned conversions, convert them to signed conversions using the // algorithm from the x86_64 __floatundidf in compiler_rt. if (!isSigned) { @@ -2860,7 +2860,7 @@ } bool SelectionDAGLegalize::ExpandNode(SDNode *Node) { - DEBUG(dbgs() << "Trying to expand node\n"); + LLVM_DEBUG(dbgs() << "Trying to expand node\n"); SmallVector Results; SDLoc dl(Node); SDValue Tmp1, Tmp2, Tmp3, Tmp4; @@ -3318,7 +3318,7 @@ } break; case ISD::FP_TO_FP16: - DEBUG(dbgs() << "Legalizing FP_TO_FP16\n"); + LLVM_DEBUG(dbgs() << "Legalizing FP_TO_FP16\n"); if (!TLI.useSoftFloat() && TM.Options.UnsafeFPMath) { SDValue Op = Node->getOperand(0); MVT SVT = Op.getSimpleValueType(); @@ -3928,17 +3928,17 @@ // Replace the original node with the legalized result. if (Results.empty()) { - DEBUG(dbgs() << "Cannot expand node\n"); + LLVM_DEBUG(dbgs() << "Cannot expand node\n"); return false; } - DEBUG(dbgs() << "Succesfully expanded node\n"); + LLVM_DEBUG(dbgs() << "Succesfully expanded node\n"); ReplaceNode(Node, Results.data()); return true; } void SelectionDAGLegalize::ConvertNodeToLibcall(SDNode *Node) { - DEBUG(dbgs() << "Trying to convert node to libcall\n"); + LLVM_DEBUG(dbgs() << "Trying to convert node to libcall\n"); SmallVector Results; SDLoc dl(Node); // FIXME: Check flags on the node to see if we can use a finite call. @@ -4238,10 +4238,10 @@ // Replace the original node with the legalized result. if (!Results.empty()) { - DEBUG(dbgs() << "Successfully converted node to libcall\n"); + LLVM_DEBUG(dbgs() << "Successfully converted node to libcall\n"); ReplaceNode(Node, Results.data()); } else - DEBUG(dbgs() << "Could not convert node to libcall\n"); + LLVM_DEBUG(dbgs() << "Could not convert node to libcall\n"); } // Determine the vector type to use in place of an original scalar element when @@ -4255,7 +4255,7 @@ } void SelectionDAGLegalize::PromoteNode(SDNode *Node) { - DEBUG(dbgs() << "Trying to promote node\n"); + LLVM_DEBUG(dbgs() << "Trying to promote node\n"); SmallVector Results; MVT OVT = Node->getSimpleValueType(0); if (Node->getOpcode() == ISD::UINT_TO_FP || @@ -4693,10 +4693,10 @@ // Replace the original node with the legalized result. if (!Results.empty()) { - DEBUG(dbgs() << "Successfully promoted node\n"); + LLVM_DEBUG(dbgs() << "Successfully promoted node\n"); ReplaceNode(Node, Results.data()); } else - DEBUG(dbgs() << "Could not promote node\n"); + LLVM_DEBUG(dbgs() << "Could not promote node\n"); } /// This is the entry point for the file. Index: lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp =================================================================== --- lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp +++ lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp @@ -47,7 +47,7 @@ //===----------------------------------------------------------------------===// bool DAGTypeLegalizer::SoftenFloatResult(SDNode *N, unsigned ResNo) { - DEBUG(dbgs() << "Soften float result " << ResNo << ": "; N->dump(&DAG); + LLVM_DEBUG(dbgs() << "Soften float result " << ResNo << ": "; N->dump(&DAG); dbgs() << "\n"); SDValue R = SDValue(); @@ -738,7 +738,7 @@ //===----------------------------------------------------------------------===// bool DAGTypeLegalizer::SoftenFloatOperand(SDNode *N, unsigned OpNo) { - DEBUG(dbgs() << "Soften float operand " << OpNo << ": "; N->dump(&DAG); + LLVM_DEBUG(dbgs() << "Soften float operand " << OpNo << ": "; N->dump(&DAG); dbgs() << "\n"); SDValue Res = SDValue(); @@ -1039,7 +1039,7 @@ /// have invalid operands or may have other results that need promotion, we just /// know that (at least) one result needs expansion. void DAGTypeLegalizer::ExpandFloatResult(SDNode *N, unsigned ResNo) { - DEBUG(dbgs() << "Expand float result: "; N->dump(&DAG); dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Expand float result: "; N->dump(&DAG); dbgs() << "\n"); SDValue Lo, Hi; Lo = Hi = SDValue(); @@ -1538,7 +1538,7 @@ /// types of the node are known to be legal, but other operands of the node may /// need promotion or expansion as well as the specified one. bool DAGTypeLegalizer::ExpandFloatOperand(SDNode *N, unsigned OpNo) { - DEBUG(dbgs() << "Expand float operand: "; N->dump(&DAG); dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Expand float operand: "; N->dump(&DAG); dbgs() << "\n"); SDValue Res = SDValue(); // See if the target wants to custom expand this node. Index: lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp =================================================================== --- lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp +++ lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp @@ -36,12 +36,12 @@ /// may also have invalid operands or may have other results that need /// expansion, we just know that (at least) one result needs promotion. void DAGTypeLegalizer::PromoteIntegerResult(SDNode *N, unsigned ResNo) { - DEBUG(dbgs() << "Promote integer result: "; N->dump(&DAG); dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Promote integer result: "; N->dump(&DAG); dbgs() << "\n"); SDValue Res = SDValue(); // See if the target wants to custom expand this node. if (CustomLowerNode(N, N->getValueType(ResNo), true)) { - DEBUG(dbgs() << "Node has been custom expanded, done\n"); + LLVM_DEBUG(dbgs() << "Node has been custom expanded, done\n"); return; } @@ -894,11 +894,11 @@ /// result types of the node are known to be legal, but other operands of the /// node may need promotion or expansion as well as the specified one. bool DAGTypeLegalizer::PromoteIntegerOperand(SDNode *N, unsigned OpNo) { - DEBUG(dbgs() << "Promote integer operand: "; N->dump(&DAG); dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Promote integer operand: "; N->dump(&DAG); dbgs() << "\n"); SDValue Res = SDValue(); if (CustomLowerNode(N, N->getOperand(OpNo).getValueType(), false)) { - DEBUG(dbgs() << "Node has been custom lowered, done\n"); + LLVM_DEBUG(dbgs() << "Node has been custom lowered, done\n"); return false; } @@ -1346,7 +1346,7 @@ /// have invalid operands or may have other results that need promotion, we just /// know that (at least) one result needs expansion. void DAGTypeLegalizer::ExpandIntegerResult(SDNode *N, unsigned ResNo) { - DEBUG(dbgs() << "Expand integer result: "; N->dump(&DAG); dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Expand integer result: "; N->dump(&DAG); dbgs() << "\n"); SDValue Lo, Hi; Lo = Hi = SDValue(); @@ -2884,7 +2884,7 @@ /// result types of the node are known to be legal, but other operands of the /// node may need promotion or expansion as well as the specified one. bool DAGTypeLegalizer::ExpandIntegerOperand(SDNode *N, unsigned OpNo) { - DEBUG(dbgs() << "Expand integer operand: "; N->dump(&DAG); dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Expand integer operand: "; N->dump(&DAG); dbgs() << "\n"); SDValue Res = SDValue(); if (CustomLowerNode(N, N->getOperand(OpNo).getValueType(), false)) Index: lib/CodeGen/SelectionDAG/LegalizeTypes.cpp =================================================================== --- lib/CodeGen/SelectionDAG/LegalizeTypes.cpp +++ lib/CodeGen/SelectionDAG/LegalizeTypes.cpp @@ -224,9 +224,9 @@ assert(N->getNodeId() == ReadyToProcess && "Node should be ready if on worklist!"); - DEBUG(dbgs() << "Legalizing node: "; N->dump(&DAG)); + LLVM_DEBUG(dbgs() << "Legalizing node: "; N->dump(&DAG)); if (IgnoreNodeResults(N)) { - DEBUG(dbgs() << "Ignoring node results\n"); + LLVM_DEBUG(dbgs() << "Ignoring node results\n"); goto ScanOperands; } @@ -234,11 +234,11 @@ // types are illegal. for (unsigned i = 0, NumResults = N->getNumValues(); i < NumResults; ++i) { EVT ResultVT = N->getValueType(i); - DEBUG(dbgs() << "Analyzing result type: " << + LLVM_DEBUG(dbgs() << "Analyzing result type: " << ResultVT.getEVTString() << "\n"); switch (getTypeAction(ResultVT)) { case TargetLowering::TypeLegal: - DEBUG(dbgs() << "Legal result type\n"); + LLVM_DEBUG(dbgs() << "Legal result type\n"); break; // The following calls must take care of *all* of the node's results, // not just the illegal result they were passed (this includes results @@ -296,11 +296,11 @@ continue; const auto Op = N->getOperand(i); - DEBUG(dbgs() << "Analyzing operand: "; Op.dump(&DAG)); + LLVM_DEBUG(dbgs() << "Analyzing operand: "; Op.dump(&DAG)); EVT OpVT = Op.getValueType(); switch (getTypeAction(OpVT)) { case TargetLowering::TypeLegal: - DEBUG(dbgs() << "Legal operand\n"); + LLVM_DEBUG(dbgs() << "Legal operand\n"); continue; // The following calls must either replace all of the node's results // using ReplaceValueWith, and return "false"; or update the node's @@ -370,7 +370,7 @@ } if (i == NumOperands) { - DEBUG(dbgs() << "Legally typed node: "; N->dump(&DAG); dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Legally typed node: "; N->dump(&DAG); dbgs() << "\n"); } } NodeDone: Index: lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp =================================================================== --- lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp +++ lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp @@ -229,7 +229,7 @@ LoadSDNode *LD = cast(Op.getNode()); ISD::LoadExtType ExtType = LD->getExtensionType(); if (LD->getMemoryVT().isVector() && ExtType != ISD::NON_EXTLOAD) { - DEBUG(dbgs() << "\nLegalizing extending vector load: "; Node->dump(&DAG)); + LLVM_DEBUG(dbgs() << "\nLegalizing extending vector load: "; Node->dump(&DAG)); switch (TLI.getLoadExtAction(LD->getExtensionType(), LD->getValueType(0), LD->getMemoryVT())) { default: llvm_unreachable("This action is not supported yet!"); @@ -261,7 +261,7 @@ EVT StVT = ST->getMemoryVT(); MVT ValVT = ST->getValue().getSimpleValueType(); if (StVT.isVector() && ST->isTruncatingStore()) { - DEBUG(dbgs() << "\nLegalizing truncating vector store: "; + LLVM_DEBUG(dbgs() << "\nLegalizing truncating vector store: "; Node->dump(&DAG)); switch (TLI.getTruncStoreAction(ValVT, StVT)) { default: llvm_unreachable("This action is not supported yet!"); @@ -383,7 +383,7 @@ break; } - DEBUG(dbgs() << "\nLegalizing vector op: "; Node->dump(&DAG)); + LLVM_DEBUG(dbgs() << "\nLegalizing vector op: "; Node->dump(&DAG)); switch (TLI.getOperationAction(Node->getOpcode(), QueryType)) { default: llvm_unreachable("This action is not supported yet!"); @@ -392,16 +392,16 @@ Changed = true; break; case TargetLowering::Legal: - DEBUG(dbgs() << "Legal node: nothing to do\n"); + LLVM_DEBUG(dbgs() << "Legal node: nothing to do\n"); break; case TargetLowering::Custom: { - DEBUG(dbgs() << "Trying custom legalization\n"); + LLVM_DEBUG(dbgs() << "Trying custom legalization\n"); if (SDValue Tmp1 = TLI.LowerOperation(Op, DAG)) { - DEBUG(dbgs() << "Successfully custom legalized node\n"); + LLVM_DEBUG(dbgs() << "Successfully custom legalized node\n"); Result = Tmp1; break; } - DEBUG(dbgs() << "Could not custom legalize node\n"); + LLVM_DEBUG(dbgs() << "Could not custom legalize node\n"); LLVM_FALLTHROUGH; } case TargetLowering::Expand: Index: lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp =================================================================== --- lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp +++ lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp @@ -33,7 +33,7 @@ //===----------------------------------------------------------------------===// void DAGTypeLegalizer::ScalarizeVectorResult(SDNode *N, unsigned ResNo) { - DEBUG(dbgs() << "Scalarize node result " << ResNo << ": "; + LLVM_DEBUG(dbgs() << "Scalarize node result " << ResNo << ": "; N->dump(&DAG); dbgs() << "\n"); SDValue R = SDValue(); @@ -443,7 +443,7 @@ //===----------------------------------------------------------------------===// bool DAGTypeLegalizer::ScalarizeVectorOperand(SDNode *N, unsigned OpNo) { - DEBUG(dbgs() << "Scalarize node operand " << OpNo << ": "; + LLVM_DEBUG(dbgs() << "Scalarize node operand " << OpNo << ": "; N->dump(&DAG); dbgs() << "\n"); SDValue Res = SDValue(); @@ -628,7 +628,7 @@ /// invalid operands or may have other results that need legalization, we just /// know that (at least) one result needs vector splitting. void DAGTypeLegalizer::SplitVectorResult(SDNode *N, unsigned ResNo) { - DEBUG(dbgs() << "Split node result: "; + LLVM_DEBUG(dbgs() << "Split node result: "; N->dump(&DAG); dbgs() << "\n"); SDValue Lo, Hi; @@ -1376,7 +1376,7 @@ std::tie(SplitLoVT, SplitHiVT) = DAG.GetSplitDestVTs(NewSrcVT); if (TLI.isTypeLegal(SrcVT) && !TLI.isTypeLegal(SplitSrcVT) && TLI.isTypeLegal(NewSrcVT) && TLI.isTypeLegal(SplitLoVT)) { - DEBUG(dbgs() << "Split vector extend via incremental extend:"; + LLVM_DEBUG(dbgs() << "Split vector extend via incremental extend:"; N->dump(&DAG); dbgs() << "\n"); // Extend the source vector by one step. SDValue NewSrc = @@ -1512,7 +1512,7 @@ /// the node are known to be legal, but other operands of the node may need /// legalization as well as the specified one. bool DAGTypeLegalizer::SplitVectorOperand(SDNode *N, unsigned OpNo) { - DEBUG(dbgs() << "Split node operand: "; + LLVM_DEBUG(dbgs() << "Split node operand: "; N->dump(&DAG); dbgs() << "\n"); SDValue Res = SDValue(); @@ -2183,7 +2183,7 @@ //===----------------------------------------------------------------------===// void DAGTypeLegalizer::WidenVectorResult(SDNode *N, unsigned ResNo) { - DEBUG(dbgs() << "Widen node result " << ResNo << ": "; + LLVM_DEBUG(dbgs() << "Widen node result " << ResNo << ": "; N->dump(&DAG); dbgs() << "\n"); @@ -3329,7 +3329,7 @@ // Widen Vector Operand //===----------------------------------------------------------------------===// bool DAGTypeLegalizer::WidenVectorOperand(SDNode *N, unsigned OpNo) { - DEBUG(dbgs() << "Widen node operand " << OpNo << ": "; + LLVM_DEBUG(dbgs() << "Widen node operand " << OpNo << ": "; N->dump(&DAG); dbgs() << "\n"); SDValue Res = SDValue(); Index: lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp =================================================================== --- lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp +++ lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp @@ -115,7 +115,7 @@ /// Schedule - Schedule the DAG using list scheduling. void ScheduleDAGFast::Schedule() { - DEBUG(dbgs() << "********** List Scheduling **********\n"); + LLVM_DEBUG(dbgs() << "********** List Scheduling **********\n"); NumLiveRegs = 0; LiveRegDefs.resize(TRI->getNumRegs(), nullptr); @@ -124,7 +124,7 @@ // Build the scheduling graph. BuildSchedGraph(nullptr); - DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su) + LLVM_DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su) SUnits[su].dumpAll(this)); // Execute the actual scheduling loop. @@ -180,8 +180,8 @@ /// count of its predecessors. If a predecessor pending count is zero, add it to /// the Available queue. void ScheduleDAGFast::ScheduleNodeBottomUp(SUnit *SU, unsigned CurCycle) { - DEBUG(dbgs() << "*** Scheduling [" << CurCycle << "]: "); - DEBUG(SU->dump(this)); + LLVM_DEBUG(dbgs() << "*** Scheduling [" << CurCycle << "]: "); + LLVM_DEBUG(SU->dump(this)); assert(CurCycle >= SU->getHeight() && "Node scheduled below its height!"); SU->setHeightToAtLeast(CurCycle); @@ -236,7 +236,7 @@ if (!TII->unfoldMemoryOperand(*DAG, N, NewNodes)) return nullptr; - DEBUG(dbgs() << "Unfolding SU # " << SU->NodeNum << "\n"); + LLVM_DEBUG(dbgs() << "Unfolding SU # " << SU->NodeNum << "\n"); assert(NewNodes.size() == 2 && "Expected a load folding node!"); N = NewNodes[1]; @@ -346,7 +346,7 @@ SU = NewSU; } - DEBUG(dbgs() << "Duplicating SU # " << SU->NodeNum << "\n"); + LLVM_DEBUG(dbgs() << "Duplicating SU # " << SU->NodeNum << "\n"); NewSU = Clone(SU); // New SUnit has the exact same predecessors. @@ -592,13 +592,13 @@ // Issue copies, these can be expensive cross register class copies. SmallVector Copies; InsertCopiesAndMoveSuccs(LRDef, Reg, DestRC, RC, Copies); - DEBUG(dbgs() << "Adding an edge from SU # " << TrySU->NodeNum + LLVM_DEBUG(dbgs() << "Adding an edge from SU # " << TrySU->NodeNum << " to SU #" << Copies.front()->NodeNum << "\n"); AddPred(TrySU, SDep(Copies.front(), SDep::Artificial)); NewDef = Copies.back(); } - DEBUG(dbgs() << "Adding an edge from SU # " << NewDef->NodeNum + LLVM_DEBUG(dbgs() << "Adding an edge from SU # " << NewDef->NodeNum << " to SU #" << TrySU->NodeNum << "\n"); LiveRegDefs[Reg] = NewDef; AddPred(NewDef, SDep(TrySU, SDep::Artificial)); @@ -666,8 +666,8 @@ // These nodes do not need to be translated into MIs. return; - DEBUG(dbgs() << "\n*** Scheduling: "); - DEBUG(N->dump(DAG)); + LLVM_DEBUG(dbgs() << "\n*** Scheduling: "); + LLVM_DEBUG(N->dump(DAG)); Sequence.push_back(N); unsigned NumOps = N->getNumOperands(); @@ -713,7 +713,7 @@ } void ScheduleDAGLinearize::Schedule() { - DEBUG(dbgs() << "********** DAG Linearization **********\n"); + LLVM_DEBUG(dbgs() << "********** DAG Linearization **********\n"); SmallVector Glues; unsigned DAGSize = 0; @@ -763,7 +763,7 @@ InstrEmitter Emitter(BB, InsertPos); DenseMap VRBaseMap; - DEBUG({ + LLVM_DEBUG({ dbgs() << "\n*** Final schedule ***\n"; }); @@ -771,11 +771,11 @@ unsigned NumNodes = Sequence.size(); for (unsigned i = 0; i != NumNodes; ++i) { SDNode *N = Sequence[NumNodes-i-1]; - DEBUG(N->dump(DAG)); + LLVM_DEBUG(N->dump(DAG)); Emitter.EmitNode(N, false, false, VRBaseMap); } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); InsertPos = Emitter.getInsertPos(); return Emitter.getBlock(); Index: lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp =================================================================== --- lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp +++ lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp @@ -346,7 +346,7 @@ /// Schedule - Schedule the DAG using list scheduling. void ScheduleDAGRRList::Schedule() { - DEBUG(dbgs() << "********** List Scheduling " << printMBBReference(*BB) + LLVM_DEBUG(dbgs() << "********** List Scheduling " << printMBBReference(*BB) << " '" << BB->getName() << "' **********\n"); CurCycle = 0; @@ -364,7 +364,7 @@ // Build the scheduling graph. BuildSchedGraph(nullptr); - DEBUG(for (SUnit &SU : SUnits) + LLVM_DEBUG(for (SUnit &SU : SUnits) SU.dumpAll(this)); Topo.InitDAGTopologicalSorting(); @@ -377,7 +377,7 @@ AvailableQueue->releaseState(); - DEBUG({ + LLVM_DEBUG({ dbgs() << "*** Final schedule ***\n"; dumpSchedule(); dbgs() << '\n'; @@ -728,12 +728,12 @@ /// count of its predecessors. If a predecessor pending count is zero, add it to /// the Available queue. void ScheduleDAGRRList::ScheduleNodeBottomUp(SUnit *SU) { - DEBUG(dbgs() << "\n*** Scheduling [" << CurCycle << "]: "); - DEBUG(SU->dump(this)); + LLVM_DEBUG(dbgs() << "\n*** Scheduling [" << CurCycle << "]: "); + LLVM_DEBUG(SU->dump(this)); #ifndef NDEBUG if (CurCycle < SU->getHeight()) - DEBUG(dbgs() << " Height [" << SU->getHeight() + LLVM_DEBUG(dbgs() << " Height [" << SU->getHeight() << "] pipeline stall!\n"); #endif @@ -827,8 +827,8 @@ /// UnscheduleNodeBottomUp - Remove the node from the schedule, update its and /// its predecessor states to reflect the change. void ScheduleDAGRRList::UnscheduleNodeBottomUp(SUnit *SU) { - DEBUG(dbgs() << "*** Unscheduling [" << SU->getHeight() << "]: "); - DEBUG(SU->dump(this)); + LLVM_DEBUG(dbgs() << "*** Unscheduling [" << SU->getHeight() << "]: "); + LLVM_DEBUG(SU->dump(this)); for (SDep &Pred : SU->Preds) { CapturePred(&Pred); @@ -1010,7 +1010,7 @@ computeLatency(LoadSU); } - DEBUG(dbgs() << "Unfolding SU #" << SU->NodeNum << "\n"); + LLVM_DEBUG(dbgs() << "Unfolding SU #" << SU->NodeNum << "\n"); // Now that we are committed to unfolding replace DAG Uses. for (unsigned i = 0; i != NumVals; ++i) @@ -1117,12 +1117,12 @@ if (!N) return nullptr; - DEBUG(dbgs() << "Considering duplicating the SU\n"); - DEBUG(SU->dump(this)); + LLVM_DEBUG(dbgs() << "Considering duplicating the SU\n"); + LLVM_DEBUG(SU->dump(this)); if (N->getGluedNode() && !TII->canCopyGluedNodeDuringSchedule(N)) { - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "Giving up because it has incoming glue and the target does not " "want to copy it\n"); return nullptr; @@ -1133,7 +1133,7 @@ for (unsigned i = 0, e = N->getNumValues(); i != e; ++i) { MVT VT = N->getSimpleValueType(i); if (VT == MVT::Glue) { - DEBUG(dbgs() << "Giving up because it has outgoing glue\n"); + LLVM_DEBUG(dbgs() << "Giving up because it has outgoing glue\n"); return nullptr; } else if (VT == MVT::Other) TryUnfold = true; @@ -1141,7 +1141,7 @@ for (const SDValue &Op : N->op_values()) { MVT VT = Op.getNode()->getSimpleValueType(Op.getResNo()); if (VT == MVT::Glue && !TII->canCopyGluedNodeDuringSchedule(N)) { - DEBUG(dbgs() << "Giving up because it one of the operands is glue and " + LLVM_DEBUG(dbgs() << "Giving up because it one of the operands is glue and " "the target does not want to copy it\n"); return nullptr; } @@ -1159,7 +1159,7 @@ return SU; } - DEBUG(dbgs() << " Duplicating SU #" << SU->NodeNum << "\n"); + LLVM_DEBUG(dbgs() << " Duplicating SU #" << SU->NodeNum << "\n"); NewSU = CreateClone(SU); // New SUnit has the exact same predecessors. @@ -1420,7 +1420,7 @@ // Furthermore, it may have been made available again, in which case it is // now already in the AvailableQueue. if (SU->isAvailable && !SU->NodeQueueId) { - DEBUG(dbgs() << " Repushing SU #" << SU->NodeNum << '\n'); + LLVM_DEBUG(dbgs() << " Repushing SU #" << SU->NodeNum << '\n'); AvailableQueue->push(SU); } if (i < Interferences.size()) @@ -1441,7 +1441,7 @@ SmallVector LRegs; if (!DelayForLiveRegsBottomUp(CurSU, LRegs)) break; - DEBUG(dbgs() << " Interfering reg "; + LLVM_DEBUG(dbgs() << " Interfering reg "; if (LRegs[0] == TRI->getNumRegs()) dbgs() << "CallResource"; else @@ -1492,17 +1492,17 @@ if (!BtSU->isPending) AvailableQueue->remove(BtSU); } - DEBUG(dbgs() << "ARTIFICIAL edge from SU(" << BtSU->NodeNum << ") to SU(" + LLVM_DEBUG(dbgs() << "ARTIFICIAL edge from SU(" << BtSU->NodeNum << ") to SU(" << TrySU->NodeNum << ")\n"); AddPred(TrySU, SDep(BtSU, SDep::Artificial)); // If one or more successors has been unscheduled, then the current // node is no longer available. if (!TrySU->isAvailable || !TrySU->NodeQueueId) { - DEBUG(dbgs() << "TrySU not available; choosing node from queue\n"); + LLVM_DEBUG(dbgs() << "TrySU not available; choosing node from queue\n"); CurSU = AvailableQueue->pop(); } else { - DEBUG(dbgs() << "TrySU available\n"); + LLVM_DEBUG(dbgs() << "TrySU available\n"); // Available and in AvailableQueue AvailableQueue->remove(TrySU); CurSU = TrySU; @@ -1546,13 +1546,13 @@ // Issue copies, these can be expensive cross register class copies. SmallVector Copies; InsertCopiesAndMoveSuccs(LRDef, Reg, DestRC, RC, Copies); - DEBUG(dbgs() << " Adding an edge from SU #" << TrySU->NodeNum + LLVM_DEBUG(dbgs() << " Adding an edge from SU #" << TrySU->NodeNum << " to SU #" << Copies.front()->NodeNum << "\n"); AddPred(TrySU, SDep(Copies.front(), SDep::Artificial)); NewDef = Copies.back(); } - DEBUG(dbgs() << " Adding an edge from SU #" << NewDef->NodeNum + LLVM_DEBUG(dbgs() << " Adding an edge from SU #" << NewDef->NodeNum << " to SU #" << TrySU->NodeNum << "\n"); LiveRegDefs[Reg] = NewDef; AddPred(NewDef, SDep(TrySU, SDep::Artificial)); @@ -1581,7 +1581,7 @@ // priority. If it is not ready put it back. Schedule the node. Sequence.reserve(SUnits.size()); while (!AvailableQueue->empty() || !Interferences.empty()) { - DEBUG(dbgs() << "\nExamining Available:\n"; + LLVM_DEBUG(dbgs() << "\nExamining Available:\n"; AvailableQueue->dump(this)); // Pick the best node to schedule taking all constraints into @@ -2045,7 +2045,7 @@ unsigned Id = RC->getID(); unsigned RP = RegPressure[Id]; if (!RP) continue; - DEBUG(dbgs() << TRI->getRegClassName(RC) << ": " << RP << " / " + LLVM_DEBUG(dbgs() << TRI->getRegClassName(RC) << ": " << RP << " / " << RegLimit[Id] << '\n'); } } @@ -2198,14 +2198,14 @@ if (RegPressure[RCId] < Cost) { // Register pressure tracking is imprecise. This can happen. But we try // hard not to let it happen because it likely results in poor scheduling. - DEBUG(dbgs() << " SU(" << SU->NodeNum << ") has too many regdefs\n"); + LLVM_DEBUG(dbgs() << " SU(" << SU->NodeNum << ") has too many regdefs\n"); RegPressure[RCId] = 0; } else { RegPressure[RCId] -= Cost; } } - DEBUG(dumpRegPressure()); + LLVM_DEBUG(dumpRegPressure()); } void RegReductionPQBase::unscheduledNode(SUnit *SU) { @@ -2285,7 +2285,7 @@ } } - DEBUG(dumpRegPressure()); + LLVM_DEBUG(dumpRegPressure()); } //===----------------------------------------------------------------------===// @@ -2380,7 +2380,7 @@ if (!hasOnlyLiveInOpers(SU) || !hasOnlyLiveOutUses(SU)) return; - DEBUG(dbgs() << "VRegCycle: SU(" << SU->NodeNum << ")\n"); + LLVM_DEBUG(dbgs() << "VRegCycle: SU(" << SU->NodeNum << ")\n"); SU->isVRegCycle = true; @@ -2418,7 +2418,7 @@ if (Pred.isCtrl()) continue; // ignore chain preds if (Pred.getSUnit()->isVRegCycle && Pred.getSUnit()->getNode()->getOpcode() == ISD::CopyFromReg) { - DEBUG(dbgs() << " VReg cycle use: SU (" << SU->NodeNum << ")\n"); + LLVM_DEBUG(dbgs() << " VReg cycle use: SU (" << SU->NodeNum << ")\n"); return true; } } @@ -2478,7 +2478,7 @@ int LDepth = left->getDepth() - LPenalty; int RDepth = right->getDepth() - RPenalty; if (LDepth != RDepth) { - DEBUG(dbgs() << " Comparing latency of SU (" << left->NodeNum + LLVM_DEBUG(dbgs() << " Comparing latency of SU (" << left->NodeNum << ") depth " << LDepth << " vs SU (" << right->NodeNum << ") depth " << RDepth << "\n"); return LDepth < RDepth ? 1 : -1; @@ -2502,7 +2502,7 @@ static const char *const PhysRegMsg[] = { " has no physreg", " defines a physreg" }; #endif - DEBUG(dbgs() << " SU (" << left->NodeNum << ") " + LLVM_DEBUG(dbgs() << " SU (" << left->NodeNum << ") " << PhysRegMsg[LHasPhysReg] << " SU(" << right->NodeNum << ") " << PhysRegMsg[RHasPhysReg] << "\n"); return LHasPhysReg < RHasPhysReg; @@ -2648,12 +2648,12 @@ // Avoid causing spills. If register pressure is high, schedule for // register pressure reduction. if (LHigh && !RHigh) { - DEBUG(dbgs() << " pressure SU(" << left->NodeNum << ") > SU(" + LLVM_DEBUG(dbgs() << " pressure SU(" << left->NodeNum << ") > SU(" << right->NodeNum << ")\n"); return true; } else if (!LHigh && RHigh) { - DEBUG(dbgs() << " pressure SU(" << right->NodeNum << ") > SU(" + LLVM_DEBUG(dbgs() << " pressure SU(" << right->NodeNum << ") > SU(" << left->NodeNum << ")\n"); return false; } @@ -2716,7 +2716,7 @@ RPDiff = SPQ->RegPressureDiff(right, RLiveUses); } if (!DisableSchedRegPressure && LPDiff != RPDiff) { - DEBUG(dbgs() << "RegPressureDiff SU(" << left->NodeNum << "): " << LPDiff + LLVM_DEBUG(dbgs() << "RegPressureDiff SU(" << left->NodeNum << "): " << LPDiff << " != SU(" << right->NodeNum << "): " << RPDiff << "\n"); return LPDiff > RPDiff; } @@ -2729,7 +2729,7 @@ } if (!DisableSchedLiveUses && (LLiveUses != RLiveUses)) { - DEBUG(dbgs() << "Live uses SU(" << left->NodeNum << "): " << LLiveUses + LLVM_DEBUG(dbgs() << "Live uses SU(" << left->NodeNum << "): " << LLiveUses << " != SU(" << right->NodeNum << "): " << RLiveUses << "\n"); return LLiveUses < RLiveUses; } @@ -2744,7 +2744,7 @@ if (!DisableSchedCriticalPath) { int spread = (int)left->getDepth() - (int)right->getDepth(); if (std::abs(spread) > MaxReorderWindow) { - DEBUG(dbgs() << "Depth of SU(" << left->NodeNum << "): " + LLVM_DEBUG(dbgs() << "Depth of SU(" << left->NodeNum << "): " << left->getDepth() << " != SU(" << right->NodeNum << "): " << right->getDepth() << "\n"); return left->getDepth() < right->getDepth(); @@ -2967,7 +2967,7 @@ // Ok, the transformation is safe and the heuristics suggest it is // profitable. Update the graph. - DEBUG(dbgs() << " Prescheduling SU #" << SU.NodeNum + LLVM_DEBUG(dbgs() << " Prescheduling SU #" << SU.NodeNum << " next to PredSU #" << PredSU->NodeNum << " to guide scheduling in the presence of multiple uses\n"); for (unsigned i = 0; i != PredSU->Succs.size(); ++i) { @@ -3058,7 +3058,7 @@ (isLiveOut && !hasOnlyLiveOutUses(SuccSU)) || (!SU.isCommutable && SuccSU->isCommutable)) && !scheduleDAG->IsReachable(SuccSU, &SU)) { - DEBUG(dbgs() << " Adding a pseudo-two-addr edge from SU #" + LLVM_DEBUG(dbgs() << " Adding a pseudo-two-addr edge from SU #" << SU.NodeNum << " to SU #" << SuccSU->NodeNum << "\n"); scheduleDAG->AddPred(&SU, SDep(SuccSU, SDep::Artificial)); } Index: lib/CodeGen/SelectionDAG/ScheduleDAGVLIW.cpp =================================================================== --- lib/CodeGen/SelectionDAG/ScheduleDAGVLIW.cpp +++ lib/CodeGen/SelectionDAG/ScheduleDAGVLIW.cpp @@ -93,7 +93,7 @@ /// Schedule - Schedule the DAG using list scheduling. void ScheduleDAGVLIW::Schedule() { - DEBUG(dbgs() << "********** List Scheduling " << printMBBReference(*BB) + LLVM_DEBUG(dbgs() << "********** List Scheduling " << printMBBReference(*BB) << " '" << BB->getName() << "' **********\n"); // Build the scheduling graph. @@ -151,8 +151,8 @@ /// count of its successors. If a successor pending count is zero, add it to /// the Available queue. void ScheduleDAGVLIW::scheduleNodeTopDown(SUnit *SU, unsigned CurCycle) { - DEBUG(dbgs() << "*** Scheduling [" << CurCycle << "]: "); - DEBUG(SU->dump(this)); + LLVM_DEBUG(dbgs() << "*** Scheduling [" << CurCycle << "]: "); + LLVM_DEBUG(SU->dump(this)); Sequence.push_back(SU); assert(CurCycle >= SU->getDepth() && "Node scheduled above its depth!"); @@ -246,7 +246,7 @@ } else if (!HasNoopHazards) { // Otherwise, we have a pipeline stall, but no other problem, just advance // the current cycle and try again. - DEBUG(dbgs() << "*** Advancing cycle, no work to do\n"); + LLVM_DEBUG(dbgs() << "*** Advancing cycle, no work to do\n"); HazardRec->AdvanceCycle(); ++NumStalls; ++CurCycle; @@ -254,7 +254,7 @@ // Otherwise, we have no instructions to issue and we have instructions // that will fault if we don't do this right. This is the case for // processors without pipeline interlocks and other cases. - DEBUG(dbgs() << "*** Emitting noop\n"); + LLVM_DEBUG(dbgs() << "*** Emitting noop\n"); HazardRec->EmitNoop(); Sequence.push_back(nullptr); // NULL here means noop ++NumNoops; Index: lib/CodeGen/SelectionDAG/SelectionDAG.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -90,7 +90,7 @@ #define DEBUG_TYPE "selectiondag" static void NewSDValueDbgMsg(SDValue V, StringRef Msg, SelectionDAG *G) { - DEBUG( + LLVM_DEBUG( dbgs() << Msg; V.getNode()->dump(G); ); @@ -7222,7 +7222,7 @@ DV->isIndirect(), DV->getDebugLoc(), DV->getOrder()); ClonedDVs.push_back(Clone); DV->setIsInvalidated(); - DEBUG(dbgs() << "SALVAGE: Rewriting"; N0.getNode()->dumprFull(this); + LLVM_DEBUG(dbgs() << "SALVAGE: Rewriting"; N0.getNode()->dumprFull(this); dbgs() << " into " << *DIExpr << '\n'); } } Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -1097,7 +1097,7 @@ DAG.AddDbgValue(SDV, Val.getNode(), false); } } else - DEBUG(dbgs() << "Dropping debug info for " << *DI << "\n"); + LLVM_DEBUG(dbgs() << "Dropping debug info for " << *DI << "\n"); DanglingDebugInfoMap[V] = DanglingDebugInfo(); } } @@ -2716,7 +2716,7 @@ if (isVectorReductionOp(&I)) { vec_redux = true; - DEBUG(dbgs() << "Detected a reduction operation:" << I << "\n"); + LLVM_DEBUG(dbgs() << "Detected a reduction operation:" << I << "\n"); } SDNodeFlags Flags; @@ -5184,7 +5184,7 @@ const Value *Address = DI.getVariableLocation(); if (!Address || isa(Address) || (Address->use_empty() && !isa(Address))) { - DEBUG(dbgs() << "Dropping debug info for " << DI << "\n"); + LLVM_DEBUG(dbgs() << "Dropping debug info for " << DI << "\n"); return nullptr; } @@ -5245,7 +5245,7 @@ // virtual register info from the FuncInfo.ValueMap. if (!EmitFuncArgumentDbgValue(Address, Variable, Expression, dl, true, N)) { - DEBUG(dbgs() << "Dropping debug info for " << DI << "\n"); + LLVM_DEBUG(dbgs() << "Dropping debug info for " << DI << "\n"); } } return nullptr; @@ -5288,8 +5288,8 @@ return nullptr; } - DEBUG(dbgs() << "Dropping debug location info for:\n " << DI << "\n"); - DEBUG(dbgs() << " Last seen at:\n " << *V << "\n"); + LLVM_DEBUG(dbgs() << "Dropping debug location info for:\n " << DI << "\n"); + LLVM_DEBUG(dbgs() << " Last seen at:\n " << *V << "\n"); return nullptr; } @@ -8522,7 +8522,7 @@ continue; } - DEBUG(dbgs() << "Found argument copy elision candidate: " << *AI << '\n'); + LLVM_DEBUG(dbgs() << "Found argument copy elision candidate: " << *AI << '\n'); // Mark this alloca and store for argument copy elision. *Info = StaticAllocaInfo::Elidable; @@ -8563,7 +8563,7 @@ int OldIndex = AllocaIndex; MachineFrameInfo &MFI = FuncInfo->MF->getFrameInfo(); if (MFI.getObjectSize(FixedIndex) != MFI.getObjectSize(OldIndex)) { - DEBUG(dbgs() << " argument copy elision failed due to bad fixed stack " + LLVM_DEBUG(dbgs() << " argument copy elision failed due to bad fixed stack " "object size\n"); return; } @@ -8573,7 +8573,7 @@ AI->getAllocatedType()); } if (MFI.getObjectAlignment(FixedIndex) < RequiredAlignment) { - DEBUG(dbgs() << " argument copy elision failed: alignment of alloca " + LLVM_DEBUG(dbgs() << " argument copy elision failed: alignment of alloca " "greater than stack argument alignment (" << RequiredAlignment << " vs " << MFI.getObjectAlignment(FixedIndex) << ")\n"); @@ -8582,7 +8582,7 @@ // Perform the elision. Delete the old stack object and replace its only use // in the variable info map. Mark the stack object as mutable. - DEBUG({ + LLVM_DEBUG({ dbgs() << "Eliding argument copy from " << Arg << " to " << *AI << '\n' << " Replacing frame index " << OldIndex << " with " << FixedIndex << '\n'; @@ -8754,7 +8754,7 @@ "LowerFormalArguments didn't return a valid chain!"); assert(InVals.size() == Ins.size() && "LowerFormalArguments didn't emit the correct number of values!"); - DEBUG({ + LLVM_DEBUG({ for (unsigned i = 0, e = Ins.size(); i != e; ++i) { assert(InVals[i].getNode() && "LowerFormalArguments emitted a null value!"); @@ -9905,7 +9905,7 @@ if (!SwitchPeeled) return SwitchMBB; - DEBUG(dbgs() << "Peeled one top case in switch stmt, prob: " << TopCaseProb + LLVM_DEBUG(dbgs() << "Peeled one top case in switch stmt, prob: " << TopCaseProb << "\n"); // Record the MBB for the peeled switch statement. @@ -9923,10 +9923,10 @@ Clusters.erase(PeeledCaseIt); for (CaseCluster &CC : Clusters) { - DEBUG(dbgs() << "Scale the probablity for one cluster, before scaling: " + LLVM_DEBUG(dbgs() << "Scale the probablity for one cluster, before scaling: " << CC.Prob << "\n"); CC.Prob = scaleCaseProbality(CC.Prob, TopCaseProb); - DEBUG(dbgs() << "After scaling: " << CC.Prob << "\n"); + LLVM_DEBUG(dbgs() << "After scaling: " << CC.Prob << "\n"); } PeeledCaseProb = TopCaseProb; return PeeledSwitchMBB; @@ -10005,7 +10005,7 @@ findJumpTables(Clusters, &SI, DefaultMBB); findBitTestClusters(Clusters, &SI); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Case clusters: "; for (const CaseCluster &C : Clusters) { if (C.Kind == CC_JumpTable) dbgs() << "JT:"; Index: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -211,14 +211,14 @@ return; IS.OptLevel = NewOptLevel; IS.TM.setOptLevel(NewOptLevel); - DEBUG(dbgs() << "\nChanging optimization level for Function " + LLVM_DEBUG(dbgs() << "\nChanging optimization level for Function " << IS.MF->getFunction().getName() << "\n"); - DEBUG(dbgs() << "\tBefore: -O" << SavedOptLevel + LLVM_DEBUG(dbgs() << "\tBefore: -O" << SavedOptLevel << " ; After: -O" << NewOptLevel << "\n"); SavedFastISel = IS.TM.Options.EnableFastISel; if (NewOptLevel == CodeGenOpt::None) { IS.TM.setFastISel(IS.TM.getO0WantsFastISel()); - DEBUG(dbgs() << "\tFastISel is " + LLVM_DEBUG(dbgs() << "\tFastISel is " << (IS.TM.Options.EnableFastISel ? "enabled" : "disabled") << "\n"); } @@ -227,9 +227,9 @@ ~OptLevelChanger() { if (IS.OptLevel == SavedOptLevel) return; - DEBUG(dbgs() << "\nRestoring optimization level for Function " + LLVM_DEBUG(dbgs() << "\nRestoring optimization level for Function " << IS.MF->getFunction().getName() << "\n"); - DEBUG(dbgs() << "\tBefore: -O" << IS.OptLevel + LLVM_DEBUG(dbgs() << "\tBefore: -O" << IS.OptLevel << " ; After: -O" << SavedOptLevel << "\n"); IS.OptLevel = SavedOptLevel; IS.TM.setOptLevel(SavedOptLevel); @@ -410,7 +410,7 @@ auto *LIWP = getAnalysisIfAvailable(); LoopInfo *LI = LIWP ? &LIWP->getLoopInfo() : nullptr; - DEBUG(dbgs() << "\n\n\n=== " << Fn.getName() << "\n"); + LLVM_DEBUG(dbgs() << "\n\n\n=== " << Fn.getName() << "\n"); SplitCriticalSideEffectEdges(const_cast(Fn), DT, LI); @@ -513,7 +513,7 @@ // FIXME: VR def may not be in entry block. Def->getParent()->insert(std::next(InsertPos), MI); } else - DEBUG(dbgs() << "Dropping debug info for dead vreg" + LLVM_DEBUG(dbgs() << "Dropping debug info for dead vreg" << TargetRegisterInfo::virtReg2Index(Reg) << "\n"); } @@ -621,8 +621,8 @@ // at this point. FuncInfo->clear(); - DEBUG(dbgs() << "*** MachineFunction at end of ISel ***\n"); - DEBUG(MF->print(dbgs())); + LLVM_DEBUG(dbgs() << "*** MachineFunction at end of ISel ***\n"); + LLVM_DEBUG(MF->print(dbgs())); return true; } @@ -730,7 +730,7 @@ BlockName = (MF->getName() + ":" + FuncInfo->MBB->getBasicBlock()->getName()).str(); } - DEBUG(dbgs() << "Initial selection DAG: " << printMBBReference(*FuncInfo->MBB) + LLVM_DEBUG(dbgs() << "Initial selection DAG: " << printMBBReference(*FuncInfo->MBB) << " '" << BlockName << "'\n"; CurDAG->dump()); @@ -744,7 +744,7 @@ CurDAG->Combine(BeforeLegalizeTypes, AA, OptLevel); } - DEBUG(dbgs() << "Optimized lowered selection DAG: " + LLVM_DEBUG(dbgs() << "Optimized lowered selection DAG: " << printMBBReference(*FuncInfo->MBB) << " '" << BlockName << "'\n"; CurDAG->dump()); @@ -761,7 +761,7 @@ Changed = CurDAG->LegalizeTypes(); } - DEBUG(dbgs() << "Type-legalized selection DAG: " + LLVM_DEBUG(dbgs() << "Type-legalized selection DAG: " << printMBBReference(*FuncInfo->MBB) << " '" << BlockName << "'\n"; CurDAG->dump()); @@ -780,7 +780,7 @@ CurDAG->Combine(AfterLegalizeTypes, AA, OptLevel); } - DEBUG(dbgs() << "Optimized type-legalized selection DAG: " + LLVM_DEBUG(dbgs() << "Optimized type-legalized selection DAG: " << printMBBReference(*FuncInfo->MBB) << " '" << BlockName << "'\n"; CurDAG->dump()); @@ -793,7 +793,7 @@ } if (Changed) { - DEBUG(dbgs() << "Vector-legalized selection DAG: " + LLVM_DEBUG(dbgs() << "Vector-legalized selection DAG: " << printMBBReference(*FuncInfo->MBB) << " '" << BlockName << "'\n"; CurDAG->dump()); @@ -804,7 +804,7 @@ CurDAG->LegalizeTypes(); } - DEBUG(dbgs() << "Vector/type-legalized selection DAG: " + LLVM_DEBUG(dbgs() << "Vector/type-legalized selection DAG: " << printMBBReference(*FuncInfo->MBB) << " '" << BlockName << "'\n"; CurDAG->dump()); @@ -819,7 +819,7 @@ CurDAG->Combine(AfterLegalizeVectorOps, AA, OptLevel); } - DEBUG(dbgs() << "Optimized vector-legalized selection DAG: " + LLVM_DEBUG(dbgs() << "Optimized vector-legalized selection DAG: " << printMBBReference(*FuncInfo->MBB) << " '" << BlockName << "'\n"; CurDAG->dump()); @@ -834,7 +834,7 @@ CurDAG->Legalize(); } - DEBUG(dbgs() << "Legalized selection DAG: " + LLVM_DEBUG(dbgs() << "Legalized selection DAG: " << printMBBReference(*FuncInfo->MBB) << " '" << BlockName << "'\n"; CurDAG->dump()); @@ -849,7 +849,7 @@ CurDAG->Combine(AfterLegalizeDAG, AA, OptLevel); } - DEBUG(dbgs() << "Optimized legalized selection DAG: " + LLVM_DEBUG(dbgs() << "Optimized legalized selection DAG: " << printMBBReference(*FuncInfo->MBB) << " '" << BlockName << "'\n"; CurDAG->dump()); @@ -868,7 +868,7 @@ DoInstructionSelection(); } - DEBUG(dbgs() << "Selected selection DAG: " + LLVM_DEBUG(dbgs() << "Selected selection DAG: " << printMBBReference(*FuncInfo->MBB) << " '" << BlockName << "'\n"; CurDAG->dump()); @@ -938,7 +938,7 @@ } // end anonymous namespace void SelectionDAGISel::DoInstructionSelection() { - DEBUG(dbgs() << "===== Instruction selection begins: " + LLVM_DEBUG(dbgs() << "===== Instruction selection begins: " << printMBBReference(*FuncInfo->MBB) << " '" << FuncInfo->MBB->getName() << "'\n"); @@ -985,7 +985,7 @@ if (Node->isStrictFPOpcode()) Node = CurDAG->mutateStrictFPToFP(Node); - DEBUG(dbgs() << "\nISEL: Starting selection on root node: "; + LLVM_DEBUG(dbgs() << "\nISEL: Starting selection on root node: "; Node->dump(CurDAG)); Select(Node); @@ -994,7 +994,7 @@ CurDAG->setRoot(Dummy.getValue()); } - DEBUG(dbgs() << "\n===== Instruction selection ends:\n"); + LLVM_DEBUG(dbgs() << "\n===== Instruction selection ends:\n"); PostprocessISelDAG(); } @@ -1384,7 +1384,7 @@ // Initialize the Fast-ISel state, if needed. FastISel *FastIS = nullptr; if (TM.Options.EnableFastISel) { - DEBUG(dbgs() << "Enabling fast-isel\n"); + LLVM_DEBUG(dbgs() << "Enabling fast-isel\n"); FastIS = TLI->createFastISel(*FuncInfo, LibInfo); } @@ -1731,7 +1731,7 @@ void SelectionDAGISel::FinishBasicBlock() { - DEBUG(dbgs() << "Total amount of phi nodes to update: " + LLVM_DEBUG(dbgs() << "Total amount of phi nodes to update: " << FuncInfo->PHINodesToUpdate.size() << "\n"; for (unsigned i = 0, e = FuncInfo->PHINodesToUpdate.size(); i != e; ++i) dbgs() << "Node " << i << " : (" @@ -2378,7 +2378,7 @@ if (!NowDeadNodes.empty()) CurDAG->RemoveDeadNodes(NowDeadNodes); - DEBUG(dbgs() << "ISEL: Match complete!\n"); + LLVM_DEBUG(dbgs() << "ISEL: Match complete!\n"); } enum ChainResult { @@ -2994,7 +2994,7 @@ // update the chain results when the pattern is complete. SmallVector ChainNodesMatched; - DEBUG(dbgs() << "ISEL: Starting pattern match\n"); + LLVM_DEBUG(dbgs() << "ISEL: Starting pattern match\n"); // Determine where to start the interpreter. Normally we start at opcode #0, // but if the state machine starts with an OPC_SwitchOpcode, then we @@ -3006,7 +3006,7 @@ // Already computed the OpcodeOffset table, just index into it. if (N.getOpcode() < OpcodeOffset.size()) MatcherIndex = OpcodeOffset[N.getOpcode()]; - DEBUG(dbgs() << " Initial Opcode index to " << MatcherIndex << "\n"); + LLVM_DEBUG(dbgs() << " Initial Opcode index to " << MatcherIndex << "\n"); } else if (MatcherTable[0] == OPC_SwitchOpcode) { // Otherwise, the table isn't computed, but the state machine does start @@ -3073,7 +3073,7 @@ if (!Result) break; - DEBUG(dbgs() << " Skipped scope entry (due to false predicate) at " + LLVM_DEBUG(dbgs() << " Skipped scope entry (due to false predicate) at " << "index " << MatcherIndexOfPredicate << ", continuing at " << FailIndex << "\n"); ++NumDAGIselRetries; @@ -3124,7 +3124,7 @@ if (auto *MN = dyn_cast(N)) MatchedMemRefs.push_back(MN->getMemOperand()); else { - DEBUG( + LLVM_DEBUG( dbgs() << "Expected MemSDNode "; N->dump(CurDAG); dbgs() << '\n' @@ -3249,7 +3249,7 @@ if (CaseSize == 0) break; // Otherwise, execute the case we found. - DEBUG(dbgs() << " OpcodeSwitch from " << SwitchStart + LLVM_DEBUG(dbgs() << " OpcodeSwitch from " << SwitchStart << " to " << MatcherIndex << "\n"); continue; } @@ -3281,7 +3281,7 @@ if (CaseSize == 0) break; // Otherwise, execute the case we found. - DEBUG(dbgs() << " TypeSwitch[" << EVT(CurNodeVT).getEVTString() + LLVM_DEBUG(dbgs() << " TypeSwitch[" << EVT(CurNodeVT).getEVTString() << "] from " << SwitchStart << " to " << MatcherIndex<<'\n'); continue; } @@ -3662,7 +3662,7 @@ Res->setMemRefs(MemRefs, MemRefs + NumMemRefs); } - DEBUG( + LLVM_DEBUG( if (!MatchedMemRefs.empty() && Res->memoperands_empty()) dbgs() << " Dropping mem operands\n"; dbgs() << " " @@ -3731,7 +3731,7 @@ // If the code reached this point, then the match failed. See if there is // another child to try in the current 'Scope', otherwise pop it until we // find a case to check. - DEBUG(dbgs() << " Match failed at index " << CurrentOpcodeIndex << "\n"); + LLVM_DEBUG(dbgs() << " Match failed at index " << CurrentOpcodeIndex << "\n"); ++NumDAGIselRetries; while (true) { if (MatchScopes.empty()) { @@ -3751,7 +3751,7 @@ MatchedMemRefs.resize(LastScope.NumMatchedMemRefs); MatcherIndex = LastScope.FailIndex; - DEBUG(dbgs() << " Continuing at " << MatcherIndex << "\n"); + LLVM_DEBUG(dbgs() << " Continuing at " << MatcherIndex << "\n"); InputChain = LastScope.InputChain; InputGlue = LastScope.InputGlue; Index: lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp @@ -229,7 +229,7 @@ if (level >= 20) { if (!printed) { printed = true; - DEBUG(dbgs() << "setSubgraphColor hit max level\n"); + LLVM_DEBUG(dbgs() << "setSubgraphColor hit max level\n"); } return true; } Index: lib/CodeGen/ShrinkWrap.cpp =================================================================== --- lib/CodeGen/ShrinkWrap.cpp +++ lib/CodeGen/ShrinkWrap.cpp @@ -242,7 +242,7 @@ RegScavenger *RS) const { if (MI.getOpcode() == FrameSetupOpcode || MI.getOpcode() == FrameDestroyOpcode) { - DEBUG(dbgs() << "Frame instruction: " << MI << '\n'); + LLVM_DEBUG(dbgs() << "Frame instruction: " << MI << '\n'); return true; } for (const MachineOperand &MO : MI.operands()) { @@ -268,7 +268,7 @@ } // Skip FrameIndex operands in DBG_VALUE instructions. if (UseOrDefCSR || (MO.isFI() && !MI.isDebugValue())) { - DEBUG(dbgs() << "Use or define CSR(" << UseOrDefCSR << ") or FI(" + LLVM_DEBUG(dbgs() << "Use or define CSR(" << UseOrDefCSR << ") or FI(" << MO.isFI() << "): " << MI << '\n'); return true; } @@ -300,7 +300,7 @@ Save = MDT->findNearestCommonDominator(Save, &MBB); if (!Save) { - DEBUG(dbgs() << "Found a block that is not reachable from Entry\n"); + LLVM_DEBUG(dbgs() << "Found a block that is not reachable from Entry\n"); return; } @@ -334,7 +334,7 @@ } if (!Restore) { - DEBUG(dbgs() << "Restore point needs to be spanned on several blocks\n"); + LLVM_DEBUG(dbgs() << "Restore point needs to be spanned on several blocks\n"); return; } @@ -452,7 +452,7 @@ if (skipFunction(MF.getFunction()) || MF.empty() || !isShrinkWrapEnabled(MF)) return false; - DEBUG(dbgs() << "**** Analysing " << MF.getName() << '\n'); + LLVM_DEBUG(dbgs() << "**** Analysing " << MF.getName() << '\n'); init(MF); @@ -463,7 +463,7 @@ // results. Moreover, we may miss that the prologue and // epilogue are not in the same loop, leading to unbalanced // construction/deconstruction of the stack frame. - DEBUG(dbgs() << "Irreducible CFGs are not supported yet\n"); + LLVM_DEBUG(dbgs() << "Irreducible CFGs are not supported yet\n"); return false; } @@ -472,11 +472,11 @@ TRI->requiresRegisterScavenging(MF) ? new RegScavenger() : nullptr); for (MachineBasicBlock &MBB : MF) { - DEBUG(dbgs() << "Look into: " << MBB.getNumber() << ' ' << MBB.getName() + LLVM_DEBUG(dbgs() << "Look into: " << MBB.getNumber() << ' ' << MBB.getName() << '\n'); if (MBB.isEHFuncletEntry()) { - DEBUG(dbgs() << "EH Funclets are not supported yet.\n"); + LLVM_DEBUG(dbgs() << "EH Funclets are not supported yet.\n"); return false; } @@ -489,7 +489,7 @@ // If we are at a point where we cannot improve the placement of // save/restore instructions, just give up. if (!ArePointsInteresting()) { - DEBUG(dbgs() << "No Shrink wrap candidate found\n"); + LLVM_DEBUG(dbgs() << "No Shrink wrap candidate found\n"); return false; } // No need to look for other instructions, this basic block @@ -502,16 +502,16 @@ // because it means we did not encounter any frame/CSR related code. // Otherwise, we would have returned from the previous loop. assert(!Save && !Restore && "We miss a shrink-wrap opportunity?!"); - DEBUG(dbgs() << "Nothing to shrink-wrap\n"); + LLVM_DEBUG(dbgs() << "Nothing to shrink-wrap\n"); return false; } - DEBUG(dbgs() << "\n ** Results **\nFrequency of the Entry: " << EntryFreq + LLVM_DEBUG(dbgs() << "\n ** Results **\nFrequency of the Entry: " << EntryFreq << '\n'); const TargetFrameLowering *TFI = MF.getSubtarget().getFrameLowering(); do { - DEBUG(dbgs() << "Shrink wrap candidates (#, Name, Freq):\nSave: " + LLVM_DEBUG(dbgs() << "Shrink wrap candidates (#, Name, Freq):\nSave: " << Save->getNumber() << ' ' << Save->getName() << ' ' << MBFI->getBlockFreq(Save).getFrequency() << "\nRestore: " << Restore->getNumber() << ' ' << Restore->getName() << ' ' @@ -523,7 +523,7 @@ ((TargetCanUseSaveAsPrologue = TFI->canUseAsPrologue(*Save)) && TFI->canUseAsEpilogue(*Restore))) break; - DEBUG(dbgs() << "New points are too expensive or invalid for the target\n"); + LLVM_DEBUG(dbgs() << "New points are too expensive or invalid for the target\n"); MachineBasicBlock *NewBB; if (!IsSaveCheap || !TargetCanUseSaveAsPrologue) { Save = FindIDom<>(*Save, Save->predecessors(), *MDT); @@ -545,7 +545,7 @@ return false; } - DEBUG(dbgs() << "Final shrink wrap candidates:\nSave: " << Save->getNumber() + LLVM_DEBUG(dbgs() << "Final shrink wrap candidates:\nSave: " << Save->getNumber() << ' ' << Save->getName() << "\nRestore: " << Restore->getNumber() << ' ' << Restore->getName() << '\n'); Index: lib/CodeGen/SjLjEHPrepare.cpp =================================================================== --- lib/CodeGen/SjLjEHPrepare.cpp +++ lib/CodeGen/SjLjEHPrepare.cpp @@ -301,7 +301,7 @@ for (InvokeInst *Invoke : Invokes) { BasicBlock *UnwindBlock = Invoke->getUnwindDest(); if (UnwindBlock != &BB && LiveBBs.count(UnwindBlock)) { - DEBUG(dbgs() << "SJLJ Spill: " << Inst << " around " + LLVM_DEBUG(dbgs() << "SJLJ Spill: " << Inst << " around " << UnwindBlock->getName() << "\n"); NeedsSpill = true; break; Index: lib/CodeGen/SlotIndexes.cpp =================================================================== --- lib/CodeGen/SlotIndexes.cpp +++ lib/CodeGen/SlotIndexes.cpp @@ -96,7 +96,7 @@ // Sort the Idx2MBBMap std::sort(idx2MBBMap.begin(), idx2MBBMap.end(), Idx2MBBCompare()); - DEBUG(mf->print(dbgs(), this)); + LLVM_DEBUG(mf->print(dbgs(), this)); // And we're done! return false; @@ -146,7 +146,7 @@ void SlotIndexes::renumberIndexes() { // Renumber updates the index of every element of the index list. - DEBUG(dbgs() << "\n*** Renumbering SlotIndexes ***\n"); + LLVM_DEBUG(dbgs() << "\n*** Renumbering SlotIndexes ***\n"); ++NumGlobalRenum; unsigned index = 0; @@ -173,7 +173,7 @@ // If the next index is bigger, we have caught up. } while (curItr != indexList.end() && curItr->getIndex() <= index); - DEBUG(dbgs() << "\n*** Renumbered SlotIndexes " << startItr->getIndex() << '-' + LLVM_DEBUG(dbgs() << "\n*** Renumbered SlotIndexes " << startItr->getIndex() << '-' << index << " ***\n"); ++NumLocalRenum; } Index: lib/CodeGen/SplitKit.cpp =================================================================== --- lib/CodeGen/SplitKit.cpp +++ lib/CodeGen/SplitKit.cpp @@ -191,7 +191,7 @@ // I am looking at you, RegisterCoalescer! DidRepairRange = true; ++NumRepairs; - DEBUG(dbgs() << "*** Fixing inconsistent live interval! ***\n"); + LLVM_DEBUG(dbgs() << "*** Fixing inconsistent live interval! ***\n"); const_cast(LIS) .shrinkToUses(const_cast(CurLI)); UseBlocks.clear(); @@ -201,7 +201,7 @@ assert(fixed && "Couldn't fix broken live interval"); } - DEBUG(dbgs() << "Analyze counted " + LLVM_DEBUG(dbgs() << "Analyze counted " << UseSlots.size() << " instrs in " << UseBlocks.size() << " blocks, through " << NumThroughBlocks << " blocks.\n"); @@ -685,20 +685,20 @@ void SplitEditor::selectIntv(unsigned Idx) { assert(Idx != 0 && "Cannot select the complement interval"); assert(Idx < Edit->size() && "Can only select previously opened interval"); - DEBUG(dbgs() << " selectIntv " << OpenIdx << " -> " << Idx << '\n'); + LLVM_DEBUG(dbgs() << " selectIntv " << OpenIdx << " -> " << Idx << '\n'); OpenIdx = Idx; } SlotIndex SplitEditor::enterIntvBefore(SlotIndex Idx) { assert(OpenIdx && "openIntv not called before enterIntvBefore"); - DEBUG(dbgs() << " enterIntvBefore " << Idx); + LLVM_DEBUG(dbgs() << " enterIntvBefore " << Idx); Idx = Idx.getBaseIndex(); VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Idx); if (!ParentVNI) { - DEBUG(dbgs() << ": not live\n"); + LLVM_DEBUG(dbgs() << ": not live\n"); return Idx; } - DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n'); + LLVM_DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n'); MachineInstr *MI = LIS.getInstructionFromIndex(Idx); assert(MI && "enterIntvBefore called with invalid index"); @@ -708,14 +708,14 @@ SlotIndex SplitEditor::enterIntvAfter(SlotIndex Idx) { assert(OpenIdx && "openIntv not called before enterIntvAfter"); - DEBUG(dbgs() << " enterIntvAfter " << Idx); + LLVM_DEBUG(dbgs() << " enterIntvAfter " << Idx); Idx = Idx.getBoundaryIndex(); VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Idx); if (!ParentVNI) { - DEBUG(dbgs() << ": not live\n"); + LLVM_DEBUG(dbgs() << ": not live\n"); return Idx; } - DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n'); + LLVM_DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n'); MachineInstr *MI = LIS.getInstructionFromIndex(Idx); assert(MI && "enterIntvAfter called with invalid index"); @@ -728,18 +728,18 @@ assert(OpenIdx && "openIntv not called before enterIntvAtEnd"); SlotIndex End = LIS.getMBBEndIdx(&MBB); SlotIndex Last = End.getPrevSlot(); - DEBUG(dbgs() << " enterIntvAtEnd " << printMBBReference(MBB) << ", " + LLVM_DEBUG(dbgs() << " enterIntvAtEnd " << printMBBReference(MBB) << ", " << Last); VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Last); if (!ParentVNI) { - DEBUG(dbgs() << ": not live\n"); + LLVM_DEBUG(dbgs() << ": not live\n"); return End; } - DEBUG(dbgs() << ": valno " << ParentVNI->id); + LLVM_DEBUG(dbgs() << ": valno " << ParentVNI->id); VNInfo *VNI = defFromParent(OpenIdx, ParentVNI, Last, MBB, SA.getLastSplitPointIter(&MBB)); RegAssign.insert(VNI->def, End, OpenIdx); - DEBUG(dump()); + LLVM_DEBUG(dump()); return VNI->def; } @@ -750,23 +750,23 @@ void SplitEditor::useIntv(SlotIndex Start, SlotIndex End) { assert(OpenIdx && "openIntv not called before useIntv"); - DEBUG(dbgs() << " useIntv [" << Start << ';' << End << "):"); + LLVM_DEBUG(dbgs() << " useIntv [" << Start << ';' << End << "):"); RegAssign.insert(Start, End, OpenIdx); - DEBUG(dump()); + LLVM_DEBUG(dump()); } SlotIndex SplitEditor::leaveIntvAfter(SlotIndex Idx) { assert(OpenIdx && "openIntv not called before leaveIntvAfter"); - DEBUG(dbgs() << " leaveIntvAfter " << Idx); + LLVM_DEBUG(dbgs() << " leaveIntvAfter " << Idx); // The interval must be live beyond the instruction at Idx. SlotIndex Boundary = Idx.getBoundaryIndex(); VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Boundary); if (!ParentVNI) { - DEBUG(dbgs() << ": not live\n"); + LLVM_DEBUG(dbgs() << ": not live\n"); return Boundary.getNextSlot(); } - DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n'); + LLVM_DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n'); MachineInstr *MI = LIS.getInstructionFromIndex(Boundary); assert(MI && "No instruction at index"); @@ -788,16 +788,16 @@ SlotIndex SplitEditor::leaveIntvBefore(SlotIndex Idx) { assert(OpenIdx && "openIntv not called before leaveIntvBefore"); - DEBUG(dbgs() << " leaveIntvBefore " << Idx); + LLVM_DEBUG(dbgs() << " leaveIntvBefore " << Idx); // The interval must be live into the instruction at Idx. Idx = Idx.getBaseIndex(); VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Idx); if (!ParentVNI) { - DEBUG(dbgs() << ": not live\n"); + LLVM_DEBUG(dbgs() << ": not live\n"); return Idx.getNextSlot(); } - DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n'); + LLVM_DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n'); MachineInstr *MI = LIS.getInstructionFromIndex(Idx); assert(MI && "No instruction at index"); @@ -808,19 +808,19 @@ SlotIndex SplitEditor::leaveIntvAtTop(MachineBasicBlock &MBB) { assert(OpenIdx && "openIntv not called before leaveIntvAtTop"); SlotIndex Start = LIS.getMBBStartIdx(&MBB); - DEBUG(dbgs() << " leaveIntvAtTop " << printMBBReference(MBB) << ", " + LLVM_DEBUG(dbgs() << " leaveIntvAtTop " << printMBBReference(MBB) << ", " << Start); VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Start); if (!ParentVNI) { - DEBUG(dbgs() << ": not live\n"); + LLVM_DEBUG(dbgs() << ": not live\n"); return Start; } VNInfo *VNI = defFromParent(0, ParentVNI, Start, MBB, MBB.SkipPHIsLabelsAndDebug(MBB.begin())); RegAssign.insert(Start, VNI->def, OpenIdx); - DEBUG(dump()); + LLVM_DEBUG(dump()); return VNI->def; } @@ -835,9 +835,9 @@ // The complement interval will be extended as needed by LRCalc.extend(). if (ParentVNI) forceRecompute(0, *ParentVNI); - DEBUG(dbgs() << " overlapIntv [" << Start << ';' << End << "):"); + LLVM_DEBUG(dbgs() << " overlapIntv [" << Start << ';' << End << "):"); RegAssign.insert(Start, End, OpenIdx); - DEBUG(dump()); + LLVM_DEBUG(dump()); } //===----------------------------------------------------------------------===// @@ -846,7 +846,7 @@ void SplitEditor::removeBackCopies(SmallVectorImpl &Copies) { LiveInterval *LI = &LIS.getInterval(Edit->get(0)); - DEBUG(dbgs() << "Removing " << Copies.size() << " back-copies.\n"); + LLVM_DEBUG(dbgs() << "Removing " << Copies.size() << " back-copies.\n"); RegAssignMap::iterator AssignI; AssignI.setMap(RegAssign); @@ -861,7 +861,7 @@ do AtBegin = MBBI == MBB->begin(); while (!AtBegin && (--MBBI)->isDebugValue()); - DEBUG(dbgs() << "Removing " << Def << '\t' << *MI); + LLVM_DEBUG(dbgs() << "Removing " << Def << '\t' << *MI); LIS.removeVRegDefAt(*LI, Def); LIS.RemoveMachineInstrFromMaps(*MI); MI->eraseFromParent(); @@ -876,11 +876,11 @@ continue; unsigned RegIdx = AssignI.value(); if (AtBegin || !MBBI->readsVirtualRegister(Edit->getReg())) { - DEBUG(dbgs() << " cannot find simple kill of RegIdx " << RegIdx << '\n'); + LLVM_DEBUG(dbgs() << " cannot find simple kill of RegIdx " << RegIdx << '\n'); forceRecompute(RegIdx, *Edit->getParent().getVNInfoAt(Def)); } else { SlotIndex Kill = LIS.getInstructionIndex(*MBBI).getRegSlot(); - DEBUG(dbgs() << " move kill to " << Kill << '\t' << *MBBI); + LLVM_DEBUG(dbgs() << " move kill to " << Kill << '\t' << *MBBI); AssignI.setStop(Kill); } } @@ -907,14 +907,14 @@ // MBB isn't in a loop, it doesn't get any better. All dominators have a // higher frequency by definition. if (!Loop) { - DEBUG(dbgs() << "Def in " << printMBBReference(*DefMBB) << " dominates " + LLVM_DEBUG(dbgs() << "Def in " << printMBBReference(*DefMBB) << " dominates " << printMBBReference(*MBB) << " at depth 0\n"); return MBB; } // We'll never be able to exit the DefLoop. if (Loop == DefLoop) { - DEBUG(dbgs() << "Def in " << printMBBReference(*DefMBB) << " dominates " + LLVM_DEBUG(dbgs() << "Def in " << printMBBReference(*DefMBB) << " dominates " << printMBBReference(*MBB) << " in the same loop\n"); return MBB; } @@ -924,7 +924,7 @@ if (Depth < BestDepth) { BestMBB = MBB; BestDepth = Depth; - DEBUG(dbgs() << "Def in " << printMBBReference(*DefMBB) << " dominates " + LLVM_DEBUG(dbgs() << "Def in " << printMBBReference(*DefMBB) << " dominates " << printMBBReference(*MBB) << " at depth " << Depth << '\n'); } @@ -1031,14 +1031,14 @@ // instruction in the complement range. All other copies of ParentVNI // should be eliminated. if (VNI->def == ParentVNI->def) { - DEBUG(dbgs() << "Direct complement def at " << VNI->def << '\n'); + LLVM_DEBUG(dbgs() << "Direct complement def at " << VNI->def << '\n'); Dom = DomPair(ValMBB, VNI->def); continue; } // Skip the singly mapped values. There is nothing to gain from hoisting a // single back-copy. if (Values.lookup(std::make_pair(0, ParentVNI->id)).getPointer()) { - DEBUG(dbgs() << "Single complement def at " << VNI->def << '\n'); + LLVM_DEBUG(dbgs() << "Single complement def at " << VNI->def << '\n'); continue; } @@ -1062,7 +1062,7 @@ Costs[ParentVNI->id] += MBFI.getBlockFreq(ValMBB); } - DEBUG(dbgs() << "Multi-mapped complement " << VNI->id << '@' << VNI->def + LLVM_DEBUG(dbgs() << "Multi-mapped complement " << VNI->id << '@' << VNI->def << " for parent " << ParentVNI->id << '@' << ParentVNI->def << " hoist to " << printMBBReference(*Dom.first) << ' ' << Dom.second << '\n'); @@ -1118,7 +1118,7 @@ bool Skipped = false; RegAssignMap::const_iterator AssignI = RegAssign.begin(); for (const LiveRange::Segment &S : Edit->getParent()) { - DEBUG(dbgs() << " blit " << S << ':'); + LLVM_DEBUG(dbgs() << " blit " << S << ':'); VNInfo *ParentVNI = S.valno; // RegAssign has holes where RegIdx 0 should be used. SlotIndex Start = S.start; @@ -1140,14 +1140,14 @@ } // The interval [Start;End) is continuously mapped to RegIdx, ParentVNI. - DEBUG(dbgs() << " [" << Start << ';' << End << ")=" << RegIdx + LLVM_DEBUG(dbgs() << " [" << Start << ';' << End << ")=" << RegIdx << '(' << printReg(Edit->get(RegIdx)) << ')'); LiveInterval &LI = LIS.getInterval(Edit->get(RegIdx)); // Check for a simply defined value that can be blitted directly. ValueForcePair VFP = Values.lookup(std::make_pair(RegIdx, ParentVNI->id)); if (VNInfo *VNI = VFP.getPointer()) { - DEBUG(dbgs() << ':' << VNI->id); + LLVM_DEBUG(dbgs() << ':' << VNI->id); LI.addSegment(LiveInterval::Segment(Start, End, VNI)); Start = End; continue; @@ -1155,7 +1155,7 @@ // Skip values with forced recomputation. if (VFP.getInt()) { - DEBUG(dbgs() << "(recalc)"); + LLVM_DEBUG(dbgs() << "(recalc)"); Skipped = true; Start = End; continue; @@ -1174,7 +1174,7 @@ if (Start != BlockStart) { VNInfo *VNI = LI.extendInBlock(BlockStart, std::min(BlockEnd, End)); assert(VNI && "Missing def for complex mapped value"); - DEBUG(dbgs() << ':' << VNI->id << "*" << printMBBReference(*MBB)); + LLVM_DEBUG(dbgs() << ':' << VNI->id << "*" << printMBBReference(*MBB)); // MBB has its own def. Is it also live-out? if (BlockEnd <= End) LRC.setLiveOutValue(&*MBB, VNI); @@ -1187,7 +1187,7 @@ // Handle the live-in blocks covered by [Start;End). assert(Start <= BlockStart && "Expected live-in block"); while (BlockStart < End) { - DEBUG(dbgs() << ">" << printMBBReference(*MBB)); + LLVM_DEBUG(dbgs() << ">" << printMBBReference(*MBB)); BlockEnd = LIS.getMBBEndIdx(&*MBB); if (BlockStart == ParentVNI->def) { // This block has the def of a parent PHI, so it isn't live-in. @@ -1212,7 +1212,7 @@ } Start = End; } while (Start != S.end); - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); } LRCalc[0].calculateValues(); @@ -1314,7 +1314,7 @@ ++RI; // LiveDebugVariables should have handled all DBG_VALUE instructions. if (MI->isDebugValue()) { - DEBUG(dbgs() << "Zapping " << *MI); + LLVM_DEBUG(dbgs() << "Zapping " << *MI); MO.setReg(0); continue; } @@ -1330,7 +1330,7 @@ unsigned RegIdx = RegAssign.lookup(Idx); LiveInterval &LI = LIS.getInterval(Edit->get(RegIdx)); MO.setReg(LI.reg); - DEBUG(dbgs() << " rewr " << printMBBReference(*MI->getParent()) << '\t' + LLVM_DEBUG(dbgs() << " rewr " << printMBBReference(*MI->getParent()) << '\t' << Idx << ':' << RegIdx << '\t' << *MI); // Extend liveness to Idx if the instruction reads reg. @@ -1416,7 +1416,7 @@ if (!MI->allDefsAreDead()) continue; - DEBUG(dbgs() << "All defs dead: " << *MI); + LLVM_DEBUG(dbgs() << "All defs dead: " << *MI); Dead.push_back(MI); } } @@ -1598,7 +1598,7 @@ SlotIndex Start, Stop; std::tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(MBBNum); - DEBUG(dbgs() << "%bb." << MBBNum << " [" << Start << ';' << Stop << ") intf " + LLVM_DEBUG(dbgs() << "%bb." << MBBNum << " [" << Start << ';' << Stop << ") intf " << LeaveBefore << '-' << EnterAfter << ", live-through " << IntvIn << " -> " << IntvOut); @@ -1611,7 +1611,7 @@ MachineBasicBlock *MBB = VRM.getMachineFunction().getBlockNumbered(MBBNum); if (!IntvOut) { - DEBUG(dbgs() << ", spill on entry.\n"); + LLVM_DEBUG(dbgs() << ", spill on entry.\n"); // // <<<<<<<<< Possible LeaveBefore interference. // |-----------| Live through. @@ -1625,7 +1625,7 @@ } if (!IntvIn) { - DEBUG(dbgs() << ", reload on exit.\n"); + LLVM_DEBUG(dbgs() << ", reload on exit.\n"); // // >>>>>>> Possible EnterAfter interference. // |-----------| Live through. @@ -1639,7 +1639,7 @@ } if (IntvIn == IntvOut && !LeaveBefore && !EnterAfter) { - DEBUG(dbgs() << ", straight through.\n"); + LLVM_DEBUG(dbgs() << ", straight through.\n"); // // |-----------| Live through. // ------------- Straight through, same intv, no interference. @@ -1655,7 +1655,7 @@ if (IntvIn != IntvOut && (!LeaveBefore || !EnterAfter || LeaveBefore.getBaseIndex() > EnterAfter.getBoundaryIndex())) { - DEBUG(dbgs() << ", switch avoiding interference.\n"); + LLVM_DEBUG(dbgs() << ", switch avoiding interference.\n"); // // >>>> <<<< Non-overlapping EnterAfter/LeaveBefore interference. // |-----------| Live through. @@ -1676,7 +1676,7 @@ return; } - DEBUG(dbgs() << ", create local intv for interference.\n"); + LLVM_DEBUG(dbgs() << ", create local intv for interference.\n"); // // >>><><><><<<< Overlapping EnterAfter/LeaveBefore interference. // |-----------| Live through. @@ -1700,7 +1700,7 @@ SlotIndex Start, Stop; std::tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(BI.MBB); - DEBUG(dbgs() << printMBBReference(*BI.MBB) << " [" << Start << ';' << Stop + LLVM_DEBUG(dbgs() << printMBBReference(*BI.MBB) << " [" << Start << ';' << Stop << "), uses " << BI.FirstInstr << '-' << BI.LastInstr << ", reg-in " << IntvIn << ", leave before " << LeaveBefore << (BI.LiveOut ? ", stack-out" : ", killed in block")); @@ -1710,7 +1710,7 @@ assert((!LeaveBefore || LeaveBefore > Start) && "Bad interference"); if (!BI.LiveOut && (!LeaveBefore || LeaveBefore >= BI.LastInstr)) { - DEBUG(dbgs() << " before interference.\n"); + LLVM_DEBUG(dbgs() << " before interference.\n"); // // <<< Interference after kill. // |---o---x | Killed in block. @@ -1735,13 +1735,13 @@ // \_____ Stack interval is live-out. // if (BI.LastInstr < LSP) { - DEBUG(dbgs() << ", spill after last use before interference.\n"); + LLVM_DEBUG(dbgs() << ", spill after last use before interference.\n"); selectIntv(IntvIn); SlotIndex Idx = leaveIntvAfter(BI.LastInstr); useIntv(Start, Idx); assert((!LeaveBefore || Idx <= LeaveBefore) && "Interference"); } else { - DEBUG(dbgs() << ", spill before last split point.\n"); + LLVM_DEBUG(dbgs() << ", spill before last split point.\n"); selectIntv(IntvIn); SlotIndex Idx = leaveIntvBefore(LSP); overlapIntv(Idx, BI.LastInstr); @@ -1756,7 +1756,7 @@ // different register. unsigned LocalIntv = openIntv(); (void)LocalIntv; - DEBUG(dbgs() << ", creating local interval " << LocalIntv << ".\n"); + LLVM_DEBUG(dbgs() << ", creating local interval " << LocalIntv << ".\n"); if (!BI.LiveOut || BI.LastInstr < LSP) { // @@ -1792,7 +1792,7 @@ SlotIndex Start, Stop; std::tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(BI.MBB); - DEBUG(dbgs() << printMBBReference(*BI.MBB) << " [" << Start << ';' << Stop + LLVM_DEBUG(dbgs() << printMBBReference(*BI.MBB) << " [" << Start << ';' << Stop << "), uses " << BI.FirstInstr << '-' << BI.LastInstr << ", reg-out " << IntvOut << ", enter after " << EnterAfter << (BI.LiveIn ? ", stack-in" : ", defined in block")); @@ -1804,7 +1804,7 @@ assert((!EnterAfter || EnterAfter < LSP) && "Bad interference"); if (!BI.LiveIn && (!EnterAfter || EnterAfter <= BI.FirstInstr)) { - DEBUG(dbgs() << " after interference.\n"); + LLVM_DEBUG(dbgs() << " after interference.\n"); // // >>>> Interference before def. // | o---o---| Defined in block. @@ -1816,7 +1816,7 @@ } if (!EnterAfter || EnterAfter < BI.FirstInstr.getBaseIndex()) { - DEBUG(dbgs() << ", reload after interference.\n"); + LLVM_DEBUG(dbgs() << ", reload after interference.\n"); // // >>>> Interference before def. // |---o---o---| Live-through, stack-in. @@ -1832,7 +1832,7 @@ // The interference is overlapping somewhere we wanted to use IntvOut. That // means we need to create a local interval that can be allocated a // different register. - DEBUG(dbgs() << ", interference overlaps uses.\n"); + LLVM_DEBUG(dbgs() << ", interference overlaps uses.\n"); // // >>>>>>> Interference overlapping uses. // |---o---o---| Live-through, stack-in. Index: lib/CodeGen/StackColoring.cpp =================================================================== --- lib/CodeGen/StackColoring.cpp +++ lib/CodeGen/StackColoring.cpp @@ -672,12 +672,12 @@ } const AllocaInst *Allocation = MFI->getObjectAllocation(Slot); if (Allocation) { - DEBUG(dbgs() << "Found a lifetime "); - DEBUG(dbgs() << (MI.getOpcode() == TargetOpcode::LIFETIME_START + LLVM_DEBUG(dbgs() << "Found a lifetime "); + LLVM_DEBUG(dbgs() << (MI.getOpcode() == TargetOpcode::LIFETIME_START ? "start" : "end")); - DEBUG(dbgs() << " marker for slot #" << Slot); - DEBUG(dbgs() << " with allocation: " << Allocation->getName() + LLVM_DEBUG(dbgs() << " marker for slot #" << Slot); + LLVM_DEBUG(dbgs() << " with allocation: " << Allocation->getName() << "\n"); } Markers.push_back(&MI); @@ -707,7 +707,7 @@ for (unsigned slot = 0; slot < NumSlot; ++slot) if (NumStartLifetimes[slot] > 1 || NumEndLifetimes[slot] > 1) ConservativeSlots.set(slot); - DEBUG(dumpBV("Conservative slots", ConservativeSlots)); + LLVM_DEBUG(dumpBV("Conservative slots", ConservativeSlots)); // Step 2: compute begin/end sets for each block @@ -738,14 +738,14 @@ BlockInfo.End.set(Slot); } else { for (auto Slot : slots) { - DEBUG(dbgs() << "Found a use of slot #" << Slot); - DEBUG(dbgs() << " at " << printMBBReference(*MBB) << " index "); - DEBUG(Indexes->getInstructionIndex(MI).print(dbgs())); + LLVM_DEBUG(dbgs() << "Found a use of slot #" << Slot); + LLVM_DEBUG(dbgs() << " at " << printMBBReference(*MBB) << " index "); + LLVM_DEBUG(Indexes->getInstructionIndex(MI).print(dbgs())); const AllocaInst *Allocation = MFI->getObjectAllocation(Slot); if (Allocation) { - DEBUG(dbgs() << " with allocation: "<< Allocation->getName()); + LLVM_DEBUG(dbgs() << " with allocation: "<< Allocation->getName()); } - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n"); if (BlockInfo.End.test(Slot)) { BlockInfo.End.reset(Slot); } @@ -880,7 +880,7 @@ } Markers.clear(); - DEBUG(dbgs()<<"Removed "<(VI.Var)->getName() << "].\n"); VI.Slot = SlotRemap[VI.Slot]; FixedDbg++; @@ -1064,9 +1064,9 @@ SlotRemap.count(H.CatchObj.FrameIndex)) H.CatchObj.FrameIndex = SlotRemap[H.CatchObj.FrameIndex]; - DEBUG(dbgs()<<"Fixed "<getInstructionIndex(I); if (Interval->find(Index) == Interval->end()) { Interval->clear(); - DEBUG(dbgs()<<"Invalidating range #"<getFrameInfo(); @@ -1156,21 +1156,21 @@ unsigned NumMarkers = collectMarkers(NumSlots); unsigned TotalSize = 0; - DEBUG(dbgs()<<"Found "<getObjectIndexEnd(); ++i) { - DEBUG(dbgs()<<"Slot #"<getObjectSize(i)<<" bytes.\n"); + LLVM_DEBUG(dbgs()<<"Slot #"<getObjectSize(i)<<" bytes.\n"); TotalSize += MFI->getObjectSize(i); } - DEBUG(dbgs()<<"Total Stack size: "<getObjectAlignment(FirstSlot), MFI->getObjectAlignment(SecondSlot)); @@ -1280,7 +1280,7 @@ // Record statistics. StackSpaceSaved += ReducedSize; StackSlotMerged += RemovedSlots; - DEBUG(dbgs()<<"Merge "<first < RHS->first; }); // Gather all spill slots into a list. - DEBUG(dbgs() << "Spill slot intervals:\n"); + LLVM_DEBUG(dbgs() << "Spill slot intervals:\n"); for (auto *I : Intervals) { LiveInterval &li = I->second; - DEBUG(li.dump()); + LLVM_DEBUG(li.dump()); int FI = TargetRegisterInfo::stackSlot2Index(li.reg); if (MFI->isDeadObjectIndex(FI)) continue; @@ -225,7 +225,7 @@ OrigSizes[FI] = MFI->getObjectSize(FI); AllColors.set(FI); } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); // Sort them by weight. std::stable_sort(SSIntervals.begin(), SSIntervals.end(), IntervalSorter()); @@ -267,7 +267,7 @@ } if (Color != -1 && MFI->getStackID(Color) != MFI->getStackID(FI)) { - DEBUG(dbgs() << "cannot share FIs with different stack IDs\n"); + LLVM_DEBUG(dbgs() << "cannot share FIs with different stack IDs\n"); Share = false; } @@ -282,7 +282,7 @@ // Record the assignment. Assignments[Color].push_back(li); - DEBUG(dbgs() << "Assigning fi#" << FI << " to fi#" << Color << "\n"); + LLVM_DEBUG(dbgs() << "Assigning fi#" << FI << " to fi#" << Color << "\n"); // Change size and alignment of the allocated slot. If there are multiple // objects sharing the same slot, then make sure the size and alignment @@ -305,7 +305,7 @@ SmallVector, 16> RevMap(NumObjs); BitVector UsedColors(NumObjs); - DEBUG(dbgs() << "Color spill slot intervals:\n"); + LLVM_DEBUG(dbgs() << "Color spill slot intervals:\n"); bool Changed = false; for (unsigned i = 0, e = SSIntervals.size(); i != e; ++i) { LiveInterval *li = SSIntervals[i]; @@ -319,7 +319,7 @@ Changed |= (SS != NewSS); } - DEBUG(dbgs() << "\nSpill slots after coloring:\n"); + LLVM_DEBUG(dbgs() << "\nSpill slots after coloring:\n"); for (unsigned i = 0, e = SSIntervals.size(); i != e; ++i) { LiveInterval *li = SSIntervals[i]; int SS = TargetRegisterInfo::stackSlot2Index(li->reg); @@ -330,8 +330,8 @@ #ifndef NDEBUG for (unsigned i = 0, e = SSIntervals.size(); i != e; ++i) - DEBUG(SSIntervals[i]->dump()); - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(SSIntervals[i]->dump()); + LLVM_DEBUG(dbgs() << '\n'); #endif if (!Changed) @@ -358,7 +358,7 @@ // Delete unused stack slots. while (NextColor != -1) { - DEBUG(dbgs() << "Removing unused stack object fi#" << NextColor << "\n"); + LLVM_DEBUG(dbgs() << "Removing unused stack object fi#" << NextColor << "\n"); MFI->RemoveStackObject(NextColor); NextColor = AllColors.find_next(NextColor); } @@ -450,7 +450,7 @@ } bool StackSlotColoring::runOnMachineFunction(MachineFunction &MF) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "********** Stack Slot Coloring **********\n" << "********** Function: " << MF.getName() << '\n'; }); Index: lib/CodeGen/TailDuplicator.cpp =================================================================== --- lib/CodeGen/TailDuplicator.cpp +++ lib/CodeGen/TailDuplicator.cpp @@ -262,7 +262,7 @@ bool MadeChange = false; if (PreRegAlloc && TailDupVerify) { - DEBUG(dbgs() << "\n*** Before tail-duplicating\n"); + LLVM_DEBUG(dbgs() << "\n*** Before tail-duplicating\n"); VerifyPHIs(*MF, true); } @@ -718,7 +718,7 @@ continue; Changed = true; - DEBUG(dbgs() << "\nTail-duplicating into PredBB: " << *PredBB + LLVM_DEBUG(dbgs() << "\nTail-duplicating into PredBB: " << *PredBB << "From simple Succ: " << *TailBB); MachineBasicBlock *NewTarget = *TailBB->succ_begin(); @@ -799,7 +799,7 @@ MachineBasicBlock *ForcedLayoutPred, SmallVectorImpl &TDBBs, SmallVectorImpl &Copies) { - DEBUG(dbgs() << "\n*** Tail-duplicating " << printMBBReference(*TailBB) + LLVM_DEBUG(dbgs() << "\n*** Tail-duplicating " << printMBBReference(*TailBB) << '\n'); DenseSet UsedByPhi; @@ -830,7 +830,7 @@ if (IsLayoutSuccessor) continue; - DEBUG(dbgs() << "\nTail-duplicating into PredBB: " << *PredBB + LLVM_DEBUG(dbgs() << "\nTail-duplicating into PredBB: " << *PredBB << "From Succ: " << *TailBB); TDBBs.push_back(PredBB); @@ -893,7 +893,7 @@ (!PriorTBB || PriorTBB == TailBB) && TailBB->pred_size() == 1 && !TailBB->hasAddressTaken()) { - DEBUG(dbgs() << "\nMerging into block: " << *PrevBB + LLVM_DEBUG(dbgs() << "\nMerging into block: " << *PrevBB << "From MBB: " << *TailBB); // There may be a branch to the layout successor. This is unlikely but it // happens. The correct thing to do is to remove the branch before @@ -999,7 +999,7 @@ MachineBasicBlock *MBB, function_ref *RemovalCallback) { assert(MBB->pred_empty() && "MBB must be dead!"); - DEBUG(dbgs() << "\nRemoving MBB: " << *MBB); + LLVM_DEBUG(dbgs() << "\nRemoving MBB: " << *MBB); if (RemovalCallback) (*RemovalCallback)(MBB); Index: lib/CodeGen/TargetRegisterInfo.cpp =================================================================== --- lib/CodeGen/TargetRegisterInfo.cpp +++ lib/CodeGen/TargetRegisterInfo.cpp @@ -436,7 +436,7 @@ if (F.hasFnAttribute("stackrealign") || requiresRealignment) { if (canRealignStack(MF)) return true; - DEBUG(dbgs() << "Can't realign function's stack: " << F.getName() << "\n"); + LLVM_DEBUG(dbgs() << "Can't realign function's stack: " << F.getName() << "\n"); } return false; } Index: lib/CodeGen/TwoAddressInstructionPass.cpp =================================================================== --- lib/CodeGen/TwoAddressInstructionPass.cpp +++ lib/CodeGen/TwoAddressInstructionPass.cpp @@ -685,15 +685,15 @@ unsigned RegCIdx, unsigned Dist) { unsigned RegC = MI->getOperand(RegCIdx).getReg(); - DEBUG(dbgs() << "2addr: COMMUTING : " << *MI); + LLVM_DEBUG(dbgs() << "2addr: COMMUTING : " << *MI); MachineInstr *NewMI = TII->commuteInstruction(*MI, false, RegBIdx, RegCIdx); if (NewMI == nullptr) { - DEBUG(dbgs() << "2addr: COMMUTING FAILED!\n"); + LLVM_DEBUG(dbgs() << "2addr: COMMUTING FAILED!\n"); return false; } - DEBUG(dbgs() << "2addr: COMMUTED TO: " << *NewMI); + LLVM_DEBUG(dbgs() << "2addr: COMMUTED TO: " << *NewMI); assert(NewMI == MI && "TargetInstrInfo::commuteInstruction() should not return a new " "instruction unless it was requested."); @@ -740,8 +740,8 @@ if (!NewMI) return false; - DEBUG(dbgs() << "2addr: CONVERTING 2-ADDR: " << *mi); - DEBUG(dbgs() << "2addr: TO 3-ADDR: " << *NewMI); + LLVM_DEBUG(dbgs() << "2addr: CONVERTING 2-ADDR: " << *mi); + LLVM_DEBUG(dbgs() << "2addr: TO 3-ADDR: " << *NewMI); bool Sunk = false; if (LIS) @@ -1014,7 +1014,7 @@ LV->addVirtualRegisterKilled(Reg, *MI); } - DEBUG(dbgs() << "\trescheduled below kill: " << *KillMI); + LLVM_DEBUG(dbgs() << "\trescheduled below kill: " << *KillMI); return true; } @@ -1181,7 +1181,7 @@ LV->addVirtualRegisterKilled(Reg, *MI); } - DEBUG(dbgs() << "\trescheduled kill: " << *KillMI); + LLVM_DEBUG(dbgs() << "\trescheduled kill: " << *KillMI); return true; } @@ -1343,7 +1343,7 @@ const MCInstrDesc &UnfoldMCID = TII->get(NewOpc); if (UnfoldMCID.getNumDefs() == 1) { // Unfold the load. - DEBUG(dbgs() << "2addr: UNFOLDING: " << MI); + LLVM_DEBUG(dbgs() << "2addr: UNFOLDING: " << MI); const TargetRegisterClass *RC = TRI->getAllocatableClass( TII->getRegClass(UnfoldMCID, LoadRegIndex, TRI, *MF)); @@ -1352,7 +1352,7 @@ if (!TII->unfoldMemoryOperand(*MF, MI, Reg, /*UnfoldLoad=*/true, /*UnfoldStore=*/false, NewMIs)) { - DEBUG(dbgs() << "2addr: ABANDONING UNFOLD\n"); + LLVM_DEBUG(dbgs() << "2addr: ABANDONING UNFOLD\n"); return false; } assert(NewMIs.size() == 2 && @@ -1365,7 +1365,7 @@ MBB->insert(mi, NewMIs[0]); MBB->insert(mi, NewMIs[1]); - DEBUG(dbgs() << "2addr: NEW LOAD: " << *NewMIs[0] + LLVM_DEBUG(dbgs() << "2addr: NEW LOAD: " << *NewMIs[0] << "2addr: NEW INST: " << *NewMIs[1]); // Transform the instruction, now that it no longer has a load. @@ -1431,7 +1431,7 @@ // Transforming didn't eliminate the tie and didn't lead to an // improvement. Clean up the unfolded instructions and keep the // original. - DEBUG(dbgs() << "2addr: ABANDONING UNFOLD\n"); + LLVM_DEBUG(dbgs() << "2addr: ABANDONING UNFOLD\n"); NewMIs[0]->eraseFromParent(); NewMIs[1]->eraseFromParent(); } @@ -1475,7 +1475,7 @@ MRI->constrainRegClass(DstReg, RC); SrcMO.setReg(DstReg); SrcMO.setSubReg(0); - DEBUG(dbgs() << "\t\trewrite undef:\t" << *MI); + LLVM_DEBUG(dbgs() << "\t\trewrite undef:\t" << *MI); continue; } TiedOperands[SrcReg].push_back(std::make_pair(SrcIdx, DstIdx)); @@ -1574,7 +1574,7 @@ } } - DEBUG(dbgs() << "\t\tprepend:\t" << *MIB); + LLVM_DEBUG(dbgs() << "\t\tprepend:\t" << *MIB); MachineOperand &MO = MI->getOperand(SrcIdx); assert(MO.isReg() && MO.getReg() == RegB && MO.isUse() && @@ -1668,8 +1668,8 @@ bool MadeChange = false; - DEBUG(dbgs() << "********** REWRITING TWO-ADDR INSTRS **********\n"); - DEBUG(dbgs() << "********** Function: " + LLVM_DEBUG(dbgs() << "********** REWRITING TWO-ADDR INSTRS **********\n"); + LLVM_DEBUG(dbgs() << "********** Function: " << MF->getName() << '\n'); // This pass takes the function out of SSA form. @@ -1713,7 +1713,7 @@ ++NumTwoAddressInstrs; MadeChange = true; - DEBUG(dbgs() << '\t' << *mi); + LLVM_DEBUG(dbgs() << '\t' << *mi); // If the instruction has a single pair of tied operands, try some // transformations that may either eliminate the tied operands or @@ -1740,7 +1740,7 @@ // Now iterate over the information collected above. for (auto &TO : TiedOperands) { processTiedPairs(&*mi, TO.second, Dist); - DEBUG(dbgs() << "\t\trewrite to:\t" << *mi); + LLVM_DEBUG(dbgs() << "\t\trewrite to:\t" << *mi); } // Rewrite INSERT_SUBREG as COPY now that we no longer need SSA form. @@ -1754,7 +1754,7 @@ mi->getOperand(0).setIsUndef(mi->getOperand(1).isUndef()); mi->RemoveOperand(1); mi->setDesc(TII->get(TargetOpcode::COPY)); - DEBUG(dbgs() << "\t\tconvert to:\t" << *mi); + LLVM_DEBUG(dbgs() << "\t\tconvert to:\t" << *mi); } // Clear TiedOperands here instead of at the top of the loop @@ -1787,7 +1787,7 @@ if (MI.getOperand(0).getSubReg() || TargetRegisterInfo::isPhysicalRegister(DstReg) || !(MI.getNumOperands() & 1)) { - DEBUG(dbgs() << "Illegal REG_SEQUENCE instruction:" << MI); + LLVM_DEBUG(dbgs() << "Illegal REG_SEQUENCE instruction:" << MI); llvm_unreachable(nullptr); } @@ -1838,19 +1838,19 @@ if (LV && isKill && !TargetRegisterInfo::isPhysicalRegister(SrcReg)) LV->replaceKillInstruction(SrcReg, MI, *CopyMI); - DEBUG(dbgs() << "Inserted: " << *CopyMI); + LLVM_DEBUG(dbgs() << "Inserted: " << *CopyMI); } MachineBasicBlock::iterator EndMBBI = std::next(MachineBasicBlock::iterator(MI)); if (!DefEmitted) { - DEBUG(dbgs() << "Turned: " << MI << " into an IMPLICIT_DEF"); + LLVM_DEBUG(dbgs() << "Turned: " << MI << " into an IMPLICIT_DEF"); MI.setDesc(TII->get(TargetOpcode::IMPLICIT_DEF)); for (int j = MI.getNumOperands() - 1, ee = 0; j > ee; --j) MI.RemoveOperand(j); } else { - DEBUG(dbgs() << "Eliminated: " << MI); + LLVM_DEBUG(dbgs() << "Eliminated: " << MI); MI.eraseFromParent(); } Index: lib/CodeGen/VirtRegMap.cpp =================================================================== --- lib/CodeGen/VirtRegMap.cpp +++ lib/CodeGen/VirtRegMap.cpp @@ -241,10 +241,10 @@ Indexes = &getAnalysis(); LIS = &getAnalysis(); VRM = &getAnalysis(); - DEBUG(dbgs() << "********** REWRITE VIRTUAL REGISTERS **********\n" + LLVM_DEBUG(dbgs() << "********** REWRITE VIRTUAL REGISTERS **********\n" << "********** Function: " << MF->getName() << '\n'); - DEBUG(VRM->dump()); + LLVM_DEBUG(VRM->dump()); // Add kill flags while we still have virtual registers. LIS->addKillFlags(VRM); @@ -376,7 +376,7 @@ void VirtRegRewriter::handleIdentityCopy(MachineInstr &MI) const { if (!MI.isIdentityCopy()) return; - DEBUG(dbgs() << "Identity copy: " << MI); + LLVM_DEBUG(dbgs() << "Identity copy: " << MI); ++NumIdCopies; // Copies like: @@ -387,14 +387,14 @@ // instruction to maintain this information. if (MI.getOperand(0).isUndef() || MI.getNumOperands() > 2) { MI.setDesc(TII->get(TargetOpcode::KILL)); - DEBUG(dbgs() << " replace by: " << MI); + LLVM_DEBUG(dbgs() << " replace by: " << MI); return; } if (Indexes) Indexes->removeSingleMachineInstrFromMaps(MI); MI.eraseFromBundle(); - DEBUG(dbgs() << " deleted.\n"); + LLVM_DEBUG(dbgs() << " deleted.\n"); } /// The liverange splitting logic sometimes produces bundles of copies when @@ -461,7 +461,7 @@ for (MachineFunction::iterator MBBI = MF->begin(), MBBE = MF->end(); MBBI != MBBE; ++MBBI) { - DEBUG(MBBI->print(dbgs(), Indexes)); + LLVM_DEBUG(MBBI->print(dbgs(), Indexes)); for (MachineBasicBlock::instr_iterator MII = MBBI->instr_begin(), MIE = MBBI->instr_end(); MII != MIE;) { MachineInstr *MI = &*MII; @@ -544,7 +544,7 @@ while (!SuperDefs.empty()) MI->addRegisterDefined(SuperDefs.pop_back_val(), TRI); - DEBUG(dbgs() << "> " << *MI); + LLVM_DEBUG(dbgs() << "> " << *MI); expandCopyBundle(*MI); Index: lib/CodeGen/WinEHPrepare.cpp =================================================================== --- lib/CodeGen/WinEHPrepare.cpp +++ lib/CodeGen/WinEHPrepare.cpp @@ -271,9 +271,9 @@ } int CatchHigh = FuncInfo.getLastStateNumber(); addTryBlockMapEntry(FuncInfo, TryLow, TryHigh, CatchHigh, Handlers); - DEBUG(dbgs() << "TryLow[" << BB->getName() << "]: " << TryLow << '\n'); - DEBUG(dbgs() << "TryHigh[" << BB->getName() << "]: " << TryHigh << '\n'); - DEBUG(dbgs() << "CatchHigh[" << BB->getName() << "]: " << CatchHigh + LLVM_DEBUG(dbgs() << "TryLow[" << BB->getName() << "]: " << TryLow << '\n'); + LLVM_DEBUG(dbgs() << "TryHigh[" << BB->getName() << "]: " << TryHigh << '\n'); + LLVM_DEBUG(dbgs() << "CatchHigh[" << BB->getName() << "]: " << CatchHigh << '\n'); } else { auto *CleanupPad = cast(FirstNonPHI); @@ -285,7 +285,7 @@ int CleanupState = addUnwindMapEntry(FuncInfo, ParentState, BB); FuncInfo.EHPadStateMap[CleanupPad] = CleanupState; - DEBUG(dbgs() << "Assigning state #" << CleanupState << " to BB " + LLVM_DEBUG(dbgs() << "Assigning state #" << CleanupState << " to BB " << BB->getName() << '\n'); for (const BasicBlock *PredBlock : predecessors(BB)) { if ((PredBlock = getEHPadFromPredecessor(PredBlock, @@ -351,7 +351,7 @@ // Everything in the __try block uses TryState as its parent state. FuncInfo.EHPadStateMap[CatchSwitch] = TryState; - DEBUG(dbgs() << "Assigning state #" << TryState << " to BB " + LLVM_DEBUG(dbgs() << "Assigning state #" << TryState << " to BB " << CatchPadBB->getName() << '\n'); for (const BasicBlock *PredBlock : predecessors(BB)) if ((PredBlock = getEHPadFromPredecessor(PredBlock, @@ -387,7 +387,7 @@ int CleanupState = addSEHFinally(FuncInfo, ParentState, BB); FuncInfo.EHPadStateMap[CleanupPad] = CleanupState; - DEBUG(dbgs() << "Assigning state #" << CleanupState << " to BB " + LLVM_DEBUG(dbgs() << "Assigning state #" << CleanupState << " to BB " << BB->getName() << '\n'); for (const BasicBlock *PredBlock : predecessors(BB)) if ((PredBlock = @@ -1034,17 +1034,17 @@ demotePHIsOnFunclets(F); if (!DisableCleanups) { - DEBUG(verifyFunction(F)); + LLVM_DEBUG(verifyFunction(F)); removeImplausibleInstructions(F); - DEBUG(verifyFunction(F)); + LLVM_DEBUG(verifyFunction(F)); cleanupPreparedFunclets(F); } - DEBUG(verifyPreparedFunclets(F)); + LLVM_DEBUG(verifyPreparedFunclets(F)); // Recolor the CFG to verify that all is well. - DEBUG(colorFunclets(F)); - DEBUG(verifyPreparedFunclets(F)); + LLVM_DEBUG(colorFunclets(F)); + LLVM_DEBUG(verifyPreparedFunclets(F)); BlockColors.clear(); FuncletBlocks.clear(); Index: lib/ExecutionEngine/ExecutionEngine.cpp =================================================================== --- lib/ExecutionEngine/ExecutionEngine.cpp +++ lib/ExecutionEngine/ExecutionEngine.cpp @@ -214,7 +214,7 @@ assert(!Name.empty() && "Empty GlobalMapping symbol name!"); - DEBUG(dbgs() << "JIT: Map \'" << Name << "\' to [" << Addr << "]\n";); + LLVM_DEBUG(dbgs() << "JIT: Map \'" << Name << "\' to [" << Addr << "]\n";); uint64_t &CurVal = EEState.getGlobalAddressMap()[Name]; assert((!CurVal || !Addr) && "GlobalMapping already established!"); CurVal = Addr; @@ -343,13 +343,13 @@ unsigned PtrSize = EE->getDataLayout().getPointerSize(); Array = make_unique((InputArgv.size()+1)*PtrSize); - DEBUG(dbgs() << "JIT: ARGV = " << (void*)Array.get() << "\n"); + LLVM_DEBUG(dbgs() << "JIT: ARGV = " << (void*)Array.get() << "\n"); Type *SBytePtr = Type::getInt8PtrTy(C); for (unsigned i = 0; i != InputArgv.size(); ++i) { unsigned Size = InputArgv[i].size()+1; auto Dest = make_unique(Size); - DEBUG(dbgs() << "JIT: ARGV[" << i << "] = " << (void*)Dest.get() << "\n"); + LLVM_DEBUG(dbgs() << "JIT: ARGV[" << i << "] = " << (void*)Dest.get() << "\n"); std::copy(InputArgv[i].begin(), InputArgv[i].end(), Dest.get()); Dest[Size-1] = 0; @@ -1180,8 +1180,8 @@ } void ExecutionEngine::InitializeMemory(const Constant *Init, void *Addr) { - DEBUG(dbgs() << "JIT: Initializing " << Addr << " "); - DEBUG(Init->dump()); + LLVM_DEBUG(dbgs() << "JIT: Initializing " << Addr << " "); + LLVM_DEBUG(Init->dump()); if (isa(Init)) return; @@ -1228,7 +1228,7 @@ return; } - DEBUG(dbgs() << "Bad Type: " << *Init->getType() << "\n"); + LLVM_DEBUG(dbgs() << "Bad Type: " << *Init->getType() << "\n"); llvm_unreachable("Unknown constant type to initialize memory with!"); } Index: lib/ExecutionEngine/Interpreter/Execution.cpp =================================================================== --- lib/ExecutionEngine/Interpreter/Execution.cpp +++ lib/ExecutionEngine/Interpreter/Execution.cpp @@ -976,7 +976,7 @@ // Allocate enough memory to hold the type... void *Memory = safe_malloc(MemToAlloc); - DEBUG(dbgs() << "Allocated Type: " << *Ty << " (" << TypeSize << " bytes) x " + LLVM_DEBUG(dbgs() << "Allocated Type: " << *Ty << " (" << TypeSize << " bytes) x " << NumElements << " (Total: " << MemToAlloc << ") at " << uintptr_t(Memory) << '\n'); @@ -1025,7 +1025,7 @@ GenericValue Result; Result.PointerVal = ((char*)getOperandValue(Ptr, SF).PointerVal) + Total; - DEBUG(dbgs() << "GEP Index " << Total << " bytes.\n"); + LLVM_DEBUG(dbgs() << "GEP Index " << Total << " bytes.\n"); return Result; } @@ -2118,7 +2118,7 @@ // Track the number of dynamic instructions executed. ++NumDynamicInsts; - DEBUG(dbgs() << "About to interpret: " << I); + LLVM_DEBUG(dbgs() << "About to interpret: " << I); visit(I); // Dispatch to one of the visit* methods... } } Index: lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp =================================================================== --- lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp +++ lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp @@ -57,9 +57,9 @@ void OProfileJITEventListener::initialize() { if (!Wrapper->op_open_agent()) { const std::string err_str = sys::StrError(); - DEBUG(dbgs() << "Failed to connect to OProfile agent: " << err_str << "\n"); + LLVM_DEBUG(dbgs() << "Failed to connect to OProfile agent: " << err_str << "\n"); } else { - DEBUG(dbgs() << "Connected to OProfile agent.\n"); + LLVM_DEBUG(dbgs() << "Connected to OProfile agent.\n"); } } @@ -67,10 +67,10 @@ if (Wrapper->isAgentAvailable()) { if (Wrapper->op_close_agent() == -1) { const std::string err_str = sys::StrError(); - DEBUG(dbgs() << "Failed to disconnect from OProfile agent: " + LLVM_DEBUG(dbgs() << "Failed to disconnect from OProfile agent: " << err_str << "\n"); } else { - DEBUG(dbgs() << "Disconnected from OProfile agent.\n"); + LLVM_DEBUG(dbgs() << "Disconnected from OProfile agent.\n"); } } } @@ -103,7 +103,7 @@ if (Wrapper->op_write_native_code(Name.data(), Addr, (void *)Addr, Size) == -1) { - DEBUG(dbgs() << "Failed to tell OProfile about native function " << Name + LLVM_DEBUG(dbgs() << "Failed to tell OProfile about native function " << Name << " at [" << (void *)Addr << "-" << ((char *)Addr + Size) << "]\n"); continue; @@ -135,7 +135,7 @@ uint64_t Addr = *AddrOrErr; if (Wrapper->op_unload_native_code(Addr) == -1) { - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "Failed to tell OProfile about unload of native function at " << (void*)Addr << "\n"); continue; Index: lib/ExecutionEngine/OProfileJIT/OProfileWrapper.cpp =================================================================== --- lib/ExecutionEngine/OProfileJIT/OProfileWrapper.cpp +++ lib/ExecutionEngine/OProfileJIT/OProfileWrapper.cpp @@ -64,13 +64,13 @@ // If the oprofile daemon is not running, don't load the opagent library if (!isOProfileRunning()) { - DEBUG(dbgs() << "OProfile daemon is not detected.\n"); + LLVM_DEBUG(dbgs() << "OProfile daemon is not detected.\n"); return false; } std::string error; if(!DynamicLibrary::LoadLibraryPermanently("libopagent.so", &error)) { - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "OProfile connector library libopagent.so could not be loaded: " << error << "\n"); } Index: lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp =================================================================== --- lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp +++ lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp @@ -122,7 +122,7 @@ MutexGuard locked(lock); // Print out the sections prior to relocation. - DEBUG( + LLVM_DEBUG( for (int i = 0, e = Sections.size(); i != e; ++i) dumpSectionMemory(Sections[i], "before relocations"); ); @@ -140,14 +140,14 @@ // entry provides the section to which the relocation will be applied. int Idx = it->first; uint64_t Addr = Sections[Idx].getLoadAddress(); - DEBUG(dbgs() << "Resolving relocations Section #" << Idx << "\t" + LLVM_DEBUG(dbgs() << "Resolving relocations Section #" << Idx << "\t" << format("%p", (uintptr_t)Addr) << "\n"); resolveRelocationList(it->second, Addr); } Relocations.clear(); // Print out sections after relocation. - DEBUG( + LLVM_DEBUG( for (int i = 0, e = Sections.size(); i != e; ++i) dumpSectionMemory(Sections[i], "after relocations"); ); @@ -230,7 +230,7 @@ } // Parse symbols - DEBUG(dbgs() << "Parse symbols:\n"); + LLVM_DEBUG(dbgs() << "Parse symbols:\n"); for (symbol_iterator I = Obj.symbol_begin(), E = Obj.symbol_end(); I != E; ++I) { uint32_t Flags = I->getFlags(); @@ -297,7 +297,7 @@ unsigned SectionID = AbsoluteSymbolSection; - DEBUG(dbgs() << "\tType: " << SymType << " (absolute) Name: " << Name + LLVM_DEBUG(dbgs() << "\tType: " << SymType << " (absolute) Name: " << Name << " SID: " << SectionID << " Offset: " << format("%p", (uintptr_t)Addr) << " flags: " << Flags << "\n"); @@ -329,7 +329,7 @@ else return SectionIDOrErr.takeError(); - DEBUG(dbgs() << "\tType: " << SymType << " Name: " << Name + LLVM_DEBUG(dbgs() << "\tType: " << SymType << " Name: " << Name << " SID: " << SectionID << " Offset: " << format("%p", (uintptr_t)SectOffset) << " flags: " << Flags << "\n"); @@ -344,7 +344,7 @@ return std::move(Err); // Parse and process relocations - DEBUG(dbgs() << "Parse relocations:\n"); + LLVM_DEBUG(dbgs() << "Parse relocations:\n"); for (section_iterator SI = Obj.section_begin(), SE = Obj.section_end(); SI != SE; ++SI) { StubMap Stubs; @@ -367,7 +367,7 @@ else return SectionIDOrErr.takeError(); - DEBUG(dbgs() << "\tSectionID: " << SectionID << "\n"); + LLVM_DEBUG(dbgs() << "\tSectionID: " << SectionID << "\n"); for (; I != E;) if (auto IOrErr = processRelocationRef(SectionID, I, Obj, LocalSections, Stubs)) @@ -669,7 +669,7 @@ SectionEntry("", Addr, CommonSize, CommonSize, 0)); memset(Addr, 0, CommonSize); - DEBUG(dbgs() << "emitCommonSection SectionID: " << SectionID << " new addr: " + LLVM_DEBUG(dbgs() << "emitCommonSection SectionID: " << SectionID << " new addr: " << format("%p", Addr) << " DataSize: " << CommonSize << "\n"); // Assign the address of each symbol @@ -688,7 +688,7 @@ Offset += AlignOffset; } JITSymbolFlags JITSymFlags = getJITSymbolFlags(Sym); - DEBUG(dbgs() << "Allocating common symbol " << Name << " address " + LLVM_DEBUG(dbgs() << "Allocating common symbol " << Name << " address " << format("%p", Addr) << "\n"); GlobalSymbolTable[Name] = SymbolTableEntry(SectionID, Offset, JITSymFlags); @@ -785,7 +785,7 @@ DataSize &= ~(getStubAlignment() - 1); } - DEBUG(dbgs() << "emitSection SectionID: " << SectionID << " Name: " << Name + LLVM_DEBUG(dbgs() << "emitSection SectionID: " << SectionID << " Name: " << Name << " obj addr: " << format("%p", pData) << " new addr: " << format("%p", Addr) << " DataSize: " << DataSize << " StubBufSize: " << StubBufSize @@ -796,7 +796,7 @@ // with these sections). Allocate = 0; Addr = nullptr; - DEBUG(dbgs() << "emitSection SectionID: " << SectionID << " Name: " << Name + LLVM_DEBUG(dbgs() << "emitSection SectionID: " << SectionID << " Name: " << Name << " obj addr: " << format("%p", data.data()) << " new addr: 0" << " DataSize: " << DataSize << " StubBufSize: " << StubBufSize << " Allocate: " << Allocate << "\n"); @@ -976,7 +976,7 @@ // Addr is a uint64_t because we can't assume the pointer width // of the target is the same as that of the host. Just use a generic // "big enough" type. - DEBUG(dbgs() << "Reassigning address for section " << SectionID << " (" + LLVM_DEBUG(dbgs() << "Reassigning address for section " << SectionID << " (" << Sections[SectionID].getName() << "): " << format("0x%016" PRIx64, Sections[SectionID].getLoadAddress()) << " -> " << format("0x%016" PRIx64, Addr) << "\n"); @@ -1034,7 +1034,7 @@ StringRef Name = i->first(); if (Name.size() == 0) { // This is an absolute symbol, use an address of zero. - DEBUG(dbgs() << "Resolving absolute relocations." + LLVM_DEBUG(dbgs() << "Resolving absolute relocations." << "\n"); RelocationList &Relocs = i->second; resolveRelocationList(Relocs, 0); @@ -1077,7 +1077,7 @@ // if the target symbol is Thumb. Addr = modifyAddressBasedOnFlags(Addr, Flags); - DEBUG(dbgs() << "Resolving relocations Name: " << Name << "\t" + LLVM_DEBUG(dbgs() << "Resolving relocations Name: " << Name << "\t" << format("0x%lx", Addr) << "\n"); // This list may have been updated when we called getSymbolAddress, so // don't change this code to get the list earlier. Index: lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp =================================================================== --- lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp +++ lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp @@ -688,11 +688,11 @@ bool RuntimeDyldCheckerImpl::check(StringRef CheckExpr) const { CheckExpr = CheckExpr.trim(); - DEBUG(dbgs() << "RuntimeDyldChecker: Checking '" << CheckExpr << "'...\n"); + LLVM_DEBUG(dbgs() << "RuntimeDyldChecker: Checking '" << CheckExpr << "'...\n"); RuntimeDyldCheckerExprEval P(*this, ErrStream); bool Result = P.evaluate(CheckExpr); (void)Result; - DEBUG(dbgs() << "RuntimeDyldChecker: '" << CheckExpr << "' " + LLVM_DEBUG(dbgs() << "RuntimeDyldChecker: '" << CheckExpr << "' " << (Result ? "passed" : "FAILED") << ".\n"); return Result; } Index: lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp =================================================================== --- lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -273,7 +273,7 @@ case ELF::R_X86_64_64: { support::ulittle64_t::ref(Section.getAddressWithOffset(Offset)) = Value + Addend; - DEBUG(dbgs() << "Writing " << format("%p", (Value + Addend)) << " at " + LLVM_DEBUG(dbgs() << "Writing " << format("%p", (Value + Addend)) << " at " << format("%p\n", Section.getAddressWithOffset(Offset))); break; } @@ -286,7 +286,7 @@ uint32_t TruncatedAddr = (Value & 0xFFFFFFFF); support::ulittle32_t::ref(Section.getAddressWithOffset(Offset)) = TruncatedAddr; - DEBUG(dbgs() << "Writing " << format("%p", TruncatedAddr) << " at " + LLVM_DEBUG(dbgs() << "Writing " << format("%p", TruncatedAddr) << " at " << format("%p\n", Section.getAddressWithOffset(Offset))); break; } @@ -354,7 +354,7 @@ // Data should use target endian. Code should always use little endian. bool isBE = Arch == Triple::aarch64_be; - DEBUG(dbgs() << "resolveAArch64Relocation, LocalAddress: 0x" + LLVM_DEBUG(dbgs() << "resolveAArch64Relocation, LocalAddress: 0x" << format("%llx", Section.getAddressWithOffset(Offset)) << " FinalAddress: 0x" << format("%llx", FinalAddress) << " Value: 0x" << format("%llx", Value) << " Type: 0x" @@ -474,7 +474,7 @@ uint32_t FinalAddress = Section.getLoadAddressWithOffset(Offset) & 0xFFFFFFFF; Value += Addend; - DEBUG(dbgs() << "resolveARMRelocation, LocalAddress: " + LLVM_DEBUG(dbgs() << "resolveARMRelocation, LocalAddress: " << Section.getAddressWithOffset(Offset) << " FinalAddress: " << format("%p", FinalAddress) << " Value: " << format("%x", Value) << " Type: " << format("%x", Type) @@ -859,7 +859,7 @@ break; case ELF::R_BPF_64_64: { write(isBE, Section.getAddressWithOffset(Offset), Value + Addend); - DEBUG(dbgs() << "Writing " << format("%p", (Value + Addend)) << " at " + LLVM_DEBUG(dbgs() << "Writing " << format("%p", (Value + Addend)) << " at " << format("%p\n", Section.getAddressWithOffset(Offset))); break; } @@ -867,7 +867,7 @@ Value += Addend; assert(Value <= UINT32_MAX); write(isBE, Section.getAddressWithOffset(Offset), static_cast(Value)); - DEBUG(dbgs() << "Writing " << format("%p", Value) << " at " + LLVM_DEBUG(dbgs() << "Writing " << format("%p", Value) << " at " << format("%p\n", Section.getAddressWithOffset(Offset))); break; } @@ -1025,7 +1025,7 @@ relocation_iterator RelI, StubMap &Stubs) { - DEBUG(dbgs() << "\t\tThis is an AArch64 branch relocation."); + LLVM_DEBUG(dbgs() << "\t\tThis is an AArch64 branch relocation."); SectionEntry &Section = Sections[SectionID]; uint64_t Offset = RelI->getOffset(); @@ -1036,10 +1036,10 @@ resolveRelocation(Section, Offset, (uint64_t)Section.getAddressWithOffset(i->second), RelType, 0); - DEBUG(dbgs() << " Stub function found\n"); + LLVM_DEBUG(dbgs() << " Stub function found\n"); } else if (!resolveAArch64ShortBranch(SectionID, RelI, Value)) { // Create a new stub function. - DEBUG(dbgs() << " Create a new stub function\n"); + LLVM_DEBUG(dbgs() << " Create a new stub function\n"); Stubs[Value] = Section.getStubOffset(); uint8_t *StubTargetAddr = createStubFunction( Section.getAddressWithOffset(Section.getStubOffset())); @@ -1096,7 +1096,7 @@ else return TargetNameOrErr.takeError(); } - DEBUG(dbgs() << "\t\tRelType: " << RelType << " Addend: " << Addend + LLVM_DEBUG(dbgs() << "\t\tRelType: " << RelType << " Addend: " << Addend << " TargetName: " << TargetName << "\n"); RelocationValueRef Value; // First search for the symbol in the local symbol table @@ -1138,7 +1138,7 @@ section_iterator si = *SectionOrErr; if (si == Obj.section_end()) llvm_unreachable("Symbol section not found, bad object file format!"); - DEBUG(dbgs() << "\t\tThis is section symbol\n"); + LLVM_DEBUG(dbgs() << "\t\tThis is section symbol\n"); bool isCode = si->isText(); if (auto SectionIDOrErr = findOrEmitSection(Obj, (*si), isCode, ObjSectionToID)) @@ -1170,7 +1170,7 @@ uint64_t Offset = RelI->getOffset(); - DEBUG(dbgs() << "\t\tSectionID: " << SectionID << " Offset: " << Offset + LLVM_DEBUG(dbgs() << "\t\tSectionID: " << SectionID << " Offset: " << Offset << "\n"); if ((Arch == Triple::aarch64 || Arch == Triple::aarch64_be)) { if (RelType == ELF::R_AARCH64_CALL26 || RelType == ELF::R_AARCH64_JUMP26) { @@ -1193,7 +1193,7 @@ if (RelType == ELF::R_ARM_PC24 || RelType == ELF::R_ARM_CALL || RelType == ELF::R_ARM_JUMP24) { // This is an ARM branch relocation, need to use a stub function. - DEBUG(dbgs() << "\t\tThis is an ARM branch relocation.\n"); + LLVM_DEBUG(dbgs() << "\t\tThis is an ARM branch relocation.\n"); SectionEntry &Section = Sections[SectionID]; // Look for an existing stub. @@ -1203,10 +1203,10 @@ Section, Offset, reinterpret_cast(Section.getAddressWithOffset(i->second)), RelType, 0); - DEBUG(dbgs() << " Stub function found\n"); + LLVM_DEBUG(dbgs() << " Stub function found\n"); } else { // Create a new stub function. - DEBUG(dbgs() << " Create a new stub function\n"); + LLVM_DEBUG(dbgs() << " Create a new stub function\n"); Stubs[Value] = Section.getStubOffset(); uint8_t *StubTargetAddr = createStubFunction( Section.getAddressWithOffset(Section.getStubOffset())); @@ -1241,7 +1241,7 @@ uint32_t Opcode = readBytesUnaligned(Placeholder, 4); if (RelType == ELF::R_MIPS_26) { // This is an Mips branch relocation, need to use a stub function. - DEBUG(dbgs() << "\t\tThis is a Mips branch relocation."); + LLVM_DEBUG(dbgs() << "\t\tThis is a Mips branch relocation."); SectionEntry &Section = Sections[SectionID]; // Extract the addend from the instruction. @@ -1256,10 +1256,10 @@ if (i != Stubs.end()) { RelocationEntry RE(SectionID, Offset, RelType, i->second); addRelocationForSection(RE, SectionID); - DEBUG(dbgs() << " Stub function found\n"); + LLVM_DEBUG(dbgs() << " Stub function found\n"); } else { // Create a new stub function. - DEBUG(dbgs() << " Create a new stub function\n"); + LLVM_DEBUG(dbgs() << " Create a new stub function\n"); Stubs[Value] = Section.getStubOffset(); unsigned AbiVariant = Obj.getPlatformFlags(); @@ -1343,7 +1343,7 @@ addRelocationForSection(RE, Value.SectionID); } else if (RelType == ELF::R_MIPS_26) { // This is an Mips branch relocation, need to use a stub function. - DEBUG(dbgs() << "\t\tThis is a Mips branch relocation."); + LLVM_DEBUG(dbgs() << "\t\tThis is a Mips branch relocation."); SectionEntry &Section = Sections[SectionID]; // Look up for existing stub. @@ -1351,10 +1351,10 @@ if (i != Stubs.end()) { RelocationEntry RE(SectionID, Offset, RelType, i->second); addRelocationForSection(RE, SectionID); - DEBUG(dbgs() << " Stub function found\n"); + LLVM_DEBUG(dbgs() << " Stub function found\n"); } else { // Create a new stub function. - DEBUG(dbgs() << " Create a new stub function\n"); + LLVM_DEBUG(dbgs() << " Create a new stub function\n"); Stubs[Value] = Section.getStubOffset(); unsigned AbiVariant = Obj.getPlatformFlags(); @@ -1458,10 +1458,10 @@ reinterpret_cast( Section.getAddressWithOffset(i->second)), RelType, 0); - DEBUG(dbgs() << " Stub function found\n"); + LLVM_DEBUG(dbgs() << " Stub function found\n"); } else { // Create a new stub function. - DEBUG(dbgs() << " Create a new stub function\n"); + LLVM_DEBUG(dbgs() << " Create a new stub function\n"); Stubs[Value] = Section.getStubOffset(); uint8_t *StubTargetAddr = createStubFunction( Section.getAddressWithOffset(Section.getStubOffset()), @@ -1578,7 +1578,7 @@ // parts of the stub separately. However, as things stand, we allocate // a stub for every relocation, so using a GOT in JIT code should be // no less space efficient than using an explicit constant pool. - DEBUG(dbgs() << "\t\tThis is a SystemZ indirect relocation."); + LLVM_DEBUG(dbgs() << "\t\tThis is a SystemZ indirect relocation."); SectionEntry &Section = Sections[SectionID]; // Look for an existing stub. @@ -1586,10 +1586,10 @@ uintptr_t StubAddress; if (i != Stubs.end()) { StubAddress = uintptr_t(Section.getAddressWithOffset(i->second)); - DEBUG(dbgs() << " Stub function found\n"); + LLVM_DEBUG(dbgs() << " Stub function found\n"); } else { // Create a new stub function. - DEBUG(dbgs() << " Create a new stub function\n"); + LLVM_DEBUG(dbgs() << " Create a new stub function\n"); uintptr_t BaseAddress = uintptr_t(Section.getAddress()); uintptr_t StubAlignment = getStubAlignment(); @@ -1640,10 +1640,10 @@ uintptr_t StubAddress; if (i != Stubs.end()) { StubAddress = uintptr_t(Section.getAddress()) + i->second; - DEBUG(dbgs() << " Stub function found\n"); + LLVM_DEBUG(dbgs() << " Stub function found\n"); } else { // Create a new stub function (equivalent to a PLT entry). - DEBUG(dbgs() << " Create a new stub function\n"); + LLVM_DEBUG(dbgs() << " Create a new stub function\n"); uintptr_t BaseAddress = uintptr_t(Section.getAddress()); uintptr_t StubAlignment = getStubAlignment(); Index: lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp =================================================================== --- lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp +++ lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp @@ -196,7 +196,7 @@ assert((PTSectionSize % PTEntrySize) == 0 && "Pointers section does not contain a whole number of stubs?"); - DEBUG(dbgs() << "Populating pointer table section " + LLVM_DEBUG(dbgs() << "Populating pointer table section " << Sections[PTSectionID].getName() << ", Section ID " << PTSectionID << ", " << NumPTEntries << " entries, " << PTEntrySize << " bytes each:\n"); @@ -210,7 +210,7 @@ IndirectSymbolName = *IndirectSymbolNameOrErr; else return IndirectSymbolNameOrErr.takeError(); - DEBUG(dbgs() << " " << IndirectSymbolName << ": index " << SymbolIndex + LLVM_DEBUG(dbgs() << " " << IndirectSymbolName << ": index " << SymbolIndex << ", PT offset: " << PTEntryOffset << "\n"); RelocationEntry RE(PTSectionID, PTEntryOffset, MachO::GENERIC_RELOC_VANILLA, 0, false, 2); @@ -275,7 +275,7 @@ int64_t DeltaForEH) { typedef typename Impl::TargetPtrT TargetPtrT; - DEBUG(dbgs() << "Processing FDE: Delta for text: " << DeltaForText + LLVM_DEBUG(dbgs() << "Processing FDE: Delta for text: " << DeltaForText << ", Delta for EH: " << DeltaForEH << "\n"); uint32_t Length = readBytesUnaligned(P, 4); P += 4; Index: lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h =================================================================== --- lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h +++ lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h @@ -80,7 +80,7 @@ SmallString<32> RelTypeName; RelI->getTypeName(RelTypeName); #endif - DEBUG(dbgs() << "\t\tIn Section " << SectionID << " Offset " << Offset + LLVM_DEBUG(dbgs() << "\t\tIn Section " << SectionID << " Offset " << Offset << " RelType: " << RelTypeName << " TargetName: " << TargetName << " Addend " << Addend << "\n"); @@ -145,7 +145,7 @@ : Sections[RE.Sections.SectionA].getLoadAddressWithOffset( RE.Addend); assert(Result <= UINT32_MAX && "relocation overflow"); - DEBUG(dbgs() << "\t\tOffset: " << RE.Offset + LLVM_DEBUG(dbgs() << "\t\tOffset: " << RE.Offset << " RelType: IMAGE_REL_I386_DIR32" << " TargetSection: " << RE.Sections.SectionA << " Value: " << format("0x%08" PRIx32, Result) << '\n'); @@ -159,7 +159,7 @@ Sections[RE.Sections.SectionA].getLoadAddressWithOffset(RE.Addend) - Sections[0].getLoadAddress(); assert(Result <= UINT32_MAX && "relocation overflow"); - DEBUG(dbgs() << "\t\tOffset: " << RE.Offset + LLVM_DEBUG(dbgs() << "\t\tOffset: " << RE.Offset << " RelType: IMAGE_REL_I386_DIR32NB" << " TargetSection: " << RE.Sections.SectionA << " Value: " << format("0x%08" PRIx32, Result) << '\n'); @@ -176,7 +176,7 @@ "relocation overflow"); assert(static_cast(Result) >= INT32_MIN && "relocation underflow"); - DEBUG(dbgs() << "\t\tOffset: " << RE.Offset + LLVM_DEBUG(dbgs() << "\t\tOffset: " << RE.Offset << " RelType: IMAGE_REL_I386_REL32" << " TargetSection: " << RE.Sections.SectionA << " Value: " << format("0x%08" PRIx32, Result) << '\n'); @@ -187,7 +187,7 @@ // 16-bit section index of the section that contains the target. assert(static_cast(RE.SectionID) <= UINT16_MAX && "relocation overflow"); - DEBUG(dbgs() << "\t\tOffset: " << RE.Offset + LLVM_DEBUG(dbgs() << "\t\tOffset: " << RE.Offset << " RelType: IMAGE_REL_I386_SECTION Value: " << RE.SectionID << '\n'); writeBytesUnaligned(RE.SectionID, Target, 2); @@ -196,7 +196,7 @@ // 32-bit offset of the target from the beginning of its section. assert(static_cast(RE.Addend) <= UINT32_MAX && "relocation overflow"); - DEBUG(dbgs() << "\t\tOffset: " << RE.Offset + LLVM_DEBUG(dbgs() << "\t\tOffset: " << RE.Offset << " RelType: IMAGE_REL_I386_SECREL Value: " << RE.Addend << '\n'); writeBytesUnaligned(RE.Addend, Target, 4); Index: lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h =================================================================== --- lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h +++ lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h @@ -97,7 +97,7 @@ SmallString<32> RelTypeName; RelI->getTypeName(RelTypeName); #endif - DEBUG(dbgs() << "\t\tIn Section " << SectionID << " Offset " << Offset + LLVM_DEBUG(dbgs() << "\t\tIn Section " << SectionID << " Offset " << Offset << " RelType: " << RelTypeName << " TargetName: " << TargetName << " Addend " << Addend << "\n"); @@ -187,7 +187,7 @@ : Sections[RE.Sections.SectionA].getLoadAddressWithOffset(RE.Addend); Result |= ISASelectionBit; assert(Result <= UINT32_MAX && "relocation overflow"); - DEBUG(dbgs() << "\t\tOffset: " << RE.Offset + LLVM_DEBUG(dbgs() << "\t\tOffset: " << RE.Offset << " RelType: IMAGE_REL_ARM_ADDR32" << " TargetSection: " << RE.Sections.SectionA << " Value: " << format("0x%08" PRIx32, Result) << '\n'); @@ -200,7 +200,7 @@ uint64_t Result = Sections[RE.Sections.SectionA].getLoadAddress() - Sections[0].getLoadAddress() + RE.Addend; assert(Result <= UINT32_MAX && "relocation overflow"); - DEBUG(dbgs() << "\t\tOffset: " << RE.Offset + LLVM_DEBUG(dbgs() << "\t\tOffset: " << RE.Offset << " RelType: IMAGE_REL_ARM_ADDR32NB" << " TargetSection: " << RE.Sections.SectionA << " Value: " << format("0x%08" PRIx32, Result) << '\n'); @@ -212,7 +212,7 @@ // 16-bit section index of the section that contains the target. assert(static_cast(RE.SectionID) <= UINT16_MAX && "relocation overflow"); - DEBUG(dbgs() << "\t\tOffset: " << RE.Offset + LLVM_DEBUG(dbgs() << "\t\tOffset: " << RE.Offset << " RelType: IMAGE_REL_ARM_SECTION Value: " << RE.SectionID << '\n'); writeBytesUnaligned(RE.SectionID, Target, 2); @@ -221,7 +221,7 @@ // 32-bit offset of the target from the beginning of its section. assert(static_cast(RE.Addend) <= UINT32_MAX && "relocation overflow"); - DEBUG(dbgs() << "\t\tOffset: " << RE.Offset + LLVM_DEBUG(dbgs() << "\t\tOffset: " << RE.Offset << " RelType: IMAGE_REL_ARM_SECREL Value: " << RE.Addend << '\n'); writeBytesUnaligned(RE.Addend, Target, 2); @@ -231,7 +231,7 @@ uint64_t Result = Sections[RE.Sections.SectionA].getLoadAddressWithOffset(RE.Addend); assert(Result <= UINT32_MAX && "relocation overflow"); - DEBUG(dbgs() << "\t\tOffset: " << RE.Offset + LLVM_DEBUG(dbgs() << "\t\tOffset: " << RE.Offset << " RelType: IMAGE_REL_ARM_MOV32T" << " TargetSection: " << RE.Sections.SectionA << " Value: " << format("0x%08" PRIx32, Result) << '\n'); @@ -262,7 +262,7 @@ "relocation overflow"); assert(static_cast(RE.Addend) >= INT32_MIN && "relocation underflow"); - DEBUG(dbgs() << "\t\tOffset: " << RE.Offset + LLVM_DEBUG(dbgs() << "\t\tOffset: " << RE.Offset << " RelType: IMAGE_REL_ARM_BRANCH20T" << " Value: " << static_cast(Value) << '\n'); static_cast(Value); @@ -277,7 +277,7 @@ "relocation overflow"); assert(static_cast(RE.Addend) >= INT32_MIN && "relocation underflow"); - DEBUG(dbgs() << "\t\tOffset: " << RE.Offset + LLVM_DEBUG(dbgs() << "\t\tOffset: " << RE.Offset << " RelType: IMAGE_REL_ARM_BRANCH24T" << " Value: " << static_cast(Value) << '\n'); static_cast(Value); @@ -292,7 +292,7 @@ "relocation overflow"); assert(static_cast(RE.Addend) >= INT32_MIN && "relocation underflow"); - DEBUG(dbgs() << "\t\tOffset: " << RE.Offset + LLVM_DEBUG(dbgs() << "\t\tOffset: " << RE.Offset << " RelType: IMAGE_REL_ARM_BLX23T" << " Value: " << static_cast(Value) << '\n'); static_cast(Value); Index: lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h =================================================================== --- lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h +++ lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h @@ -160,7 +160,7 @@ return TargetNameOrErr.takeError(); StringRef TargetName = *TargetNameOrErr; - DEBUG(dbgs() << "\t\tIn Section " << SectionID << " Offset " << Offset + LLVM_DEBUG(dbgs() << "\t\tIn Section " << SectionID << " Offset " << Offset << " RelType: " << RelType << " TargetName: " << TargetName << " Addend " << Addend << "\n"); Index: lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldELFMips.cpp =================================================================== --- lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldELFMips.cpp +++ lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldELFMips.cpp @@ -55,7 +55,7 @@ uint64_t Offset, uint64_t Value, uint32_t Type) { - DEBUG(dbgs() << "evaluateMIPS32Relocation, LocalAddress: 0x" + LLVM_DEBUG(dbgs() << "evaluateMIPS32Relocation, LocalAddress: 0x" << format("%llx", Section.getAddressWithOffset(Offset)) << " FinalAddress: 0x" << format("%llx", Section.getLoadAddressWithOffset(Offset)) @@ -110,7 +110,7 @@ const SectionEntry &Section, uint64_t Offset, uint64_t Value, uint32_t Type, int64_t Addend, uint64_t SymOffset, SID SectionID) { - DEBUG(dbgs() << "evaluateMIPS64Relocation, LocalAddress: 0x" + LLVM_DEBUG(dbgs() << "evaluateMIPS64Relocation, LocalAddress: 0x" << format("%llx", Section.getAddressWithOffset(Offset)) << " FinalAddress: 0x" << format("%llx", Section.getLoadAddressWithOffset(Offset)) @@ -307,7 +307,7 @@ uint8_t *TargetPtr = Section.getAddressWithOffset(Offset); Value += Addend; - DEBUG(dbgs() << "resolveMIPSO32Relocation, LocalAddress: " + LLVM_DEBUG(dbgs() << "resolveMIPSO32Relocation, LocalAddress: " << Section.getAddressWithOffset(Offset) << " FinalAddress: " << format("%p", Section.getLoadAddressWithOffset(Offset)) << " Value: " << format("%x", Value) Index: lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h =================================================================== --- lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h +++ lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h @@ -311,7 +311,7 @@ } void resolveRelocation(const RelocationEntry &RE, uint64_t Value) override { - DEBUG(dumpRelocationToResolve(RE, Value)); + LLVM_DEBUG(dumpRelocationToResolve(RE, Value)); const SectionEntry &Section = Sections[RE.SectionID]; uint8_t *LocalAddress = Section.getAddressWithOffset(RE.Offset); Index: lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h =================================================================== --- lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h +++ lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h @@ -182,7 +182,7 @@ } void resolveRelocation(const RelocationEntry &RE, uint64_t Value) override { - DEBUG(dumpRelocationToResolve(RE, Value)); + LLVM_DEBUG(dumpRelocationToResolve(RE, Value)); const SectionEntry &Section = Sections[RE.SectionID]; uint8_t *LocalAddress = Section.getAddressWithOffset(RE.Offset); @@ -388,7 +388,7 @@ // addend = Encoded - Expected // = Encoded - (AddrA - AddrB) - DEBUG(dbgs() << "Found SECTDIFF: AddrA: " << AddrA << ", AddrB: " << AddrB + LLVM_DEBUG(dbgs() << "Found SECTDIFF: AddrA: " << AddrA << ", AddrB: " << AddrB << ", Addend: " << Addend << ", SectionA ID: " << SectionAID << ", SectionAOffset: " << SectionAOffset << ", SectionB ID: " << SectionBID Index: lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOI386.h =================================================================== --- lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOI386.h +++ lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOI386.h @@ -97,7 +97,7 @@ } void resolveRelocation(const RelocationEntry &RE, uint64_t Value) override { - DEBUG(dumpRelocationToResolve(RE, Value)); + LLVM_DEBUG(dumpRelocationToResolve(RE, Value)); const SectionEntry &Section = Sections[RE.SectionID]; uint8_t *LocalAddress = Section.getAddressWithOffset(RE.Offset); @@ -192,7 +192,7 @@ // Compute the addend 'C' from the original expression 'A - B + C'. Addend -= AddrA - AddrB; - DEBUG(dbgs() << "Found SECTDIFF: AddrA: " << AddrA << ", AddrB: " << AddrB + LLVM_DEBUG(dbgs() << "Found SECTDIFF: AddrA: " << AddrA << ", AddrB: " << AddrB << ", Addend: " << Addend << ", SectionA ID: " << SectionAID << ", SectionAOffset: " << SectionAOffset << ", SectionB ID: " << SectionBID Index: lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h =================================================================== --- lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h +++ lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h @@ -85,7 +85,7 @@ } void resolveRelocation(const RelocationEntry &RE, uint64_t Value) override { - DEBUG(dumpRelocationToResolve(RE, Value)); + LLVM_DEBUG(dumpRelocationToResolve(RE, Value)); const SectionEntry &Section = Sections[RE.SectionID]; uint8_t *LocalAddress = Section.getAddressWithOffset(RE.Offset); Index: lib/IR/ConstantsContext.h =================================================================== --- lib/IR/ConstantsContext.h +++ lib/IR/ConstantsContext.h @@ -695,7 +695,7 @@ return nullptr; } - void dump() const { DEBUG(dbgs() << "Constant.cpp: ConstantUniqueMap\n"); } + void dump() const { LLVM_DEBUG(dbgs() << "Constant.cpp: ConstantUniqueMap\n"); } }; } // end namespace llvm Index: lib/IR/Core.cpp =================================================================== --- lib/IR/Core.cpp +++ lib/IR/Core.cpp @@ -1532,7 +1532,7 @@ GV->setLinkage(GlobalValue::LinkOnceODRLinkage); break; case LLVMLinkOnceODRAutoHideLinkage: - DEBUG(errs() << "LLVMSetLinkage(): LLVMLinkOnceODRAutoHideLinkage is no " + LLVM_DEBUG(errs() << "LLVMSetLinkage(): LLVMLinkOnceODRAutoHideLinkage is no " "longer supported."); break; case LLVMWeakAnyLinkage: @@ -1557,18 +1557,18 @@ GV->setLinkage(GlobalValue::PrivateLinkage); break; case LLVMDLLImportLinkage: - DEBUG(errs() + LLVM_DEBUG(errs() << "LLVMSetLinkage(): LLVMDLLImportLinkage is no longer supported."); break; case LLVMDLLExportLinkage: - DEBUG(errs() + LLVM_DEBUG(errs() << "LLVMSetLinkage(): LLVMDLLExportLinkage is no longer supported."); break; case LLVMExternalWeakLinkage: GV->setLinkage(GlobalValue::ExternalWeakLinkage); break; case LLVMGhostLinkage: - DEBUG(errs() + LLVM_DEBUG(errs() << "LLVMSetLinkage(): LLVMGhostLinkage is no longer supported."); break; case LLVMCommonLinkage: Index: lib/IR/Pass.cpp =================================================================== --- lib/IR/Pass.cpp +++ lib/IR/Pass.cpp @@ -159,7 +159,7 @@ return true; if (F.hasFnAttribute(Attribute::OptimizeNone)) { - DEBUG(dbgs() << "Skipping pass '" << getPassName() << "' on function " + LLVM_DEBUG(dbgs() << "Skipping pass '" << getPassName() << "' on function " << F.getName() << "\n"); return true; } @@ -194,7 +194,7 @@ if (F->hasFnAttribute(Attribute::OptimizeNone)) { // Report this only once per function. if (&BB == &F->getEntryBlock()) - DEBUG(dbgs() << "Skipping pass '" << getPassName() + LLVM_DEBUG(dbgs() << "Skipping pass '" << getPassName() << "' on function " << F->getName() << "\n"); return true; } Index: lib/IR/SafepointIRVerifier.cpp =================================================================== --- lib/IR/SafepointIRVerifier.cpp +++ lib/IR/SafepointIRVerifier.cpp @@ -535,7 +535,7 @@ Contribution.erase(&I); PoisonedDefs.erase(&I); ValidUnrelocatedDefs.insert(&I); - DEBUG(dbgs() << "Removing urelocated " << I << " from Contribution of " + LLVM_DEBUG(dbgs() << "Removing urelocated " << I << " from Contribution of " << BB->getName() << "\n"); ContributionChanged = true; } else if (PoisonedPointerDef) { @@ -543,7 +543,7 @@ // update of all successors. Contribution.erase(&I); PoisonedDefs.insert(&I); - DEBUG(dbgs() << "Removing poisoned " << I << " from Contribution of " + LLVM_DEBUG(dbgs() << "Removing poisoned " << I << " from Contribution of " << BB->getName() << "\n"); ContributionChanged = true; } else { @@ -594,7 +594,7 @@ AvailableOut = std::move(Temp); } - DEBUG(dbgs() << "Transfered block " << BB->getName() << " from "; + LLVM_DEBUG(dbgs() << "Transfered block " << BB->getName() << " from "; PrintValueSet(dbgs(), AvailableIn.begin(), AvailableIn.end()); dbgs() << " to "; PrintValueSet(dbgs(), AvailableOut.begin(), AvailableOut.end()); @@ -698,7 +698,7 @@ } static void Verify(const Function &F, const DominatorTree &DT) { - DEBUG(dbgs() << "Verifying gc pointers in function: " << F.getName() << "\n"); + LLVM_DEBUG(dbgs() << "Verifying gc pointers in function: " << F.getName() << "\n"); if (PrintOnly) dbgs() << "Verifying gc pointers in function: " << F.getName() << "\n"; Index: lib/IR/ValueSymbolTable.cpp =================================================================== --- lib/IR/ValueSymbolTable.cpp +++ lib/IR/ValueSymbolTable.cpp @@ -74,7 +74,7 @@ // Try inserting the name, assuming it won't conflict. if (vmap.insert(V->getValueName())) { - //DEBUG(dbgs() << " Inserted value: " << V->getValueName() << ": " << *V << "\n"); + //LLVM_DEBUG(dbgs() << " Inserted value: " << V->getValueName() << ": " << *V << "\n"); return; } @@ -89,7 +89,7 @@ } void ValueSymbolTable::removeValueName(ValueName *V) { - //DEBUG(dbgs() << " Removing Value: " << V->getKeyData() << "\n"); + //LLVM_DEBUG(dbgs() << " Removing Value: " << V->getKeyData() << "\n"); // Remove the value from the symbol table. vmap.remove(V); } @@ -101,7 +101,7 @@ // In the common case, the name is not already in the symbol table. auto IterBool = vmap.insert(std::make_pair(Name, V)); if (IterBool.second) { - //DEBUG(dbgs() << " Inserted value: " << Entry.getKeyData() << ": " + //LLVM_DEBUG(dbgs() << " Inserted value: " << Entry.getKeyData() << ": " // << *V << "\n"); return &*IterBool.first; } Index: lib/LTO/ThinLTOCodeGenerator.cpp =================================================================== --- lib/LTO/ThinLTOCodeGenerator.cpp +++ lib/LTO/ThinLTOCodeGenerator.cpp @@ -978,7 +978,7 @@ { auto ErrOrBuffer = CacheEntry.tryLoadingBuffer(); - DEBUG(dbgs() << "Cache " << (ErrOrBuffer ? "hit" : "miss") << " '" + LLVM_DEBUG(dbgs() << "Cache " << (ErrOrBuffer ? "hit" : "miss") << " '" << CacheEntryPath << "' for buffer " << count << " " << ModuleIdentifier << "\n"); Index: lib/MC/MachObjectWriter.cpp =================================================================== --- lib/MC/MachObjectWriter.cpp +++ lib/MC/MachObjectWriter.cpp @@ -952,7 +952,7 @@ report_fatal_error("Data region not terminated"); - DEBUG(dbgs() << "data in code region-- kind: " << Data->Kind + LLVM_DEBUG(dbgs() << "data in code region-- kind: " << Data->Kind << " start: " << Start << "(" << Data->Start->getName() << ")" << " end: " << End << "(" << Data->End->getName() << ")" << " size: " << End - Start Index: lib/MC/WasmObjectWriter.cpp =================================================================== --- lib/MC/WasmObjectWriter.cpp +++ lib/MC/WasmObjectWriter.cpp @@ -292,7 +292,7 @@ assert((Name != nullptr) == (SectionId == wasm::WASM_SEC_CUSTOM) && "Only custom sections can have names"); - DEBUG(dbgs() << "startSection " << SectionId << ": " << Name << "\n"); + LLVM_DEBUG(dbgs() << "startSection " << SectionId << ": " << Name << "\n"); encodeULEB128(SectionId, getStream()); Section.SizeOffset = getStream().tell(); @@ -318,7 +318,7 @@ if (uint32_t(Size) != Size) report_fatal_error("section size does not fit in a uint32_t"); - DEBUG(dbgs() << "endSection size=" << Size << "\n"); + LLVM_DEBUG(dbgs() << "endSection size=" << Size << "\n"); // Write the final section size to the payload_len field, which follows // the section id byte. @@ -425,7 +425,7 @@ unsigned Type = getRelocType(Target, Fixup); WasmRelocationEntry Rec(FixupOffset, SymA, C, Type, &FixupSection); - DEBUG(dbgs() << "WasmReloc: " << Rec << "\n"); + LLVM_DEBUG(dbgs() << "WasmReloc: " << Rec << "\n"); // Relocation other than R_WEBASSEMBLY_TYPE_INDEX_LEB are currently required // to be against a named symbol. @@ -525,7 +525,7 @@ static void addData(SmallVectorImpl &DataBytes, MCSectionWasm &DataSection) { - DEBUG(errs() << "addData: " << DataSection.getSectionName() << "\n"); + LLVM_DEBUG(errs() << "addData: " << DataSection.getSectionName() << "\n"); DataBytes.resize(alignTo(DataBytes.size(), DataSection.getAlignment())); @@ -564,7 +564,7 @@ // See: test/MC/WebAssembly/bss.ll if (LastFragmentSize == 0) DataBytes.resize(DataBytes.size() + 1); - DEBUG(dbgs() << "addData -> " << DataBytes.size() << "\n"); + LLVM_DEBUG(dbgs() << "addData -> " << DataBytes.size() << "\n"); } uint32_t @@ -592,7 +592,7 @@ RelEntry.FixupSection->getSectionOffset() + RelEntry.Offset; - DEBUG(dbgs() << "applyRelocation: " << RelEntry << "\n"); + LLVM_DEBUG(dbgs() << "applyRelocation: " << RelEntry << "\n"); uint32_t Value = getProvisionalValue(RelEntry); switch (RelEntry.Type) { @@ -947,14 +947,14 @@ FunctionTypes.push_back(F); TypeIndices[&Symbol] = Pair.first->second; - DEBUG(dbgs() << "registerFunctionType: " << Symbol << " new:" << Pair.second << "\n"); - DEBUG(dbgs() << " -> type index: " << Pair.first->second << "\n"); + LLVM_DEBUG(dbgs() << "registerFunctionType: " << Symbol << " new:" << Pair.second << "\n"); + LLVM_DEBUG(dbgs() << " -> type index: " << Pair.first->second << "\n"); return Pair.first->second; } void WasmObjectWriter::writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) { - DEBUG(dbgs() << "WasmObjectWriter::writeObject\n"); + LLVM_DEBUG(dbgs() << "WasmObjectWriter::writeObject\n"); MCContext &Ctx = Asm.getContext(); int32_t PtrType = is64Bit() ? wasm::WASM_TYPE_I64 : wasm::WASM_TYPE_I32; @@ -1069,7 +1069,7 @@ continue; const auto &WS = static_cast(S); - DEBUG(dbgs() << "MCSymbol: '" << S << "'" + LLVM_DEBUG(dbgs() << "MCSymbol: '" << S << "'" << " isDefined=" << S.isDefined() << " isExternal=" << S.isExternal() << " isTemporary=" << S.isTemporary() @@ -1113,7 +1113,7 @@ Index = SymbolIndices.find(&WS)->second; } - DEBUG(dbgs() << " -> function index: " << Index << "\n"); + LLVM_DEBUG(dbgs() << " -> function index: " << Index << "\n"); } else { if (WS.isTemporary() && !WS.getSize()) continue; @@ -1140,7 +1140,7 @@ Global.Type.Mutable = false; Global.InitialValue = DataSection.getMemoryOffset() + Layout.getSymbolOffset(WS); SymbolIndices[&WS] = Index; - DEBUG(dbgs() << " -> global index: " << Index << "\n"); + LLVM_DEBUG(dbgs() << " -> global index: " << Index << "\n"); Globals.push_back(Global); } @@ -1153,7 +1153,7 @@ Export.Kind = wasm::WASM_EXTERNAL_FUNCTION; else Export.Kind = wasm::WASM_EXTERNAL_GLOBAL; - DEBUG(dbgs() << " -> export " << Exports.size() << "\n"); + LLVM_DEBUG(dbgs() << " -> export " << Exports.size() << "\n"); Exports.push_back(Export); if (!WS.isExternal()) @@ -1180,10 +1180,10 @@ // Find the target symbol of this weak alias and export that index const auto &WS = static_cast(S); const MCSymbolWasm *ResolvedSym = ResolveSymbol(WS); - DEBUG(dbgs() << WS.getName() << ": weak alias of '" << *ResolvedSym << "'\n"); + LLVM_DEBUG(dbgs() << WS.getName() << ": weak alias of '" << *ResolvedSym << "'\n"); assert(SymbolIndices.count(ResolvedSym) > 0); uint32_t Index = SymbolIndices.find(ResolvedSym)->second; - DEBUG(dbgs() << " -> index:" << Index << "\n"); + LLVM_DEBUG(dbgs() << " -> index:" << Index << "\n"); wasm::WasmExport Export; Export.Name = WS.getName(); @@ -1192,7 +1192,7 @@ Export.Kind = wasm::WASM_EXTERNAL_FUNCTION; else Export.Kind = wasm::WASM_EXTERNAL_GLOBAL; - DEBUG(dbgs() << " -> export " << Exports.size() << "\n"); + LLVM_DEBUG(dbgs() << " -> export " << Exports.size() << "\n"); Exports.push_back(Export); if (!WS.isExternal()) @@ -1212,7 +1212,7 @@ uint32_t SymbolIndex = SymbolIndices.find(&WS)->second; uint32_t TableIndex = TableElems.size() + kInitialTableOffset; if (TableIndices.try_emplace(&WS, TableIndex).second) { - DEBUG(dbgs() << " -> adding " << WS.getName() + LLVM_DEBUG(dbgs() << " -> adding " << WS.getName() << " to table: " << TableIndex << "\n"); TableElems.push_back(SymbolIndex); registerFunctionType(WS); Index: lib/Object/WasmObjectFile.cpp =================================================================== --- lib/Object/WasmObjectFile.cpp +++ lib/Object/WasmObjectFile.cpp @@ -328,7 +328,7 @@ SymbolMap.try_emplace(Import.Field, Symbols.size()); Symbols.emplace_back(Import.Field, WasmSymbol::SymbolType::GLOBAL_IMPORT, GlobalIndex++); - DEBUG(dbgs() << "Adding import: " << Symbols.back() + LLVM_DEBUG(dbgs() << "Adding import: " << Symbols.back() << " sym index:" << Symbols.size() << "\n"); break; case wasm::WASM_EXTERNAL_FUNCTION: @@ -336,7 +336,7 @@ Symbols.emplace_back(Import.Field, WasmSymbol::SymbolType::FUNCTION_IMPORT, FunctionIndex++, Import.SigIndex); - DEBUG(dbgs() << "Adding import: " << Symbols.back() + LLVM_DEBUG(dbgs() << "Adding import: " << Symbols.back() << " sym index:" << Symbols.size() << "\n"); break; default: @@ -355,7 +355,7 @@ auto Pair = SymbolMap.try_emplace(Export.Name, Symbols.size()); if (Pair.second) { Symbols.emplace_back(Export.Name, ExportType, Export.Index); - DEBUG(dbgs() << "Adding export: " << Symbols.back() + LLVM_DEBUG(dbgs() << "Adding export: " << Symbols.back() << " sym index:" << Symbols.size() << "\n"); } else { uint32_t SymIndex = Pair.first->second; @@ -364,7 +364,7 @@ NewSym.setAltIndex(OldSym.ElementIndex); Symbols[SymIndex] = NewSym; - DEBUG(dbgs() << "Replacing existing symbol: " << NewSym + LLVM_DEBUG(dbgs() << "Replacing existing symbol: " << NewSym << " sym index:" << SymIndex << "\n"); } } @@ -412,7 +412,7 @@ uint32_t SymIndex = iter->second; assert(SymIndex < Symbols.size()); Symbols[SymIndex].Flags = Flags; - DEBUG(dbgs() << "Set symbol flags index:" + LLVM_DEBUG(dbgs() << "Set symbol flags index:" << SymIndex << " name:" << Symbols[SymIndex].Name << " expected:" << Symbol << " flags: " << Flags << "\n"); @@ -881,7 +881,7 @@ uint32_t Result = SymbolRef::SF_None; const WasmSymbol &Sym = getWasmSymbol(Symb); - DEBUG(dbgs() << "getSymbolFlags: ptr=" << &Sym << " " << Sym << "\n"); + LLVM_DEBUG(dbgs() << "getSymbolFlags: ptr=" << &Sym << " " << Sym << "\n"); if (Sym.isBindingWeak()) Result |= SymbolRef::SF_Weak; if (!Sym.isBindingLocal()) Index: lib/ProfileData/Coverage/CoverageMapping.cpp =================================================================== --- lib/ProfileData/Coverage/CoverageMapping.cpp +++ lib/ProfileData/Coverage/CoverageMapping.cpp @@ -344,7 +344,7 @@ else Segments.emplace_back(StartLoc.first, StartLoc.second, IsRegionEntry); - DEBUG({ + LLVM_DEBUG({ const auto &Last = Segments.back(); dbgs() << "Segment at " << Last.Line << ":" << Last.Col << " (count = " << Last.Count << ")" @@ -522,7 +522,7 @@ sortNestedRegions(Regions); ArrayRef CombinedRegions = combineRegions(Regions); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Combined regions:\n"; for (const auto &CR : CombinedRegions) dbgs() << " " << CR.LineStart << ":" << CR.ColumnStart << " -> " @@ -537,7 +537,7 @@ const auto &L = Segments[I - 1]; const auto &R = Segments[I]; if (!(L.Line < R.Line) && !(L.Line == R.Line && L.Col < R.Col)) { - DEBUG(dbgs() << " ! Segment " << L.Line << ":" << L.Col + LLVM_DEBUG(dbgs() << " ! Segment " << L.Line << ":" << L.Col << " followed by " << R.Line << ":" << R.Col << "\n"); assert(false && "Coverage segments not unique or sorted"); } @@ -611,7 +611,7 @@ } } - DEBUG(dbgs() << "Emitting segments for file: " << Filename << "\n"); + LLVM_DEBUG(dbgs() << "Emitting segments for file: " << Filename << "\n"); FileCoverage.Segments = SegmentBuilder::buildSegments(Regions); return FileCoverage; @@ -652,7 +652,7 @@ FunctionCoverage.Expansions.emplace_back(CR, Function); } - DEBUG(dbgs() << "Emitting segments for function: " << Function.Name << "\n"); + LLVM_DEBUG(dbgs() << "Emitting segments for function: " << Function.Name << "\n"); FunctionCoverage.Segments = SegmentBuilder::buildSegments(Regions); return FunctionCoverage; @@ -670,7 +670,7 @@ ExpansionCoverage.Expansions.emplace_back(CR, Expansion.Function); } - DEBUG(dbgs() << "Emitting segments for expansion of file " << Expansion.FileID + LLVM_DEBUG(dbgs() << "Emitting segments for expansion of file " << Expansion.FileID << "\n"); ExpansionCoverage.Segments = SegmentBuilder::buildSegments(Regions); Index: lib/ProfileData/Coverage/CoverageMappingReader.cpp =================================================================== --- lib/ProfileData/Coverage/CoverageMappingReader.cpp +++ lib/ProfileData/Coverage/CoverageMappingReader.cpp @@ -228,7 +228,7 @@ ColumnEnd = std::numeric_limits::max(); } - DEBUG({ + LLVM_DEBUG({ dbgs() << "Counter in file " << InferredFileID << " " << LineStart << ":" << ColumnStart << " -> " << (LineStart + NumLines) << ":" << ColumnEnd << ", "; Index: lib/Support/APInt.cpp =================================================================== --- lib/Support/APInt.cpp +++ lib/Support/APInt.cpp @@ -1255,18 +1255,18 @@ // The DEBUG macros here tend to be spam in the debug output if you're not // debugging this code. Disable them unless KNUTH_DEBUG is defined. -#pragma push_macro("DEBUG") +#pragma push_macro("LLVM_DEBUG") #ifndef KNUTH_DEBUG -#undef DEBUG -#define DEBUG(X) do {} while (false) +#undef LLVM_DEBUG +#define LLVM_DEBUG(X) do {} while (false) #endif - DEBUG(dbgs() << "KnuthDiv: m=" << m << " n=" << n << '\n'); - DEBUG(dbgs() << "KnuthDiv: original:"); - DEBUG(for (int i = m+n; i >=0; i--) dbgs() << " " << u[i]); - DEBUG(dbgs() << " by"); - DEBUG(for (int i = n; i >0; i--) dbgs() << " " << v[i-1]); - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "KnuthDiv: m=" << m << " n=" << n << '\n'); + LLVM_DEBUG(dbgs() << "KnuthDiv: original:"); + LLVM_DEBUG(for (int i = m+n; i >=0; i--) dbgs() << " " << u[i]); + LLVM_DEBUG(dbgs() << " by"); + LLVM_DEBUG(for (int i = n; i >0; i--) dbgs() << " " << v[i-1]); + LLVM_DEBUG(dbgs() << '\n'); // D1. [Normalize.] Set d = b / (v[n-1] + 1) and multiply all the digits of // u and v by d. Note that we have taken Knuth's advice here to use a power // of 2 value for d such that d * v[n-1] >= b/2 (b is the base). A power of @@ -1292,16 +1292,16 @@ } u[m+n] = u_carry; - DEBUG(dbgs() << "KnuthDiv: normal:"); - DEBUG(for (int i = m+n; i >=0; i--) dbgs() << " " << u[i]); - DEBUG(dbgs() << " by"); - DEBUG(for (int i = n; i >0; i--) dbgs() << " " << v[i-1]); - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "KnuthDiv: normal:"); + LLVM_DEBUG(for (int i = m+n; i >=0; i--) dbgs() << " " << u[i]); + LLVM_DEBUG(dbgs() << " by"); + LLVM_DEBUG(for (int i = n; i >0; i--) dbgs() << " " << v[i-1]); + LLVM_DEBUG(dbgs() << '\n'); // D2. [Initialize j.] Set j to m. This is the loop counter over the places. int j = m; do { - DEBUG(dbgs() << "KnuthDiv: quotient digit #" << j << '\n'); + LLVM_DEBUG(dbgs() << "KnuthDiv: quotient digit #" << j << '\n'); // D3. [Calculate q'.]. // Set qp = (u[j+n]*b + u[j+n-1]) / v[n-1]. (qp=qprime=q') // Set rp = (u[j+n]*b + u[j+n-1]) % v[n-1]. (rp=rprime=r') @@ -1311,7 +1311,7 @@ // value qp is one too large, and it eliminates all cases where qp is two // too large. uint64_t dividend = Make_64(u[j+n], u[j+n-1]); - DEBUG(dbgs() << "KnuthDiv: dividend == " << dividend << '\n'); + LLVM_DEBUG(dbgs() << "KnuthDiv: dividend == " << dividend << '\n'); uint64_t qp = dividend / v[n-1]; uint64_t rp = dividend % v[n-1]; if (qp == b || qp*v[n-2] > b*rp + u[j+n-2]) { @@ -1320,7 +1320,7 @@ if (rp < b && (qp == b || qp*v[n-2] > b*rp + u[j+n-2])) qp--; } - DEBUG(dbgs() << "KnuthDiv: qp == " << qp << ", rp == " << rp << '\n'); + LLVM_DEBUG(dbgs() << "KnuthDiv: qp == " << qp << ", rp == " << rp << '\n'); // D4. [Multiply and subtract.] Replace (u[j+n]u[j+n-1]...u[j]) with // (u[j+n]u[j+n-1]..u[j]) - qp * (v[n-1]...v[1]v[0]). This computation @@ -1336,15 +1336,15 @@ int64_t subres = int64_t(u[j+i]) - borrow - Lo_32(p); u[j+i] = Lo_32(subres); borrow = Hi_32(p) - Hi_32(subres); - DEBUG(dbgs() << "KnuthDiv: u[j+i] = " << u[j+i] + LLVM_DEBUG(dbgs() << "KnuthDiv: u[j+i] = " << u[j+i] << ", borrow = " << borrow << '\n'); } bool isNeg = u[j+n] < borrow; u[j+n] -= Lo_32(borrow); - DEBUG(dbgs() << "KnuthDiv: after subtraction:"); - DEBUG(for (int i = m+n; i >=0; i--) dbgs() << " " << u[i]); - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "KnuthDiv: after subtraction:"); + LLVM_DEBUG(for (int i = m+n; i >=0; i--) dbgs() << " " << u[i]); + LLVM_DEBUG(dbgs() << '\n'); // D5. [Test remainder.] Set q[j] = qp. If the result of step D4 was // negative, go to step D6; otherwise go on to step D7. @@ -1365,16 +1365,16 @@ } u[j+n] += carry; } - DEBUG(dbgs() << "KnuthDiv: after correction:"); - DEBUG(for (int i = m+n; i >=0; i--) dbgs() << " " << u[i]); - DEBUG(dbgs() << "\nKnuthDiv: digit result = " << q[j] << '\n'); + LLVM_DEBUG(dbgs() << "KnuthDiv: after correction:"); + LLVM_DEBUG(for (int i = m+n; i >=0; i--) dbgs() << " " << u[i]); + LLVM_DEBUG(dbgs() << "\nKnuthDiv: digit result = " << q[j] << '\n'); // D7. [Loop on j.] Decrease j by one. Now if j >= 0, go back to D3. } while (--j >= 0); - DEBUG(dbgs() << "KnuthDiv: quotient:"); - DEBUG(for (int i = m; i >=0; i--) dbgs() <<" " << q[i]); - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "KnuthDiv: quotient:"); + LLVM_DEBUG(for (int i = m; i >=0; i--) dbgs() <<" " << q[i]); + LLVM_DEBUG(dbgs() << '\n'); // D8. [Unnormalize]. Now q[...] is the desired quotient, and the desired // remainder may be obtained by dividing u[...] by d. If r is non-null we @@ -1385,23 +1385,23 @@ // shift right here. if (shift) { uint32_t carry = 0; - DEBUG(dbgs() << "KnuthDiv: remainder:"); + LLVM_DEBUG(dbgs() << "KnuthDiv: remainder:"); for (int i = n-1; i >= 0; i--) { r[i] = (u[i] >> shift) | carry; carry = u[i] << (32 - shift); - DEBUG(dbgs() << " " << r[i]); + LLVM_DEBUG(dbgs() << " " << r[i]); } } else { for (int i = n-1; i >= 0; i--) { r[i] = u[i]; - DEBUG(dbgs() << " " << r[i]); + LLVM_DEBUG(dbgs() << " " << r[i]); } } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); -#pragma pop_macro("DEBUG") +#pragma pop_macro("LLVM_DEBUG") } void APInt::divide(const WordType *LHS, unsigned lhsWords, const WordType *RHS, Index: lib/Support/CachePruning.cpp =================================================================== --- lib/Support/CachePruning.cpp +++ lib/Support/CachePruning.cpp @@ -146,7 +146,7 @@ if (Policy.Expiration == seconds(0) && Policy.MaxSizePercentageOfAvailableSpace == 0 && Policy.MaxSizeBytes == 0 && Policy.MaxSizeFiles == 0) { - DEBUG(dbgs() << "No pruning settings set, exit early\n"); + LLVM_DEBUG(dbgs() << "No pruning settings set, exit early\n"); // Nothing will be pruned, early exit return false; } @@ -173,7 +173,7 @@ const auto TimeStampModTime = FileStatus.getLastModificationTime(); auto TimeStampAge = CurrentTime - TimeStampModTime; if (TimeStampAge <= *Policy.Interval) { - DEBUG(dbgs() << "Timestamp file too recent (" + LLVM_DEBUG(dbgs() << "Timestamp file too recent (" << duration_cast(TimeStampAge).count() << "s old), do not prune.\n"); return false; @@ -207,7 +207,7 @@ // there. ErrorOr StatusOrErr = File->status(); if (!StatusOrErr) { - DEBUG(dbgs() << "Ignore " << File->path() << " (can't stat)\n"); + LLVM_DEBUG(dbgs() << "Ignore " << File->path() << " (can't stat)\n"); continue; } @@ -215,7 +215,7 @@ const auto FileAccessTime = StatusOrErr->getLastAccessedTime(); auto FileAge = CurrentTime - FileAccessTime; if (Policy.Expiration != seconds(0) && FileAge > Policy.Expiration) { - DEBUG(dbgs() << "Remove " << File->path() << " (" + LLVM_DEBUG(dbgs() << "Remove " << File->path() << " (" << duration_cast(FileAge).count() << "s old)\n"); sys::fs::remove(File->path()); continue; @@ -235,7 +235,7 @@ // Update size TotalSize -= FileAndSize->first; NumFiles--; - DEBUG(dbgs() << " - Remove " << FileAndSize->second << " (size " + LLVM_DEBUG(dbgs() << " - Remove " << FileAndSize->second << " (size " << FileAndSize->first << "), new occupancy is " << TotalSize << "%\n"); ++FileAndSize; @@ -263,7 +263,7 @@ AvailableSpace * Policy.MaxSizePercentageOfAvailableSpace / 100ull, Policy.MaxSizeBytes); - DEBUG(dbgs() << "Occupancy: " << ((100 * TotalSize) / AvailableSpace) + LLVM_DEBUG(dbgs() << "Occupancy: " << ((100 * TotalSize) / AvailableSpace) << "% target is: " << Policy.MaxSizePercentageOfAvailableSpace << "%, " << Policy.MaxSizeBytes << " bytes\n"); Index: lib/Support/CommandLine.cpp =================================================================== --- lib/Support/CommandLine.cpp +++ lib/Support/CommandLine.cpp @@ -1371,7 +1371,7 @@ // Now that we know if -debug is specified, we can use it. // Note that if ReadResponseFiles == true, this must be done before the // memory allocated for the expanded command line is free()d below. - DEBUG(dbgs() << "Args: "; + LLVM_DEBUG(dbgs() << "Args: "; for (int i = 0; i < argc; ++i) dbgs() << argv[i] << ' '; dbgs() << '\n';); Index: lib/Support/DAGDeltaAlgorithm.cpp =================================================================== --- lib/Support/DAGDeltaAlgorithm.cpp +++ lib/Support/DAGDeltaAlgorithm.cpp @@ -124,7 +124,7 @@ /// ExecuteOneTest - Execute a single test predicate on the change set \p S. bool ExecuteOneTest(const changeset_ty &S) { // Check dependencies invariant. - DEBUG({ + LLVM_DEBUG({ for (changeset_ty::const_iterator it = S.begin(), ie = S.end(); it != ie; ++it) for (succ_iterator_ty it2 = succ_begin(*it), @@ -224,7 +224,7 @@ PredClosure[*it2].insert(*it); // Dump useful debug info. - DEBUG({ + LLVM_DEBUG({ llvm::errs() << "-- DAGDeltaAlgorithmImpl --\n"; llvm::errs() << "Changes: ["; for (changeset_ty::const_iterator it = Changes.begin(), @@ -312,7 +312,7 @@ // Invariant: CurrentSet intersect Required == {} // Invariant: Required == (Required union succ*(Required)) while (!CurrentSet.empty()) { - DEBUG({ + LLVM_DEBUG({ llvm::errs() << "DAG_DD - " << CurrentSet.size() << " active changes, " << Required.size() << " required changes\n"; }); Index: lib/Support/Debug.cpp =================================================================== --- lib/Support/Debug.cpp +++ lib/Support/Debug.cpp @@ -11,7 +11,7 @@ // code, without it being enabled all of the time, and without having to add // command line options to enable it. // -// In particular, just wrap your code with the DEBUG() macro, and it will be +// In particular, just wrap your code with the LLVM_DEBUG() macro, and it will be // enabled automatically if you specify '-debug' on the command-line. // Alternatively, you can also use the SET_DEBUG_TYPE("foo") macro to specify // that your debug code belongs to class "foo". Then, on the command line, you @@ -19,7 +19,7 @@ // foo class. // // When compiling without assertions, the -debug-* options and all code in -// DEBUG() statements disappears, so it does not affect the runtime of the code. +// LLVM_DEBUG() statements disappears, so it does not affect the runtime of the code. // //===----------------------------------------------------------------------===// Index: lib/Support/RandomNumberGenerator.cpp =================================================================== --- lib/Support/RandomNumberGenerator.cpp +++ lib/Support/RandomNumberGenerator.cpp @@ -36,7 +36,7 @@ cl::desc("Seed for the random number generator"), cl::init(0)); RandomNumberGenerator::RandomNumberGenerator(StringRef Salt) { - DEBUG( + LLVM_DEBUG( if (Seed == 0) dbgs() << "Warning! Using unseeded random number generator.\n" ); Index: lib/Target/AArch64/AArch64A53Fix835769.cpp =================================================================== --- lib/Target/AArch64/AArch64A53Fix835769.cpp +++ lib/Target/AArch64/AArch64A53Fix835769.cpp @@ -116,7 +116,7 @@ bool AArch64A53Fix835769::runOnMachineFunction(MachineFunction &F) { - DEBUG(dbgs() << "***** AArch64A53Fix835769 *****\n"); + LLVM_DEBUG(dbgs() << "***** AArch64A53Fix835769 *****\n"); bool Changed = false; TII = F.getSubtarget().getInstrInfo(); @@ -190,7 +190,7 @@ bool AArch64A53Fix835769::runOnBasicBlock(MachineBasicBlock &MBB) { bool Changed = false; - DEBUG(dbgs() << "Running on MBB: " << MBB << " - scanning instructions...\n"); + LLVM_DEBUG(dbgs() << "Running on MBB: " << MBB << " - scanning instructions...\n"); // First, scan the basic block, looking for a sequence of 2 instructions // that match the conditions under which the erratum may trigger. @@ -206,9 +206,9 @@ for (auto &MI : MBB) { MachineInstr *CurrInstr = &MI; - DEBUG(dbgs() << " Examining: " << MI); + LLVM_DEBUG(dbgs() << " Examining: " << MI); if (PrevInstr) { - DEBUG(dbgs() << " PrevInstr: " << *PrevInstr + LLVM_DEBUG(dbgs() << " PrevInstr: " << *PrevInstr << " CurrInstr: " << *CurrInstr << " isFirstInstructionInSequence(PrevInstr): " << isFirstInstructionInSequence(PrevInstr) << "\n" @@ -216,7 +216,7 @@ << isSecondInstructionInSequence(CurrInstr) << "\n"); if (isFirstInstructionInSequence(PrevInstr) && isSecondInstructionInSequence(CurrInstr)) { - DEBUG(dbgs() << " ** pattern found at Idx " << Idx << "!\n"); + LLVM_DEBUG(dbgs() << " ** pattern found at Idx " << Idx << "!\n"); Sequences.push_back(CurrInstr); } } @@ -225,7 +225,7 @@ ++Idx; } - DEBUG(dbgs() << "Scan complete, " << Sequences.size() + LLVM_DEBUG(dbgs() << "Scan complete, " << Sequences.size() << " occurrences of pattern found.\n"); // Then update the basic block, inserting nops between the detected sequences. Index: lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp =================================================================== --- lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp +++ lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp @@ -315,7 +315,7 @@ return false; bool Changed = false; - DEBUG(dbgs() << "***** AArch64A57FPLoadBalancing *****\n"); + LLVM_DEBUG(dbgs() << "***** AArch64A57FPLoadBalancing *****\n"); MRI = &F.getRegInfo(); TRI = F.getRegInfo().getTargetRegisterInfo(); @@ -330,7 +330,7 @@ bool AArch64A57FPLoadBalancing::runOnBasicBlock(MachineBasicBlock &MBB) { bool Changed = false; - DEBUG(dbgs() << "Running on MBB: " << MBB << " - scanning instructions...\n"); + LLVM_DEBUG(dbgs() << "Running on MBB: " << MBB << " - scanning instructions...\n"); // First, scan the basic block producing a set of chains. @@ -343,7 +343,7 @@ for (auto &MI : MBB) scanInstruction(&MI, Idx++, ActiveChains, AllChains); - DEBUG(dbgs() << "Scan complete, "<< AllChains.size() << " chains created.\n"); + LLVM_DEBUG(dbgs() << "Scan complete, "<< AllChains.size() << " chains created.\n"); // Group the chains into disjoint sets based on their liveness range. This is // a poor-man's version of graph coloring. Ideally we'd create an interference @@ -360,7 +360,7 @@ for (auto &J : AllChains) if (I != J && I->rangeOverlapsWith(*J)) EC.unionSets(I.get(), J.get()); - DEBUG(dbgs() << "Created " << EC.getNumClasses() << " disjoint sets.\n"); + LLVM_DEBUG(dbgs() << "Created " << EC.getNumClasses() << " disjoint sets.\n"); // Now we assume that every member of an equivalence class interferes // with every other member of that class, and with no members of other classes. @@ -440,7 +440,7 @@ MachineBasicBlock &MBB, int &Parity) { bool Changed = false; - DEBUG(dbgs() << "colorChainSet(): #sets=" << GV.size() << "\n"); + LLVM_DEBUG(dbgs() << "colorChainSet(): #sets=" << GV.size() << "\n"); // Sort by descending size order so that we allocate the most important // sets first. @@ -470,7 +470,7 @@ // But if we really don't care, use the chain's preferred color. C = G->getPreferredColor(); - DEBUG(dbgs() << " - Parity=" << Parity << ", Color=" + LLVM_DEBUG(dbgs() << " - Parity=" << Parity << ", Color=" << ColorNames[(int)C] << "\n"); // If we'll need a fixup FMOV, don't bother. Testing has shown that this @@ -478,7 +478,7 @@ // slowing code down instead of speeding it up. if (G->requiresFixup() && C != G->getPreferredColor()) { C = G->getPreferredColor(); - DEBUG(dbgs() << " - " << G->str() << " - not worthwhile changing; " + LLVM_DEBUG(dbgs() << " - " << G->str() << " - not worthwhile changing; " "color remains " << ColorNames[(int)C] << "\n"); } @@ -528,17 +528,17 @@ bool AArch64A57FPLoadBalancing::colorChain(Chain *G, Color C, MachineBasicBlock &MBB) { bool Changed = false; - DEBUG(dbgs() << " - colorChain(" << G->str() << ", " + LLVM_DEBUG(dbgs() << " - colorChain(" << G->str() << ", " << ColorNames[(int)C] << ")\n"); // Try and obtain a free register of the right class. Without a register // to play with we cannot continue. int Reg = scavengeRegister(G, C, MBB); if (Reg == -1) { - DEBUG(dbgs() << "Scavenging (thus coloring) failed!\n"); + LLVM_DEBUG(dbgs() << "Scavenging (thus coloring) failed!\n"); return false; } - DEBUG(dbgs() << " - Scavenged register: " << printReg(Reg, TRI) << "\n"); + LLVM_DEBUG(dbgs() << " - Scavenged register: " << printReg(Reg, TRI) << "\n"); std::map Substs; for (MachineInstr &I : *G) { @@ -586,11 +586,11 @@ assert(Substs.size() == 0 && "No substitutions should be left active!"); if (G->getKill()) { - DEBUG(dbgs() << " - Kill instruction seen.\n"); + LLVM_DEBUG(dbgs() << " - Kill instruction seen.\n"); } else { // We didn't have a kill instruction, but we didn't seem to need to change // the destination register anyway. - DEBUG(dbgs() << " - Destination register not changed.\n"); + LLVM_DEBUG(dbgs() << " - Destination register not changed.\n"); } return Changed; } @@ -611,7 +611,7 @@ // unit. unsigned DestReg = MI->getOperand(0).getReg(); - DEBUG(dbgs() << "New chain started for register " << printReg(DestReg, TRI) + LLVM_DEBUG(dbgs() << "New chain started for register " << printReg(DestReg, TRI) << " at " << *MI); auto G = llvm::make_unique(MI, Idx, getColor(DestReg)); @@ -631,7 +631,7 @@ maybeKillChain(MI->getOperand(0), Idx, ActiveChains); if (ActiveChains.find(AccumReg) != ActiveChains.end()) { - DEBUG(dbgs() << "Chain found for accumulator register " + LLVM_DEBUG(dbgs() << "Chain found for accumulator register " << printReg(AccumReg, TRI) << " in MI " << *MI); // For simplicity we only chain together sequences of MULs/MLAs where the @@ -641,7 +641,7 @@ // FIXME: We could extend to handle the non-kill cases for more coverage. if (MI->getOperand(3).isKill()) { // Add to chain. - DEBUG(dbgs() << "Instruction was successfully added to chain.\n"); + LLVM_DEBUG(dbgs() << "Instruction was successfully added to chain.\n"); ActiveChains[AccumReg]->add(MI, Idx, getColor(DestReg)); // Handle cases where the destination is not the same as the accumulator. if (DestReg != AccumReg) { @@ -651,12 +651,12 @@ return; } - DEBUG(dbgs() << "Cannot add to chain because accumulator operand wasn't " + LLVM_DEBUG(dbgs() << "Cannot add to chain because accumulator operand wasn't " << "marked !\n"); maybeKillChain(MI->getOperand(3), Idx, ActiveChains); } - DEBUG(dbgs() << "Creating new chain for dest register " + LLVM_DEBUG(dbgs() << "Creating new chain for dest register " << printReg(DestReg, TRI) << "\n"); auto G = llvm::make_unique(MI, Idx, getColor(DestReg)); ActiveChains[DestReg] = G.get(); @@ -685,7 +685,7 @@ // If this is a KILL of a current chain, record it. if (MO.isKill() && ActiveChains.find(MO.getReg()) != ActiveChains.end()) { - DEBUG(dbgs() << "Kill seen for chain " << printReg(MO.getReg(), TRI) + LLVM_DEBUG(dbgs() << "Kill seen for chain " << printReg(MO.getReg(), TRI) << "\n"); ActiveChains[MO.getReg()]->setKill(MI, Idx, /*Immutable=*/MO.isTied()); } @@ -696,7 +696,7 @@ for (auto I = ActiveChains.begin(), E = ActiveChains.end(); I != E;) { if (MO.clobbersPhysReg(I->first)) { - DEBUG(dbgs() << "Kill (regmask) seen for chain " + LLVM_DEBUG(dbgs() << "Kill (regmask) seen for chain " << printReg(I->first, TRI) << "\n"); I->second->setKill(MI, Idx, /*Immutable=*/true); ActiveChains.erase(I++); Index: lib/Target/AArch64/AArch64AdvSIMDScalarPass.cpp =================================================================== --- lib/Target/AArch64/AArch64AdvSIMDScalarPass.cpp +++ lib/Target/AArch64/AArch64AdvSIMDScalarPass.cpp @@ -277,7 +277,7 @@ MachineInstrBuilder MIB = BuildMI(*MI.getParent(), MI, MI.getDebugLoc(), TII->get(AArch64::COPY), Dst) .addReg(Src, getKillRegState(IsKill)); - DEBUG(dbgs() << " adding copy: " << *MIB); + LLVM_DEBUG(dbgs() << " adding copy: " << *MIB); ++NumCopiesInserted; return MIB; } @@ -286,7 +286,7 @@ // to its equivalant AdvSIMD scalar instruction. Update inputs and outputs // to be the correct register class, minimizing cross-class copies. void AArch64AdvSIMDScalar::transformInstruction(MachineInstr &MI) { - DEBUG(dbgs() << "Scalar transform: " << MI); + LLVM_DEBUG(dbgs() << "Scalar transform: " << MI); MachineBasicBlock *MBB = MI.getParent(); unsigned OldOpc = MI.getOpcode(); @@ -391,7 +391,7 @@ // runOnMachineFunction - Pass entry point from PassManager. bool AArch64AdvSIMDScalar::runOnMachineFunction(MachineFunction &mf) { bool Changed = false; - DEBUG(dbgs() << "***** AArch64AdvSIMDScalar *****\n"); + LLVM_DEBUG(dbgs() << "***** AArch64AdvSIMDScalar *****\n"); if (skipFunction(mf.getFunction())) return false; Index: lib/Target/AArch64/AArch64CollectLOH.cpp =================================================================== --- lib/Target/AArch64/AArch64CollectLOH.cpp +++ lib/Target/AArch64/AArch64CollectLOH.cpp @@ -380,7 +380,7 @@ static void handleADRP(const MachineInstr &MI, AArch64FunctionInfo &AFI, LOHInfo &Info) { if (Info.LastADRP != nullptr) { - DEBUG(dbgs() << "Adding MCLOH_AdrpAdrp:\n" << '\t' << MI << '\t' + LLVM_DEBUG(dbgs() << "Adding MCLOH_AdrpAdrp:\n" << '\t' << MI << '\t' << *Info.LastADRP); AFI.addLOHDirective(MCLOH_AdrpAdrp, {&MI, Info.LastADRP}); ++NumADRPSimpleCandidate; @@ -390,47 +390,47 @@ if (Info.IsCandidate) { switch (Info.Type) { case MCLOH_AdrpAdd: - DEBUG(dbgs() << "Adding MCLOH_AdrpAdd:\n" << '\t' << MI << '\t' + LLVM_DEBUG(dbgs() << "Adding MCLOH_AdrpAdd:\n" << '\t' << MI << '\t' << *Info.MI0); AFI.addLOHDirective(MCLOH_AdrpAdd, {&MI, Info.MI0}); ++NumADRSimpleCandidate; break; case MCLOH_AdrpLdr: if (supportLoadFromLiteral(*Info.MI0)) { - DEBUG(dbgs() << "Adding MCLOH_AdrpLdr:\n" << '\t' << MI << '\t' + LLVM_DEBUG(dbgs() << "Adding MCLOH_AdrpLdr:\n" << '\t' << MI << '\t' << *Info.MI0); AFI.addLOHDirective(MCLOH_AdrpLdr, {&MI, Info.MI0}); ++NumADRPToLDR; } break; case MCLOH_AdrpAddLdr: - DEBUG(dbgs() << "Adding MCLOH_AdrpAddLdr:\n" << '\t' << MI << '\t' + LLVM_DEBUG(dbgs() << "Adding MCLOH_AdrpAddLdr:\n" << '\t' << MI << '\t' << *Info.MI1 << '\t' << *Info.MI0); AFI.addLOHDirective(MCLOH_AdrpAddLdr, {&MI, Info.MI1, Info.MI0}); ++NumADDToLDR; break; case MCLOH_AdrpAddStr: if (Info.MI1 != nullptr) { - DEBUG(dbgs() << "Adding MCLOH_AdrpAddStr:\n" << '\t' << MI << '\t' + LLVM_DEBUG(dbgs() << "Adding MCLOH_AdrpAddStr:\n" << '\t' << MI << '\t' << *Info.MI1 << '\t' << *Info.MI0); AFI.addLOHDirective(MCLOH_AdrpAddStr, {&MI, Info.MI1, Info.MI0}); ++NumADDToSTR; } break; case MCLOH_AdrpLdrGotLdr: - DEBUG(dbgs() << "Adding MCLOH_AdrpLdrGotLdr:\n" << '\t' << MI << '\t' + LLVM_DEBUG(dbgs() << "Adding MCLOH_AdrpLdrGotLdr:\n" << '\t' << MI << '\t' << *Info.MI1 << '\t' << *Info.MI0); AFI.addLOHDirective(MCLOH_AdrpLdrGotLdr, {&MI, Info.MI1, Info.MI0}); ++NumLDRToLDR; break; case MCLOH_AdrpLdrGotStr: - DEBUG(dbgs() << "Adding MCLOH_AdrpLdrGotStr:\n" << '\t' << MI << '\t' + LLVM_DEBUG(dbgs() << "Adding MCLOH_AdrpLdrGotStr:\n" << '\t' << MI << '\t' << *Info.MI1 << '\t' << *Info.MI0); AFI.addLOHDirective(MCLOH_AdrpLdrGotStr, {&MI, Info.MI1, Info.MI0}); ++NumLDRToSTR; break; case MCLOH_AdrpLdrGot: - DEBUG(dbgs() << "Adding MCLOH_AdrpLdrGot:\n" << '\t' << MI << '\t' + LLVM_DEBUG(dbgs() << "Adding MCLOH_AdrpLdrGot:\n" << '\t' << MI << '\t' << *Info.MI0); AFI.addLOHDirective(MCLOH_AdrpLdrGot, {&MI, Info.MI0}); break; @@ -485,7 +485,7 @@ if (skipFunction(MF.getFunction())) return false; - DEBUG(dbgs() << "********** AArch64 Collect LOH **********\n" + LLVM_DEBUG(dbgs() << "********** AArch64 Collect LOH **********\n" << "Looking in function " << MF.getName() << '\n'); LOHInfo LOHInfos[N_GPR_REGS]; Index: lib/Target/AArch64/AArch64CondBrTuning.cpp =================================================================== --- lib/Target/AArch64/AArch64CondBrTuning.cpp +++ lib/Target/AArch64/AArch64CondBrTuning.cpp @@ -201,10 +201,10 @@ I->readsRegister(AArch64::NZCV, TRI)) return false; } - DEBUG(dbgs() << " Replacing instructions:\n "); - DEBUG(DefMI.print(dbgs())); - DEBUG(dbgs() << " "); - DEBUG(MI.print(dbgs())); + LLVM_DEBUG(dbgs() << " Replacing instructions:\n "); + LLVM_DEBUG(DefMI.print(dbgs())); + LLVM_DEBUG(dbgs() << " "); + LLVM_DEBUG(MI.print(dbgs())); NewCmp = convertToFlagSetting(DefMI, IsFlagSetting); NewBr = convertToCondBr(MI); @@ -260,10 +260,10 @@ I->readsRegister(AArch64::NZCV, TRI)) return false; } - DEBUG(dbgs() << " Replacing instructions:\n "); - DEBUG(DefMI.print(dbgs())); - DEBUG(dbgs() << " "); - DEBUG(MI.print(dbgs())); + LLVM_DEBUG(dbgs() << " Replacing instructions:\n "); + LLVM_DEBUG(DefMI.print(dbgs())); + LLVM_DEBUG(dbgs() << " "); + LLVM_DEBUG(MI.print(dbgs())); NewCmp = convertToFlagSetting(DefMI, IsFlagSetting); NewBr = convertToCondBr(MI); @@ -275,10 +275,10 @@ (void)NewCmp; (void)NewBr; assert(NewCmp && NewBr && "Expected new instructions."); - DEBUG(dbgs() << " with instruction:\n "); - DEBUG(NewCmp->print(dbgs())); - DEBUG(dbgs() << " "); - DEBUG(NewBr->print(dbgs())); + LLVM_DEBUG(dbgs() << " with instruction:\n "); + LLVM_DEBUG(NewCmp->print(dbgs())); + LLVM_DEBUG(dbgs() << " "); + LLVM_DEBUG(NewBr->print(dbgs())); // If this was a flag setting version of the instruction, we use the original // instruction by just clearing the dead marked on the implicit-def of NCZV. @@ -293,7 +293,7 @@ if (skipFunction(MF.getFunction())) return false; - DEBUG(dbgs() << "********** AArch64 Conditional Branch Tuning **********\n" + LLVM_DEBUG(dbgs() << "********** AArch64 Conditional Branch Tuning **********\n" << "********** Function: " << MF.getName() << '\n'); TII = static_cast(MF.getSubtarget().getInstrInfo()); Index: lib/Target/AArch64/AArch64ConditionOptimizer.cpp =================================================================== --- lib/Target/AArch64/AArch64ConditionOptimizer.cpp +++ lib/Target/AArch64/AArch64ConditionOptimizer.cpp @@ -173,13 +173,13 @@ case AArch64::ADDSXri: { unsigned ShiftAmt = AArch64_AM::getShiftValue(I->getOperand(3).getImm()); if (!I->getOperand(2).isImm()) { - DEBUG(dbgs() << "Immediate of cmp is symbolic, " << *I << '\n'); + LLVM_DEBUG(dbgs() << "Immediate of cmp is symbolic, " << *I << '\n'); return nullptr; } else if (I->getOperand(2).getImm() << ShiftAmt >= 0xfff) { - DEBUG(dbgs() << "Immediate of cmp may be out of range, " << *I << '\n'); + LLVM_DEBUG(dbgs() << "Immediate of cmp may be out of range, " << *I << '\n'); return nullptr; } else if (!MRI->use_empty(I->getOperand(0).getReg())) { - DEBUG(dbgs() << "Destination of cmp is not dead, " << *I << '\n'); + LLVM_DEBUG(dbgs() << "Destination of cmp is not dead, " << *I << '\n'); return nullptr; } return &*I; @@ -207,7 +207,7 @@ return nullptr; } } - DEBUG(dbgs() << "Flags not defined in " << printMBBReference(*MBB) << '\n'); + LLVM_DEBUG(dbgs() << "Flags not defined in " << printMBBReference(*MBB) << '\n'); return nullptr; } @@ -325,7 +325,7 @@ } bool AArch64ConditionOptimizer::runOnMachineFunction(MachineFunction &MF) { - DEBUG(dbgs() << "********** AArch64 Conditional Compares **********\n" + LLVM_DEBUG(dbgs() << "********** AArch64 Conditional Compares **********\n" << "********** Function: " << MF.getName() << '\n'); if (skipFunction(MF.getFunction())) return false; @@ -384,15 +384,15 @@ const int HeadImm = (int)HeadCmpMI->getOperand(2).getImm(); const int TrueImm = (int)TrueCmpMI->getOperand(2).getImm(); - DEBUG(dbgs() << "Head branch:\n"); - DEBUG(dbgs() << "\tcondition: " + LLVM_DEBUG(dbgs() << "Head branch:\n"); + LLVM_DEBUG(dbgs() << "\tcondition: " << AArch64CC::getCondCodeName(HeadCmp) << '\n'); - DEBUG(dbgs() << "\timmediate: " << HeadImm << '\n'); + LLVM_DEBUG(dbgs() << "\timmediate: " << HeadImm << '\n'); - DEBUG(dbgs() << "True branch:\n"); - DEBUG(dbgs() << "\tcondition: " + LLVM_DEBUG(dbgs() << "True branch:\n"); + LLVM_DEBUG(dbgs() << "\tcondition: " << AArch64CC::getCondCodeName(TrueCmp) << '\n'); - DEBUG(dbgs() << "\timmediate: " << TrueImm << '\n'); + LLVM_DEBUG(dbgs() << "\timmediate: " << TrueImm << '\n'); if (((HeadCmp == AArch64CC::GT && TrueCmp == AArch64CC::LT) || (HeadCmp == AArch64CC::LT && TrueCmp == AArch64CC::GT)) && Index: lib/Target/AArch64/AArch64ConditionalCompares.cpp =================================================================== --- lib/Target/AArch64/AArch64ConditionalCompares.cpp +++ lib/Target/AArch64/AArch64ConditionalCompares.cpp @@ -311,7 +311,7 @@ return &*I; } ++NumCmpTermRejs; - DEBUG(dbgs() << "Flags not used by terminator: " << *I); + LLVM_DEBUG(dbgs() << "Flags not used by terminator: " << *I); return nullptr; } @@ -329,7 +329,7 @@ // Check that the immediate operand is within range, ccmp wants a uimm5. // Rd = SUBSri Rn, imm, shift if (I->getOperand(3).getImm() || !isUInt<5>(I->getOperand(2).getImm())) { - DEBUG(dbgs() << "Immediate out of range for ccmp: " << *I); + LLVM_DEBUG(dbgs() << "Immediate out of range for ccmp: " << *I); ++NumImmRangeRejs; return nullptr; } @@ -340,7 +340,7 @@ case AArch64::ADDSXrr: if (isDeadDef(I->getOperand(0).getReg())) return &*I; - DEBUG(dbgs() << "Can't convert compare with live destination: " << *I); + LLVM_DEBUG(dbgs() << "Can't convert compare with live destination: " << *I); ++NumLiveDstRejs; return nullptr; case AArch64::FCMPSrr: @@ -358,18 +358,18 @@ // The ccmp doesn't produce exactly the same flags as the original // compare, so reject the transform if there are uses of the flags // besides the terminators. - DEBUG(dbgs() << "Can't create ccmp with multiple uses: " << *I); + LLVM_DEBUG(dbgs() << "Can't create ccmp with multiple uses: " << *I); ++NumMultNZCVUses; return nullptr; } if (PRI.Defined || PRI.Clobbered) { - DEBUG(dbgs() << "Not convertible compare: " << *I); + LLVM_DEBUG(dbgs() << "Not convertible compare: " << *I); ++NumUnknNZCVDefs; return nullptr; } } - DEBUG(dbgs() << "Flags not defined in " << printMBBReference(*MBB) << '\n'); + LLVM_DEBUG(dbgs() << "Flags not defined in " << printMBBReference(*MBB) << '\n'); return nullptr; } @@ -383,7 +383,7 @@ // Reject any live-in physregs. It's probably NZCV/EFLAGS, and very hard to // get right. if (!MBB->livein_empty()) { - DEBUG(dbgs() << printMBBReference(*MBB) << " has live-ins.\n"); + LLVM_DEBUG(dbgs() << printMBBReference(*MBB) << " has live-ins.\n"); return false; } @@ -396,14 +396,14 @@ continue; if (++InstrCount > BlockInstrLimit && !Stress) { - DEBUG(dbgs() << printMBBReference(*MBB) << " has more than " + LLVM_DEBUG(dbgs() << printMBBReference(*MBB) << " has more than " << BlockInstrLimit << " instructions.\n"); return false; } // There shouldn't normally be any phis in a single-predecessor block. if (I.isPHI()) { - DEBUG(dbgs() << "Can't hoist: " << I); + LLVM_DEBUG(dbgs() << "Can't hoist: " << I); return false; } @@ -411,20 +411,20 @@ // speculate GOT or constant pool loads that are guaranteed not to trap, // but we don't support that for now. if (I.mayLoad()) { - DEBUG(dbgs() << "Won't speculate load: " << I); + LLVM_DEBUG(dbgs() << "Won't speculate load: " << I); return false; } // We never speculate stores, so an AA pointer isn't necessary. bool DontMoveAcrossStore = true; if (!I.isSafeToMove(nullptr, DontMoveAcrossStore)) { - DEBUG(dbgs() << "Can't speculate: " << I); + LLVM_DEBUG(dbgs() << "Can't speculate: " << I); return false; } // Only CmpMI is allowed to clobber the flags. if (&I != CmpMI && I.modifiesRegister(AArch64::NZCV, TRI)) { - DEBUG(dbgs() << "Clobbers flags: " << I); + LLVM_DEBUG(dbgs() << "Clobbers flags: " << I); return false; } } @@ -458,7 +458,7 @@ return false; // The CFG topology checks out. - DEBUG(dbgs() << "\nTriangle: " << printMBBReference(*Head) << " -> " + LLVM_DEBUG(dbgs() << "\nTriangle: " << printMBBReference(*Head) << " -> " << printMBBReference(*CmpBB) << " -> " << printMBBReference(*Tail) << '\n'); ++NumConsidered; @@ -470,13 +470,13 @@ // always be safe to sink the ccmp down to immediately before the CmpBB // terminators. if (!trivialTailPHIs()) { - DEBUG(dbgs() << "Can't handle phis in Tail.\n"); + LLVM_DEBUG(dbgs() << "Can't handle phis in Tail.\n"); ++NumPhiRejs; return false; } if (!Tail->livein_empty()) { - DEBUG(dbgs() << "Can't handle live-in physregs in Tail.\n"); + LLVM_DEBUG(dbgs() << "Can't handle live-in physregs in Tail.\n"); ++NumPhysRejs; return false; } @@ -484,13 +484,13 @@ // CmpBB should never have PHIs since Head is its only predecessor. // FIXME: Clean them up if it happens. if (!CmpBB->empty() && CmpBB->front().isPHI()) { - DEBUG(dbgs() << "Can't handle phis in CmpBB.\n"); + LLVM_DEBUG(dbgs() << "Can't handle phis in CmpBB.\n"); ++NumPhi2Rejs; return false; } if (!CmpBB->livein_empty()) { - DEBUG(dbgs() << "Can't handle live-in physregs in CmpBB.\n"); + LLVM_DEBUG(dbgs() << "Can't handle live-in physregs in CmpBB.\n"); ++NumPhysRejs; return false; } @@ -499,7 +499,7 @@ HeadCond.clear(); MachineBasicBlock *TBB = nullptr, *FBB = nullptr; if (TII->analyzeBranch(*Head, TBB, FBB, HeadCond)) { - DEBUG(dbgs() << "Head branch not analyzable.\n"); + LLVM_DEBUG(dbgs() << "Head branch not analyzable.\n"); ++NumHeadBranchRejs; return false; } @@ -507,13 +507,13 @@ // This is weird, probably some sort of degenerate CFG, or an edge to a // landing pad. if (!TBB || HeadCond.empty()) { - DEBUG(dbgs() << "AnalyzeBranch didn't find conditional branch in Head.\n"); + LLVM_DEBUG(dbgs() << "AnalyzeBranch didn't find conditional branch in Head.\n"); ++NumHeadBranchRejs; return false; } if (!parseCond(HeadCond, HeadCmpBBCC)) { - DEBUG(dbgs() << "Unsupported branch type on Head\n"); + LLVM_DEBUG(dbgs() << "Unsupported branch type on Head\n"); ++NumHeadBranchRejs; return false; } @@ -527,19 +527,19 @@ CmpBBCond.clear(); TBB = FBB = nullptr; if (TII->analyzeBranch(*CmpBB, TBB, FBB, CmpBBCond)) { - DEBUG(dbgs() << "CmpBB branch not analyzable.\n"); + LLVM_DEBUG(dbgs() << "CmpBB branch not analyzable.\n"); ++NumCmpBranchRejs; return false; } if (!TBB || CmpBBCond.empty()) { - DEBUG(dbgs() << "AnalyzeBranch didn't find conditional branch in CmpBB.\n"); + LLVM_DEBUG(dbgs() << "AnalyzeBranch didn't find conditional branch in CmpBB.\n"); ++NumCmpBranchRejs; return false; } if (!parseCond(CmpBBCond, CmpBBTailCC)) { - DEBUG(dbgs() << "Unsupported branch type on CmpBB\n"); + LLVM_DEBUG(dbgs() << "Unsupported branch type on CmpBB\n"); ++NumCmpBranchRejs; return false; } @@ -547,7 +547,7 @@ if (TBB != Tail) CmpBBTailCC = AArch64CC::getInvertedCondCode(CmpBBTailCC); - DEBUG(dbgs() << "Head->CmpBB on " << AArch64CC::getCondCodeName(HeadCmpBBCC) + LLVM_DEBUG(dbgs() << "Head->CmpBB on " << AArch64CC::getCondCodeName(HeadCmpBBCC) << ", CmpBB->Tail on " << AArch64CC::getCondCodeName(CmpBBTailCC) << '\n'); @@ -563,7 +563,7 @@ } void SSACCmpConv::convert(SmallVectorImpl &RemovedBlocks) { - DEBUG(dbgs() << "Merging " << printMBBReference(*CmpBB) << " into " + LLVM_DEBUG(dbgs() << "Merging " << printMBBReference(*CmpBB) << " into " << printMBBReference(*Head) << ":\n" << *CmpBB); @@ -710,7 +710,7 @@ RemovedBlocks.push_back(CmpBB); CmpBB->eraseFromParent(); - DEBUG(dbgs() << "Result:\n" << *Head); + LLVM_DEBUG(dbgs() << "Result:\n" << *Head); ++NumConverted; } @@ -860,13 +860,13 @@ // If code size is the main concern if (MinSize) { int CodeSizeDelta = CmpConv.expectedCodeSizeDelta(); - DEBUG(dbgs() << "Code size delta: " << CodeSizeDelta << '\n'); + LLVM_DEBUG(dbgs() << "Code size delta: " << CodeSizeDelta << '\n'); // If we are minimizing the code size, do the conversion whatever // the cost is. if (CodeSizeDelta < 0) return true; if (CodeSizeDelta > 0) { - DEBUG(dbgs() << "Code size is increasing, give up on this one.\n"); + LLVM_DEBUG(dbgs() << "Code size is increasing, give up on this one.\n"); return false; } // CodeSizeDelta == 0, continue with the regular heuristics @@ -885,10 +885,10 @@ Trace.getInstrCycles(*CmpConv.Head->getFirstTerminator()).Depth; unsigned CmpBBDepth = Trace.getInstrCycles(*CmpConv.CmpBB->getFirstTerminator()).Depth; - DEBUG(dbgs() << "Head depth: " << HeadDepth + LLVM_DEBUG(dbgs() << "Head depth: " << HeadDepth << "\nCmpBB depth: " << CmpBBDepth << '\n'); if (CmpBBDepth > HeadDepth + DelayLimit) { - DEBUG(dbgs() << "Branch delay would be larger than " << DelayLimit + LLVM_DEBUG(dbgs() << "Branch delay would be larger than " << DelayLimit << " cycles.\n"); return false; } @@ -896,13 +896,13 @@ // Check the resource depth at the bottom of CmpBB - these instructions will // be speculated. unsigned ResDepth = Trace.getResourceDepth(true); - DEBUG(dbgs() << "Resources: " << ResDepth << '\n'); + LLVM_DEBUG(dbgs() << "Resources: " << ResDepth << '\n'); // Heuristic: The speculatively executed instructions must all be able to // merge into the Head block. The Head critical path should dominate the // resource cost of the speculated instructions. if (ResDepth > HeadDepth) { - DEBUG(dbgs() << "Too many instructions to speculate.\n"); + LLVM_DEBUG(dbgs() << "Too many instructions to speculate.\n"); return false; } return true; @@ -922,7 +922,7 @@ } bool AArch64ConditionalCompares::runOnMachineFunction(MachineFunction &MF) { - DEBUG(dbgs() << "********** AArch64 Conditional Compares **********\n" + LLVM_DEBUG(dbgs() << "********** AArch64 Conditional Compares **********\n" << "********** Function: " << MF.getName() << '\n'); if (skipFunction(MF.getFunction())) return false; Index: lib/Target/AArch64/AArch64DeadRegisterDefinitionsPass.cpp =================================================================== --- lib/Target/AArch64/AArch64DeadRegisterDefinitionsPass.cpp +++ lib/Target/AArch64/AArch64DeadRegisterDefinitionsPass.cpp @@ -136,18 +136,18 @@ // We need to skip this instruction because while it appears to have a // dead def it uses a frame index which might expand into a multi // instruction sequence during EPI. - DEBUG(dbgs() << " Ignoring, operand is frame index\n"); + LLVM_DEBUG(dbgs() << " Ignoring, operand is frame index\n"); continue; } if (MI.definesRegister(AArch64::XZR) || MI.definesRegister(AArch64::WZR)) { // It is not allowed to write to the same register (not even the zero // register) twice in a single instruction. - DEBUG(dbgs() << " Ignoring, XZR or WZR already used by the instruction\n"); + LLVM_DEBUG(dbgs() << " Ignoring, XZR or WZR already used by the instruction\n"); continue; } if (shouldSkip(MI, MF)) { - DEBUG(dbgs() << " Ignoring, Atomic instruction with acquire semantics using WZR/XZR\n"); + LLVM_DEBUG(dbgs() << " Ignoring, Atomic instruction with acquire semantics using WZR/XZR\n"); continue; } @@ -163,30 +163,30 @@ (!MO.isDead() && !MRI->use_nodbg_empty(Reg))) continue; assert(!MO.isImplicit() && "Unexpected implicit def!"); - DEBUG(dbgs() << " Dead def operand #" << I << " in:\n "; + LLVM_DEBUG(dbgs() << " Dead def operand #" << I << " in:\n "; MI.print(dbgs())); // Be careful not to change the register if it's a tied operand. if (MI.isRegTiedToUseOperand(I)) { - DEBUG(dbgs() << " Ignoring, def is tied operand.\n"); + LLVM_DEBUG(dbgs() << " Ignoring, def is tied operand.\n"); continue; } const TargetRegisterClass *RC = TII->getRegClass(Desc, I, TRI, MF); unsigned NewReg; if (RC == nullptr) { - DEBUG(dbgs() << " Ignoring, register is not a GPR.\n"); + LLVM_DEBUG(dbgs() << " Ignoring, register is not a GPR.\n"); continue; } else if (RC->contains(AArch64::WZR)) NewReg = AArch64::WZR; else if (RC->contains(AArch64::XZR)) NewReg = AArch64::XZR; else { - DEBUG(dbgs() << " Ignoring, register is not a GPR.\n"); + LLVM_DEBUG(dbgs() << " Ignoring, register is not a GPR.\n"); continue; } - DEBUG(dbgs() << " Replacing with zero register. New:\n "); + LLVM_DEBUG(dbgs() << " Replacing with zero register. New:\n "); MO.setReg(NewReg); MO.setIsDead(); - DEBUG(MI.print(dbgs())); + LLVM_DEBUG(MI.print(dbgs())); ++NumDeadDefsReplaced; Changed = true; // Only replace one dead register, see check for zero register above. @@ -204,7 +204,7 @@ TRI = MF.getSubtarget().getRegisterInfo(); TII = MF.getSubtarget().getInstrInfo(); MRI = &MF.getRegInfo(); - DEBUG(dbgs() << "***** AArch64DeadRegisterDefinitions *****\n"); + LLVM_DEBUG(dbgs() << "***** AArch64DeadRegisterDefinitions *****\n"); Changed = false; for (auto &MBB : MF) processMachineBasicBlock(MBB); Index: lib/Target/AArch64/AArch64FalkorHWPFFix.cpp =================================================================== --- lib/Target/AArch64/AArch64FalkorHWPFFix.cpp +++ lib/Target/AArch64/AArch64FalkorHWPFFix.cpp @@ -166,7 +166,7 @@ LoadI->setMetadata(FALKOR_STRIDED_ACCESS_MD, MDNode::get(LoadI->getContext(), {})); ++NumStridedLoadsMarked; - DEBUG(dbgs() << "Load: " << I << " marked as strided\n"); + LLVM_DEBUG(dbgs() << "Load: " << I << " marked as strided\n"); MadeChange = true; } } @@ -727,7 +727,7 @@ continue; bool Fixed = false; - DEBUG(dbgs() << "Attempting to fix tag collision: " << MI); + LLVM_DEBUG(dbgs() << "Attempting to fix tag collision: " << MI); for (unsigned ScratchReg : AArch64::GPR64RegClass) { if (!LR.available(ScratchReg) || MRI.isReserved(ScratchReg)) @@ -740,7 +740,7 @@ if (TagMap.count(NewTag)) continue; - DEBUG(dbgs() << "Changing base reg to: " << printReg(ScratchReg, TRI) + LLVM_DEBUG(dbgs() << "Changing base reg to: " << printReg(ScratchReg, TRI) << '\n'); // Rewrite: @@ -759,7 +759,7 @@ // If the load does a pre/post increment, then insert a MOV after as // well to update the real base register. if (LdI.IsPrePost) { - DEBUG(dbgs() << "Doing post MOV of incremented reg: " + LLVM_DEBUG(dbgs() << "Doing post MOV of incremented reg: " << printReg(ScratchReg, TRI) << '\n'); MI.getOperand(0).setReg( ScratchReg); // Change tied operand pre/post update dest. Index: lib/Target/AArch64/AArch64FrameLowering.cpp =================================================================== --- lib/Target/AArch64/AArch64FrameLowering.cpp +++ lib/Target/AArch64/AArch64FrameLowering.cpp @@ -1135,7 +1135,7 @@ StrOpc = RPI.isPaired() ? AArch64::STPXi : AArch64::STRXui; else StrOpc = RPI.isPaired() ? AArch64::STPDi : AArch64::STRDui; - DEBUG(dbgs() << "CSR spill: (" << printReg(Reg1, TRI); + LLVM_DEBUG(dbgs() << "CSR spill: (" << printReg(Reg1, TRI); if (RPI.isPaired()) dbgs() << ", " << printReg(Reg2, TRI); dbgs() << ") -> fi#(" << RPI.FrameIdx; @@ -1198,7 +1198,7 @@ LdrOpc = RPI.isPaired() ? AArch64::LDPXi : AArch64::LDRXui; else LdrOpc = RPI.isPaired() ? AArch64::LDPDi : AArch64::LDRDui; - DEBUG(dbgs() << "CSR restore: (" << printReg(Reg1, TRI); + LLVM_DEBUG(dbgs() << "CSR restore: (" << printReg(Reg1, TRI); if (RPI.isPaired()) dbgs() << ", " << printReg(Reg2, TRI); dbgs() << ") -> fi#(" << RPI.FrameIdx; @@ -1295,7 +1295,7 @@ } } - DEBUG(dbgs() << "*** determineCalleeSaves\nUsed CSRs:"; + LLVM_DEBUG(dbgs() << "*** determineCalleeSaves\nUsed CSRs:"; for (unsigned Reg : SavedRegs.set_bits()) dbgs() << ' ' << printReg(Reg, RegInfo); dbgs() << "\n";); @@ -1307,7 +1307,7 @@ // The CSR spill slots have not been allocated yet, so estimateStackSize // won't include them. unsigned CFSize = MFI.estimateStackSize(MF) + 8 * NumRegsSpilled; - DEBUG(dbgs() << "Estimated stack frame size: " << CFSize << " bytes.\n"); + LLVM_DEBUG(dbgs() << "Estimated stack frame size: " << CFSize << " bytes.\n"); unsigned EstimatedStackSizeLimit = estimateRSStackSizeLimit(MF); bool BigStack = (CFSize > EstimatedStackSizeLimit); if (BigStack || !CanEliminateFrame || RegInfo->cannotEliminateFrame(MF)) @@ -1321,7 +1321,7 @@ // here. if (BigStack) { if (!ExtraCSSpill && UnspilledCSGPR != AArch64::NoRegister) { - DEBUG(dbgs() << "Spilling " << printReg(UnspilledCSGPR, RegInfo) + LLVM_DEBUG(dbgs() << "Spilling " << printReg(UnspilledCSGPR, RegInfo) << " to get a scratch register.\n"); SavedRegs.set(UnspilledCSGPR); // MachO's compact unwind format relies on all registers being stored in @@ -1342,7 +1342,7 @@ unsigned Align = TRI->getSpillAlignment(RC); int FI = MFI.CreateStackObject(Size, Align, false); RS->addScavengingFrameIndex(FI); - DEBUG(dbgs() << "No available CS registers, allocated fi#" << FI + LLVM_DEBUG(dbgs() << "No available CS registers, allocated fi#" << FI << " as the emergency spill slot.\n"); } } Index: lib/Target/AArch64/AArch64ISelDAGToDAG.cpp =================================================================== --- lib/Target/AArch64/AArch64ISelDAGToDAG.cpp +++ lib/Target/AArch64/AArch64ISelDAGToDAG.cpp @@ -1551,7 +1551,7 @@ // Bail out on large immediates. This happens when no proper // combining/constant folding was performed. if (!BiggerPattern && (SrlImm <= 0 || SrlImm >= VT.getSizeInBits())) { - DEBUG((dbgs() << N + LLVM_DEBUG((dbgs() << N << ": Found large shift immediate, this should not happen\n")); return false; } @@ -1694,7 +1694,7 @@ // Missing combines/constant folding may have left us with strange // constants. if (ShlImm >= VT.getSizeInBits()) { - DEBUG((dbgs() << N + LLVM_DEBUG((dbgs() << N << ": Found large shift immediate, this should not happen\n")); return false; } @@ -2655,7 +2655,7 @@ void AArch64DAGToDAGISel::Select(SDNode *Node) { // If we have a custom node, we already have selected! if (Node->isMachineOpcode()) { - DEBUG(errs() << "== "; Node->dump(CurDAG); errs() << "\n"); + LLVM_DEBUG(errs() << "== "; Node->dump(CurDAG); errs() << "\n"); Node->setNodeId(-1); return; } @@ -2752,9 +2752,9 @@ } SDValue Extract = CurDAG->getTargetExtractSubreg(SubReg, SDLoc(Node), VT, Node->getOperand(0)); - DEBUG(dbgs() << "ISEL: Custom selection!\n=> "); - DEBUG(Extract->dumpr(CurDAG)); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "ISEL: Custom selection!\n=> "); + LLVM_DEBUG(Extract->dumpr(CurDAG)); + LLVM_DEBUG(dbgs() << "\n"); ReplaceNode(Node, Extract.getNode()); return; } Index: lib/Target/AArch64/AArch64ISelLowering.cpp =================================================================== --- lib/Target/AArch64/AArch64ISelLowering.cpp +++ lib/Target/AArch64/AArch64ISelLowering.cpp @@ -1433,7 +1433,7 @@ static bool isLegalArithImmed(uint64_t C) { // Matches AArch64DAGToDAGISel::SelectArithImmed(). bool IsLegal = (C >> 12 == 0) || ((C & 0xFFFULL) == 0 && C >> 24 == 0); - DEBUG(dbgs() << "Is imm " << C << " legal: " << (IsLegal ? "yes\n" : "no\n")); + LLVM_DEBUG(dbgs() << "Is imm " << C << " legal: " << (IsLegal ? "yes\n" : "no\n")); return IsLegal; } @@ -2575,8 +2575,8 @@ SDValue AArch64TargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const { - DEBUG(dbgs() << "Custom lowering: "); - DEBUG(Op.dump()); + LLVM_DEBUG(dbgs() << "Custom lowering: "); + LLVM_DEBUG(Op.dump()); switch (Op.getOpcode()) { default: @@ -3701,7 +3701,7 @@ template SDValue AArch64TargetLowering::getGOT(NodeTy *N, SelectionDAG &DAG, unsigned Flags) const { - DEBUG(dbgs() << "AArch64TargetLowering::getGOT\n"); + LLVM_DEBUG(dbgs() << "AArch64TargetLowering::getGOT\n"); SDLoc DL(N); EVT Ty = getPointerTy(DAG.getDataLayout()); SDValue GotAddr = getTargetNode(N, Ty, DAG, AArch64II::MO_GOT | Flags); @@ -3714,7 +3714,7 @@ template SDValue AArch64TargetLowering::getAddrLarge(NodeTy *N, SelectionDAG &DAG, unsigned Flags) const { - DEBUG(dbgs() << "AArch64TargetLowering::getAddrLarge\n"); + LLVM_DEBUG(dbgs() << "AArch64TargetLowering::getAddrLarge\n"); SDLoc DL(N); EVT Ty = getPointerTy(DAG.getDataLayout()); const unsigned char MO_NC = AArch64II::MO_NC; @@ -3730,7 +3730,7 @@ template SDValue AArch64TargetLowering::getAddr(NodeTy *N, SelectionDAG &DAG, unsigned Flags) const { - DEBUG(dbgs() << "AArch64TargetLowering::getAddr\n"); + LLVM_DEBUG(dbgs() << "AArch64TargetLowering::getAddr\n"); SDLoc DL(N); EVT Ty = getPointerTy(DAG.getDataLayout()); SDValue Hi = getTargetNode(N, Ty, DAG, AArch64II::MO_PAGE | Flags); @@ -4928,9 +4928,9 @@ bool AArch64TargetLowering::isOffsetFoldingLegal( const GlobalAddressSDNode *GA) const { - DEBUG(dbgs() << "Skipping offset folding global address: "); - DEBUG(GA->dump()); - DEBUG(dbgs() << "AArch64 doesn't support folding offsets into global " + LLVM_DEBUG(dbgs() << "Skipping offset folding global address: "); + LLVM_DEBUG(GA->dump()); + LLVM_DEBUG(dbgs() << "AArch64 doesn't support folding offsets into global " "addresses\n"); return false; } @@ -4940,7 +4940,7 @@ // FIXME: We should be able to handle f128 as well with a clever lowering. if (Imm.isPosZero() && (VT == MVT::f64 || VT == MVT::f32 || (VT == MVT::f16 && Subtarget->hasFullFP16()))) { - DEBUG(dbgs() << "Legal fp imm: materialize 0 using the zero register\n"); + LLVM_DEBUG(dbgs() << "Legal fp imm: materialize 0 using the zero register\n"); return true; } @@ -4961,14 +4961,14 @@ } if (IsLegal) { - DEBUG(dbgs() << "Legal " << FPType << " imm value: " << ImmStrVal << "\n"); + LLVM_DEBUG(dbgs() << "Legal " << FPType << " imm value: " << ImmStrVal << "\n"); return true; } if (!FPType.empty()) - DEBUG(dbgs() << "Illegal " << FPType << " imm value: " << ImmStrVal << "\n"); + LLVM_DEBUG(dbgs() << "Illegal " << FPType << " imm value: " << ImmStrVal << "\n"); else - DEBUG(dbgs() << "Illegal fp imm " << ImmStrVal << ": unsupported fp type\n"); + LLVM_DEBUG(dbgs() << "Illegal fp imm " << ImmStrVal << ": unsupported fp type\n"); return false; } @@ -5407,7 +5407,7 @@ SDValue AArch64TargetLowering::ReconstructShuffle(SDValue Op, SelectionDAG &DAG) const { assert(Op.getOpcode() == ISD::BUILD_VECTOR && "Unknown opcode!"); - DEBUG(dbgs() << "AArch64TargetLowering::ReconstructShuffle\n"); + LLVM_DEBUG(dbgs() << "AArch64TargetLowering::ReconstructShuffle\n"); SDLoc dl(Op); EVT VT = Op.getValueType(); unsigned NumElts = VT.getVectorNumElements(); @@ -5443,7 +5443,7 @@ continue; else if (V.getOpcode() != ISD::EXTRACT_VECTOR_ELT || !isa(V.getOperand(1))) { - DEBUG(dbgs() << "Reshuffle failed: " + LLVM_DEBUG(dbgs() << "Reshuffle failed: " "a shuffle can only come from building a vector from " "various elements of other vectors, provided their " "indices are constant\n"); @@ -5463,7 +5463,7 @@ } if (Sources.size() > 2) { - DEBUG(dbgs() << "Reshuffle failed: currently only do something sane when at " + LLVM_DEBUG(dbgs() << "Reshuffle failed: currently only do something sane when at " "most two source vectors are involved\n"); return SDValue(); } @@ -5510,7 +5510,7 @@ assert(SrcVT.getSizeInBits() == 2 * VT.getSizeInBits()); if (Src.MaxElt - Src.MinElt >= NumSrcElts) { - DEBUG(dbgs() << "Reshuffle failed: span too large for a VEXT to cope\n"); + LLVM_DEBUG(dbgs() << "Reshuffle failed: span too large for a VEXT to cope\n"); return SDValue(); } @@ -5556,7 +5556,7 @@ } // Final sanity check before we try to actually produce a shuffle. - DEBUG( + LLVM_DEBUG( for (auto Src : Sources) assert(Src.ShuffleVec.getValueType() == ShuffleVT); ); @@ -5592,7 +5592,7 @@ // Final check before we try to produce nonsense... if (!isShuffleMaskLegal(Mask, ShuffleVT)) { - DEBUG(dbgs() << "Reshuffle failed: illegal shuffle mask\n"); + LLVM_DEBUG(dbgs() << "Reshuffle failed: illegal shuffle mask\n"); return SDValue(); } @@ -5604,7 +5604,7 @@ ShuffleOps[1], Mask); SDValue V = DAG.getNode(ISD::BITCAST, dl, VT, Shuffle); - DEBUG( + LLVM_DEBUG( dbgs() << "Reshuffle, creating node: "; Shuffle.dump(); dbgs() << "Reshuffle, creating node: "; @@ -6567,10 +6567,10 @@ DAG.getConstant(Intrin, DL, MVT::i32), X, Y, Shift.getOperand(1)); - DEBUG(dbgs() << "aarch64-lower: transformed: \n"); - DEBUG(N->dump(&DAG)); - DEBUG(dbgs() << "into: \n"); - DEBUG(ResultSLI->dump(&DAG)); + LLVM_DEBUG(dbgs() << "aarch64-lower: transformed: \n"); + LLVM_DEBUG(N->dump(&DAG)); + LLVM_DEBUG(dbgs() << "into: \n"); + LLVM_DEBUG(ResultSLI->dump(&DAG)); ++NumShiftInserts; return ResultSLI; @@ -6738,12 +6738,12 @@ } if (!Value.getNode()) { - DEBUG(dbgs() << "LowerBUILD_VECTOR: value undefined, creating undef node\n"); + LLVM_DEBUG(dbgs() << "LowerBUILD_VECTOR: value undefined, creating undef node\n"); return DAG.getUNDEF(VT); } if (isOnlyLowElement) { - DEBUG(dbgs() << "LowerBUILD_VECTOR: only low element used, creating 1 " + LLVM_DEBUG(dbgs() << "LowerBUILD_VECTOR: only low element used, creating 1 " "SCALAR_TO_VECTOR node\n"); return DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, VT, Value); } @@ -6754,7 +6754,7 @@ if (!isConstant) { if (Value.getOpcode() != ISD::EXTRACT_VECTOR_ELT || Value.getValueType() != VT) { - DEBUG(dbgs() << "LowerBUILD_VECTOR: use DUP for non-constant splats\n"); + LLVM_DEBUG(dbgs() << "LowerBUILD_VECTOR: use DUP for non-constant splats\n"); return DAG.getNode(AArch64ISD::DUP, dl, VT, Value); } @@ -6763,7 +6763,7 @@ SDValue Lane = Value.getOperand(1); Value = Value.getOperand(0); if (Value.getValueSizeInBits() == 64) { - DEBUG(dbgs() << "LowerBUILD_VECTOR: DUPLANE works on 128-bit vectors, " + LLVM_DEBUG(dbgs() << "LowerBUILD_VECTOR: DUPLANE works on 128-bit vectors, " "widening it\n"); Value = WidenVector(Value, DAG); } @@ -6777,14 +6777,14 @@ EVT EltTy = VT.getVectorElementType(); assert ((EltTy == MVT::f16 || EltTy == MVT::f32 || EltTy == MVT::f64) && "Unsupported floating-point vector type"); - DEBUG(dbgs() << "LowerBUILD_VECTOR: float constant splats, creating int " + LLVM_DEBUG(dbgs() << "LowerBUILD_VECTOR: float constant splats, creating int " "BITCASTS, and try again\n"); MVT NewType = MVT::getIntegerVT(EltTy.getSizeInBits()); for (unsigned i = 0; i < NumElts; ++i) Ops.push_back(DAG.getNode(ISD::BITCAST, dl, NewType, Op.getOperand(i))); EVT VecVT = EVT::getVectorVT(*DAG.getContext(), NewType, NumElts); SDValue Val = DAG.getBuildVector(VecVT, dl, Ops); - DEBUG( + LLVM_DEBUG( dbgs() << "LowerBUILD_VECTOR: trying to lower new vector: "; Val.dump(); ); @@ -6815,7 +6815,7 @@ // This will generate a load from the constant pool. if (isConstant) { - DEBUG(dbgs() << "LowerBUILD_VECTOR: all elements are constant, use default " + LLVM_DEBUG(dbgs() << "LowerBUILD_VECTOR: all elements are constant, use default " "expansion\n"); return SDValue(); } @@ -6833,7 +6833,7 @@ // shuffle is valid for the target) and materialization element by element // on the stack followed by a load for everything else. if (!isConstant && !usesOnlyOneValue) { - DEBUG(dbgs() << "LowerBUILD_VECTOR: alternatives failed, creating sequence " + LLVM_DEBUG(dbgs() << "LowerBUILD_VECTOR: alternatives failed, creating sequence " "of INSERT_VECTOR_ELT\n"); SDValue Vec = DAG.getUNDEF(VT); @@ -6851,11 +6851,11 @@ // extended (i32) and it is safe to cast them to the vector type by ignoring // the upper bits of the lowest lane (e.g. v8i8, v4i16). if (!Op0.isUndef()) { - DEBUG(dbgs() << "Creating node for op0, it is not undefined:\n"); + LLVM_DEBUG(dbgs() << "Creating node for op0, it is not undefined:\n"); Vec = DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, VT, Op0); ++i; } - DEBUG( + LLVM_DEBUG( if (i < NumElts) dbgs() << "Creating nodes for the other vector elements:\n"; ); @@ -6869,7 +6869,7 @@ return Vec; } - DEBUG(dbgs() << "LowerBUILD_VECTOR: use default expansion, failed to find " + LLVM_DEBUG(dbgs() << "LowerBUILD_VECTOR: use default expansion, failed to find " "better alternative\n"); return SDValue(); } @@ -7961,14 +7961,14 @@ // 12-bit optionally shifted immediates are legal for adds. bool AArch64TargetLowering::isLegalAddImmediate(int64_t Immed) const { if (Immed == std::numeric_limits::min()) { - DEBUG(dbgs() << "Illegal add imm " << Immed << ": avoid UB for INT64_MIN\n"); + LLVM_DEBUG(dbgs() << "Illegal add imm " << Immed << ": avoid UB for INT64_MIN\n"); return false; } // Same encoding for add/sub, just flip the sign. Immed = std::abs(Immed); bool IsLegal = ((Immed >> 12) == 0 || ((Immed & 0xfff) == 0 && Immed >> 24 == 0)); - DEBUG(dbgs() << "Is " << Immed << " legal add imm: " << + LLVM_DEBUG(dbgs() << "Is " << Immed << " legal add imm: " << (IsLegal ? "yes" : "no") << "\n"); return IsLegal; } @@ -8760,7 +8760,7 @@ SVT.getVectorNumElements() != VT.getVectorNumElements() * 2) return SDValue(); - DEBUG(dbgs() << "aarch64-lower: bitcast extract_subvector simplification\n"); + LLVM_DEBUG(dbgs() << "aarch64-lower: bitcast extract_subvector simplification\n"); // Create the simplified form to just extract the low or high half of the // vector directly rather than bothering with the bitcasts. @@ -8848,7 +8848,7 @@ if (!RHSTy.isVector()) return SDValue(); - DEBUG(dbgs() << "aarch64-lower: concat_vectors bitcast simplification\n"); + LLVM_DEBUG(dbgs() << "aarch64-lower: concat_vectors bitcast simplification\n"); MVT ConcatTy = MVT::getVectorVT(RHSTy.getVectorElementType(), RHSTy.getVectorNumElements() * 2); @@ -10428,7 +10428,7 @@ SelectionDAG &DAG = DCI.DAG; switch (N->getOpcode()) { default: - DEBUG(dbgs() << "Custom combining: skipping\n"); + LLVM_DEBUG(dbgs() << "Custom combining: skipping\n"); break; case ISD::ADD: case ISD::SUB: Index: lib/Target/AArch64/AArch64InstructionSelector.cpp =================================================================== --- lib/Target/AArch64/AArch64InstructionSelector.cpp +++ lib/Target/AArch64/AArch64InstructionSelector.cpp @@ -174,7 +174,7 @@ const AArch64RegisterInfo &TRI) { LLT Ty = MRI.getType(I.getOperand(0).getReg()); if (!Ty.isValid()) { - DEBUG(dbgs() << "Generic binop register should be typed\n"); + LLVM_DEBUG(dbgs() << "Generic binop register should be typed\n"); return true; } @@ -182,7 +182,7 @@ for (auto &MO : I.operands()) { // FIXME: Support non-register operands. if (!MO.isReg()) { - DEBUG(dbgs() << "Generic inst non-reg operands are unsupported\n"); + LLVM_DEBUG(dbgs() << "Generic inst non-reg operands are unsupported\n"); return true; } @@ -191,18 +191,18 @@ // bank out of the minimal class for the register. // Either way, this needs to be documented (and possibly verified). if (!TargetRegisterInfo::isVirtualRegister(MO.getReg())) { - DEBUG(dbgs() << "Generic inst has physical register operand\n"); + LLVM_DEBUG(dbgs() << "Generic inst has physical register operand\n"); return true; } const RegisterBank *OpBank = RBI.getRegBank(MO.getReg(), MRI, TRI); if (!OpBank) { - DEBUG(dbgs() << "Generic register has no bank or class\n"); + LLVM_DEBUG(dbgs() << "Generic register has no bank or class\n"); return true; } if (PrevOpBank && OpBank != PrevOpBank) { - DEBUG(dbgs() << "Generic inst operands have different banks\n"); + LLVM_DEBUG(dbgs() << "Generic inst operands have different banks\n"); return true; } PrevOpBank = OpBank; @@ -378,7 +378,7 @@ const TargetRegisterClass *RC = getRegClassForTypeOnBank( MRI.getType(DstReg), RegBank, RBI, /* GetAllRegSet */ true); if (!RC) { - DEBUG(dbgs() << "Unexpected bitcast size " << DstSize << '\n'); + LLVM_DEBUG(dbgs() << "Unexpected bitcast size " << DstSize << '\n'); return false; } @@ -412,7 +412,7 @@ // we hit another of its use or its defs. // Copies do not have constraints. if (!RBI.constrainGenericRegister(DstReg, *RC, MRI)) { - DEBUG(dbgs() << "Failed to constrain " << TII.getName(I.getOpcode()) + LLVM_DEBUG(dbgs() << "Failed to constrain " << TII.getName(I.getOpcode()) << " operand\n"); return false; } @@ -686,13 +686,13 @@ DefRC = RegClassOrBank.dyn_cast(); if (!DefRC) { if (!DefTy.isValid()) { - DEBUG(dbgs() << "PHI operand has no type, not a gvreg?\n"); + LLVM_DEBUG(dbgs() << "PHI operand has no type, not a gvreg?\n"); return false; } const RegisterBank &RB = *RegClassOrBank.get(); DefRC = getRegClassForTypeOnBank(DefTy, RB, RBI); if (!DefRC) { - DEBUG(dbgs() << "PHI operand has unexpected size/bank\n"); + LLVM_DEBUG(dbgs() << "PHI operand has unexpected size/bank\n"); return false; } } @@ -710,7 +710,7 @@ if (I.getNumOperands() != I.getNumExplicitOperands()) { - DEBUG(dbgs() << "Generic instruction has unexpected implicit operands\n"); + LLVM_DEBUG(dbgs() << "Generic instruction has unexpected implicit operands\n"); return false; } @@ -726,7 +726,7 @@ // We shouldn't need this on AArch64, but it would be implemented as an // EXTRACT_SUBREG followed by a TBNZW because TBNZX has no encoding if the // bit being tested is < 32. - DEBUG(dbgs() << "G_BRCOND has type: " << Ty + LLVM_DEBUG(dbgs() << "G_BRCOND has type: " << Ty << ", expected at most 32-bits"); return false; } @@ -767,14 +767,14 @@ // FIXME: Redundant check, but even less readable when factored out. if (isFP) { if (Ty != s32 && Ty != s64) { - DEBUG(dbgs() << "Unable to materialize FP " << Ty + LLVM_DEBUG(dbgs() << "Unable to materialize FP " << Ty << " constant, expected: " << s32 << " or " << s64 << '\n'); return false; } if (RB.getID() != AArch64::FPRRegBankID) { - DEBUG(dbgs() << "Unable to materialize FP " << Ty + LLVM_DEBUG(dbgs() << "Unable to materialize FP " << Ty << " constant on bank: " << RB << ", expected: FPR\n"); return false; } @@ -786,14 +786,14 @@ } else { // s32 and s64 are covered by tablegen. if (Ty != p0) { - DEBUG(dbgs() << "Unable to materialize integer " << Ty + LLVM_DEBUG(dbgs() << "Unable to materialize integer " << Ty << " constant, expected: " << s32 << ", " << s64 << ", or " << p0 << '\n'); return false; } if (RB.getID() != AArch64::GPRRegBankID) { - DEBUG(dbgs() << "Unable to materialize integer " << Ty + LLVM_DEBUG(dbgs() << "Unable to materialize integer " << Ty << " constant on bank: " << RB << ", expected: GPR\n"); return false; } @@ -820,7 +820,7 @@ .addUse(DefGPRReg); if (!RBI.constrainGenericRegister(DefReg, FPRRC, MRI)) { - DEBUG(dbgs() << "Failed to constrain G_FCONSTANT def operand\n"); + LLVM_DEBUG(dbgs() << "Failed to constrain G_FCONSTANT def operand\n"); return false; } @@ -908,7 +908,7 @@ case TargetOpcode::G_FRAME_INDEX: { // allocas and G_FRAME_INDEX are only supported in addrspace(0). if (Ty != LLT::pointer(0, 64)) { - DEBUG(dbgs() << "G_FRAME_INDEX pointer has type: " << Ty + LLVM_DEBUG(dbgs() << "G_FRAME_INDEX pointer has type: " << Ty << ", expected: " << LLT::pointer(0, 64) << '\n'); return false; } @@ -981,14 +981,14 @@ LLT PtrTy = MRI.getType(I.getOperand(1).getReg()); if (PtrTy != LLT::pointer(0, 64)) { - DEBUG(dbgs() << "Load/Store pointer has type: " << PtrTy + LLVM_DEBUG(dbgs() << "Load/Store pointer has type: " << PtrTy << ", expected: " << LLT::pointer(0, 64) << '\n'); return false; } auto &MemOp = **I.memoperands_begin(); if (MemOp.getOrdering() != AtomicOrdering::NotAtomic) { - DEBUG(dbgs() << "Atomic load/store not supported yet\n"); + LLVM_DEBUG(dbgs() << "Atomic load/store not supported yet\n"); return false; } @@ -1066,12 +1066,12 @@ const RegisterBank &RB = *RBI.getRegBank(DefReg, MRI, TRI); if (RB.getID() != AArch64::GPRRegBankID) { - DEBUG(dbgs() << "G_[SU]MULH on bank: " << RB << ", expected: GPR\n"); + LLVM_DEBUG(dbgs() << "G_[SU]MULH on bank: " << RB << ", expected: GPR\n"); return false; } if (Ty != LLT::scalar(64)) { - DEBUG(dbgs() << "G_[SU]MULH has type: " << Ty + LLVM_DEBUG(dbgs() << "G_[SU]MULH has type: " << Ty << ", expected: " << LLT::scalar(64) << '\n'); return false; } @@ -1138,7 +1138,7 @@ const RegisterBank &SrcRB = *RBI.getRegBank(SrcReg, MRI, TRI); if (DstRB.getID() != SrcRB.getID()) { - DEBUG(dbgs() << "G_TRUNC/G_PTRTOINT input/output on different banks\n"); + LLVM_DEBUG(dbgs() << "G_TRUNC/G_PTRTOINT input/output on different banks\n"); return false; } @@ -1155,7 +1155,7 @@ if (!RBI.constrainGenericRegister(SrcReg, *SrcRC, MRI) || !RBI.constrainGenericRegister(DstReg, *DstRC, MRI)) { - DEBUG(dbgs() << "Failed to constrain G_TRUNC/G_PTRTOINT\n"); + LLVM_DEBUG(dbgs() << "Failed to constrain G_TRUNC/G_PTRTOINT\n"); return false; } @@ -1169,7 +1169,7 @@ SrcRC == &AArch64::GPR64RegClass) { I.getOperand(1).setSubReg(AArch64::sub_32); } else { - DEBUG(dbgs() << "Unhandled mismatched classes in G_TRUNC/G_PTRTOINT\n"); + LLVM_DEBUG(dbgs() << "Unhandled mismatched classes in G_TRUNC/G_PTRTOINT\n"); return false; } @@ -1192,25 +1192,25 @@ const RegisterBank &RBDst = *RBI.getRegBank(DstReg, MRI, TRI); if (RBDst.getID() != AArch64::GPRRegBankID) { - DEBUG(dbgs() << "G_ANYEXT on bank: " << RBDst << ", expected: GPR\n"); + LLVM_DEBUG(dbgs() << "G_ANYEXT on bank: " << RBDst << ", expected: GPR\n"); return false; } const RegisterBank &RBSrc = *RBI.getRegBank(SrcReg, MRI, TRI); if (RBSrc.getID() != AArch64::GPRRegBankID) { - DEBUG(dbgs() << "G_ANYEXT on bank: " << RBSrc << ", expected: GPR\n"); + LLVM_DEBUG(dbgs() << "G_ANYEXT on bank: " << RBSrc << ", expected: GPR\n"); return false; } const unsigned DstSize = MRI.getType(DstReg).getSizeInBits(); if (DstSize == 0) { - DEBUG(dbgs() << "G_ANYEXT operand has no size, not a gvreg?\n"); + LLVM_DEBUG(dbgs() << "G_ANYEXT operand has no size, not a gvreg?\n"); return false; } if (DstSize != 64 && DstSize > 32) { - DEBUG(dbgs() << "G_ANYEXT to size: " << DstSize + LLVM_DEBUG(dbgs() << "G_ANYEXT to size: " << DstSize << ", expected: 32 or 64\n"); return false; } @@ -1239,7 +1239,7 @@ const RegisterBank &RB = *RBI.getRegBank(DefReg, MRI, TRI); if (RB.getID() != AArch64::GPRRegBankID) { - DEBUG(dbgs() << TII.getName(I.getOpcode()) << " on bank: " << RB + LLVM_DEBUG(dbgs() << TII.getName(I.getOpcode()) << " on bank: " << RB << ", expected: GPR\n"); return false; } @@ -1248,7 +1248,7 @@ if (DstTy == LLT::scalar(64)) { // FIXME: Can we avoid manually doing this? if (!RBI.constrainGenericRegister(SrcReg, AArch64::GPR32RegClass, MRI)) { - DEBUG(dbgs() << "Failed to constrain " << TII.getName(Opcode) + LLVM_DEBUG(dbgs() << "Failed to constrain " << TII.getName(Opcode) << " operand\n"); return false; } @@ -1317,7 +1317,7 @@ case TargetOpcode::G_SELECT: { if (MRI.getType(I.getOperand(1).getReg()) != LLT::scalar(1)) { - DEBUG(dbgs() << "G_SELECT cond has type: " << Ty + LLVM_DEBUG(dbgs() << "G_SELECT cond has type: " << Ty << ", expected: " << LLT::scalar(1) << '\n'); return false; } @@ -1356,7 +1356,7 @@ } case TargetOpcode::G_ICMP: { if (Ty != LLT::scalar(32)) { - DEBUG(dbgs() << "G_ICMP result has type: " << Ty + LLVM_DEBUG(dbgs() << "G_ICMP result has type: " << Ty << ", expected: " << LLT::scalar(32) << '\n'); return false; } @@ -1403,7 +1403,7 @@ case TargetOpcode::G_FCMP: { if (Ty != LLT::scalar(32)) { - DEBUG(dbgs() << "G_FCMP result has type: " << Ty + LLVM_DEBUG(dbgs() << "G_FCMP result has type: " << Ty << ", expected: " << LLT::scalar(32) << '\n'); return false; } Index: lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp =================================================================== --- lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp +++ lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp @@ -705,13 +705,13 @@ .setMemRefs(I->mergeMemRefsWith(*MergeMI)); (void)MIB; - DEBUG(dbgs() << "Creating wider store. Replacing instructions:\n "); - DEBUG(I->print(dbgs())); - DEBUG(dbgs() << " "); - DEBUG(MergeMI->print(dbgs())); - DEBUG(dbgs() << " with instruction:\n "); - DEBUG(((MachineInstr *)MIB)->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Creating wider store. Replacing instructions:\n "); + LLVM_DEBUG(I->print(dbgs())); + LLVM_DEBUG(dbgs() << " "); + LLVM_DEBUG(MergeMI->print(dbgs())); + LLVM_DEBUG(dbgs() << " with instruction:\n "); + LLVM_DEBUG(((MachineInstr *)MIB)->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); // Erase the old instructions. I->eraseFromParent(); @@ -822,11 +822,11 @@ (void)MIB; - DEBUG(dbgs() << "Creating pair load/store. Replacing instructions:\n "); - DEBUG(I->print(dbgs())); - DEBUG(dbgs() << " "); - DEBUG(Paired->print(dbgs())); - DEBUG(dbgs() << " with instruction:\n "); + LLVM_DEBUG(dbgs() << "Creating pair load/store. Replacing instructions:\n "); + LLVM_DEBUG(I->print(dbgs())); + LLVM_DEBUG(dbgs() << " "); + LLVM_DEBUG(Paired->print(dbgs())); + LLVM_DEBUG(dbgs() << " with instruction:\n "); if (SExtIdx != -1) { // Generate the sign extension for the proper result of the ldp. // I.e., with X1, that would be: @@ -840,8 +840,8 @@ unsigned DstRegW = TRI->getSubReg(DstRegX, AArch64::sub_32); // Update the result of LDP to use the W instead of the X variant. DstMO.setReg(DstRegW); - DEBUG(((MachineInstr *)MIB)->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(((MachineInstr *)MIB)->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); // Make the machine verifier happy by providing a definition for // the X register. // Insert this definition right after the generated LDP, i.e., before @@ -858,12 +858,12 @@ .addImm(0) .addImm(31); (void)MIBSXTW; - DEBUG(dbgs() << " Extend operand:\n "); - DEBUG(((MachineInstr *)MIBSXTW)->print(dbgs())); + LLVM_DEBUG(dbgs() << " Extend operand:\n "); + LLVM_DEBUG(((MachineInstr *)MIBSXTW)->print(dbgs())); } else { - DEBUG(((MachineInstr *)MIB)->print(dbgs())); + LLVM_DEBUG(((MachineInstr *)MIB)->print(dbgs())); } - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n"); // Erase the old instructions. I->eraseFromParent(); @@ -901,9 +901,9 @@ break; } } - DEBUG(dbgs() << "Remove load instruction:\n "); - DEBUG(LoadI->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Remove load instruction:\n "); + LLVM_DEBUG(LoadI->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); LoadI->eraseFromParent(); return NextI; } @@ -974,15 +974,15 @@ break; } - DEBUG(dbgs() << "Promoting load by replacing :\n "); - DEBUG(StoreI->print(dbgs())); - DEBUG(dbgs() << " "); - DEBUG(LoadI->print(dbgs())); - DEBUG(dbgs() << " with instructions:\n "); - DEBUG(StoreI->print(dbgs())); - DEBUG(dbgs() << " "); - DEBUG((BitExtMI)->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Promoting load by replacing :\n "); + LLVM_DEBUG(StoreI->print(dbgs())); + LLVM_DEBUG(dbgs() << " "); + LLVM_DEBUG(LoadI->print(dbgs())); + LLVM_DEBUG(dbgs() << " with instructions:\n "); + LLVM_DEBUG(StoreI->print(dbgs())); + LLVM_DEBUG(dbgs() << " "); + LLVM_DEBUG((BitExtMI)->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); // Erase the old instructions. LoadI->eraseFromParent(); @@ -1368,18 +1368,18 @@ if (IsPreIdx) { ++NumPreFolded; - DEBUG(dbgs() << "Creating pre-indexed load/store."); + LLVM_DEBUG(dbgs() << "Creating pre-indexed load/store."); } else { ++NumPostFolded; - DEBUG(dbgs() << "Creating post-indexed load/store."); + LLVM_DEBUG(dbgs() << "Creating post-indexed load/store."); } - DEBUG(dbgs() << " Replacing instructions:\n "); - DEBUG(I->print(dbgs())); - DEBUG(dbgs() << " "); - DEBUG(Update->print(dbgs())); - DEBUG(dbgs() << " with instruction:\n "); - DEBUG(((MachineInstr *)MIB)->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " Replacing instructions:\n "); + LLVM_DEBUG(I->print(dbgs())); + LLVM_DEBUG(dbgs() << " "); + LLVM_DEBUG(Update->print(dbgs())); + LLVM_DEBUG(dbgs() << " with instruction:\n "); + LLVM_DEBUG(((MachineInstr *)MIB)->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); // Erase the old instructions for the block. I->eraseFromParent(); Index: lib/Target/AArch64/AArch64PBQPRegAlloc.cpp =================================================================== --- lib/Target/AArch64/AArch64PBQPRegAlloc.cpp +++ lib/Target/AArch64/AArch64PBQPRegAlloc.cpp @@ -164,9 +164,9 @@ LiveIntervals &LIs = G.getMetadata().LIS; if (TRI->isPhysicalRegister(Rd) || TRI->isPhysicalRegister(Ra)) { - DEBUG(dbgs() << "Rd is a physical reg:" << TRI->isPhysicalRegister(Rd) + LLVM_DEBUG(dbgs() << "Rd is a physical reg:" << TRI->isPhysicalRegister(Rd) << '\n'); - DEBUG(dbgs() << "Ra is a physical reg:" << TRI->isPhysicalRegister(Ra) + LLVM_DEBUG(dbgs() << "Ra is a physical reg:" << TRI->isPhysicalRegister(Ra) << '\n'); return false; } @@ -247,13 +247,13 @@ // Do some Chain management if (Chains.count(Ra)) { if (Rd != Ra) { - DEBUG(dbgs() << "Moving acc chain from " << printReg(Ra, TRI) << " to " + LLVM_DEBUG(dbgs() << "Moving acc chain from " << printReg(Ra, TRI) << " to " << printReg(Rd, TRI) << '\n';); Chains.remove(Ra); Chains.insert(Rd); } } else { - DEBUG(dbgs() << "Creating new acc chain for " << printReg(Rd, TRI) + LLVM_DEBUG(dbgs() << "Creating new acc chain for " << printReg(Rd, TRI) << '\n';); Chains.insert(Rd); } @@ -279,7 +279,7 @@ assert(edge != G.invalidEdgeId() && "PBQP error ! The edge should exist !"); - DEBUG(dbgs() << "Refining constraint !\n";); + LLVM_DEBUG(dbgs() << "Refining constraint !\n";); if (G.getEdgeNode1Id(edge) == node2) { std::swap(node1, node2); @@ -329,7 +329,7 @@ LiveIntervals &LIs = G.getMetadata().LIS; TRI = MF.getSubtarget().getRegisterInfo(); - DEBUG(MF.dump()); + LLVM_DEBUG(MF.dump()); for (const auto &MBB: MF) { Chains.clear(); // FIXME: really needed ? Could not work at MF level ? @@ -340,7 +340,7 @@ for (auto r : Chains) { SmallVector toDel; if(regJustKilledBefore(LIs, r, MI)) { - DEBUG(dbgs() << "Killing chain " << printReg(r, TRI) << " at "; + LLVM_DEBUG(dbgs() << "Killing chain " << printReg(r, TRI) << " at "; MI.print(dbgs());); toDel.push_back(r); } Index: lib/Target/AArch64/AArch64PromoteConstant.cpp =================================================================== --- lib/Target/AArch64/AArch64PromoteConstant.cpp +++ lib/Target/AArch64/AArch64PromoteConstant.cpp @@ -119,7 +119,7 @@ /// Iterate over the functions and promote the interesting constants into /// global variables with module scope. bool runOnModule(Module &M) override { - DEBUG(dbgs() << getPassName() << '\n'); + LLVM_DEBUG(dbgs() << getPassName() << '\n'); if (skipModule(M)) return false; bool Changed = false; @@ -380,9 +380,9 @@ (IPI.first->getParent() != NewPt->getParent() && DT.dominates(IPI.first->getParent(), NewPt->getParent()))) { // No need to insert this point. Just record the dominated use. - DEBUG(dbgs() << "Insertion point dominated by:\n"); - DEBUG(IPI.first->print(dbgs())); - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "Insertion point dominated by:\n"); + LLVM_DEBUG(IPI.first->print(dbgs())); + LLVM_DEBUG(dbgs() << '\n'); IPI.second.emplace_back(User, OpNo); return true; } @@ -408,9 +408,9 @@ // Instructions are in the same block. // By construction, NewPt is dominating the other. // Indeed, isDominated returned false with the exact same arguments. - DEBUG(dbgs() << "Merge insertion point with:\n"); - DEBUG(IPI->first->print(dbgs())); - DEBUG(dbgs() << "\nat considered insertion point.\n"); + LLVM_DEBUG(dbgs() << "Merge insertion point with:\n"); + LLVM_DEBUG(IPI->first->print(dbgs())); + LLVM_DEBUG(dbgs() << "\nat considered insertion point.\n"); appendAndTransferDominatedUses(NewPt, User, OpNo, IPI, InsertPts); return true; } @@ -430,11 +430,11 @@ } // else, CommonDominator is the block of NewBB, hence NewBB is the last // possible insertion point in that block. - DEBUG(dbgs() << "Merge insertion point with:\n"); - DEBUG(IPI->first->print(dbgs())); - DEBUG(dbgs() << '\n'); - DEBUG(NewPt->print(dbgs())); - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "Merge insertion point with:\n"); + LLVM_DEBUG(IPI->first->print(dbgs())); + LLVM_DEBUG(dbgs() << '\n'); + LLVM_DEBUG(NewPt->print(dbgs())); + LLVM_DEBUG(dbgs() << '\n'); appendAndTransferDominatedUses(NewPt, User, OpNo, IPI, InsertPts); return true; } @@ -443,15 +443,15 @@ void AArch64PromoteConstant::computeInsertionPoint( Instruction *User, unsigned OpNo, InsertionPoints &InsertPts) { - DEBUG(dbgs() << "Considered use, opidx " << OpNo << ":\n"); - DEBUG(User->print(dbgs())); - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "Considered use, opidx " << OpNo << ":\n"); + LLVM_DEBUG(User->print(dbgs())); + LLVM_DEBUG(dbgs() << '\n'); Instruction *InsertionPoint = findInsertionPoint(*User, OpNo); - DEBUG(dbgs() << "Considered insertion point:\n"); - DEBUG(InsertionPoint->print(dbgs())); - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "Considered insertion point:\n"); + LLVM_DEBUG(InsertionPoint->print(dbgs())); + LLVM_DEBUG(dbgs() << '\n'); if (isDominated(InsertionPoint, User, OpNo, InsertPts)) return; @@ -460,7 +460,7 @@ if (tryAndMerge(InsertionPoint, User, OpNo, InsertPts)) return; - DEBUG(dbgs() << "Keep considered insertion point\n"); + LLVM_DEBUG(dbgs() << "Keep considered insertion point\n"); // It is definitely useful by its own InsertPts[InsertionPoint].emplace_back(User, OpNo); @@ -476,9 +476,9 @@ *F.getParent(), C.getType(), true, GlobalValue::InternalLinkage, nullptr, "_PromotedConst", nullptr, GlobalVariable::NotThreadLocal); PC.GV->setInitializer(&C); - DEBUG(dbgs() << "Global replacement: "); - DEBUG(PC.GV->print(dbgs())); - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "Global replacement: "); + LLVM_DEBUG(PC.GV->print(dbgs())); + LLVM_DEBUG(dbgs() << '\n'); ++NumPromoted; } @@ -495,10 +495,10 @@ // Create the load of the global variable. IRBuilder<> Builder(IPI.first); LoadInst *LoadedCst = Builder.CreateLoad(&PromotedGV); - DEBUG(dbgs() << "**********\n"); - DEBUG(dbgs() << "New def: "); - DEBUG(LoadedCst->print(dbgs())); - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "**********\n"); + LLVM_DEBUG(dbgs() << "New def: "); + LLVM_DEBUG(LoadedCst->print(dbgs())); + LLVM_DEBUG(dbgs() << '\n'); // Update the dominated uses. for (auto Use : IPI.second) { @@ -507,7 +507,7 @@ findInsertionPoint(*Use.first, Use.second)) && "Inserted definition does not dominate all its uses!"); #endif - DEBUG({ + LLVM_DEBUG({ dbgs() << "Use to update " << Use.second << ":"; Use.first->print(dbgs()); dbgs() << '\n'; @@ -523,7 +523,7 @@ PromotionCacheTy &PromotionCache) { // Promote the constants. for (auto U = Updates.begin(), E = Updates.end(); U != E;) { - DEBUG(dbgs() << "** Compute insertion points **\n"); + LLVM_DEBUG(dbgs() << "** Compute insertion points **\n"); auto First = U; Constant *C = First->C; InsertionPoints InsertPts; Index: lib/Target/AArch64/AArch64RedundantCopyElimination.cpp =================================================================== --- lib/Target/AArch64/AArch64RedundantCopyElimination.cpp +++ lib/Target/AArch64/AArch64RedundantCopyElimination.cpp @@ -427,9 +427,9 @@ } if (IsCopy) - DEBUG(dbgs() << "Remove redundant Copy : " << *MI); + LLVM_DEBUG(dbgs() << "Remove redundant Copy : " << *MI); else - DEBUG(dbgs() << "Remove redundant Move : " << *MI); + LLVM_DEBUG(dbgs() << "Remove redundant Move : " << *MI); MI->eraseFromParent(); Changed = true; @@ -473,7 +473,7 @@ // Clear kills in the range where changes were made. This is conservative, // but should be okay since kill markers are being phased out. - DEBUG(dbgs() << "Clearing kill flags.\n\tFirstUse: " << *FirstUse + LLVM_DEBUG(dbgs() << "Clearing kill flags.\n\tFirstUse: " << *FirstUse << "\tLastChange: " << *LastChange); for (MachineInstr &MMI : make_range(FirstUse, PredMBB->end())) MMI.clearKillInfo(); Index: lib/Target/AArch64/AArch64StorePairSuppress.cpp =================================================================== --- lib/Target/AArch64/AArch64StorePairSuppress.cpp +++ lib/Target/AArch64/AArch64StorePairSuppress.cpp @@ -91,7 +91,7 @@ if (SCDesc->isValid() && !SCDesc->isVariant()) { unsigned ResLenWithSTP = BBTrace.getResourceLength(None, SCDesc); if (ResLenWithSTP > ResLength) { - DEBUG(dbgs() << " Suppress STP in BB: " << BB->getNumber() + LLVM_DEBUG(dbgs() << " Suppress STP in BB: " << BB->getNumber() << " resources " << ResLength << " -> " << ResLenWithSTP << "\n"); return false; @@ -131,10 +131,10 @@ Traces = &getAnalysis(); MinInstr = nullptr; - DEBUG(dbgs() << "*** " << getPassName() << ": " << MF.getName() << '\n'); + LLVM_DEBUG(dbgs() << "*** " << getPassName() << ": " << MF.getName() << '\n'); if (!SchedModel.hasInstrSchedModel()) { - DEBUG(dbgs() << " Skipping pass: no machine model present.\n"); + LLVM_DEBUG(dbgs() << " Skipping pass: no machine model present.\n"); return false; } @@ -156,7 +156,7 @@ if (!SuppressSTP && shouldAddSTPToBlock(MI.getParent())) break; // Otherwise, continue unpairing the stores in this block. - DEBUG(dbgs() << "Unpairing store " << MI << "\n"); + LLVM_DEBUG(dbgs() << "Unpairing store " << MI << "\n"); SuppressSTP = true; TII->suppressLdStPair(MI); } Index: lib/Target/AArch64/AArch64TargetTransformInfo.cpp =================================================================== --- lib/Target/AArch64/AArch64TargetTransformInfo.cpp +++ lib/Target/AArch64/AArch64TargetTransformInfo.cpp @@ -690,13 +690,13 @@ }; int StridedLoads = countStridedLoads(L, SE); - DEBUG(dbgs() << "falkor-hwpf: detected " << StridedLoads + LLVM_DEBUG(dbgs() << "falkor-hwpf: detected " << StridedLoads << " strided loads\n"); // Pick the largest power of 2 unroll count that won't result in too many // strided loads. if (StridedLoads) { UP.MaxCount = 1 << Log2_32(MaxStridedLoads / StridedLoads); - DEBUG(dbgs() << "falkor-hwpf: setting unroll MaxCount to " << UP.MaxCount + LLVM_DEBUG(dbgs() << "falkor-hwpf: setting unroll MaxCount to " << UP.MaxCount << '\n'); } } Index: lib/Target/AMDGPU/AMDGPUInline.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUInline.cpp +++ lib/Target/AMDGPU/AMDGPUInline.cpp @@ -161,7 +161,7 @@ return false; } if (isa(*std::next(I->getIterator()))) { - DEBUG(dbgs() << " Wrapper only call detected: " + LLVM_DEBUG(dbgs() << " Wrapper only call detected: " << Callee->getName() << '\n'); return true; } Index: lib/Target/AMDGPU/AMDGPULibCalls.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPULibCalls.cpp +++ lib/Target/AMDGPU/AMDGPULibCalls.cpp @@ -765,7 +765,7 @@ ArrayRef tmp(DVal); nval = ConstantDataVector::get(context, tmp); } - DEBUG(errs() << "AMDIC: " << *CI + LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *nval << "\n"); replaceCall(nval); return true; @@ -776,7 +776,7 @@ for (int i = 0; i < sz; ++i) { if (CF->isExactlyValue(ftbl[i].input)) { Value *nval = ConstantFP::get(CF->getType(), ftbl[i].result); - DEBUG(errs() << "AMDIC: " << *CI + LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *nval << "\n"); replaceCall(nval); return true; @@ -798,11 +798,11 @@ AMDGPULibFunc nf = FInfo; nf.setPrefix(AMDGPULibFunc::NATIVE); if (Constant *FPExpr = getFunction(M, nf)) { - DEBUG(dbgs() << "AMDIC: " << *CI << " ---> "); + LLVM_DEBUG(dbgs() << "AMDIC: " << *CI << " ---> "); CI->setCalledFunction(FPExpr); - DEBUG(dbgs() << *CI << '\n'); + LLVM_DEBUG(dbgs() << *CI << '\n'); return true; } @@ -820,7 +820,7 @@ Value *nval = B.CreateFDiv(ConstantFP::get(CF->getType(), 1.0), opr0, "recip2div"); - DEBUG(errs() << "AMDIC: " << *CI + LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *nval << "\n"); replaceCall(nval); return true; @@ -899,7 +899,7 @@ if ((CF && CF->isZero()) || (CINT && ci_opr1 == 0) || CZero) { // pow/powr/pown(x, 0) == 1 - DEBUG(errs() << "AMDIC: " << *CI << " ---> 1\n"); + LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> 1\n"); Constant *cnval = ConstantFP::get(eltType, 1.0); if (getVecSize(FInfo) > 1) { cnval = ConstantDataVector::getSplat(getVecSize(FInfo), cnval); @@ -909,14 +909,14 @@ } if ((CF && CF->isExactlyValue(1.0)) || (CINT && ci_opr1 == 1)) { // pow/powr/pown(x, 1.0) = x - DEBUG(errs() << "AMDIC: " << *CI + LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr0 << "\n"); replaceCall(opr0); return true; } if ((CF && CF->isExactlyValue(2.0)) || (CINT && ci_opr1 == 2)) { // pow/powr/pown(x, 2.0) = x*x - DEBUG(errs() << "AMDIC: " << *CI + LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr0 << " * " << *opr0 << "\n"); Value *nval = B.CreateFMul(opr0, opr0, "__pow2"); replaceCall(nval); @@ -924,7 +924,7 @@ } if ((CF && CF->isExactlyValue(-1.0)) || (CINT && ci_opr1 == -1)) { // pow/powr/pown(x, -1.0) = 1.0/x - DEBUG(errs() << "AMDIC: " << *CI + LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> 1 / " << *opr0 << "\n"); Constant *cnval = ConstantFP::get(eltType, 1.0); if (getVecSize(FInfo) > 1) { @@ -942,7 +942,7 @@ if (Constant *FPExpr = getFunction(M, AMDGPULibFunc(issqrt ? AMDGPULibFunc::EI_SQRT : AMDGPULibFunc::EI_RSQRT, FInfo))) { - DEBUG(errs() << "AMDIC: " << *CI << " ---> " + LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << FInfo.getName().c_str() << "(" << *opr0 << ")\n"); Value *nval = CreateCallEx(B,FPExpr, opr0, issqrt ? "__pow2sqrt" : "__pow2rsqrt"); @@ -999,7 +999,7 @@ } nval = B.CreateFDiv(cnval, nval, "__1powprod"); } - DEBUG(errs() << "AMDIC: " << *CI << " ---> " + LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << ((ci_opr1 < 0) ? "1/prod(" : "prod(") << *opr0 << ")\n"); replaceCall(nval); return true; @@ -1137,7 +1137,7 @@ nval = B.CreateBitCast(nval, opr0->getType()); } - DEBUG(errs() << "AMDIC: " << *CI << " ---> " + LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << "exp2(" << *opr1 << " * log2(" << *opr0 << "))\n"); replaceCall(nval); @@ -1155,7 +1155,7 @@ } int ci_opr1 = (int)CINT->getSExtValue(); if (ci_opr1 == 1) { // rootn(x, 1) = x - DEBUG(errs() << "AMDIC: " << *CI + LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr0 << "\n"); replaceCall(opr0); return true; @@ -1166,7 +1166,7 @@ Module *M = CI->getModule(); if (Constant *FPExpr = getFunction(M, AMDGPULibFunc(AMDGPULibFunc::EI_SQRT, FInfo))) { - DEBUG(errs() << "AMDIC: " << *CI << " ---> sqrt(" << *opr0 << ")\n"); + LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> sqrt(" << *opr0 << ")\n"); Value *nval = CreateCallEx(B,FPExpr, opr0, "__rootn2sqrt"); replaceCall(nval); return true; @@ -1175,13 +1175,13 @@ Module *M = CI->getModule(); if (Constant *FPExpr = getFunction(M, AMDGPULibFunc(AMDGPULibFunc::EI_CBRT, FInfo))) { - DEBUG(errs() << "AMDIC: " << *CI << " ---> cbrt(" << *opr0 << ")\n"); + LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> cbrt(" << *opr0 << ")\n"); Value *nval = CreateCallEx(B,FPExpr, opr0, "__rootn2cbrt"); replaceCall(nval); return true; } } else if (ci_opr1 == -1) { // rootn(x, -1) = 1.0/x - DEBUG(errs() << "AMDIC: " << *CI << " ---> 1.0 / " << *opr0 << "\n"); + LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> 1.0 / " << *opr0 << "\n"); Value *nval = B.CreateFDiv(ConstantFP::get(opr0->getType(), 1.0), opr0, "__rootn2div"); @@ -1193,7 +1193,7 @@ Module *M = CI->getModule(); if (Constant *FPExpr = getFunction(M, AMDGPULibFunc(AMDGPULibFunc::EI_RSQRT, FInfo))) { - DEBUG(errs() << "AMDIC: " << *CI << " ---> rsqrt(" << *opr0 << ")\n"); + LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> rsqrt(" << *opr0 << ")\n"); Value *nval = CreateCallEx(B,FPExpr, opr0, "__rootn2rsqrt"); replaceCall(nval); return true; @@ -1212,13 +1212,13 @@ ConstantFP *CF1 = dyn_cast(opr1); if ((CF0 && CF0->isZero()) || (CF1 && CF1->isZero())) { // fma/mad(a, b, c) = c if a=0 || b=0 - DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr2 << "\n"); + LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr2 << "\n"); replaceCall(opr2); return true; } if (CF0 && CF0->isExactlyValue(1.0f)) { // fma/mad(a, b, c) = b+c if a=1 - DEBUG(errs() << "AMDIC: " << *CI << " ---> " + LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr1 << " + " << *opr2 << "\n"); Value *nval = B.CreateFAdd(opr1, opr2, "fmaadd"); replaceCall(nval); @@ -1226,7 +1226,7 @@ } if (CF1 && CF1->isExactlyValue(1.0f)) { // fma/mad(a, b, c) = a+c if b=1 - DEBUG(errs() << "AMDIC: " << *CI << " ---> " + LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr0 << " + " << *opr2 << "\n"); Value *nval = B.CreateFAdd(opr0, opr2, "fmaadd"); replaceCall(nval); @@ -1235,7 +1235,7 @@ if (ConstantFP *CF = dyn_cast(opr2)) { if (CF->isZero()) { // fma/mad(a, b, c) = a*b if c=0 - DEBUG(errs() << "AMDIC: " << *CI << " ---> " + LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr0 << " * " << *opr1 << "\n"); Value *nval = B.CreateFMul(opr0, opr1, "fmamul"); replaceCall(nval); @@ -1263,7 +1263,7 @@ if (Constant *FPExpr = getNativeFunction( CI->getModule(), AMDGPULibFunc(AMDGPULibFunc::EI_SQRT, FInfo))) { Value *opr0 = CI->getArgOperand(0); - DEBUG(errs() << "AMDIC: " << *CI << " ---> " + LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << "sqrt(" << *opr0 << ")\n"); Value *nval = CreateCallEx(B,FPExpr, opr0, "__sqrt"); replaceCall(nval); @@ -1355,7 +1355,7 @@ P = B.CreateAddrSpaceCast(Alloc, PTy); CallInst *Call = CreateCallEx2(B, Fsincos, UI->getArgOperand(0), P); - DEBUG(errs() << "AMDIC: fold_sincos (" << *CI << ", " << *UI + LLVM_DEBUG(errs() << "AMDIC: fold_sincos (" << *CI << ", " << *UI << ") with " << *Call << "\n"); if (!isSin) { // CI->cos, UI->sin @@ -1719,7 +1719,7 @@ bool Changed = false; auto AA = &getAnalysis().getAAResults(); - DEBUG(dbgs() << "AMDIC: process function "; + LLVM_DEBUG(dbgs() << "AMDIC: process function "; F.printAsOperand(dbgs(), false, F.getParent()); dbgs() << '\n';); @@ -1737,7 +1737,7 @@ Function *Callee = CI->getCalledFunction(); if (Callee == 0) continue; - DEBUG(dbgs() << "AMDIC: try folding " << *CI << "\n"; + LLVM_DEBUG(dbgs() << "AMDIC: try folding " << *CI << "\n"; dbgs().flush()); if(Simplifier.fold(CI, AA)) Changed = true; Index: lib/Target/AMDGPU/AMDGPUMachineCFGStructurizer.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUMachineCFGStructurizer.cpp +++ lib/Target/AMDGPU/AMDGPUMachineCFGStructurizer.cpp @@ -658,7 +658,7 @@ continue; } - DEBUG(dbgs() << "Visiting " << printMBBReference(*MBB) << "\n"); + LLVM_DEBUG(dbgs() << "Visiting " << printMBBReference(*MBB) << "\n"); MBBMRT *NewMBB = new MBBMRT(MBB); MachineRegion *Region = RegionInfo->getRegionFor(MBB); @@ -695,17 +695,17 @@ const TargetRegisterInfo *TRI, PHILinearize &PHIInfo) { if (TRI->isVirtualRegister(Reg)) { - DEBUG(dbgs() << "Considering Register: " << printReg(Reg, TRI) << "\n"); + LLVM_DEBUG(dbgs() << "Considering Register: " << printReg(Reg, TRI) << "\n"); // If this is a source register to a PHI we are chaining, it // must be live out. if (PHIInfo.isSource(Reg)) { - DEBUG(dbgs() << "Add LiveOut (PHI): " << printReg(Reg, TRI) << "\n"); + LLVM_DEBUG(dbgs() << "Add LiveOut (PHI): " << printReg(Reg, TRI) << "\n"); addLiveOut(Reg); } else { // If this is live out of the MBB for (auto &UI : MRI->use_operands(Reg)) { if (UI.getParent()->getParent() != MBB) { - DEBUG(dbgs() << "Add LiveOut (MBB " << printMBBReference(*MBB) + LLVM_DEBUG(dbgs() << "Add LiveOut (MBB " << printMBBReference(*MBB) << "): " << printReg(Reg, TRI) << "\n"); addLiveOut(Reg); } else { @@ -717,7 +717,7 @@ MIE = UseInstr->getParent()->instr_end(); MII != MIE; ++MII) { if ((&(*MII)) == DefInstr) { - DEBUG(dbgs() << "Add LiveOut (Loop): " << printReg(Reg, TRI) + LLVM_DEBUG(dbgs() << "Add LiveOut (Loop): " << printReg(Reg, TRI) << "\n"); addLiveOut(Reg); } @@ -734,10 +734,10 @@ const TargetRegisterInfo *TRI, PHILinearize &PHIInfo) { if (TRI->isVirtualRegister(Reg)) { - DEBUG(dbgs() << "Considering Register: " << printReg(Reg, TRI) << "\n"); + LLVM_DEBUG(dbgs() << "Considering Register: " << printReg(Reg, TRI) << "\n"); for (auto &UI : MRI->use_operands(Reg)) { if (!Region->contains(UI.getParent()->getParent())) { - DEBUG(dbgs() << "Add LiveOut (Region " << (void *)Region + LLVM_DEBUG(dbgs() << "Add LiveOut (Region " << (void *)Region << "): " << printReg(Reg, TRI) << "\n"); addLiveOut(Reg); } @@ -749,7 +749,7 @@ const MachineRegisterInfo *MRI, const TargetRegisterInfo *TRI, PHILinearize &PHIInfo) { - DEBUG(dbgs() << "-Store Live Outs Begin (" << printMBBReference(*MBB) + LLVM_DEBUG(dbgs() << "-Store Live Outs Begin (" << printMBBReference(*MBB) << ")-\n"); for (auto &II : *MBB) { for (auto &RI : II.defs()) { @@ -774,7 +774,7 @@ for (int i = 0; i < numPreds; ++i) { if (getPHIPred(PHI, i) == MBB) { unsigned PHIReg = getPHISourceReg(PHI, i); - DEBUG(dbgs() << "Add LiveOut (PhiSource " << printMBBReference(*MBB) + LLVM_DEBUG(dbgs() << "Add LiveOut (PhiSource " << printMBBReference(*MBB) << " -> " << printMBBReference(*(*SI)) << "): " << printReg(PHIReg, TRI) << "\n"); addLiveOut(PHIReg); @@ -784,7 +784,7 @@ } } - DEBUG(dbgs() << "-Store Live Outs Endn-\n"); + LLVM_DEBUG(dbgs() << "-Store Live Outs Endn-\n"); } void LinearizedRegion::storeMBBLiveOuts(MachineBasicBlock *MBB, @@ -844,7 +844,7 @@ for (int i = 0; i < numPreds; ++i) { if (Region->contains(getPHIPred(PHI, i))) { unsigned PHIReg = getPHISourceReg(PHI, i); - DEBUG(dbgs() << "Add Region LiveOut (" << (void *)Region + LLVM_DEBUG(dbgs() << "Add Region LiveOut (" << (void *)Region << "): " << printReg(PHIReg, TRI) << "\n"); addLiveOut(PHIReg); } @@ -909,7 +909,7 @@ bool IncludeLoopPHI) { assert(Register != NewRegister && "Cannot replace a reg with itself"); - DEBUG(dbgs() << "Pepareing to replace register (region): " + LLVM_DEBUG(dbgs() << "Pepareing to replace register (region): " << printReg(Register, MRI->getTargetRegisterInfo()) << " with " << printReg(NewRegister, MRI->getTargetRegisterInfo()) << "\n"); @@ -918,11 +918,11 @@ (isLiveOut(Register) || this->getParent()->isLiveOut(Register))) { LinearizedRegion *Current = this; while (Current != nullptr && Current->getEntry() != nullptr) { - DEBUG(dbgs() << "Region before register replace\n"); - DEBUG(Current->print(dbgs(), MRI->getTargetRegisterInfo())); + LLVM_DEBUG(dbgs() << "Region before register replace\n"); + LLVM_DEBUG(Current->print(dbgs(), MRI->getTargetRegisterInfo())); Current->replaceLiveOut(Register, NewRegister); - DEBUG(dbgs() << "Region after register replace\n"); - DEBUG(Current->print(dbgs(), MRI->getTargetRegisterInfo())); + LLVM_DEBUG(dbgs() << "Region after register replace\n"); + LLVM_DEBUG(Current->print(dbgs(), MRI->getTargetRegisterInfo())); Current = Current->getParent(); } } @@ -946,12 +946,12 @@ if (ShouldReplace) { if (TargetRegisterInfo::isPhysicalRegister(NewRegister)) { - DEBUG(dbgs() << "Trying to substitute physical register: " + LLVM_DEBUG(dbgs() << "Trying to substitute physical register: " << printReg(NewRegister, MRI->getTargetRegisterInfo()) << "\n"); llvm_unreachable("Cannot substitute physical registers"); } else { - DEBUG(dbgs() << "Replacing register (region): " + LLVM_DEBUG(dbgs() << "Replacing register (region): " << printReg(Register, MRI->getTargetRegisterInfo()) << " with " << printReg(NewRegister, MRI->getTargetRegisterInfo()) @@ -1022,16 +1022,16 @@ if (hasNoDef(Reg, MRI)) continue; if (!MRI->hasOneDef(Reg)) { - DEBUG(this->getEntry()->getParent()->dump()); - DEBUG(dbgs() << printReg(Reg, TRI) << "\n"); + LLVM_DEBUG(this->getEntry()->getParent()->dump()); + LLVM_DEBUG(dbgs() << printReg(Reg, TRI) << "\n"); } if (MRI->def_begin(Reg) == MRI->def_end()) { - DEBUG(dbgs() << "Register " + LLVM_DEBUG(dbgs() << "Register " << printReg(Reg, MRI->getTargetRegisterInfo()) << " has NO defs\n"); } else if (!MRI->hasOneDef(Reg)) { - DEBUG(dbgs() << "Register " + LLVM_DEBUG(dbgs() << "Register " << printReg(Reg, MRI->getTargetRegisterInfo()) << " has multiple defs\n"); } @@ -1041,7 +1041,7 @@ MachineOperand *UseOperand = &(RI); bool UseIsOutsideDefMBB = Def->getParent()->getParent() != MBB; if (UseIsOutsideDefMBB && UseOperand->isKill()) { - DEBUG(dbgs() << "Removing kill flag on register: " + LLVM_DEBUG(dbgs() << "Removing kill flag on register: " << printReg(Reg, TRI) << "\n"); UseOperand->setIsKill(false); } @@ -1415,8 +1415,8 @@ MachineInstr &Instr = *I; if (Instr.isPHI()) { unsigned PHIDestReg = getPHIDestReg(Instr); - DEBUG(dbgs() << "Extractking killed phi:\n"); - DEBUG(Instr.dump()); + LLVM_DEBUG(dbgs() << "Extractking killed phi:\n"); + LLVM_DEBUG(Instr.dump()); PHIs.insert(&Instr); PHIInfo.addDest(PHIDestReg, Instr.getDebugLoc()); storePHILinearizationInfoDest(PHIDestReg, Instr); @@ -1448,9 +1448,9 @@ MachineBasicBlock *SourceMBB, SmallVector &PHIIndices, unsigned *ReplaceReg) { - DEBUG(dbgs() << "Shrink PHI: "); - DEBUG(PHI.dump()); - DEBUG(dbgs() << " to " << printReg(getPHIDestReg(PHI), TRI) << " = PHI("); + LLVM_DEBUG(dbgs() << "Shrink PHI: "); + LLVM_DEBUG(PHI.dump()); + LLVM_DEBUG(dbgs() << " to " << printReg(getPHIDestReg(PHI), TRI) << " = PHI("); bool Replaced = false; unsigned NumInputs = getPHINumInputs(PHI); @@ -1480,7 +1480,7 @@ if (SourceMBB) { MIB.addReg(CombinedSourceReg); MIB.addMBB(SourceMBB); - DEBUG(dbgs() << printReg(CombinedSourceReg, TRI) << ", " + LLVM_DEBUG(dbgs() << printReg(CombinedSourceReg, TRI) << ", " << printMBBReference(*SourceMBB)); } @@ -1492,10 +1492,10 @@ MachineBasicBlock *SourcePred = getPHIPred(PHI, i); MIB.addReg(SourceReg); MIB.addMBB(SourcePred); - DEBUG(dbgs() << printReg(SourceReg, TRI) << ", " + LLVM_DEBUG(dbgs() << printReg(SourceReg, TRI) << ", " << printMBBReference(*SourcePred)); } - DEBUG(dbgs() << ")\n"); + LLVM_DEBUG(dbgs() << ")\n"); } PHI.eraseFromParent(); return Replaced; @@ -1504,9 +1504,9 @@ void AMDGPUMachineCFGStructurizer::replacePHI( MachineInstr &PHI, unsigned CombinedSourceReg, MachineBasicBlock *LastMerge, SmallVector &PHIRegionIndices) { - DEBUG(dbgs() << "Replace PHI: "); - DEBUG(PHI.dump()); - DEBUG(dbgs() << " with " << printReg(getPHIDestReg(PHI), TRI) << " = PHI("); + LLVM_DEBUG(dbgs() << "Replace PHI: "); + LLVM_DEBUG(PHI.dump()); + LLVM_DEBUG(dbgs() << " with " << printReg(getPHIDestReg(PHI), TRI) << " = PHI("); bool HasExternalEdge = false; unsigned NumInputs = getPHINumInputs(PHI); @@ -1523,7 +1523,7 @@ getPHIDestReg(PHI)); MIB.addReg(CombinedSourceReg); MIB.addMBB(LastMerge); - DEBUG(dbgs() << printReg(CombinedSourceReg, TRI) << ", " + LLVM_DEBUG(dbgs() << printReg(CombinedSourceReg, TRI) << ", " << printMBBReference(*LastMerge)); for (unsigned i = 0; i < NumInputs; ++i) { if (isPHIRegionIndex(PHIRegionIndices, i)) { @@ -1533,10 +1533,10 @@ MachineBasicBlock *SourcePred = getPHIPred(PHI, i); MIB.addReg(SourceReg); MIB.addMBB(SourcePred); - DEBUG(dbgs() << printReg(SourceReg, TRI) << ", " + LLVM_DEBUG(dbgs() << printReg(SourceReg, TRI) << ", " << printMBBReference(*SourcePred)); } - DEBUG(dbgs() << ")\n"); + LLVM_DEBUG(dbgs() << ")\n"); } else { replaceRegisterWith(getPHIDestReg(PHI), CombinedSourceReg); } @@ -1546,9 +1546,9 @@ void AMDGPUMachineCFGStructurizer::replaceEntryPHI( MachineInstr &PHI, unsigned CombinedSourceReg, MachineBasicBlock *IfMBB, SmallVector &PHIRegionIndices) { - DEBUG(dbgs() << "Replace entry PHI: "); - DEBUG(PHI.dump()); - DEBUG(dbgs() << " with "); + LLVM_DEBUG(dbgs() << "Replace entry PHI: "); + LLVM_DEBUG(PHI.dump()); + LLVM_DEBUG(dbgs() << " with "); unsigned NumInputs = getPHINumInputs(PHI); unsigned NumNonRegionInputs = NumInputs; @@ -1561,17 +1561,17 @@ if (NumNonRegionInputs == 0) { auto DestReg = getPHIDestReg(PHI); replaceRegisterWith(DestReg, CombinedSourceReg); - DEBUG(dbgs() << " register " << printReg(CombinedSourceReg, TRI) << "\n"); + LLVM_DEBUG(dbgs() << " register " << printReg(CombinedSourceReg, TRI) << "\n"); PHI.eraseFromParent(); } else { - DEBUG(dbgs() << printReg(getPHIDestReg(PHI), TRI) << " = PHI("); + LLVM_DEBUG(dbgs() << printReg(getPHIDestReg(PHI), TRI) << " = PHI("); MachineBasicBlock *MBB = PHI.getParent(); MachineInstrBuilder MIB = BuildMI(*MBB, PHI, PHI.getDebugLoc(), TII->get(TargetOpcode::PHI), getPHIDestReg(PHI)); MIB.addReg(CombinedSourceReg); MIB.addMBB(IfMBB); - DEBUG(dbgs() << printReg(CombinedSourceReg, TRI) << ", " + LLVM_DEBUG(dbgs() << printReg(CombinedSourceReg, TRI) << ", " << printMBBReference(*IfMBB)); unsigned NumInputs = getPHINumInputs(PHI); for (unsigned i = 0; i < NumInputs; ++i) { @@ -1582,10 +1582,10 @@ MachineBasicBlock *SourcePred = getPHIPred(PHI, i); MIB.addReg(SourceReg); MIB.addMBB(SourcePred); - DEBUG(dbgs() << printReg(SourceReg, TRI) << ", " + LLVM_DEBUG(dbgs() << printReg(SourceReg, TRI) << ", " << printMBBReference(*SourcePred)); } - DEBUG(dbgs() << ")\n"); + LLVM_DEBUG(dbgs() << ")\n"); PHI.eraseFromParent(); } } @@ -1607,7 +1607,7 @@ } } - DEBUG(dbgs() << "Register " << printReg(Reg, TRI) << " is " + LLVM_DEBUG(dbgs() << "Register " << printReg(Reg, TRI) << " is " << (IsDead ? "dead" : "alive") << " after PHI replace\n"); if (IsDead) { LRegion->removeLiveOut(Reg); @@ -1682,7 +1682,7 @@ void AMDGPUMachineCFGStructurizer::insertUnconditionalBranch(MachineBasicBlock *MBB, MachineBasicBlock *Dest, const DebugLoc &DL) { - DEBUG(dbgs() << "Inserting unconditional branch: " << MBB->getNumber() + LLVM_DEBUG(dbgs() << "Inserting unconditional branch: " << MBB->getNumber() << " -> " << Dest->getNumber() << "\n"); MachineBasicBlock::instr_iterator Terminator = MBB->getFirstInstrTerminator(); bool HasTerminator = Terminator != MBB->instr_end(); @@ -1732,7 +1732,7 @@ MF->insert(ExitIter, LastMerge); LastMerge->addSuccessor(Exit); insertUnconditionalBranch(LastMerge, Exit); - DEBUG(dbgs() << "Created exit block: " << LastMerge->getNumber() << "\n"); + LLVM_DEBUG(dbgs() << "Created exit block: " << LastMerge->getNumber() << "\n"); } return LastMerge; } @@ -1748,7 +1748,7 @@ if (MergeBB->succ_begin() == MergeBB->succ_end()) { return; } - DEBUG(dbgs() << "Merge PHI (" << printMBBReference(*MergeBB) + LLVM_DEBUG(dbgs() << "Merge PHI (" << printMBBReference(*MergeBB) << "): " << printReg(DestRegister, TRI) << " = PHI(" << printReg(IfSourceRegister, TRI) << ", " << printMBBReference(*IfBB) << printReg(CodeSourceRegister, TRI) @@ -1810,7 +1810,7 @@ for (auto SI : Succs) { std::pair Edge = SI; - DEBUG(dbgs() << "Removing edge: " << printMBBReference(*Edge.first) + LLVM_DEBUG(dbgs() << "Removing edge: " << printMBBReference(*Edge.first) << " -> " << printMBBReference(*Edge.second) << "\n"); Edge.first->removeSuccessor(Edge.second); } @@ -1844,12 +1844,12 @@ IfBB->addSuccessor(MergeBB); IfBB->addSuccessor(CodeBBStart); - DEBUG(dbgs() << "Created If block: " << IfBB->getNumber() << "\n"); + LLVM_DEBUG(dbgs() << "Created If block: " << IfBB->getNumber() << "\n"); // Ensure that the MergeBB is a successor of the CodeEndBB. if (!CodeBBEnd->isSuccessor(MergeBB)) CodeBBEnd->addSuccessor(MergeBB); - DEBUG(dbgs() << "Moved " << printMBBReference(*CodeBBStart) << " through " + LLVM_DEBUG(dbgs() << "Moved " << printMBBReference(*CodeBBStart) << " through " << printMBBReference(*CodeBBEnd) << "\n"); // If we have a single predecessor we can find a reasonable debug location @@ -1935,16 +1935,16 @@ MachineInstr *AMDGPUMachineCFGStructurizer::getDefInstr(unsigned Reg) { if (MRI->def_begin(Reg) == MRI->def_end()) { - DEBUG(dbgs() << "Register " << printReg(Reg, MRI->getTargetRegisterInfo()) + LLVM_DEBUG(dbgs() << "Register " << printReg(Reg, MRI->getTargetRegisterInfo()) << " has NO defs\n"); } else if (!MRI->hasOneDef(Reg)) { - DEBUG(dbgs() << "Register " << printReg(Reg, MRI->getTargetRegisterInfo()) + LLVM_DEBUG(dbgs() << "Register " << printReg(Reg, MRI->getTargetRegisterInfo()) << " has multiple defs\n"); - DEBUG(dbgs() << "DEFS BEGIN:\n"); + LLVM_DEBUG(dbgs() << "DEFS BEGIN:\n"); for (auto DI = MRI->def_begin(Reg), DE = MRI->def_end(); DI != DE; ++DI) { - DEBUG(DI->getParent()->dump()); + LLVM_DEBUG(DI->getParent()->dump()); } - DEBUG(dbgs() << "DEFS END\n"); + LLVM_DEBUG(dbgs() << "DEFS END\n"); } assert(MRI->hasOneDef(Reg) && "Register has multiple definitions"); @@ -1986,7 +1986,7 @@ const TargetRegisterClass *RegClass = MRI->getRegClass(DestReg); unsigned NextDestReg = MRI->createVirtualRegister(RegClass); bool IsLastDef = PHIInfo.getNumSources(DestReg) == 1; - DEBUG(dbgs() << "Insert Chained PHI\n"); + LLVM_DEBUG(dbgs() << "Insert Chained PHI\n"); insertMergePHI(IfBB, InnerRegion->getExit(), MergeBB, DestReg, NextDestReg, SourceReg, IsLastDef); @@ -2022,16 +2022,16 @@ } for (auto LI : OldLiveOuts) { - DEBUG(dbgs() << "LiveOut: " << printReg(LI, TRI)); + LLVM_DEBUG(dbgs() << "LiveOut: " << printReg(LI, TRI)); if (!containsDef(CodeBB, InnerRegion, LI) || (!IsSingleBB && (getDefInstr(LI)->getParent() == LRegion->getExit()))) { // If the register simly lives through the CodeBB, we don't have // to rewrite anything since the register is not defined in this // part of the code. - DEBUG(dbgs() << "- through"); + LLVM_DEBUG(dbgs() << "- through"); continue; } - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n"); unsigned Reg = LI; if (/*!PHIInfo.isSource(Reg) &&*/ Reg != InnerRegion->getBBSelectRegOut()) { // If the register is live out, we do want to create a phi, @@ -2048,12 +2048,12 @@ unsigned IfSourceReg = MRI->createVirtualRegister(RegClass); // Create initializer, this value is never used, but is needed // to satisfy SSA. - DEBUG(dbgs() << "Initializer for reg: " << printReg(Reg) << "\n"); + LLVM_DEBUG(dbgs() << "Initializer for reg: " << printReg(Reg) << "\n"); TII->materializeImmediate(*IfBB, IfBB->getFirstTerminator(), DebugLoc(), IfSourceReg, 0); InnerRegion->replaceRegisterOutsideRegion(Reg, PHIDestReg, true, MRI); - DEBUG(dbgs() << "Insert Non-Chained Live out PHI\n"); + LLVM_DEBUG(dbgs() << "Insert Non-Chained Live out PHI\n"); insertMergePHI(IfBB, InnerRegion->getExit(), MergeBB, PHIDestReg, IfSourceReg, Reg, true); } @@ -2063,22 +2063,22 @@ // is a source block for a definition. SmallVector Sources; if (PHIInfo.findSourcesFromMBB(CodeBB, Sources)) { - DEBUG(dbgs() << "Inserting PHI Live Out from " << printMBBReference(*CodeBB) + LLVM_DEBUG(dbgs() << "Inserting PHI Live Out from " << printMBBReference(*CodeBB) << "\n"); for (auto SI : Sources) { unsigned DestReg; PHIInfo.findDest(SI, CodeBB, DestReg); insertChainedPHI(IfBB, CodeBB, MergeBB, InnerRegion, DestReg, SI); } - DEBUG(dbgs() << "Insertion done.\n"); + LLVM_DEBUG(dbgs() << "Insertion done.\n"); } - DEBUG(PHIInfo.dump(MRI)); + LLVM_DEBUG(PHIInfo.dump(MRI)); } void AMDGPUMachineCFGStructurizer::prunePHIInfo(MachineBasicBlock *MBB) { - DEBUG(dbgs() << "Before PHI Prune\n"); - DEBUG(PHIInfo.dump(MRI)); + LLVM_DEBUG(dbgs() << "Before PHI Prune\n"); + LLVM_DEBUG(PHIInfo.dump(MRI)); SmallVector, 4> ElimiatedSources; for (auto DRI = PHIInfo.dests_begin(), DE = PHIInfo.dests_end(); DRI != DE; @@ -2118,8 +2118,8 @@ PHIInfo.removeSource(std::get<0>(SourceInfo), std::get<1>(SourceInfo), std::get<2>(SourceInfo)); } - DEBUG(dbgs() << "After PHI Prune\n"); - DEBUG(PHIInfo.dump(MRI)); + LLVM_DEBUG(dbgs() << "After PHI Prune\n"); + LLVM_DEBUG(PHIInfo.dump(MRI)); } void AMDGPUMachineCFGStructurizer::createEntryPHI(LinearizedRegion *CurrentRegion, @@ -2127,7 +2127,7 @@ MachineBasicBlock *Entry = CurrentRegion->getEntry(); MachineBasicBlock *Exit = CurrentRegion->getExit(); - DEBUG(dbgs() << "RegionExit: " << Exit->getNumber() + LLVM_DEBUG(dbgs() << "RegionExit: " << Exit->getNumber() << " Pred: " << (*(Entry->pred_begin()))->getNumber() << "\n"); int NumSources = 0; @@ -2145,7 +2145,7 @@ const DebugLoc &DL = Entry->findDebugLoc(Entry->begin()); MachineInstrBuilder MIB = BuildMI(*Entry, Entry->instr_begin(), DL, TII->get(TargetOpcode::PHI), DestReg); - DEBUG(dbgs() << "Entry PHI " << printReg(DestReg, TRI) << " = PHI("); + LLVM_DEBUG(dbgs() << "Entry PHI " << printReg(DestReg, TRI) << " = PHI("); unsigned CurrentBackedgeReg = 0; @@ -2169,7 +2169,7 @@ BackedgePHI.addReg(getPHISourceReg(*PHIDefInstr, 1)); BackedgePHI.addMBB((*SRI).second); CurrentBackedgeReg = NewBackedgeReg; - DEBUG(dbgs() << "Inserting backedge PHI: " + LLVM_DEBUG(dbgs() << "Inserting backedge PHI: " << printReg(NewBackedgeReg, TRI) << " = PHI(" << printReg(CurrentBackedgeReg, TRI) << ", " << printMBBReference(*getPHIPred(*PHIDefInstr, 0)) @@ -2180,7 +2180,7 @@ } else { MIB.addReg(SourceReg); MIB.addMBB((*SRI).second); - DEBUG(dbgs() << printReg(SourceReg, TRI) << ", " + LLVM_DEBUG(dbgs() << printReg(SourceReg, TRI) << ", " << printMBBReference(*(*SRI).second) << ", "); } } @@ -2189,16 +2189,16 @@ if (CurrentBackedgeReg != 0) { MIB.addReg(CurrentBackedgeReg); MIB.addMBB(Exit); - DEBUG(dbgs() << printReg(CurrentBackedgeReg, TRI) << ", " + LLVM_DEBUG(dbgs() << printReg(CurrentBackedgeReg, TRI) << ", " << printMBBReference(*Exit) << ")\n"); } else { - DEBUG(dbgs() << ")\n"); + LLVM_DEBUG(dbgs() << ")\n"); } } } void AMDGPUMachineCFGStructurizer::createEntryPHIs(LinearizedRegion *CurrentRegion) { - DEBUG(PHIInfo.dump(MRI)); + LLVM_DEBUG(PHIInfo.dump(MRI)); for (auto DRI = PHIInfo.dests_begin(), DE = PHIInfo.dests_end(); DRI != DE; ++DRI) { @@ -2219,7 +2219,7 @@ MachineOperand &O = *I; ++I; if (TargetRegisterInfo::isPhysicalRegister(NewRegister)) { - DEBUG(dbgs() << "Trying to substitute physical register: " + LLVM_DEBUG(dbgs() << "Trying to substitute physical register: " << printReg(NewRegister, MRI->getTargetRegisterInfo()) << "\n"); llvm_unreachable("Cannot substitute physical registers"); @@ -2227,7 +2227,7 @@ // in the future This is how we do it: // O.substPhysReg(NewRegister, *TRI); } else { - DEBUG(dbgs() << "Replacing register: " + LLVM_DEBUG(dbgs() << "Replacing register: " << printReg(Register, MRI->getTargetRegisterInfo()) << " with " << printReg(NewRegister, MRI->getTargetRegisterInfo()) @@ -2239,19 +2239,19 @@ getRegionMRT()->replaceLiveOutReg(Register, NewRegister); - DEBUG(PHIInfo.dump(MRI)); + LLVM_DEBUG(PHIInfo.dump(MRI)); } void AMDGPUMachineCFGStructurizer::resolvePHIInfos(MachineBasicBlock *FunctionEntry) { - DEBUG(dbgs() << "Resolve PHI Infos\n"); - DEBUG(PHIInfo.dump(MRI)); + LLVM_DEBUG(dbgs() << "Resolve PHI Infos\n"); + LLVM_DEBUG(PHIInfo.dump(MRI)); for (auto DRI = PHIInfo.dests_begin(), DE = PHIInfo.dests_end(); DRI != DE; ++DRI) { unsigned DestReg = *DRI; - DEBUG(dbgs() << "DestReg: " << printReg(DestReg, TRI) << "\n"); + LLVM_DEBUG(dbgs() << "DestReg: " << printReg(DestReg, TRI) << "\n"); auto SRI = PHIInfo.sources_begin(DestReg); unsigned SourceReg = (*SRI).first; - DEBUG(dbgs() << "DestReg: " << printReg(DestReg, TRI) + LLVM_DEBUG(dbgs() << "DestReg: " << printReg(DestReg, TRI) << " SourceReg: " << printReg(SourceReg, TRI) << "\n"); assert(PHIInfo.sources_end(DestReg) == ++SRI && @@ -2326,9 +2326,9 @@ MachineOperand RegOp = MachineOperand::CreateReg(Reg, false, false, true); ArrayRef Cond(RegOp); - DEBUG(dbgs() << "RegionExitReg: "); - DEBUG(Cond[0].print(dbgs(), TRI)); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "RegionExitReg: "); + LLVM_DEBUG(Cond[0].print(dbgs(), TRI)); + LLVM_DEBUG(dbgs() << "\n"); TII->insertBranch(*RegionExit, CurrentRegion->getEntry(), RegionExit, Cond, DebugLoc()); RegionExit->addSuccessor(CurrentRegion->getEntry()); @@ -2338,12 +2338,12 @@ LinearizedRegion InnerRegion(CodeBB, MRI, TRI, PHIInfo); InnerRegion.setParent(CurrentRegion); - DEBUG(dbgs() << "Insert BB Select PHI (BB)\n"); + LLVM_DEBUG(dbgs() << "Insert BB Select PHI (BB)\n"); insertMergePHI(IfBB, CodeBB, MergeBB, BBSelectRegOut, BBSelectRegIn, CodeBBSelectReg); InnerRegion.addMBB(MergeBB); - DEBUG(InnerRegion.print(dbgs(), TRI)); + LLVM_DEBUG(InnerRegion.print(dbgs(), TRI)); rewriteLiveOutRegs(IfBB, CodeBB, MergeBB, &InnerRegion, CurrentRegion); extractKilledPHIs(CodeBB); if (IsRegionEntryBB) { @@ -2384,16 +2384,16 @@ CurrentRegion->getRegionMRT()->getEntry()->getNumber()); MachineOperand RegOp = MachineOperand::CreateReg(Reg, false, false, true); ArrayRef Cond(RegOp); - DEBUG(dbgs() << "RegionExitReg: "); - DEBUG(Cond[0].print(dbgs(), TRI)); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "RegionExitReg: "); + LLVM_DEBUG(Cond[0].print(dbgs(), TRI)); + LLVM_DEBUG(dbgs() << "\n"); TII->insertBranch(*RegionExit, CurrentRegion->getEntry(), RegionExit, Cond, DebugLoc()); RegionExit->addSuccessor(IfBB); } } CurrentRegion->addMBBs(InnerRegion); - DEBUG(dbgs() << "Insert BB Select PHI (region)\n"); + LLVM_DEBUG(dbgs() << "Insert BB Select PHI (region)\n"); insertMergePHI(IfBB, CodeExitBB, MergeBB, BBSelectRegOut, BBSelectRegIn, CodeBBSelectReg); @@ -2439,14 +2439,14 @@ MachineInstrBuilder MIB = BuildMI(*EntrySucc, EntrySucc->instr_begin(), PHI.getDebugLoc(), TII->get(TargetOpcode::PHI), NewDestReg); - DEBUG(dbgs() << "Split Entry PHI " << printReg(NewDestReg, TRI) << " = PHI("); + LLVM_DEBUG(dbgs() << "Split Entry PHI " << printReg(NewDestReg, TRI) << " = PHI("); MIB.addReg(PHISource); MIB.addMBB(Entry); - DEBUG(dbgs() << printReg(PHISource, TRI) << ", " + LLVM_DEBUG(dbgs() << printReg(PHISource, TRI) << ", " << printMBBReference(*Entry)); MIB.addReg(RegionSourceReg); MIB.addMBB(RegionSourceMBB); - DEBUG(dbgs() << " ," << printReg(RegionSourceReg, TRI) << ", " + LLVM_DEBUG(dbgs() << " ," << printReg(RegionSourceReg, TRI) << ", " << printMBBReference(*RegionSourceMBB) << ")\n"); } @@ -2480,7 +2480,7 @@ LRegion->addMBB(NewExit); LRegion->setExit(NewExit); - DEBUG(dbgs() << "Created new exit block: " << NewExit->getNumber() << "\n"); + LLVM_DEBUG(dbgs() << "Created new exit block: " << NewExit->getNumber() << "\n"); // Replace any PHI Predecessors in the successor with NewExit for (auto &II : *Succ) { @@ -2528,7 +2528,7 @@ MachineBasicBlock *EntrySucc = split(Entry->getFirstNonPHI()); MachineBasicBlock *Exit = LRegion->getExit(); - DEBUG(dbgs() << "Split " << printMBBReference(*Entry) << " to " + LLVM_DEBUG(dbgs() << "Split " << printMBBReference(*Entry) << " to " << printMBBReference(*Entry) << " -> " << printMBBReference(*EntrySucc) << "\n"); LRegion->addMBB(EntrySucc); @@ -2621,21 +2621,21 @@ rewriteRegionExitPHIs(Region, LastMerge, LRegion); removeOldExitPreds(Region); - DEBUG(PHIInfo.dump(MRI)); + LLVM_DEBUG(PHIInfo.dump(MRI)); SetVector *Children = Region->getChildren(); - DEBUG(dbgs() << "===========If Region Start===============\n"); + LLVM_DEBUG(dbgs() << "===========If Region Start===============\n"); if (LRegion->getHasLoop()) { - DEBUG(dbgs() << "Has Backedge: Yes\n"); + LLVM_DEBUG(dbgs() << "Has Backedge: Yes\n"); } else { - DEBUG(dbgs() << "Has Backedge: No\n"); + LLVM_DEBUG(dbgs() << "Has Backedge: No\n"); } unsigned BBSelectRegIn; unsigned BBSelectRegOut; for (auto CI = Children->begin(), CE = Children->end(); CI != CE; ++CI) { - DEBUG(dbgs() << "CurrentRegion: \n"); - DEBUG(LRegion->print(dbgs(), TRI)); + LLVM_DEBUG(dbgs() << "CurrentRegion: \n"); + LLVM_DEBUG(LRegion->print(dbgs(), TRI)); auto CNI = CI; ++CNI; @@ -2649,9 +2649,9 @@ // We found the block is the exit of an inner region, we need // to put it in the current linearized region. - DEBUG(dbgs() << "Linearizing region: "); - DEBUG(InnerLRegion->print(dbgs(), TRI)); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Linearizing region: "); + LLVM_DEBUG(InnerLRegion->print(dbgs(), TRI)); + LLVM_DEBUG(dbgs() << "\n"); MachineBasicBlock *InnerEntry = InnerLRegion->getEntry(); if ((&(*(InnerEntry->getParent()->begin()))) == InnerEntry) { @@ -2669,9 +2669,9 @@ BBSelectRegOut = Child->getBBSelectRegOut(); BBSelectRegIn = Child->getBBSelectRegIn(); - DEBUG(dbgs() << "BBSelectRegIn: " << printReg(BBSelectRegIn, TRI) + LLVM_DEBUG(dbgs() << "BBSelectRegIn: " << printReg(BBSelectRegIn, TRI) << "\n"); - DEBUG(dbgs() << "BBSelectRegOut: " << printReg(BBSelectRegOut, TRI) + LLVM_DEBUG(dbgs() << "BBSelectRegOut: " << printReg(BBSelectRegOut, TRI) << "\n"); MachineBasicBlock *IfEnd = CurrentMerge; @@ -2681,7 +2681,7 @@ TII->convertNonUniformIfRegion(CurrentMerge, IfEnd); } else { MachineBasicBlock *MBB = Child->getMBBMRT()->getMBB(); - DEBUG(dbgs() << "Linearizing block: " << MBB->getNumber() << "\n"); + LLVM_DEBUG(dbgs() << "Linearizing block: " << MBB->getNumber() << "\n"); if (MBB == getSingleExitNode(*(MBB->getParent()))) { // If this is the exit block then we need to skip to the next. @@ -2693,9 +2693,9 @@ BBSelectRegOut = Child->getBBSelectRegOut(); BBSelectRegIn = Child->getBBSelectRegIn(); - DEBUG(dbgs() << "BBSelectRegIn: " << printReg(BBSelectRegIn, TRI) + LLVM_DEBUG(dbgs() << "BBSelectRegIn: " << printReg(BBSelectRegIn, TRI) << "\n"); - DEBUG(dbgs() << "BBSelectRegOut: " << printReg(BBSelectRegOut, TRI) + LLVM_DEBUG(dbgs() << "BBSelectRegOut: " << printReg(BBSelectRegOut, TRI) << "\n"); MachineBasicBlock *IfEnd = CurrentMerge; @@ -2707,7 +2707,7 @@ TII->convertNonUniformIfRegion(CurrentMerge, IfEnd); } - DEBUG(PHIInfo.dump(MRI)); + LLVM_DEBUG(PHIInfo.dump(MRI)); } } @@ -2728,7 +2728,7 @@ NewInReg, Region->getEntry()->getNumber()); // Need to be careful about updating the registers inside the region. LRegion->replaceRegisterInsideRegion(InReg, InnerSelectReg, false, MRI); - DEBUG(dbgs() << "Loop BBSelect Merge PHI:\n"); + LLVM_DEBUG(dbgs() << "Loop BBSelect Merge PHI:\n"); insertMergePHI(LRegion->getEntry(), LRegion->getExit(), NewSucc, InnerSelectReg, NewInReg, LRegion->getRegionMRT()->getInnerOutputRegister()); @@ -2740,11 +2740,11 @@ TII->insertReturn(*LastMerge); } - DEBUG(Region->getEntry()->getParent()->dump()); - DEBUG(LRegion->print(dbgs(), TRI)); - DEBUG(PHIInfo.dump(MRI)); + LLVM_DEBUG(Region->getEntry()->getParent()->dump()); + LLVM_DEBUG(LRegion->print(dbgs(), TRI)); + LLVM_DEBUG(PHIInfo.dump(MRI)); - DEBUG(dbgs() << "===========If Region End===============\n"); + LLVM_DEBUG(dbgs() << "===========If Region End===============\n"); Region->setLinearizedRegion(LRegion); return true; @@ -2784,11 +2784,11 @@ } void AMDGPUMachineCFGStructurizer::initFallthroughMap(MachineFunction &MF) { - DEBUG(dbgs() << "Fallthrough Map:\n"); + LLVM_DEBUG(dbgs() << "Fallthrough Map:\n"); for (auto &MBBI : MF) { MachineBasicBlock *MBB = MBBI.getFallThrough(); if (MBB != nullptr) { - DEBUG(dbgs() << "Fallthrough: " << MBBI.getNumber() << " -> " + LLVM_DEBUG(dbgs() << "Fallthrough: " << MBBI.getNumber() << " -> " << MBB->getNumber() << "\n"); } FallthroughMap[&MBBI] = MBB; @@ -2800,7 +2800,7 @@ LinearizedRegion *LRegion = new LinearizedRegion(); if (SelectOut) { LRegion->addLiveOut(SelectOut); - DEBUG(dbgs() << "Add LiveOut (BBSelect): " << printReg(SelectOut, TRI) + LLVM_DEBUG(dbgs() << "Add LiveOut (BBSelect): " << printReg(SelectOut, TRI) << "\n"); } LRegion->setRegionMRT(Region); @@ -2863,19 +2863,19 @@ initFallthroughMap(MF); checkRegOnlyPHIInputs(MF); - DEBUG(dbgs() << "----STRUCTURIZER START----\n"); - DEBUG(MF.dump()); + LLVM_DEBUG(dbgs() << "----STRUCTURIZER START----\n"); + LLVM_DEBUG(MF.dump()); Regions = &(getAnalysis().getRegionInfo()); - DEBUG(Regions->dump()); + LLVM_DEBUG(Regions->dump()); RegionMRT *RTree = MRT::buildMRT(MF, Regions, TII, MRI); setRegionMRT(RTree); initializeSelectRegisters(RTree, 0, MRI, TII); - DEBUG(RTree->dump(TRI)); + LLVM_DEBUG(RTree->dump(TRI)); bool result = structurizeRegions(RTree, true); delete RTree; - DEBUG(dbgs() << "----STRUCTURIZER END----\n"); + LLVM_DEBUG(dbgs() << "----STRUCTURIZER END----\n"); initFallthroughMap(MF); return result; } Index: lib/Target/AMDGPU/AMDGPUOpenCLEnqueuedBlockLowering.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUOpenCLEnqueuedBlockLowering.cpp +++ lib/Target/AMDGPU/AMDGPUOpenCLEnqueuedBlockLowering.cpp @@ -108,7 +108,7 @@ /*Initializer=*/nullptr, RuntimeHandle, /*InsertBefore=*/nullptr, GlobalValue::NotThreadLocal, AMDGPUAS::GLOBAL_ADDRESS, /*IsExternallyInitialized=*/true); - DEBUG(dbgs() << "runtime handle created: " << *GV << '\n'); + LLVM_DEBUG(dbgs() << "runtime handle created: " << *GV << '\n'); auto *NewPtr = ConstantExpr::getPointerCast(GV, AddrCast->getType()); AddrCast->replaceAllUsesWith(NewPtr); F.addFnAttr("runtime-handle", RuntimeHandle); Index: lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp +++ lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp @@ -344,13 +344,13 @@ static bool tryPromoteAllocaToVector(AllocaInst *Alloca, AMDGPUAS AS) { if (DisablePromoteAllocaToVector) { - DEBUG(dbgs() << " Promotion alloca to vector is disabled\n"); + LLVM_DEBUG(dbgs() << " Promotion alloca to vector is disabled\n"); return false; } ArrayType *AllocaTy = dyn_cast(Alloca->getAllocatedType()); - DEBUG(dbgs() << "Alloca candidate for vectorization\n"); + LLVM_DEBUG(dbgs() << "Alloca candidate for vectorization\n"); // FIXME: There is no reason why we can't support larger arrays, we // are just being conservative for now. @@ -360,7 +360,7 @@ AllocaTy->getNumElements() > 16 || AllocaTy->getNumElements() < 2 || !VectorType::isValidElementType(AllocaTy->getElementType())) { - DEBUG(dbgs() << " Cannot convert type to vector\n"); + LLVM_DEBUG(dbgs() << " Cannot convert type to vector\n"); return false; } @@ -381,7 +381,7 @@ // If we can't compute a vector index from this GEP, then we can't // promote this alloca to vector. if (!Index) { - DEBUG(dbgs() << " Cannot compute vector index for GEP " << *GEP << '\n'); + LLVM_DEBUG(dbgs() << " Cannot compute vector index for GEP " << *GEP << '\n'); return false; } @@ -396,7 +396,7 @@ VectorType *VectorTy = arrayTypeToVecType(AllocaTy); - DEBUG(dbgs() << " Converting alloca to vector " + LLVM_DEBUG(dbgs() << " Converting alloca to vector " << *AllocaTy << " -> " << *VectorTy << '\n'); for (Value *V : WorkList) { @@ -486,7 +486,7 @@ // important part is both must have the same address space at // the end. if (OtherObj != BaseAlloca) { - DEBUG(dbgs() << "Found a binary instruction with another alloca object\n"); + LLVM_DEBUG(dbgs() << "Found a binary instruction with another alloca object\n"); return false; } @@ -608,7 +608,7 @@ PointerType *PtrTy = dyn_cast(ParamTy); if (PtrTy && PtrTy->getAddressSpace() == AS.LOCAL_ADDRESS) { LocalMemLimit = 0; - DEBUG(dbgs() << "Function has local memory argument. Promoting to " + LLVM_DEBUG(dbgs() << "Function has local memory argument. Promoting to " "local memory disabled.\n"); return false; } @@ -678,7 +678,7 @@ LocalMemLimit = MaxSizeWithWaveCount; - DEBUG( + LLVM_DEBUG( dbgs() << F.getName() << " uses " << CurrentLocalMemUsage << " bytes of LDS\n" << " Rounding size to " << MaxSizeWithWaveCount << " with a maximum occupancy of " << MaxOccupancy << '\n' @@ -701,7 +701,7 @@ // First try to replace the alloca with a vector Type *AllocaTy = I.getAllocatedType(); - DEBUG(dbgs() << "Trying to promote " << I << '\n'); + LLVM_DEBUG(dbgs() << "Trying to promote " << I << '\n'); if (tryPromoteAllocaToVector(&I, AS)) return true; // Promoted to vector. @@ -717,7 +717,7 @@ case CallingConv::SPIR_KERNEL: break; default: - DEBUG(dbgs() << " promote alloca to LDS not supported with calling convention.\n"); + LLVM_DEBUG(dbgs() << " promote alloca to LDS not supported with calling convention.\n"); return false; } @@ -746,7 +746,7 @@ NewSize += AllocSize; if (NewSize > LocalMemLimit) { - DEBUG(dbgs() << " " << AllocSize + LLVM_DEBUG(dbgs() << " " << AllocSize << " bytes of local memory not available to promote\n"); return false; } @@ -756,11 +756,11 @@ std::vector WorkList; if (!collectUsesWithPtrTypes(&I, &I, WorkList)) { - DEBUG(dbgs() << " Do not know how to convert all uses\n"); + LLVM_DEBUG(dbgs() << " Do not know how to convert all uses\n"); return false; } - DEBUG(dbgs() << "Promoting alloca to local memory\n"); + LLVM_DEBUG(dbgs() << "Promoting alloca to local memory\n"); Function *F = I.getParent()->getParent(); Index: lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp +++ lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp @@ -249,7 +249,7 @@ SmallVector OutArgs; for (Argument &Arg : F.args()) { if (isOutArgumentCandidate(Arg)) { - DEBUG(dbgs() << "Found possible out argument " << Arg + LLVM_DEBUG(dbgs() << "Found possible out argument " << Arg << " in function " << F.getName() << '\n'); OutArgs.push_back(&Arg); } @@ -310,7 +310,7 @@ SI = dyn_cast(Q.getInst()); if (SI) { - DEBUG(dbgs() << "Found out argument store: " << *SI << '\n'); + LLVM_DEBUG(dbgs() << "Found out argument store: " << *SI << '\n'); ReplaceableStores.emplace_back(RI, SI); } else { ThisReplaceable = false; @@ -328,7 +328,7 @@ if (llvm::find_if(ValVec, [OutArg](const std::pair &Entry) { return Entry.first == OutArg;}) != ValVec.end()) { - DEBUG(dbgs() << "Saw multiple out arg stores" << *OutArg << '\n'); + LLVM_DEBUG(dbgs() << "Saw multiple out arg stores" << *OutArg << '\n'); // It is possible to see stores to the same argument multiple times, // but we expect these would have been optimized out already. ThisReplaceable = false; @@ -358,7 +358,7 @@ F.getFunctionType()->params(), F.isVarArg()); - DEBUG(dbgs() << "Computed new return type: " << *NewRetTy << '\n'); + LLVM_DEBUG(dbgs() << "Computed new return type: " << *NewRetTy << '\n'); Function *NewFunc = Function::Create(NewFuncTy, Function::PrivateLinkage, F.getName() + ".body"); Index: lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp +++ lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp @@ -123,7 +123,7 @@ continue; if (dependsOnLocalPhi(L, Br->getCondition())) { UP.Threshold += UnrollThresholdIf; - DEBUG(dbgs() << "Set unroll threshold " << UP.Threshold + LLVM_DEBUG(dbgs() << "Set unroll threshold " << UP.Threshold << " for loop:\n" << *L << " due to " << *Br << '\n'); if (UP.Threshold >= MaxBoost) return; @@ -200,7 +200,7 @@ // Don't use the maximum allowed value here as it will make some // programs way too big. UP.Threshold = Threshold; - DEBUG(dbgs() << "Set unroll threshold " << Threshold << " for loop:\n" + LLVM_DEBUG(dbgs() << "Set unroll threshold " << Threshold << " for loop:\n" << *L << " due to " << *GEP << '\n'); if (UP.Threshold >= MaxBoost) return; Index: lib/Target/AMDGPU/AMDILCFGStructurizer.cpp =================================================================== --- lib/Target/AMDGPU/AMDILCFGStructurizer.cpp +++ lib/Target/AMDGPU/AMDILCFGStructurizer.cpp @@ -79,16 +79,16 @@ //===----------------------------------------------------------------------===// #define SHOWNEWINSTR(i) \ - DEBUG(dbgs() << "New instr: " << *i << "\n"); + LLVM_DEBUG(dbgs() << "New instr: " << *i << "\n"); #define SHOWNEWBLK(b, msg) \ -DEBUG( \ +LLVM_DEBUG( \ dbgs() << msg << "BB" << b->getNumber() << "size " << b->size(); \ dbgs() << "\n"; \ ); #define SHOWBLK_DETAIL(b, msg) \ -DEBUG( \ +LLVM_DEBUG( \ if (b) { \ dbgs() << msg << "BB" << b->getNumber() << "size " << b->size(); \ b->print(dbgs()); \ @@ -158,19 +158,19 @@ bool runOnMachineFunction(MachineFunction &MF) override { TII = MF.getSubtarget().getInstrInfo(); TRI = &TII->getRegisterInfo(); - DEBUG(MF.dump();); + LLVM_DEBUG(MF.dump();); OrderedBlks.clear(); Visited.clear(); FuncRep = &MF; MLI = &getAnalysis(); - DEBUG(dbgs() << "LoopInfo:\n"; PrintLoopinfo(*MLI);); + LLVM_DEBUG(dbgs() << "LoopInfo:\n"; PrintLoopinfo(*MLI);); MDT = &getAnalysis(); - DEBUG(MDT->print(dbgs(), (const Module*)nullptr);); + LLVM_DEBUG(MDT->print(dbgs(), (const Module*)nullptr);); PDT = &getAnalysis(); - DEBUG(PDT->print(dbgs());); + LLVM_DEBUG(PDT->print(dbgs());); prepare(); run(); - DEBUG(MF.dump();); + LLVM_DEBUG(MF.dump();); return true; } @@ -650,7 +650,7 @@ if (MI) assert(IsReturn); else if (IsReturn) - DEBUG( + LLVM_DEBUG( dbgs() << "BB" << MBB->getNumber() <<" is return block without RETURN instr\n";); return IsReturn; @@ -714,7 +714,7 @@ //FIXME: if not reducible flow graph, make it so ??? - DEBUG(dbgs() << "AMDGPUCFGStructurizer::prepare\n";); + LLVM_DEBUG(dbgs() << "AMDGPUCFGStructurizer::prepare\n";); orderBlocks(FuncRep); @@ -757,14 +757,14 @@ bool AMDGPUCFGStructurizer::run() { //Assume reducible CFG... - DEBUG(dbgs() << "AMDGPUCFGStructurizer::run\n"); + LLVM_DEBUG(dbgs() << "AMDGPUCFGStructurizer::run\n"); #ifdef STRESSTEST //Use the worse block ordering to test the algorithm. ReverseVector(orderedBlks); #endif - DEBUG(dbgs() << "Ordered blocks:\n"; printOrderedBlocks();); + LLVM_DEBUG(dbgs() << "Ordered blocks:\n"; printOrderedBlocks();); int NumIter = 0; bool Finish = false; MachineBasicBlock *MBB; @@ -774,7 +774,7 @@ do { ++NumIter; - DEBUG( + LLVM_DEBUG( dbgs() << "numIter = " << NumIter << ", numRemaintedBlk = " << NumRemainedBlk << "\n"; ); @@ -799,7 +799,7 @@ SccBeginMBB = MBB; SccNumIter = 0; SccNumBlk = NumRemainedBlk; // Init to maximum possible number. - DEBUG( + LLVM_DEBUG( dbgs() << "start processing SCC" << getSCCNum(SccBeginMBB); dbgs() << "\n"; ); @@ -817,7 +817,7 @@ ++SccNumIter; int sccRemainedNumBlk = countActiveBlock(SccBeginIter, It); if (sccRemainedNumBlk != 1 && sccRemainedNumBlk >= SccNumBlk) { - DEBUG( + LLVM_DEBUG( dbgs() << "Can't reduce SCC " << getSCCNum(MBB) << ", sccNumIter = " << SccNumIter; dbgs() << "doesn't make any progress\n"; @@ -827,7 +827,7 @@ SccNumBlk = sccRemainedNumBlk; It = SccBeginIter; ContNextScc = false; - DEBUG( + LLVM_DEBUG( dbgs() << "repeat processing SCC" << getSCCNum(MBB) << "sccNumIter = " << SccNumIter << '\n'; ); @@ -848,7 +848,7 @@ *GraphTraits::nodes_begin(FuncRep); if (EntryMBB->succ_size() == 0) { Finish = true; - DEBUG( + LLVM_DEBUG( dbgs() << "Reduce to one block\n"; ); } else { @@ -860,7 +860,7 @@ NumRemainedBlk = NewnumRemainedBlk; } else { MakeProgress = false; - DEBUG( + LLVM_DEBUG( dbgs() << "No progress\n"; ); } @@ -875,7 +875,7 @@ It != E; ++It) { if ((*It).second && (*It).second->IsRetired) { assert(((*It).first)->getNumber() != -1); - DEBUG( + LLVM_DEBUG( dbgs() << "Erase BB" << ((*It).first)->getNumber() << "\n"; ); (*It).first->eraseFromParent(); //Remove from the parent Function. @@ -886,7 +886,7 @@ LLInfoMap.clear(); if (!Finish) { - DEBUG(FuncRep->viewCFG()); + LLVM_DEBUG(FuncRep->viewCFG()); report_fatal_error("IRREDUCIBLE_CFG"); } @@ -920,14 +920,14 @@ int NumMatch = 0; int CurMatch; - DEBUG( + LLVM_DEBUG( dbgs() << "Begin patternMatch BB" << MBB->getNumber() << "\n"; ); while ((CurMatch = patternMatchGroup(MBB)) > 0) NumMatch += CurMatch; - DEBUG( + LLVM_DEBUG( dbgs() << "End patternMatch BB" << MBB->getNumber() << ", numMatch = " << NumMatch << "\n"; ); @@ -1050,7 +1050,7 @@ for (MachineLoop *ExaminedLoop : NestedLoops) { if (ExaminedLoop->getNumBlocks() == 0 || Visited[ExaminedLoop]) continue; - DEBUG(dbgs() << "Processing:\n"; ExaminedLoop->dump();); + LLVM_DEBUG(dbgs() << "Processing:\n"; ExaminedLoop->dump();); int NumBreak = mergeLoop(ExaminedLoop); if (NumBreak == -1) break; @@ -1064,7 +1064,7 @@ MBBVector ExitingMBBs; LoopRep->getExitingBlocks(ExitingMBBs); assert(!ExitingMBBs.empty() && "Infinite Loop not supported"); - DEBUG(dbgs() << "Loop has " << ExitingMBBs.size() << " exiting blocks\n";); + LLVM_DEBUG(dbgs() << "Loop has " << ExitingMBBs.size() << " exiting blocks\n";); // We assume a single ExitBlk MBBVector ExitBlks; LoopRep->getExitBlocks(ExitBlks); @@ -1106,7 +1106,7 @@ if (LoopRep&& LoopRep == MLI->getLoopFor(Src2MBB)) { MachineBasicBlock *&TheEntry = LLInfoMap[LoopRep]; if (TheEntry) { - DEBUG( + LLVM_DEBUG( dbgs() << "isLoopContBreakBlock yes src1 = BB" << Src1MBB->getNumber() << " src2 = BB" << Src2MBB->getNumber() << "\n"; @@ -1122,7 +1122,7 @@ MachineBasicBlock *TrueMBB, MachineBasicBlock *FalseMBB) { int Num = handleJumpintoIfImp(HeadMBB, TrueMBB, FalseMBB); if (Num == 0) { - DEBUG( + LLVM_DEBUG( dbgs() << "handleJumpintoIf swap trueBlk and FalseBlk" << "\n"; ); Num = handleJumpintoIfImp(HeadMBB, FalseMBB, TrueMBB); @@ -1138,7 +1138,7 @@ //trueBlk could be the common post dominator DownBlk = TrueMBB; - DEBUG( + LLVM_DEBUG( dbgs() << "handleJumpintoIfImp head = BB" << HeadMBB->getNumber() << " true = BB" << TrueMBB->getNumber() << ", numSucc=" << TrueMBB->succ_size() @@ -1146,12 +1146,12 @@ ); while (DownBlk) { - DEBUG( + LLVM_DEBUG( dbgs() << "check down = BB" << DownBlk->getNumber(); ); if (singlePathTo(FalseMBB, DownBlk) == SinglePath_InPath) { - DEBUG( + LLVM_DEBUG( dbgs() << " working\n"; ); @@ -1166,7 +1166,7 @@ break; } - DEBUG( + LLVM_DEBUG( dbgs() << " not working\n"; ); DownBlk = (DownBlk->succ_size() == 1) ? (*DownBlk->succ_begin()) : nullptr; @@ -1247,7 +1247,7 @@ if (!MigrateFalse && FalseMBB && FalseMBB->pred_size() > 1) MigrateFalse = true; - DEBUG( + LLVM_DEBUG( dbgs() << "before improveSimpleJumpintoIf: "; showImproveSimpleJumpintoIf(HeadMBB, TrueMBB, FalseMBB, LandBlk, 0); ); @@ -1385,7 +1385,7 @@ report_fatal_error("Extra register needed to handle CFG"); } } - DEBUG( + LLVM_DEBUG( dbgs() << "result from improveSimpleJumpintoIf: "; showImproveSimpleJumpintoIf(HeadMBB, TrueMBB, FalseMBB, LandBlk, 0); ); @@ -1398,7 +1398,7 @@ void AMDGPUCFGStructurizer::mergeSerialBlock(MachineBasicBlock *DstMBB, MachineBasicBlock *SrcMBB) { - DEBUG( + LLVM_DEBUG( dbgs() << "serialPattern BB" << DstMBB->getNumber() << " <= BB" << SrcMBB->getNumber() << "\n"; ); @@ -1416,7 +1416,7 @@ MachineBasicBlock *MBB, MachineBasicBlock *TrueMBB, MachineBasicBlock *FalseMBB, MachineBasicBlock *LandMBB) { assert (TrueMBB); - DEBUG( + LLVM_DEBUG( dbgs() << "ifPattern BB" << MBB->getNumber(); dbgs() << "{ "; if (TrueMBB) { @@ -1481,7 +1481,7 @@ void AMDGPUCFGStructurizer::mergeLooplandBlock(MachineBasicBlock *DstBlk, MachineBasicBlock *LandMBB) { - DEBUG(dbgs() << "loopPattern header = BB" << DstBlk->getNumber() + LLVM_DEBUG(dbgs() << "loopPattern header = BB" << DstBlk->getNumber() << " land = BB" << LandMBB->getNumber() << "\n";); insertInstrBefore(DstBlk, AMDGPU::WHILELOOP, DebugLoc()); @@ -1491,7 +1491,7 @@ void AMDGPUCFGStructurizer::mergeLoopbreakBlock(MachineBasicBlock *ExitingMBB, MachineBasicBlock *LandMBB) { - DEBUG(dbgs() << "loopbreakPattern exiting = BB" << ExitingMBB->getNumber() + LLVM_DEBUG(dbgs() << "loopbreakPattern exiting = BB" << ExitingMBB->getNumber() << " land = BB" << LandMBB->getNumber() << "\n";); MachineInstr *BranchMI = getLoopendBlockBranchInstr(ExitingMBB); assert(BranchMI && isCondBranch(BranchMI)); @@ -1511,7 +1511,7 @@ void AMDGPUCFGStructurizer::settleLoopcontBlock(MachineBasicBlock *ContingMBB, MachineBasicBlock *ContMBB) { - DEBUG(dbgs() << "settleLoopcontBlock conting = BB" + LLVM_DEBUG(dbgs() << "settleLoopcontBlock conting = BB" << ContingMBB->getNumber() << ", cont = BB" << ContMBB->getNumber() << "\n";); @@ -1587,7 +1587,7 @@ numClonedInstr += MBB->size(); - DEBUG( + LLVM_DEBUG( dbgs() << "Cloned block: " << "BB" << MBB->getNumber() << "size " << MBB->size() << "\n"; ); @@ -1603,15 +1603,15 @@ //look for the input branchinstr, not the AMDGPU branchinstr MachineInstr *BranchMI = getNormalBlockBranchInstr(SrcMBB); if (!BranchMI) { - DEBUG( + LLVM_DEBUG( dbgs() << "migrateInstruction don't see branch instr\n"; ); SpliceEnd = SrcMBB->end(); } else { - DEBUG(dbgs() << "migrateInstruction see branch instr: " << *BranchMI); + LLVM_DEBUG(dbgs() << "migrateInstruction see branch instr: " << *BranchMI); SpliceEnd = BranchMI; } - DEBUG( + LLVM_DEBUG( dbgs() << "migrateInstruction before splice dstSize = " << DstMBB->size() << "srcSize = " << SrcMBB->size() << "\n"; ); @@ -1619,7 +1619,7 @@ //splice insert before insertPos DstMBB->splice(I, SrcMBB, SrcMBB->begin(), SpliceEnd); - DEBUG( + LLVM_DEBUG( dbgs() << "migrateInstruction after splice dstSize = " << DstMBB->size() << "srcSize = " << SrcMBB->size() << '\n'; ); @@ -1640,7 +1640,7 @@ MachineBasicBlock *DummyExitBlk = FuncRep->CreateMachineBasicBlock(); FuncRep->push_back(DummyExitBlk); //insert to function SHOWNEWBLK(DummyExitBlk, "DummyExitBlock to normalize infiniteLoop: "); - DEBUG(dbgs() << "Old branch instr: " << *BranchMI << "\n";); + LLVM_DEBUG(dbgs() << "Old branch instr: " << *BranchMI << "\n";); LLVMContext &Ctx = LoopHeader->getParent()->getFunction().getContext(); Ctx.emitError("Extra register needed to handle CFG"); return nullptr; @@ -1653,7 +1653,7 @@ // test_fc_do_while_or.c need to fix the upstream on this to remove the loop. while ((BranchMI = getLoopendBlockBranchInstr(MBB)) && isUncondBranch(BranchMI)) { - DEBUG(dbgs() << "Removing uncond branch instr: " << *BranchMI); + LLVM_DEBUG(dbgs() << "Removing uncond branch instr: " << *BranchMI); BranchMI->eraseFromParent(); } } @@ -1669,7 +1669,7 @@ MachineInstr *BranchMI = getNormalBlockBranchInstr(MBB); assert(BranchMI && isCondBranch(BranchMI)); - DEBUG(dbgs() << "Removing unneeded cond branch instr: " << *BranchMI); + LLVM_DEBUG(dbgs() << "Removing unneeded cond branch instr: " << *BranchMI); BranchMI->eraseFromParent(); SHOWNEWBLK(MBB1, "Removing redundant successor"); MBB->removeSuccessor(MBB1, true); @@ -1688,7 +1688,7 @@ if (MI) MI->eraseFromParent(); MBB->addSuccessor(DummyExitBlk); - DEBUG( + LLVM_DEBUG( dbgs() << "Add dummyExitBlock to BB" << MBB->getNumber() << " successors\n"; ); @@ -1710,7 +1710,7 @@ } void AMDGPUCFGStructurizer::retireBlock(MachineBasicBlock *MBB) { - DEBUG( + LLVM_DEBUG( dbgs() << "Retiring BB" << MBB->getNumber() << "\n"; ); Index: lib/Target/AMDGPU/GCNILPSched.cpp =================================================================== --- lib/Target/AMDGPU/GCNILPSched.cpp +++ lib/Target/AMDGPU/GCNILPSched.cpp @@ -149,7 +149,7 @@ int LDepth = left->getDepth(); int RDepth = right->getDepth(); if (LDepth != RDepth) { - DEBUG(dbgs() << " Comparing latency of SU (" << left->NodeNum + LLVM_DEBUG(dbgs() << " Comparing latency of SU (" << left->NodeNum << ") depth " << LDepth << " vs SU (" << right->NodeNum << ") depth " << RDepth << "\n"); return LDepth < RDepth ? 1 : -1; @@ -169,7 +169,7 @@ if (!DisableSchedCriticalPath) { int spread = (int)left->getDepth() - (int)right->getDepth(); if (std::abs(spread) > MaxReorderWindow) { - DEBUG(dbgs() << "Depth of SU(" << left->NodeNum << "): " + LLVM_DEBUG(dbgs() << "Depth of SU(" << left->NodeNum << "): " << left->getDepth() << " != SU(" << right->NodeNum << "): " << right->getDepth() << "\n"); return left->getDepth() < right->getDepth() ? right : left; @@ -324,7 +324,7 @@ if (AvailQueue.empty()) break; - DEBUG( + LLVM_DEBUG( dbgs() << "\n=== Picking candidate\n" "Ready queue:"; for (auto &C : AvailQueue) @@ -336,7 +336,7 @@ assert(C); AvailQueue.remove(*C); auto SU = C->SU; - DEBUG(dbgs() << "Selected "; SU->dump(&DAG)); + LLVM_DEBUG(dbgs() << "Selected "; SU->dump(&DAG)); advanceToCycle(SU->getHeight()); Index: lib/Target/AMDGPU/GCNIterativeScheduler.cpp =================================================================== --- lib/Target/AMDGPU/GCNIterativeScheduler.cpp +++ lib/Target/AMDGPU/GCNIterativeScheduler.cpp @@ -199,7 +199,7 @@ void schedule() { assert(Sch.RegionBegin == Rgn.Begin && Sch.RegionEnd == Rgn.End); - DEBUG(dbgs() << "\nScheduling "; + LLVM_DEBUG(dbgs() << "\nScheduling "; printRegion(dbgs(), Rgn.Begin, Rgn.End, Sch.LIS, 2)); Sch.BaseClass::schedule(); @@ -310,7 +310,7 @@ void GCNIterativeScheduler::schedule() { // overriden // do nothing - DEBUG( + LLVM_DEBUG( printLivenessInfo(dbgs(), RegionBegin, RegionEnd, LIS); if (!Regions.empty() && Regions.back()->Begin == RegionBegin) { dbgs() << "Max RP: "; @@ -452,7 +452,7 @@ // TODO: assert Regions are sorted descending by pressure const auto &ST = MF.getSubtarget(); const auto Occ = Regions.front()->MaxPressure.getOccupancy(ST); - DEBUG(dbgs() << "Trying to improve occupancy, target = " << TargetOcc + LLVM_DEBUG(dbgs() << "Trying to improve occupancy, target = " << TargetOcc << ", current = " << Occ << '\n'); auto NewOcc = TargetOcc; @@ -460,13 +460,13 @@ if (R->MaxPressure.getOccupancy(ST) >= NewOcc) break; - DEBUG(printRegion(dbgs(), R->Begin, R->End, LIS, 3); + LLVM_DEBUG(printRegion(dbgs(), R->Begin, R->End, LIS, 3); printLivenessInfo(dbgs(), R->Begin, R->End, LIS)); BuildDAG DAG(*R, *this); const auto MinSchedule = makeMinRegSchedule(DAG.getTopRoots(), *this); const auto MaxRP = getSchedulePressure(*R, MinSchedule); - DEBUG(dbgs() << "Occupancy improvement attempt:\n"; + LLVM_DEBUG(dbgs() << "Occupancy improvement attempt:\n"; printSchedRP(dbgs(), R->MaxPressure, MaxRP)); NewOcc = std::min(NewOcc, MaxRP.getOccupancy(ST)); @@ -475,7 +475,7 @@ setBestSchedule(*R, MinSchedule, MaxRP); } - DEBUG(dbgs() << "New occupancy = " << NewOcc + LLVM_DEBUG(dbgs() << "New occupancy = " << NewOcc << ", prev occupancy = " << Occ << '\n'); return std::max(NewOcc, Occ); } @@ -496,7 +496,7 @@ const int NumPasses = Occ < TgtOcc ? 2 : 1; TgtOcc = std::min(Occ, TgtOcc); - DEBUG(dbgs() << "Scheduling using default scheduler, " + LLVM_DEBUG(dbgs() << "Scheduling using default scheduler, " "target occupancy = " << TgtOcc << '\n'); GCNMaxOccupancySchedStrategy LStrgy(Context); @@ -509,16 +509,16 @@ Ovr.schedule(); const auto RP = getRegionPressure(*R); - DEBUG(printSchedRP(dbgs(), R->MaxPressure, RP)); + LLVM_DEBUG(printSchedRP(dbgs(), R->MaxPressure, RP)); if (RP.getOccupancy(ST) < TgtOcc) { - DEBUG(dbgs() << "Didn't fit into target occupancy O" << TgtOcc); + LLVM_DEBUG(dbgs() << "Didn't fit into target occupancy O" << TgtOcc); if (R->BestSchedule.get() && R->BestSchedule->MaxPressure.getOccupancy(ST) >= TgtOcc) { - DEBUG(dbgs() << ", scheduling minimal register\n"); + LLVM_DEBUG(dbgs() << ", scheduling minimal register\n"); scheduleBest(*R); } else { - DEBUG(dbgs() << ", restoring\n"); + LLVM_DEBUG(dbgs() << ", restoring\n"); Ovr.restoreOrder(); assert(R->MaxPressure.getOccupancy(ST) >= TgtOcc); } @@ -544,7 +544,7 @@ const auto MinSchedule = makeMinRegSchedule(DAG.getTopRoots(), *this); const auto RP = getSchedulePressure(*R, MinSchedule); - DEBUG(if (R->MaxPressure.less(ST, RP, TgtOcc)) { + LLVM_DEBUG(if (R->MaxPressure.less(ST, RP, TgtOcc)) { dbgs() << "\nWarning: Pressure becomes worse after minreg!"; printSchedRP(dbgs(), R->MaxPressure, RP); }); @@ -553,7 +553,7 @@ break; scheduleRegion(*R, MinSchedule, RP); - DEBUG(printSchedResult(dbgs(), R, RP)); + LLVM_DEBUG(printSchedResult(dbgs(), R, RP)); MaxPressure = RP; } @@ -575,7 +575,7 @@ Occ = tryMaximizeOccupancy(TgtOcc); TgtOcc = std::min(Occ, TgtOcc); - DEBUG(dbgs() << "Scheduling using default scheduler, " + LLVM_DEBUG(dbgs() << "Scheduling using default scheduler, " "target occupancy = " << TgtOcc << '\n'); for (auto R : Regions) { @@ -583,18 +583,18 @@ const auto ILPSchedule = makeGCNILPScheduler(DAG.getBottomRoots(), *this); const auto RP = getSchedulePressure(*R, ILPSchedule); - DEBUG(printSchedRP(dbgs(), R->MaxPressure, RP)); + LLVM_DEBUG(printSchedRP(dbgs(), R->MaxPressure, RP)); if (RP.getOccupancy(ST) < TgtOcc) { - DEBUG(dbgs() << "Didn't fit into target occupancy O" << TgtOcc); + LLVM_DEBUG(dbgs() << "Didn't fit into target occupancy O" << TgtOcc); if (R->BestSchedule.get() && R->BestSchedule->MaxPressure.getOccupancy(ST) >= TgtOcc) { - DEBUG(dbgs() << ", scheduling minimal register\n"); + LLVM_DEBUG(dbgs() << ", scheduling minimal register\n"); scheduleBest(*R); } } else { scheduleRegion(*R, ILPSchedule, RP); - DEBUG(printSchedResult(dbgs(), R, RP)); + LLVM_DEBUG(printSchedResult(dbgs(), R, RP)); } } } Index: lib/Target/AMDGPU/GCNMinRegStrategy.cpp =================================================================== --- lib/Target/AMDGPU/GCNMinRegStrategy.cpp +++ lib/Target/AMDGPU/GCNMinRegStrategy.cpp @@ -142,34 +142,34 @@ unsigned Num = RQ.size(); if (Num == 1) break; - DEBUG(dbgs() << "\nSelecting max priority candidates among " << Num << '\n'); + LLVM_DEBUG(dbgs() << "\nSelecting max priority candidates among " << Num << '\n'); Num = findMax(Num, [=](const Candidate &C) { return C.Priority; }); if (Num == 1) break; - DEBUG(dbgs() << "\nSelecting min non-ready producing candidate among " + LLVM_DEBUG(dbgs() << "\nSelecting min non-ready producing candidate among " << Num << '\n'); Num = findMax(Num, [=](const Candidate &C) { auto SU = C.SU; int Res = getNotReadySuccessors(SU); - DEBUG(dbgs() << "SU(" << SU->NodeNum << ") would left non-ready " + LLVM_DEBUG(dbgs() << "SU(" << SU->NodeNum << ") would left non-ready " << Res << " successors, metric = " << -Res << '\n'); return -Res; }); if (Num == 1) break; - DEBUG(dbgs() << "\nSelecting most producing candidate among " + LLVM_DEBUG(dbgs() << "\nSelecting most producing candidate among " << Num << '\n'); Num = findMax(Num, [=](const Candidate &C) { auto SU = C.SU; auto Res = getReadySuccessors(SU); - DEBUG(dbgs() << "SU(" << SU->NodeNum << ") would make ready " + LLVM_DEBUG(dbgs() << "SU(" << SU->NodeNum << ") would make ready " << Res << " successors, metric = " << Res << '\n'); return Res; }); if (Num == 1) break; Num = Num ? Num : RQ.size(); - DEBUG(dbgs() << "\nCan't find best candidate, selecting in program order among " + LLVM_DEBUG(dbgs() << "\nCan't find best candidate, selecting in program order among " << Num << '\n'); Num = findMax(Num, [=](const Candidate &C) { return -(int64_t)C.SU->NodeNum; }); assert(Num == 1); @@ -202,17 +202,17 @@ Worklist.push_back(P.getSUnit()); } } - DEBUG(dbgs() << "Make the predecessors of SU(" << SchedSU->NodeNum + LLVM_DEBUG(dbgs() << "Make the predecessors of SU(" << SchedSU->NodeNum << ")'s non-ready successors of " << Priority << " priority in ready queue: "); const auto SetEnd = Set.end(); for (auto &C : RQ) { if (Set.find(C.SU) != SetEnd) { C.Priority = Priority; - DEBUG(dbgs() << " SU(" << C.SU->NodeNum << ')'); + LLVM_DEBUG(dbgs() << " SU(" << C.SU->NodeNum << ')'); } } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); } void GCNMinRegScheduler::releaseSuccessors(const SUnit* SU, int Priority) { @@ -243,7 +243,7 @@ releaseSuccessors(&DAG.EntrySU, StepNo); while (!RQ.empty()) { - DEBUG( + LLVM_DEBUG( dbgs() << "\n=== Picking candidate, Step = " << StepNo << "\n" "Ready queue:"; for (auto &C : RQ) @@ -255,7 +255,7 @@ assert(C); RQ.remove(*C); auto SU = C->SU; - DEBUG(dbgs() << "Selected "; SU->dump(&DAG)); + LLVM_DEBUG(dbgs() << "Selected "; SU->dump(&DAG)); releaseSuccessors(SU, StepNo); Schedule.push_back(SU); Index: lib/Target/AMDGPU/GCNSchedStrategy.cpp =================================================================== --- lib/Target/AMDGPU/GCNSchedStrategy.cpp +++ lib/Target/AMDGPU/GCNSchedStrategy.cpp @@ -200,29 +200,29 @@ setPolicy(TopPolicy, /*IsPostRA=*/false, Top, &Bot); // See if BotCand is still valid (because we previously scheduled from Top). - DEBUG(dbgs() << "Picking from Bot:\n"); + LLVM_DEBUG(dbgs() << "Picking from Bot:\n"); if (!BotCand.isValid() || BotCand.SU->isScheduled || BotCand.Policy != BotPolicy) { BotCand.reset(CandPolicy()); pickNodeFromQueue(Bot, BotPolicy, DAG->getBotRPTracker(), BotCand); assert(BotCand.Reason != NoCand && "failed to find the first candidate"); } else { - DEBUG(traceCandidate(BotCand)); + LLVM_DEBUG(traceCandidate(BotCand)); } // Check if the top Q has a better candidate. - DEBUG(dbgs() << "Picking from Top:\n"); + LLVM_DEBUG(dbgs() << "Picking from Top:\n"); if (!TopCand.isValid() || TopCand.SU->isScheduled || TopCand.Policy != TopPolicy) { TopCand.reset(CandPolicy()); pickNodeFromQueue(Top, TopPolicy, DAG->getTopRPTracker(), TopCand); assert(TopCand.Reason != NoCand && "failed to find the first candidate"); } else { - DEBUG(traceCandidate(TopCand)); + LLVM_DEBUG(traceCandidate(TopCand)); } // Pick best from BotCand and TopCand. - DEBUG( + LLVM_DEBUG( dbgs() << "Top Cand: "; traceCandidate(TopCand); dbgs() << "Bot Cand: "; @@ -256,7 +256,7 @@ } } } - DEBUG( + LLVM_DEBUG( dbgs() << "Picking: "; traceCandidate(Cand); ); @@ -305,7 +305,7 @@ if (SU->isBottomReady()) Bot.removeReady(SU); - DEBUG(dbgs() << "Scheduling SU(" << SU->NodeNum << ") " << *SU->getInstr()); + LLVM_DEBUG(dbgs() << "Scheduling SU(" << SU->NodeNum << ") " << *SU->getInstr()); return SU; } @@ -318,7 +318,7 @@ MF.getFunction())), MinOccupancy(StartingOccupancy), Stage(0), RegionIdx(0) { - DEBUG(dbgs() << "Starting occupancy is " << StartingOccupancy << ".\n"); + LLVM_DEBUG(dbgs() << "Starting occupancy is " << StartingOccupancy << ".\n"); } void GCNScheduleDAGMILive::schedule() { @@ -338,7 +338,7 @@ if (LIS) { PressureBefore = Pressure[RegionIdx]; - DEBUG(dbgs() << "Pressure before scheduling:\nRegion live-ins:"; + LLVM_DEBUG(dbgs() << "Pressure before scheduling:\nRegion live-ins:"; GCNRPTracker::printLiveRegs(dbgs(), LiveIns[RegionIdx], MRI); dbgs() << "Region live-in pressure: "; llvm::getRegPressure(MRI, LiveIns[RegionIdx]).print(dbgs()); @@ -356,19 +356,19 @@ GCNMaxOccupancySchedStrategy &S = (GCNMaxOccupancySchedStrategy&)*SchedImpl; auto PressureAfter = getRealRegPressure(); - DEBUG(dbgs() << "Pressure after scheduling: "; PressureAfter.print(dbgs())); + LLVM_DEBUG(dbgs() << "Pressure after scheduling: "; PressureAfter.print(dbgs())); if (PressureAfter.getSGPRNum() <= S.SGPRCriticalLimit && PressureAfter.getVGPRNum() <= S.VGPRCriticalLimit) { Pressure[RegionIdx] = PressureAfter; - DEBUG(dbgs() << "Pressure in desired limits, done.\n"); + LLVM_DEBUG(dbgs() << "Pressure in desired limits, done.\n"); return; } unsigned WavesAfter = getMaxWaves(PressureAfter.getSGPRNum(), PressureAfter.getVGPRNum(), MF); unsigned WavesBefore = getMaxWaves(PressureBefore.getSGPRNum(), PressureBefore.getVGPRNum(), MF); - DEBUG(dbgs() << "Occupancy before scheduling: " << WavesBefore << + LLVM_DEBUG(dbgs() << "Occupancy before scheduling: " << WavesBefore << ", after " << WavesAfter << ".\n"); // We could not keep current target occupancy because of the just scheduled @@ -376,7 +376,7 @@ unsigned NewOccupancy = std::max(WavesAfter, WavesBefore); if (NewOccupancy < MinOccupancy) { MinOccupancy = NewOccupancy; - DEBUG(dbgs() << "Occupancy lowered for the function to " + LLVM_DEBUG(dbgs() << "Occupancy lowered for the function to " << MinOccupancy << ".\n"); } @@ -385,7 +385,7 @@ return; } - DEBUG(dbgs() << "Attempting to revert scheduling.\n"); + LLVM_DEBUG(dbgs() << "Attempting to revert scheduling.\n"); RegionEnd = RegionBegin; for (MachineInstr *MI : Unsched) { if (MI->isDebugValue()) @@ -415,7 +415,7 @@ } RegionEnd = MI->getIterator(); ++RegionEnd; - DEBUG(dbgs() << "Scheduling " << *MI); + LLVM_DEBUG(dbgs() << "Scheduling " << *MI); } RegionBegin = Unsched.front()->getIterator(); Regions[RegionIdx] = std::make_pair(RegionBegin, RegionEnd); @@ -490,7 +490,7 @@ void GCNScheduleDAGMILive::finalizeSchedule() { GCNMaxOccupancySchedStrategy &S = (GCNMaxOccupancySchedStrategy&)*SchedImpl; - DEBUG(dbgs() << "All regions recorded, starting actual scheduling.\n"); + LLVM_DEBUG(dbgs() << "All regions recorded, starting actual scheduling.\n"); LiveIns.resize(Regions.size()); Pressure.resize(Regions.size()); @@ -509,7 +509,7 @@ if (!LIS || StartingOccupancy <= MinOccupancy) break; - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "Retrying function scheduling with lowest recorded occupancy " << MinOccupancy << ".\n"); @@ -537,8 +537,8 @@ continue; } - DEBUG(dbgs() << "********** MI Scheduling **********\n"); - DEBUG(dbgs() << MF.getName() << ":" << printMBBReference(*MBB) << " " + LLVM_DEBUG(dbgs() << "********** MI Scheduling **********\n"); + LLVM_DEBUG(dbgs() << MF.getName() << ":" << printMBBReference(*MBB) << " " << MBB->getName() << "\n From: " << *begin() << " To: "; if (RegionEnd != MBB->end()) dbgs() << *RegionEnd; else dbgs() << "End"; Index: lib/Target/AMDGPU/R600ClauseMergePass.cpp =================================================================== --- lib/Target/AMDGPU/R600ClauseMergePass.cpp +++ lib/Target/AMDGPU/R600ClauseMergePass.cpp @@ -121,7 +121,7 @@ LaterInstCount = getCFAluSize(LatrCFAlu); unsigned CumuledInsts = RootInstCount + LaterInstCount; if (CumuledInsts >= TII->getMaxAlusPerClause()) { - DEBUG(dbgs() << "Excess inst counts\n"); + LLVM_DEBUG(dbgs() << "Excess inst counts\n"); return false; } if (RootCFAlu.getOpcode() == AMDGPU::CF_ALU_PUSH_BEFORE) @@ -139,7 +139,7 @@ RootCFAlu.getOperand(KBank0Idx).getImm() || LatrCFAlu.getOperand(KBank0LineIdx).getImm() != RootCFAlu.getOperand(KBank0LineIdx).getImm())) { - DEBUG(dbgs() << "Wrong KC0\n"); + LLVM_DEBUG(dbgs() << "Wrong KC0\n"); return false; } // Is KCache Bank 1 compatible ? @@ -155,7 +155,7 @@ RootCFAlu.getOperand(KBank1Idx).getImm() || LatrCFAlu.getOperand(KBank1LineIdx).getImm() != RootCFAlu.getOperand(KBank1LineIdx).getImm())) { - DEBUG(dbgs() << "Wrong KC0\n"); + LLVM_DEBUG(dbgs() << "Wrong KC0\n"); return false; } if (LatrCFAlu.getOperand(Mode0Idx).getImm()) { Index: lib/Target/AMDGPU/R600ControlFlowFinalizer.cpp =================================================================== --- lib/Target/AMDGPU/R600ControlFlowFinalizer.cpp +++ lib/Target/AMDGPU/R600ControlFlowFinalizer.cpp @@ -531,7 +531,7 @@ for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E;) { if (TII->usesTextureCache(*I) || TII->usesVertexCache(*I)) { - DEBUG(dbgs() << CfCount << ":"; I->dump();); + LLVM_DEBUG(dbgs() << CfCount << ":"; I->dump();); FetchClauses.push_back(MakeFetchClause(MBB, I)); CfCount++; LastAlu.back() = nullptr; @@ -549,7 +549,7 @@ switch (MI->getOpcode()) { case AMDGPU::CF_ALU_PUSH_BEFORE: if (RequiresWorkAround) { - DEBUG(dbgs() << "Applying bug work-around for ALU_PUSH_BEFORE\n"); + LLVM_DEBUG(dbgs() << "Applying bug work-around for ALU_PUSH_BEFORE\n"); BuildMI(MBB, MI, MBB.findDebugLoc(MI), TII->get(AMDGPU::CF_PUSH_EG)) .addImm(CfCount + 1) .addImm(1); @@ -562,7 +562,7 @@ case AMDGPU::CF_ALU: I = MI; AluClauses.push_back(MakeALUClause(MBB, I)); - DEBUG(dbgs() << CfCount << ":"; MI->dump();); + LLVM_DEBUG(dbgs() << CfCount << ":"; MI->dump();); CfCount++; break; case AMDGPU::WHILELOOP: { @@ -597,7 +597,7 @@ .addImm(0) .addImm(0); IfThenElseStack.push_back(MIb); - DEBUG(dbgs() << CfCount << ":"; MIb->dump();); + LLVM_DEBUG(dbgs() << CfCount << ":"; MIb->dump();); MI->eraseFromParent(); CfCount++; break; @@ -610,7 +610,7 @@ getHWInstrDesc(CF_ELSE)) .addImm(0) .addImm(0); - DEBUG(dbgs() << CfCount << ":"; MIb->dump();); + LLVM_DEBUG(dbgs() << CfCount << ":"; MIb->dump();); IfThenElseStack.push_back(MIb); MI->eraseFromParent(); CfCount++; @@ -626,7 +626,7 @@ .addImm(CfCount + 1) .addImm(1); (void)MIb; - DEBUG(dbgs() << CfCount << ":"; MIb->dump();); + LLVM_DEBUG(dbgs() << CfCount << ":"; MIb->dump();); CfCount++; } @@ -673,7 +673,7 @@ } default: if (TII->isExport(MI->getOpcode())) { - DEBUG(dbgs() << CfCount << ":"; MI->dump();); + LLVM_DEBUG(dbgs() << CfCount << ":"; MI->dump();); CfCount++; } break; Index: lib/Target/AMDGPU/R600MachineScheduler.cpp =================================================================== --- lib/Target/AMDGPU/R600MachineScheduler.cpp +++ lib/Target/AMDGPU/R600MachineScheduler.cpp @@ -78,7 +78,7 @@ AllowSwitchFromAlu = true; } else { unsigned NeededWF = 62.5f / ALUFetchRationEstimate; - DEBUG( dbgs() << NeededWF << " approx. Wavefronts Required\n" ); + LLVM_DEBUG( dbgs() << NeededWF << " approx. Wavefronts Required\n" ); // We assume the local GPR requirements to be "dominated" by the requirement // of the TEX clause (which consumes 128 bits regs) ; ALU inst before and // after TEX are indeed likely to consume or generate values from/for the @@ -124,7 +124,7 @@ NextInstKind = IDOther; } - DEBUG( + LLVM_DEBUG( if (SU) { dbgs() << " ** Pick node **\n"; SU->dump(DAG); @@ -143,7 +143,7 @@ void R600SchedStrategy::schedNode(SUnit *SU, bool IsTopNode) { if (NextInstKind != CurInstKind) { - DEBUG(dbgs() << "Instruction Type Switch\n"); + LLVM_DEBUG(dbgs() << "Instruction Type Switch\n"); if (NextInstKind != IDAlu) OccupedSlotsMask |= 31; CurEmitted = 0; @@ -173,7 +173,7 @@ } - DEBUG(dbgs() << CurEmitted << " Instructions Emitted in this clause\n"); + LLVM_DEBUG(dbgs() << CurEmitted << " Instructions Emitted in this clause\n"); if (CurInstKind != IDFetch) { MoveUnits(Pending[IDFetch], Available[IDFetch]); @@ -190,11 +190,11 @@ } void R600SchedStrategy::releaseTopNode(SUnit *SU) { - DEBUG(dbgs() << "Top Releasing ";SU->dump(DAG);); + LLVM_DEBUG(dbgs() << "Top Releasing ";SU->dump(DAG);); } void R600SchedStrategy::releaseBottomNode(SUnit *SU) { - DEBUG(dbgs() << "Bottom Releasing ";SU->dump(DAG);); + LLVM_DEBUG(dbgs() << "Bottom Releasing ";SU->dump(DAG);); if (isPhysicalRegCopy(SU->getInstr())) { PhysicalRegCopy.push_back(SU); return; @@ -345,7 +345,7 @@ } void R600SchedStrategy::PrepareNextSlot() { - DEBUG(dbgs() << "New Slot\n"); + LLVM_DEBUG(dbgs() << "New Slot\n"); assert (OccupedSlotsMask && "Slot wasn't filled"); OccupedSlotsMask = 0; // if (HwGen == R600Subtarget::NORTHERN_ISLANDS) Index: lib/Target/AMDGPU/R600OptimizeVectorRegisters.cpp =================================================================== --- lib/Target/AMDGPU/R600OptimizeVectorRegisters.cpp +++ lib/Target/AMDGPU/R600OptimizeVectorRegisters.cpp @@ -228,20 +228,20 @@ UpdatedUndef.erase(ChanPos); assert(!is_contained(UpdatedUndef, Chan) && "UpdatedUndef shouldn't contain Chan more than once!"); - DEBUG(dbgs() << " ->"; Tmp->dump();); + LLVM_DEBUG(dbgs() << " ->"; Tmp->dump();); (void)Tmp; SrcVec = DstReg; } MachineInstr *NewMI = BuildMI(MBB, Pos, DL, TII->get(AMDGPU::COPY), Reg).addReg(SrcVec); - DEBUG(dbgs() << " ->"; NewMI->dump();); + LLVM_DEBUG(dbgs() << " ->"; NewMI->dump();); - DEBUG(dbgs() << " Updating Swizzle:\n"); + LLVM_DEBUG(dbgs() << " Updating Swizzle:\n"); for (MachineRegisterInfo::use_instr_iterator It = MRI->use_instr_begin(Reg), E = MRI->use_instr_end(); It != E; ++It) { - DEBUG(dbgs() << " ";(*It).dump(); dbgs() << " ->"); + LLVM_DEBUG(dbgs() << " ";(*It).dump(); dbgs() << " ->"); SwizzleInput(*It, RemapChan); - DEBUG((*It).dump()); + LLVM_DEBUG((*It).dump()); } RSI->Instr->eraseFromParent(); @@ -372,14 +372,14 @@ if (!areAllUsesSwizzeable(Reg)) continue; - DEBUG({ + LLVM_DEBUG({ dbgs() << "Trying to optimize "; MI.dump(); }); RegSeqInfo CandidateRSI; std::vector> RemapChan; - DEBUG(dbgs() << "Using common slots...\n";); + LLVM_DEBUG(dbgs() << "Using common slots...\n";); if (tryMergeUsingCommonSlot(RSI, CandidateRSI, RemapChan)) { // Remove CandidateRSI mapping RemoveMI(CandidateRSI.Instr); @@ -387,7 +387,7 @@ trackRSI(RSI); continue; } - DEBUG(dbgs() << "Using free slots...\n";); + LLVM_DEBUG(dbgs() << "Using free slots...\n";); RemapChan.clear(); if (tryMergeUsingFreeSlot(RSI, CandidateRSI, RemapChan)) { RemoveMI(CandidateRSI.Instr); Index: lib/Target/AMDGPU/R600Packetizer.cpp =================================================================== --- lib/Target/AMDGPU/R600Packetizer.cpp +++ lib/Target/AMDGPU/R600Packetizer.cpp @@ -236,7 +236,7 @@ if (ConsideredInstUsesAlreadyWrittenVectorElement && !TII->isVectorOnly(MI) && VLIW5) { isTransSlot = true; - DEBUG({ + LLVM_DEBUG({ dbgs() << "Considering as Trans Inst :"; MI.dump(); }); @@ -249,7 +249,7 @@ // Are the Constants limitations met ? CurrentPacketMIs.push_back(&MI); if (!TII->fitsConstReadLimitations(CurrentPacketMIs)) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "Couldn't pack :\n"; MI.dump(); dbgs() << "with the following packets :\n"; @@ -266,7 +266,7 @@ // Is there a BankSwizzle set that meet Read Port limitations ? if (!TII->fitsReadPortLimitations(CurrentPacketMIs, PV, BS, isTransSlot)) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "Couldn't pack :\n"; MI.dump(); dbgs() << "with the following packets :\n"; Index: lib/Target/AMDGPU/SIAnnotateControlFlow.cpp =================================================================== --- lib/Target/AMDGPU/SIAnnotateControlFlow.cpp +++ lib/Target/AMDGPU/SIAnnotateControlFlow.cpp @@ -201,7 +201,7 @@ // \brief Erase "Phi" if it is not used any more void SIAnnotateControlFlow::eraseIfUnused(PHINode *Phi) { if (RecursivelyDeleteDeadPHINode(Phi)) { - DEBUG(dbgs() << "Erased unused condition phi\n"); + LLVM_DEBUG(dbgs() << "Erased unused condition phi\n"); } } Index: lib/Target/AMDGPU/SIFixSGPRCopies.cpp =================================================================== --- lib/Target/AMDGPU/SIFixSGPRCopies.cpp +++ lib/Target/AMDGPU/SIFixSGPRCopies.cpp @@ -515,7 +515,7 @@ if (MDT.dominates(MI1, MI2)) { if (!intereferes(MI2, MI1)) { - DEBUG(dbgs() << "Erasing from " + LLVM_DEBUG(dbgs() << "Erasing from " << printMBBReference(*MI2->getParent()) << " " << *MI2); MI2->eraseFromParent(); @@ -525,7 +525,7 @@ } } else if (MDT.dominates(MI2, MI1)) { if (!intereferes(MI1, MI2)) { - DEBUG(dbgs() << "Erasing from " + LLVM_DEBUG(dbgs() << "Erasing from " << printMBBReference(*MI1->getParent()) << " " << *MI1); MI1->eraseFromParent(); @@ -543,7 +543,7 @@ MachineBasicBlock::iterator I = MBB->getFirstNonPHI(); if (!intereferes(MI1, I) && !intereferes(MI2, I)) { - DEBUG(dbgs() << "Erasing from " + LLVM_DEBUG(dbgs() << "Erasing from " << printMBBReference(*MI1->getParent()) << " " << *MI1 << "and moving from " << printMBBReference(*MI2->getParent()) << " to " @@ -607,7 +607,7 @@ MPDT = &getAnalysis(); PDF.clear(); computePDF(&MF); - DEBUG(printPDF()); + LLVM_DEBUG(printPDF()); SmallVector Worklist; @@ -682,7 +682,7 @@ } } if (Uniform) { - DEBUG(dbgs() << "Not fixing PHI for uniform branch: " << MI << '\n'); + LLVM_DEBUG(dbgs() << "Not fixing PHI for uniform branch: " << MI << '\n'); break; } } @@ -722,7 +722,7 @@ SmallSet Visited; if (HasVGPROperand || !phiHasBreakDef(MI, MRI, Visited)) { - DEBUG(dbgs() << "Fixing PHI: " << MI); + LLVM_DEBUG(dbgs() << "Fixing PHI: " << MI); TII->moveToVALU(MI); } break; @@ -734,7 +734,7 @@ continue; } - DEBUG(dbgs() << "Fixing REG_SEQUENCE: " << MI); + LLVM_DEBUG(dbgs() << "Fixing REG_SEQUENCE: " << MI); TII->moveToVALU(MI); break; @@ -745,7 +745,7 @@ Src1RC = MRI.getRegClass(MI.getOperand(2).getReg()); if (TRI->isSGPRClass(DstRC) && (TRI->hasVGPRs(Src0RC) || TRI->hasVGPRs(Src1RC))) { - DEBUG(dbgs() << " Fixing INSERT_SUBREG: " << MI); + LLVM_DEBUG(dbgs() << " Fixing INSERT_SUBREG: " << MI); TII->moveToVALU(MI); } break; Index: lib/Target/AMDGPU/SIFixVGPRCopies.cpp =================================================================== --- lib/Target/AMDGPU/SIFixVGPRCopies.cpp +++ lib/Target/AMDGPU/SIFixVGPRCopies.cpp @@ -58,7 +58,7 @@ if (TII->isVGPRCopy(MI) && !MI.readsRegister(AMDGPU::EXEC, TRI)) { MI.addOperand(MF, MachineOperand::CreateReg(AMDGPU::EXEC, false, true)); - DEBUG(dbgs() << "Add exec use to " << MI); + LLVM_DEBUG(dbgs() << "Add exec use to " << MI); Changed = true; } break; Index: lib/Target/AMDGPU/SIFoldOperands.cpp =================================================================== --- lib/Target/AMDGPU/SIFoldOperands.cpp +++ lib/Target/AMDGPU/SIFoldOperands.cpp @@ -599,14 +599,14 @@ const MachineOperand *Src0 = TII->getNamedOperand(*MI, AMDGPU::OpName::src0); const MachineOperand *Src1 = TII->getNamedOperand(*MI, AMDGPU::OpName::src1); if (Src1->isIdenticalTo(*Src0)) { - DEBUG(dbgs() << "Folded " << *MI << " into "); + LLVM_DEBUG(dbgs() << "Folded " << *MI << " into "); int Src2Idx = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::src2); if (Src2Idx != -1) MI->RemoveOperand(Src2Idx); MI->RemoveOperand(AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::src1)); mutateCopyOp(*MI, TII->get(Src0->isReg() ? (unsigned)AMDGPU::COPY : getMovOpc(false))); - DEBUG(dbgs() << *MI << '\n'); + LLVM_DEBUG(dbgs() << *MI << '\n'); return true; } } @@ -647,7 +647,7 @@ // be folded due to multiple uses or operand constraints. if (OpToFold.isImm() && tryConstantFoldOp(*MRI, TII, UseMI, &OpToFold)) { - DEBUG(dbgs() << "Constant folded " << *UseMI <<'\n'); + LLVM_DEBUG(dbgs() << "Constant folded " << *UseMI <<'\n'); // Some constant folding cases change the same immediate's use to a new // instruction, e.g. and x, 0 -> 0. Make sure we re-visit the user @@ -714,7 +714,7 @@ // copies. MRI->clearKillFlags(Fold.OpToFold->getReg()); } - DEBUG(dbgs() << "Folded source from " << MI << " into OpNo " << + LLVM_DEBUG(dbgs() << "Folded source from " << MI << " into OpNo " << static_cast(Fold.UseOpNo) << " of " << *Fold.UseMI << '\n'); tryFoldInst(TII, Fold.UseMI); } else if (Fold.isCommuted()) { @@ -795,7 +795,7 @@ if (!DefClamp) return false; - DEBUG(dbgs() << "Folding clamp " << *DefClamp << " into " << *Def << '\n'); + LLVM_DEBUG(dbgs() << "Folding clamp " << *DefClamp << " into " << *Def << '\n'); // Clamp is applied after omod, so it is OK if omod is set. DefClamp->setImm(1); @@ -918,7 +918,7 @@ if (TII->hasModifiersSet(*Def, AMDGPU::OpName::clamp)) return false; - DEBUG(dbgs() << "Folding omod " << MI << " into " << *Def << '\n'); + LLVM_DEBUG(dbgs() << "Folding omod " << MI << " into " << *Def << '\n'); DefOMod->setImm(OMod); MRI->replaceRegWith(MI.getOperand(0).getReg(), Def->getOperand(0).getReg()); Index: lib/Target/AMDGPU/SIInsertWaitcnts.cpp =================================================================== --- lib/Target/AMDGPU/SIInsertWaitcnts.cpp +++ lib/Target/AMDGPU/SIInsertWaitcnts.cpp @@ -338,7 +338,7 @@ MachineInstr *getWaitcnt() const { return LfWaitcnt; } void print() { - DEBUG(dbgs() << " iteration " << IterCnt << '\n';); + LLVM_DEBUG(dbgs() << " iteration " << IterCnt << '\n';); } private: @@ -461,7 +461,7 @@ const MachineRegisterInfo *MRI, unsigned OpNo, int32_t Val) { RegInterval Interval = getRegInterval(MI, TII, MRI, TRI, OpNo, false); - DEBUG({ + LLVM_DEBUG({ const MachineOperand &Opnd = MI->getOperand(OpNo); assert(TRI->isVGPR(*MRI, Opnd.getReg())); }); @@ -1144,7 +1144,7 @@ ScoreBracket = BlockWaitcntBracketsMap[TBB].get(); } ScoreBracket->setRevisitLoop(true); - DEBUG(dbgs() << "set-revisit: Block" + LLVM_DEBUG(dbgs() << "set-revisit: Block" << ContainingLoop->getHeader()->getNumber() << '\n';); } } @@ -1181,7 +1181,7 @@ if (!OldWaitcnt->getParent()) MI.getParent()->insert(MI, OldWaitcnt); - DEBUG(dbgs() << "updateWaitcntInBlock\n" + LLVM_DEBUG(dbgs() << "updateWaitcntInBlock\n" << "Old Instr: " << MI << '\n' << "New Instr: " << *OldWaitcnt << '\n'); } else { @@ -1190,7 +1190,7 @@ .addImm(Enc); TrackedWaitcntSet.insert(SWaitInst); - DEBUG(dbgs() << "insertWaitcntInBlock\n" + LLVM_DEBUG(dbgs() << "insertWaitcntInBlock\n" << "Old Instr: " << MI << '\n' << "New Instr: " << *SWaitInst << '\n'); } @@ -1571,7 +1571,7 @@ BlockWaitcntBrackets *ScoreBrackets = BlockWaitcntBracketsMap[&Block].get(); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Block" << Block.getNumber(); ScoreBrackets->dump(); }); @@ -1632,7 +1632,7 @@ ScoreBrackets->clearWaitcnt(); - DEBUG({ + LLVM_DEBUG({ Inst.print(dbgs()); ScoreBrackets->dump(); }); @@ -1672,7 +1672,7 @@ if (ContainingLoop && loopBottom(ContainingLoop) == &Block) { LoopWaitcntData *WaitcntData = LoopWaitcntDataMap[ContainingLoop].get(); WaitcntData->print(); - DEBUG(dbgs() << '\n';); + LLVM_DEBUG(dbgs() << '\n';); // The iterative waitcnt insertion algorithm aims for optimal waitcnt // placement and doesn't always guarantee convergence for a loop. Each @@ -1712,7 +1712,7 @@ } if (SWaitInst) { - DEBUG({ + LLVM_DEBUG({ SWaitInst->print(dbgs()); dbgs() << "\nAdjusted score board:"; ScoreBrackets->dump(); @@ -1786,7 +1786,7 @@ if (ContainingLoop && ContainingLoop->getHeader() == &MBB && J < I && (!BlockWaitcntProcessedSet.count(&MBB))) { BlockWaitcntBracketsMap[&MBB]->setRevisitLoop(true); - DEBUG(dbgs() << "set-revisit: Block" + LLVM_DEBUG(dbgs() << "set-revisit: Block" << ContainingLoop->getHeader()->getNumber() << '\n';); } @@ -1817,7 +1817,7 @@ } LoopWaitcntData *WaitcntData = LoopWaitcntDataMap[ContainingLoop].get(); WaitcntData->incIterCnt(); - DEBUG(dbgs() << "revisit: Block" << EntryBB->getNumber() << '\n';); + LLVM_DEBUG(dbgs() << "revisit: Block" << EntryBB->getNumber() << '\n';); continue; } else { LoopWaitcntData *WaitcntData = LoopWaitcntDataMap[ContainingLoop].get(); Index: lib/Target/AMDGPU/SIInsertWaits.cpp =================================================================== --- lib/Target/AMDGPU/SIInsertWaits.cpp +++ lib/Target/AMDGPU/SIInsertWaits.cpp @@ -593,7 +593,7 @@ // Check if we need to apply the bug work-around if (VCCZCorrupt && readsVCCZ(*I)) { - DEBUG(dbgs() << "Inserting vccz bug work-around before: " << *I << '\n'); + LLVM_DEBUG(dbgs() << "Inserting vccz bug work-around before: " << *I << '\n'); // Wait on everything, not just LGKM. vccz reads usually come from // terminators, and we always wait on everything at the end of the Index: lib/Target/AMDGPU/SILoadStoreOptimizer.cpp =================================================================== --- lib/Target/AMDGPU/SILoadStoreOptimizer.cpp +++ lib/Target/AMDGPU/SILoadStoreOptimizer.cpp @@ -553,7 +553,7 @@ CI.I->eraseFromParent(); CI.Paired->eraseFromParent(); - DEBUG(dbgs() << "Inserted read2: " << *Read2 << '\n'); + LLVM_DEBUG(dbgs() << "Inserted read2: " << *Read2 << '\n'); return Next; } @@ -631,7 +631,7 @@ CI.I->eraseFromParent(); CI.Paired->eraseFromParent(); - DEBUG(dbgs() << "Inserted write2 inst: " << *Write2 << '\n'); + LLVM_DEBUG(dbgs() << "Inserted write2 inst: " << *Write2 << '\n'); return Next; } @@ -950,7 +950,7 @@ assert(MRI->isSSA() && "Must be run on SSA"); - DEBUG(dbgs() << "Running SILoadStoreOptimizer\n"); + LLVM_DEBUG(dbgs() << "Running SILoadStoreOptimizer\n"); bool Modified = false; Index: lib/Target/AMDGPU/SIMachineScheduler.cpp =================================================================== --- lib/Target/AMDGPU/SIMachineScheduler.cpp +++ lib/Target/AMDGPU/SIMachineScheduler.cpp @@ -1201,7 +1201,7 @@ NextReservedID = 1; NextNonReservedID = DAGSize + 1; - DEBUG(dbgs() << "Coloring the graph\n"); + LLVM_DEBUG(dbgs() << "Coloring the graph\n"); if (BlockVariant == SISchedulerBlockCreatorVariant::LatenciesGrouped) colorHighLatenciesGroups(); @@ -1258,7 +1258,7 @@ SIScheduleBlock *Block = CurrentBlocks[i]; Block->finalizeUnits(); } - DEBUG( + LLVM_DEBUG( dbgs() << "Blocks created:\n\n"; for (unsigned i = 0, e = CurrentBlocks.size(); i != e; ++i) { SIScheduleBlock *Block = CurrentBlocks[i]; @@ -1284,7 +1284,7 @@ unsigned DAGSize = CurrentBlocks.size(); std::vector WorkList; - DEBUG(dbgs() << "Topological Sort\n"); + LLVM_DEBUG(dbgs() << "Topological Sort\n"); WorkList.reserve(DAGSize); TopDownIndex2Block.resize(DAGSize); @@ -1331,11 +1331,11 @@ void SIScheduleBlockCreator::scheduleInsideBlocks() { unsigned DAGSize = CurrentBlocks.size(); - DEBUG(dbgs() << "\nScheduling Blocks\n\n"); + LLVM_DEBUG(dbgs() << "\nScheduling Blocks\n\n"); // We do schedule a valid scheduling such that a Block corresponds // to a range of instructions. - DEBUG(dbgs() << "First phase: Fast scheduling for Reg Liveness\n"); + LLVM_DEBUG(dbgs() << "First phase: Fast scheduling for Reg Liveness\n"); for (unsigned i = 0, e = DAGSize; i != e; ++i) { SIScheduleBlock *Block = CurrentBlocks[i]; Block->fastSchedule(); @@ -1389,7 +1389,7 @@ Block->schedule((*SUs.begin())->getInstr(), (*SUs.rbegin())->getInstr()); } - DEBUG(dbgs() << "Restoring MI Pos\n"); + LLVM_DEBUG(dbgs() << "Restoring MI Pos\n"); // Restore old ordering (which prevents a LIS->handleMove bug). for (unsigned i = PosOld.size(), e = 0; i != e; --i) { MachineBasicBlock::iterator POld = PosOld[i-1]; @@ -1403,7 +1403,7 @@ } } - DEBUG( + LLVM_DEBUG( for (unsigned i = 0, e = CurrentBlocks.size(); i != e; ++i) { SIScheduleBlock *Block = CurrentBlocks[i]; Block->printDebug(true); @@ -1559,7 +1559,7 @@ blockScheduled(Block); } - DEBUG( + LLVM_DEBUG( dbgs() << "Block Order:"; for (SIScheduleBlock* Block : BlocksScheduled) { dbgs() << ' ' << Block->getID(); @@ -1628,7 +1628,7 @@ maxVregUsage = VregCurrentUsage; if (SregCurrentUsage > maxSregUsage) maxSregUsage = SregCurrentUsage; - DEBUG( + LLVM_DEBUG( dbgs() << "Picking New Blocks\n"; dbgs() << "Available: "; for (SIScheduleBlock* Block : ReadyBlocks) @@ -1671,12 +1671,12 @@ if (TryCand.Reason != NoCand) { Cand.setBest(TryCand); Best = I; - DEBUG(dbgs() << "Best Current Choice: " << Cand.Block->getID() << ' ' + LLVM_DEBUG(dbgs() << "Best Current Choice: " << Cand.Block->getID() << ' ' << getReasonStr(Cand.Reason) << '\n'); } } - DEBUG( + LLVM_DEBUG( dbgs() << "Picking: " << Cand.Block->getID() << '\n'; dbgs() << "Is a block with high latency instruction: " << (Cand.IsHighLatency ? "yes\n" : "no\n"); @@ -1933,10 +1933,10 @@ { SmallVector TopRoots, BotRoots; SIScheduleBlockResult Best, Temp; - DEBUG(dbgs() << "Preparing Scheduling\n"); + LLVM_DEBUG(dbgs() << "Preparing Scheduling\n"); buildDAGWithRegPressure(); - DEBUG( + LLVM_DEBUG( for(SUnit& SU : SUnits) SU.dumpAll(this) ); @@ -2041,7 +2041,7 @@ scheduleMI(SU, true); - DEBUG(dbgs() << "Scheduling SU(" << SU->NodeNum << ") " + LLVM_DEBUG(dbgs() << "Scheduling SU(" << SU->NodeNum << ") " << *SU->getInstr()); } @@ -2049,7 +2049,7 @@ placeDebugValues(); - DEBUG({ + LLVM_DEBUG({ dbgs() << "*** Final schedule for " << printMBBReference(*begin()->getParent()) << " ***\n"; dumpSchedule(); Index: lib/Target/AMDGPU/SIOptimizeExecMasking.cpp =================================================================== --- lib/Target/AMDGPU/SIOptimizeExecMasking.cpp +++ lib/Target/AMDGPU/SIOptimizeExecMasking.cpp @@ -243,12 +243,12 @@ // Fold exec = COPY (S_AND_B64 reg, exec) -> exec = S_AND_B64 reg, exec if (CopyToExecInst->getOperand(1).isKill() && isLogicalOpOnExec(*PrepareExecInst) == CopyToExec) { - DEBUG(dbgs() << "Fold exec copy: " << *PrepareExecInst); + LLVM_DEBUG(dbgs() << "Fold exec copy: " << *PrepareExecInst); PrepareExecInst->getOperand(0).setReg(AMDGPU::EXEC); PrepareExecInst->getOperand(0).setIsRenamable(false); - DEBUG(dbgs() << "into: " << *PrepareExecInst << '\n'); + LLVM_DEBUG(dbgs() << "into: " << *PrepareExecInst << '\n'); CopyToExecInst->eraseFromParent(); } @@ -258,7 +258,7 @@ if (isLiveOut(MBB, CopyToExec)) { // The copied register is live out and has a second use in another block. - DEBUG(dbgs() << "Exec copy source register is live out\n"); + LLVM_DEBUG(dbgs() << "Exec copy source register is live out\n"); continue; } @@ -270,7 +270,7 @@ = std::next(CopyFromExecInst->getIterator()), JE = I->getIterator(); J != JE; ++J) { if (SaveExecInst && J->readsRegister(AMDGPU::EXEC, TRI)) { - DEBUG(dbgs() << "exec read prevents saveexec: " << *J << '\n'); + LLVM_DEBUG(dbgs() << "exec read prevents saveexec: " << *J << '\n'); // Make sure this is inserted after any VALU ops that may have been // scheduled in between. SaveExecInst = nullptr; @@ -281,7 +281,7 @@ if (J->modifiesRegister(CopyToExec, TRI)) { if (SaveExecInst) { - DEBUG(dbgs() << "Multiple instructions modify " + LLVM_DEBUG(dbgs() << "Multiple instructions modify " << printReg(CopyToExec, TRI) << '\n'); SaveExecInst = nullptr; break; @@ -293,10 +293,10 @@ if (ReadsCopyFromExec) { SaveExecInst = &*J; - DEBUG(dbgs() << "Found save exec op: " << *SaveExecInst << '\n'); + LLVM_DEBUG(dbgs() << "Found save exec op: " << *SaveExecInst << '\n'); continue; } else { - DEBUG(dbgs() << "Instruction does not read exec copy: " << *J << '\n'); + LLVM_DEBUG(dbgs() << "Instruction does not read exec copy: " << *J << '\n'); break; } } else if (ReadsCopyFromExec && !SaveExecInst) { @@ -308,7 +308,7 @@ // spill %sgpr0_sgpr1 // %sgpr2_sgpr3 = S_AND_B64 %sgpr0_sgpr1 // - DEBUG(dbgs() << "Found second use of save inst candidate: " + LLVM_DEBUG(dbgs() << "Found second use of save inst candidate: " << *J << '\n'); break; } @@ -322,7 +322,7 @@ if (!SaveExecInst) continue; - DEBUG(dbgs() << "Insert save exec op: " << *SaveExecInst << '\n'); + LLVM_DEBUG(dbgs() << "Insert save exec op: " << *SaveExecInst << '\n'); MachineOperand &Src0 = SaveExecInst->getOperand(1); MachineOperand &Src1 = SaveExecInst->getOperand(2); Index: lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp =================================================================== --- lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp +++ lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp @@ -143,7 +143,7 @@ I->hasUnmodeledSideEffects() || I->hasOrderedMemoryRef()) break; - DEBUG(dbgs() << "Removing no effect instruction: " << *I << '\n'); + LLVM_DEBUG(dbgs() << "Removing no effect instruction: " << *I << '\n'); for (auto &Op : I->operands()) { if (Op.isReg()) @@ -193,7 +193,7 @@ !getOrExecSource(*NextLead, *TII, MRI)) continue; - DEBUG(dbgs() << "Redundant EXEC = S_OR_B64 found: " << *Lead << '\n'); + LLVM_DEBUG(dbgs() << "Redundant EXEC = S_OR_B64 found: " << *Lead << '\n'); auto SaveExec = getOrExecSource(*Lead, *TII, MRI); unsigned SaveExecReg = getOrNonExecReg(*Lead, *TII); @@ -224,7 +224,7 @@ break; } - DEBUG(dbgs() << "Redundant EXEC COPY: " << *SaveExec << '\n'); + LLVM_DEBUG(dbgs() << "Redundant EXEC COPY: " << *SaveExec << '\n'); } if (SafeToReplace) { Index: lib/Target/AMDGPU/SIPeepholeSDWA.cpp =================================================================== --- lib/Target/AMDGPU/SIPeepholeSDWA.cpp +++ lib/Target/AMDGPU/SIPeepholeSDWA.cpp @@ -807,7 +807,7 @@ void SIPeepholeSDWA::matchSDWAOperands(MachineBasicBlock &MBB) { for (MachineInstr &MI : MBB) { if (auto Operand = matchSDWAOperand(MI)) { - DEBUG(dbgs() << "Match: " << MI << "To: " << *Operand << '\n'); + LLVM_DEBUG(dbgs() << "Match: " << MI << "To: " << *Operand << '\n'); SDWAOperands[&MI] = std::move(Operand); ++NumSDWAPatternsFound; } @@ -1005,7 +1005,7 @@ return false; } - DEBUG(dbgs() << "Convert instruction:" << MI + LLVM_DEBUG(dbgs() << "Convert instruction:" << MI << "Into:" << *SDWAInst << '\n'); ++NumSDWAInstructionsPeepholed; Index: lib/Target/AMDGPU/SIShrinkInstructions.cpp =================================================================== --- lib/Target/AMDGPU/SIShrinkInstructions.cpp +++ lib/Target/AMDGPU/SIShrinkInstructions.cpp @@ -493,7 +493,7 @@ } // We can shrink this instruction - DEBUG(dbgs() << "Shrinking " << MI); + LLVM_DEBUG(dbgs() << "Shrinking " << MI); MachineInstrBuilder Inst32 = BuildMI(MBB, I, MI.getDebugLoc(), TII->get(Op32)); @@ -537,7 +537,7 @@ MI.eraseFromParent(); foldImmediates(*Inst32, TII, MRI); - DEBUG(dbgs() << "e32 MI = " << *Inst32 << '\n'); + LLVM_DEBUG(dbgs() << "e32 MI = " << *Inst32 << '\n'); } Index: lib/Target/AMDGPU/SIWholeQuadMode.cpp =================================================================== --- lib/Target/AMDGPU/SIWholeQuadMode.cpp +++ lib/Target/AMDGPU/SIWholeQuadMode.cpp @@ -681,7 +681,7 @@ if (!isEntry && BI.Needs == StateWQM && BI.OutNeeds != StateExact) return; - DEBUG(dbgs() << "\nProcessing block " << printMBBReference(MBB) << ":\n"); + LLVM_DEBUG(dbgs() << "\nProcessing block " << printMBBReference(MBB) << ":\n"); unsigned SavedWQMReg = 0; unsigned SavedNonWWMReg = 0; @@ -884,7 +884,7 @@ } } - DEBUG(printInfo()); + LLVM_DEBUG(printInfo()); lowerCopyInstrs(); Index: lib/Target/ARC/ARCBranchFinalize.cpp =================================================================== --- lib/Target/ARC/ARCBranchFinalize.cpp +++ lib/Target/ARC/ARCBranchFinalize.cpp @@ -112,7 +112,7 @@ } void ARCBranchFinalize::replaceWithBRcc(MachineInstr *MI) const { - DEBUG(dbgs() << "Replacing pseudo branch with BRcc\n"); + LLVM_DEBUG(dbgs() << "Replacing pseudo branch with BRcc\n"); unsigned CC = getCCForBRcc(MI->getOperand(3).getImm()); if (CC != -1U) { BuildMI(*MI->getParent(), MI, MI->getDebugLoc(), @@ -128,8 +128,8 @@ } void ARCBranchFinalize::replaceWithCmpBcc(MachineInstr *MI) const { - DEBUG(dbgs() << "Branch: " << *MI << "\n"); - DEBUG(dbgs() << "Replacing pseudo branch with Cmp + Bcc\n"); + LLVM_DEBUG(dbgs() << "Branch: " << *MI << "\n"); + LLVM_DEBUG(dbgs() << "Replacing pseudo branch with Cmp + Bcc\n"); BuildMI(*MI->getParent(), MI, MI->getDebugLoc(), TII->get(getCmpForPseudo(MI))) .addReg(MI->getOperand(1).getReg()) @@ -141,7 +141,7 @@ } bool ARCBranchFinalize::runOnMachineFunction(MachineFunction &MF) { - DEBUG(dbgs() << "Running ARC Branch Finalize on " + LLVM_DEBUG(dbgs() << "Running ARC Branch Finalize on " << MF.getName() << "\n"); std::vector Branches; bool Changed = false; @@ -156,7 +156,7 @@ for (auto &MI : MBB) { unsigned Size = TII->getInstSizeInBytes(MI); if (Size > 8 || Size == 0) { - DEBUG(dbgs() << "Unknown (or size 0) size for: " << MI << "\n"); + LLVM_DEBUG(dbgs() << "Unknown (or size 0) size for: " << MI << "\n"); } else { MaxSize += Size; } @@ -172,7 +172,7 @@ isInt<9>(MaxSize) ? replaceWithBRcc(P.first) : replaceWithCmpBcc(P.first); } - DEBUG(dbgs() << "Estimated function size for " << MF.getName() + LLVM_DEBUG(dbgs() << "Estimated function size for " << MF.getName() << ": " << MaxSize << "\n"); return Changed; Index: lib/Target/ARC/ARCFrameLowering.cpp =================================================================== --- lib/Target/ARC/ARCFrameLowering.cpp +++ lib/Target/ARC/ARCFrameLowering.cpp @@ -59,7 +59,7 @@ Positive = true; } - DEBUG(dbgs() << "Internal: adjust stack by: " << Amount << "," << AbsAmount + LLVM_DEBUG(dbgs() << "Internal: adjust stack by: " << Amount << "," << AbsAmount << "\n"); assert((AbsAmount % 4 == 0) && "Stack adjustments must be 4-byte aligned."); @@ -88,7 +88,7 @@ void ARCFrameLowering::determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS) const { - DEBUG(dbgs() << "Determine Callee Saves: " << MF.getName() + LLVM_DEBUG(dbgs() << "Determine Callee Saves: " << MF.getName() << "\n"); TargetFrameLowering::determineCalleeSaves(MF, SavedRegs, RS); SavedRegs.set(ARC::BLINK); @@ -115,7 +115,7 @@ /// registers onto the stack, when enough callee saved registers are required. void ARCFrameLowering::emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const { - DEBUG(dbgs() << "Emit Prologue: " << MF.getName() << "\n"); + LLVM_DEBUG(dbgs() << "Emit Prologue: " << MF.getName() << "\n"); auto *AFI = MF.getInfo(); MachineModuleInfo &MMI = MF.getMMI(); MCContext &Context = MMI.getContext(); @@ -133,7 +133,7 @@ unsigned AlreadyAdjusted = 0; if (MF.getFunction().isVarArg()) { // Add in the varargs area here first. - DEBUG(dbgs() << "Varargs\n"); + LLVM_DEBUG(dbgs() << "Varargs\n"); unsigned VarArgsBytes = MFI.getObjectSize(AFI->getVarArgsFrameIndex()); BuildMI(MBB, MBBI, dl, TII->get(ARC::SUB_rru6)) .addReg(ARC::SP) @@ -141,7 +141,7 @@ .addImm(VarArgsBytes); } if (hasFP(MF)) { - DEBUG(dbgs() << "Saving FP\n"); + LLVM_DEBUG(dbgs() << "Saving FP\n"); BuildMI(MBB, MBBI, dl, TII->get(ARC::ST_AW_rs9)) .addReg(ARC::SP, RegState::Define) .addReg(ARC::FP) @@ -150,7 +150,7 @@ AlreadyAdjusted += 4; } if (UseSaveRestoreFunclet && Last > ARC::R14) { - DEBUG(dbgs() << "Creating store funclet.\n"); + LLVM_DEBUG(dbgs() << "Creating store funclet.\n"); // BL to __save_r13_to_getRegAsmName()> StackSlotsUsedByFunclet = Last - ARC::R12; BuildMI(MBB, MBBI, dl, TII->get(ARC::PUSH_S_BLINK)); @@ -166,20 +166,20 @@ } // If we haven't saved BLINK, but we need to...do that now. if (MFI.hasCalls() && !SavedBlink) { - DEBUG(dbgs() << "Creating save blink.\n"); + LLVM_DEBUG(dbgs() << "Creating save blink.\n"); BuildMI(MBB, MBBI, dl, TII->get(ARC::PUSH_S_BLINK)); AlreadyAdjusted += 4; } if (AFI->MaxCallStackReq > 0) MFI.setStackSize(MFI.getStackSize() + AFI->MaxCallStackReq); // We have already saved some of the stack... - DEBUG(dbgs() << "Adjusting stack by: " + LLVM_DEBUG(dbgs() << "Adjusting stack by: " << (MFI.getStackSize() - AlreadyAdjusted) << "\n"); generateStackAdjustment(MBB, MBBI, *ST.getInstrInfo(), dl, -(MFI.getStackSize() - AlreadyAdjusted), ARC::SP); if (hasFP(MF)) { - DEBUG(dbgs() << "Setting FP from SP.\n"); + LLVM_DEBUG(dbgs() << "Setting FP from SP.\n"); BuildMI(MBB, MBBI, dl, TII->get(isUInt<6>(MFI.getStackSize()) ? ARC::ADD_rru6 : ARC::ADD_rrlimm), @@ -235,7 +235,7 @@ /// registers onto the stack, when enough callee saved registers are required. void ARCFrameLowering::emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const { - DEBUG(dbgs() << "Emit Epilogue: " << MF.getName() << "\n"); + LLVM_DEBUG(dbgs() << "Emit Epilogue: " << MF.getName() << "\n"); auto *AFI = MF.getInfo(); const ARCInstrInfo *TII = MF.getSubtarget().getInstrInfo(); MachineBasicBlock::iterator MBBI = MBB.getFirstTerminator(); @@ -304,7 +304,7 @@ // Relieve the varargs area if necessary. if (MF.getFunction().isVarArg()) { // Add in the varargs area here first. - DEBUG(dbgs() << "Varargs\n"); + LLVM_DEBUG(dbgs() << "Varargs\n"); unsigned VarArgsBytes = MFI.getObjectSize(AFI->getVarArgsFrameIndex()); BuildMI(MBB, MBBI, MBB.findDebugLoc(MBBI), TII->get(ARC::ADD_rru6)) .addReg(ARC::SP) @@ -334,7 +334,7 @@ if (hasFP(MF)) { // Create a fixed slot at for FP int StackObj = MFI.CreateFixedSpillStackObject(4, CurOffset, true); - DEBUG(dbgs() << "Creating fixed object (" << StackObj << ") for FP at " + LLVM_DEBUG(dbgs() << "Creating fixed object (" << StackObj << ") for FP at " << CurOffset << "\n"); (void)StackObj; CurOffset -= 4; @@ -342,7 +342,7 @@ if (MFI.hasCalls() || (UseSaveRestoreFunclet && Last > ARC::R14)) { // Create a fixed slot for BLINK. int StackObj = MFI.CreateFixedSpillStackObject(4, CurOffset, true); - DEBUG(dbgs() << "Creating fixed object (" << StackObj << ") for BLINK at " + LLVM_DEBUG(dbgs() << "Creating fixed object (" << StackObj << ") for BLINK at " << CurOffset << "\n"); (void)StackObj; CurOffset -= 4; @@ -366,11 +366,11 @@ continue; if (I.getFrameIdx() == 0) { I.setFrameIdx(MFI.CreateFixedSpillStackObject(4, CurOffset, true)); - DEBUG(dbgs() << "Creating fixed object (" << I.getFrameIdx() + LLVM_DEBUG(dbgs() << "Creating fixed object (" << I.getFrameIdx() << ") for other register at " << CurOffset << "\n"); } else { MFI.setObjectOffset(I.getFrameIdx(), CurOffset); - DEBUG(dbgs() << "Updating fixed object (" << I.getFrameIdx() + LLVM_DEBUG(dbgs() << "Updating fixed object (" << I.getFrameIdx() << ") for other register at " << CurOffset << "\n"); } CurOffset -= 4; @@ -382,7 +382,7 @@ MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector &CSI, const TargetRegisterInfo *TRI) const { - DEBUG(dbgs() << "Spill callee saved registers: " + LLVM_DEBUG(dbgs() << "Spill callee saved registers: " << MBB.getParent()->getName() << "\n"); // There are routines for saving at least 3 registers (r13 to r15, etc.) unsigned Last = determineLastCalleeSave(CSI); @@ -399,7 +399,7 @@ bool ARCFrameLowering::restoreCalleeSavedRegisters( MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, std::vector &CSI, const TargetRegisterInfo *TRI) const { - DEBUG(dbgs() << "Restore callee saved registers: " + LLVM_DEBUG(dbgs() << "Restore callee saved registers: " << MBB.getParent()->getName() << "\n"); // There are routines for saving at least 3 registers (r13 to r15, etc.) unsigned Last = determineLastCalleeSave(CSI); @@ -414,16 +414,16 @@ void ARCFrameLowering::processFunctionBeforeFrameFinalized( MachineFunction &MF, RegScavenger *RS) const { const TargetRegisterInfo *RegInfo = MF.getSubtarget().getRegisterInfo(); - DEBUG(dbgs() << "Process function before frame finalized: " + LLVM_DEBUG(dbgs() << "Process function before frame finalized: " << MF.getName() << "\n"); MachineFrameInfo &MFI = MF.getFrameInfo(); - DEBUG(dbgs() << "Current stack size: " << MFI.getStackSize() << "\n"); + LLVM_DEBUG(dbgs() << "Current stack size: " << MFI.getStackSize() << "\n"); const TargetRegisterClass *RC = &ARC::GPR32RegClass; if (MFI.hasStackObjects()) { int RegScavFI = MFI.CreateStackObject( RegInfo->getSpillSize(*RC), RegInfo->getSpillAlignment(*RC), false); RS->addScavengingFrameIndex(RegScavFI); - DEBUG(dbgs() << "Created scavenging index RegScavFI=" << RegScavFI << "\n"); + LLVM_DEBUG(dbgs() << "Created scavenging index RegScavFI=" << RegScavFI << "\n"); } } @@ -440,7 +440,7 @@ MachineBasicBlock::iterator ARCFrameLowering::eliminateCallFramePseudoInstr( MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const { - DEBUG(dbgs() << "EmitCallFramePseudo: " << MF.getName() << "\n"); + LLVM_DEBUG(dbgs() << "EmitCallFramePseudo: " << MF.getName() << "\n"); const ARCInstrInfo *TII = MF.getSubtarget().getInstrInfo(); MachineInstr &Old = *I; DebugLoc dl = Old.getDebugLoc(); Index: lib/Target/ARC/ARCISelLowering.cpp =================================================================== --- lib/Target/ARC/ARCISelLowering.cpp +++ lib/Target/ARC/ARCISelLowering.cpp @@ -486,7 +486,7 @@ EVT RegVT = VA.getLocVT(); switch (RegVT.getSimpleVT().SimpleTy) { default: { - DEBUG(errs() << "LowerFormalArguments Unhandled argument type: " + LLVM_DEBUG(errs() << "LowerFormalArguments Unhandled argument type: " << (unsigned)RegVT.getSimpleVT().SimpleTy << "\n"); llvm_unreachable("Unhandled LowerFormalArguments type."); } Index: lib/Target/ARC/ARCInstrInfo.cpp =================================================================== --- lib/Target/ARC/ARCInstrInfo.cpp +++ lib/Target/ARC/ARCInstrInfo.cpp @@ -298,7 +298,7 @@ "Only support 4-byte stores to stack now."); assert(ARC::GPR32RegClass.hasSubClassEq(RC) && "Only support GPR32 stores to stack now."); - DEBUG(dbgs() << "Created store reg=" << printReg(SrcReg, TRI) + LLVM_DEBUG(dbgs() << "Created store reg=" << printReg(SrcReg, TRI) << " to FrameIndex=" << FrameIndex << "\n"); BuildMI(MBB, I, dl, get(ARC::ST_rs9)) .addReg(SrcReg, getKillRegState(isKill)) @@ -325,7 +325,7 @@ "Only support 4-byte loads from stack now."); assert(ARC::GPR32RegClass.hasSubClassEq(RC) && "Only support GPR32 stores to stack now."); - DEBUG(dbgs() << "Created load reg=" << printReg(DestReg, TRI) + LLVM_DEBUG(dbgs() << "Created load reg=" << printReg(DestReg, TRI) << " from FrameIndex=" << FrameIndex << "\n"); BuildMI(MBB, I, dl, get(ARC::LD_rs9)) .addReg(DestReg, RegState::Define) Index: lib/Target/ARC/ARCRegisterInfo.cpp =================================================================== --- lib/Target/ARC/ARCRegisterInfo.cpp +++ lib/Target/ARC/ARCRegisterInfo.cpp @@ -66,7 +66,7 @@ MBB.getParent()->getSubtarget().getRegisterInfo(); BaseReg = RS->scavengeRegister(&ARC::GPR32RegClass, II, SPAdj); assert(BaseReg && "Register scavenging failed."); - DEBUG(dbgs() << "Scavenged register " << printReg(BaseReg, TRI) + LLVM_DEBUG(dbgs() << "Scavenged register " << printReg(BaseReg, TRI) << " for FrameReg=" << printReg(FrameReg, TRI) << "+Offset=" << Offset << "\n"); (void)TRI; @@ -88,7 +88,7 @@ assert((Offset % 2 == 0) && "LDH needs 2 byte alignment."); case ARC::LDB_rs9: case ARC::LDB_X_rs9: - DEBUG(dbgs() << "Building LDFI\n"); + LLVM_DEBUG(dbgs() << "Building LDFI\n"); BuildMI(MBB, II, dl, TII.get(MI.getOpcode()), Reg) .addReg(BaseReg, KillState) .addImm(Offset) @@ -99,7 +99,7 @@ case ARC::STH_rs9: assert((Offset % 2 == 0) && "STH needs 2 byte alignment."); case ARC::STB_rs9: - DEBUG(dbgs() << "Building STFI\n"); + LLVM_DEBUG(dbgs() << "Building STFI\n"); BuildMI(MBB, II, dl, TII.get(MI.getOpcode())) .addReg(Reg, getKillRegState(MI.getOperand(0).isKill())) .addReg(BaseReg, KillState) @@ -107,7 +107,7 @@ .addMemOperand(*MI.memoperands_begin()); break; case ARC::GETFI: - DEBUG(dbgs() << "Building GETFI\n"); + LLVM_DEBUG(dbgs() << "Building GETFI\n"); BuildMI(MBB, II, dl, TII.get(isUInt<6>(Offset) ? ARC::ADD_rru6 : ARC::ADD_rrlimm)) .addReg(Reg, RegState::Define) @@ -175,14 +175,14 @@ int StackSize = MF.getFrameInfo().getStackSize(); int LocalFrameSize = MF.getFrameInfo().getLocalFrameSize(); - DEBUG(dbgs() << "\nFunction : " << MF.getName() << "\n"); - DEBUG(dbgs() << "<--------->\n"); - DEBUG(dbgs() << MI << "\n"); - DEBUG(dbgs() << "FrameIndex : " << FrameIndex << "\n"); - DEBUG(dbgs() << "ObjSize : " << ObjSize << "\n"); - DEBUG(dbgs() << "FrameOffset : " << Offset << "\n"); - DEBUG(dbgs() << "StackSize : " << StackSize << "\n"); - DEBUG(dbgs() << "LocalFrameSize : " << LocalFrameSize << "\n"); + LLVM_DEBUG(dbgs() << "\nFunction : " << MF.getName() << "\n"); + LLVM_DEBUG(dbgs() << "<--------->\n"); + LLVM_DEBUG(dbgs() << MI << "\n"); + LLVM_DEBUG(dbgs() << "FrameIndex : " << FrameIndex << "\n"); + LLVM_DEBUG(dbgs() << "ObjSize : " << ObjSize << "\n"); + LLVM_DEBUG(dbgs() << "FrameOffset : " << Offset << "\n"); + LLVM_DEBUG(dbgs() << "StackSize : " << StackSize << "\n"); + LLVM_DEBUG(dbgs() << "LocalFrameSize : " << LocalFrameSize << "\n"); (void)LocalFrameSize; // Special handling of DBG_VALUE instructions. @@ -200,7 +200,7 @@ // ldb needs no alignment, // ldh needs 2 byte alignment // ld needs 4 byte alignment - DEBUG(dbgs() << "Offset : " << Offset << "\n" + LLVM_DEBUG(dbgs() << "Offset : " << Offset << "\n" << "<--------->\n"); unsigned Reg = MI.getOperand(0).getReg(); Index: lib/Target/ARC/Disassembler/ARCDisassembler.cpp =================================================================== --- lib/Target/ARC/Disassembler/ARCDisassembler.cpp +++ lib/Target/ARC/Disassembler/ARCDisassembler.cpp @@ -122,7 +122,7 @@ uint64_t Address, const void *Decoder) { if (RegNo >= 32) { - DEBUG(dbgs() << "Not a GPR32 register."); + LLVM_DEBUG(dbgs() << "Not a GPR32 register."); return MCDisassembler::Fail; } @@ -222,7 +222,7 @@ unsigned SrcC, DstB, LImm; DstB = decodeBField(Insn); if (DstB != 62) { - DEBUG(dbgs() << "Decoding StLImm found non-limm register."); + LLVM_DEBUG(dbgs() << "Decoding StLImm found non-limm register."); return MCDisassembler::Fail; } SrcC = decodeCField(Insn); @@ -237,10 +237,10 @@ uint64_t Address, const void *Decoder) { unsigned DstA, SrcB, LImm; - DEBUG(dbgs() << "Decoding LdLImm:\n"); + LLVM_DEBUG(dbgs() << "Decoding LdLImm:\n"); SrcB = decodeBField(Insn); if (SrcB != 62) { - DEBUG(dbgs() << "Decoding LdLImm found non-limm register."); + LLVM_DEBUG(dbgs() << "Decoding LdLImm found non-limm register."); return MCDisassembler::Fail; } DstA = decodeAField(Insn); @@ -255,13 +255,13 @@ uint64_t Address, const void *Decoder) { unsigned DstA, SrcB; - DEBUG(dbgs() << "Decoding LdRLimm\n"); + LLVM_DEBUG(dbgs() << "Decoding LdRLimm\n"); DstA = decodeAField(Insn); DecodeGPR32RegisterClass(Inst, DstA, Address, Decoder); SrcB = decodeBField(Insn); DecodeGPR32RegisterClass(Inst, SrcB, Address, Decoder); if (decodeCField(Insn) != 62) { - DEBUG(dbgs() << "Decoding LdRLimm found non-limm register."); + LLVM_DEBUG(dbgs() << "Decoding LdRLimm found non-limm register."); return MCDisassembler::Fail; } Inst.addOperand(MCOperand::createImm((uint32_t)(Insn >> 32))); @@ -271,7 +271,7 @@ static DecodeStatus DecodeMoveHRegInstruction(MCInst &Inst, uint64_t Insn, uint64_t Address, const void *Decoder) { - DEBUG(dbgs() << "Decoding MOV_S h-register\n"); + LLVM_DEBUG(dbgs() << "Decoding MOV_S h-register\n"); using Field = decltype(Insn); Field h = fieldFromInstruction(Insn, 5, 3) | (fieldFromInstruction(Insn, 0, 2) << 3); @@ -322,10 +322,10 @@ Result = decodeInstruction(DecoderTable64, Instr, Insn64, Address, this, STI); if (Success == Result) { - DEBUG(dbgs() << "Successfully decoded 64-bit instruction."); + LLVM_DEBUG(dbgs() << "Successfully decoded 64-bit instruction."); return Result; } - DEBUG(dbgs() << "Not a 64-bit instruction, falling back to 32-bit."); + LLVM_DEBUG(dbgs() << "Not a 64-bit instruction, falling back to 32-bit."); } uint32_t Insn32; if (!readInstruction32(Bytes, Address, Size, Insn32)) { @@ -342,10 +342,10 @@ Result = decodeInstruction(DecoderTable48, Instr, Insn48, Address, this, STI); if (Success == Result) { - DEBUG(dbgs() << "Successfully decoded 16-bit instruction with limm."); + LLVM_DEBUG(dbgs() << "Successfully decoded 16-bit instruction with limm."); return Result; } - DEBUG(dbgs() << "Not a 16-bit instruction with limm, try without it."); + LLVM_DEBUG(dbgs() << "Not a 16-bit instruction with limm, try without it."); } uint32_t Insn16; Index: lib/Target/ARM/A15SDOptimizer.cpp =================================================================== --- lib/Target/ARM/A15SDOptimizer.cpp +++ lib/Target/ARM/A15SDOptimizer.cpp @@ -180,7 +180,7 @@ SmallVector Front; DeadInstr.insert(MI); - DEBUG(dbgs() << "Deleting base instruction " << *MI << "\n"); + LLVM_DEBUG(dbgs() << "Deleting base instruction " << *MI << "\n"); Front.push_back(MI); while (Front.size() != 0) { @@ -232,7 +232,7 @@ if (!IsDead) continue; - DEBUG(dbgs() << "Deleting instruction " << *Def << "\n"); + LLVM_DEBUG(dbgs() << "Deleting instruction " << *Def << "\n"); DeadInstr.insert(Def); } } @@ -264,7 +264,7 @@ // Is it a subreg copy of ssub_0? if (EC && EC->isCopy() && EC->getOperand(1).getSubReg() == ARM::ssub_0) { - DEBUG(dbgs() << "Found a subreg copy: " << *SPRMI); + LLVM_DEBUG(dbgs() << "Found a subreg copy: " << *SPRMI); // Find the thing we're subreg copying out of - is it of the same // regclass as DPRMI? (i.e. a DPR or QPR). @@ -272,8 +272,8 @@ const TargetRegisterClass *TRC = MRI->getRegClass(MI->getOperand(1).getReg()); if (TRC->hasSuperClassEq(MRI->getRegClass(FullReg))) { - DEBUG(dbgs() << "Subreg copy is compatible - returning "); - DEBUG(dbgs() << printReg(FullReg) << "\n"); + LLVM_DEBUG(dbgs() << "Subreg copy is compatible - returning "); + LLVM_DEBUG(dbgs() << printReg(FullReg) << "\n"); eraseInstrWithNoUses(MI); return FullReg; } @@ -387,7 +387,7 @@ continue; Front.push_back(NewMI); } else { - DEBUG(dbgs() << "Found partial copy" << *MI <<"\n"); + LLVM_DEBUG(dbgs() << "Found partial copy" << *MI <<"\n"); Outs.push_back(MI); } } @@ -642,7 +642,7 @@ // to find. MRI->constrainRegClass(NewReg, MRI->getRegClass((*I)->getReg())); - DEBUG(dbgs() << "Replacing operand " + LLVM_DEBUG(dbgs() << "Replacing operand " << **I << " with " << printReg(NewReg) << "\n"); (*I)->substVirtReg(NewReg, 0, *TRI); @@ -668,7 +668,7 @@ MRI = &Fn.getRegInfo(); bool Modified = false; - DEBUG(dbgs() << "Running on function " << Fn.getName()<< "\n"); + LLVM_DEBUG(dbgs() << "Running on function " << Fn.getName()<< "\n"); DeadInstr.clear(); Replacements.clear(); Index: lib/Target/ARM/ARMBaseInstrInfo.cpp =================================================================== --- lib/Target/ARM/ARMBaseInstrInfo.cpp +++ lib/Target/ARM/ARMBaseInstrInfo.cpp @@ -1473,7 +1473,7 @@ return false; // All clear, widen the COPY. - DEBUG(dbgs() << "widening: " << MI); + LLVM_DEBUG(dbgs() << "widening: " << MI); MachineInstrBuilder MIB(*MI.getParent()->getParent(), MI); // Get rid of the old implicit-def of DstRegD. Leave it if it defines a Q-reg @@ -1502,7 +1502,7 @@ MI.addRegisterKilled(SrcRegS, TRI, true); } - DEBUG(dbgs() << "replaced by: " << MI); + LLVM_DEBUG(dbgs() << "replaced by: " << MI); return true; } Index: lib/Target/ARM/ARMBaseRegisterInfo.cpp =================================================================== --- lib/Target/ARM/ARMBaseRegisterInfo.cpp +++ lib/Target/ARM/ARMBaseRegisterInfo.cpp @@ -838,9 +838,9 @@ auto AFI = MF->getInfo(); auto It = AFI->getCoalescedWeight(MBB); - DEBUG(dbgs() << "\tARM::shouldCoalesce - Coalesced Weight: " + LLVM_DEBUG(dbgs() << "\tARM::shouldCoalesce - Coalesced Weight: " << It->second << "\n"); - DEBUG(dbgs() << "\tARM::shouldCoalesce - Reg Weight: " + LLVM_DEBUG(dbgs() << "\tARM::shouldCoalesce - Reg Weight: " << NewRCWeight.RegWeight << "\n"); // This number is the largest round number that which meets the criteria: Index: lib/Target/ARM/ARMConstantIslandPass.cpp =================================================================== --- lib/Target/ARM/ARMConstantIslandPass.cpp +++ lib/Target/ARM/ARMConstantIslandPass.cpp @@ -301,7 +301,7 @@ return BBInfo[LHS.getNumber()].postOffset() < BBInfo[RHS.getNumber()].postOffset(); })); - DEBUG(dbgs() << "Verifying " << CPUsers.size() << " CP users.\n"); + LLVM_DEBUG(dbgs() << "Verifying " << CPUsers.size() << " CP users.\n"); for (unsigned i = 0, e = CPUsers.size(); i != e; ++i) { CPUser &U = CPUsers[i]; unsigned UserOffset = getUserOffset(U); @@ -309,12 +309,12 @@ // adjustment. if (isCPEntryInRange(U.MI, UserOffset, U.CPEMI, U.getMaxDisp()+2, U.NegOk, /* DoDump = */ true)) { - DEBUG(dbgs() << "OK\n"); + LLVM_DEBUG(dbgs() << "OK\n"); continue; } - DEBUG(dbgs() << "Out of range.\n"); + LLVM_DEBUG(dbgs() << "Out of range.\n"); dumpBBs(); - DEBUG(MF->dump()); + LLVM_DEBUG(MF->dump()); llvm_unreachable("Constant pool entry out of range!"); } #endif @@ -323,7 +323,7 @@ #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) /// print block size and offset information - debugging LLVM_DUMP_METHOD void ARMConstantIslands::dumpBBs() { - DEBUG({ + LLVM_DEBUG({ for (unsigned J = 0, E = BBInfo.size(); J !=E; ++J) { const BasicBlockInfo &BBI = BBInfo[J]; dbgs() << format("%08x %bb.%u\t", BBI.Offset, J) @@ -340,7 +340,7 @@ MF = &mf; MCP = mf.getConstantPool(); - DEBUG(dbgs() << "***** ARMConstantIslands: " + LLVM_DEBUG(dbgs() << "***** ARMConstantIslands: " << MCP->getConstants().size() << " CP entries, aligned to " << MCP->getConstantPoolAlignment() << " bytes *****\n"); @@ -393,7 +393,7 @@ // constant pool users. initializeFunctionInfo(CPEMIs); CPEMIs.clear(); - DEBUG(dumpBBs()); + LLVM_DEBUG(dumpBBs()); // Functions with jump tables need an alignment of 4 because they use the ADR // instruction, which aligns the PC to 4 bytes before adding an offset. @@ -407,7 +407,7 @@ // is no change. unsigned NoCPIters = 0, NoBRIters = 0; while (true) { - DEBUG(dbgs() << "Beginning CP iteration #" << NoCPIters << '\n'); + LLVM_DEBUG(dbgs() << "Beginning CP iteration #" << NoCPIters << '\n'); bool CPChange = false; for (unsigned i = 0, e = CPUsers.size(); i != e; ++i) // For most inputs, it converges in no more than 5 iterations. @@ -416,19 +416,19 @@ CPChange |= handleConstantPoolUser(i, NoCPIters >= CPMaxIteration / 2); if (CPChange && ++NoCPIters > CPMaxIteration) report_fatal_error("Constant Island pass failed to converge!"); - DEBUG(dumpBBs()); + LLVM_DEBUG(dumpBBs()); // Clear NewWaterList now. If we split a block for branches, it should // appear as "new water" for the next iteration of constant pool placement. NewWaterList.clear(); - DEBUG(dbgs() << "Beginning BR iteration #" << NoBRIters << '\n'); + LLVM_DEBUG(dbgs() << "Beginning BR iteration #" << NoBRIters << '\n'); bool BRChange = false; for (unsigned i = 0, e = ImmBranches.size(); i != e; ++i) BRChange |= fixupImmediateBr(ImmBranches[i]); if (BRChange && ++NoBRIters > 30) report_fatal_error("Branch Fix Up pass failed to converge!"); - DEBUG(dumpBBs()); + LLVM_DEBUG(dumpBBs()); if (!CPChange && !BRChange) break; @@ -464,7 +464,7 @@ } } - DEBUG(dbgs() << '\n'; dumpBBs()); + LLVM_DEBUG(dbgs() << '\n'; dumpBBs()); BBInfo.clear(); WaterList.clear(); @@ -533,10 +533,10 @@ // Add a new CPEntry, but no corresponding CPUser yet. CPEntries.emplace_back(1, CPEntry(CPEMI, i)); ++NumCPEs; - DEBUG(dbgs() << "Moved CPI#" << i << " to end of function, size = " + LLVM_DEBUG(dbgs() << "Moved CPI#" << i << " to end of function, size = " << Size << ", align = " << Align <<'\n'); } - DEBUG(BB->dump()); + LLVM_DEBUG(BB->dump()); } /// \brief Do initial placement of the jump tables. Because Thumb2's TBB and TBH @@ -1070,7 +1070,7 @@ unsigned CPEOffset = getOffsetOf(CPEMI); if (DoDump) { - DEBUG({ + LLVM_DEBUG({ unsigned Block = MI->getParent()->getNumber(); const BasicBlockInfo &BBI = BBInfo[Block]; dbgs() << "User of CPE#" << CPEMI->getOperand(0).getImm() @@ -1163,7 +1163,7 @@ // Check to see if the CPE is already in-range. if (isCPEntryInRange(UserMI, UserOffset, CPEMI, U.getMaxDisp(), U.NegOk, true)) { - DEBUG(dbgs() << "In range\n"); + LLVM_DEBUG(dbgs() << "In range\n"); return 1; } @@ -1179,7 +1179,7 @@ continue; if (isCPEntryInRange(UserMI, UserOffset, CPEs[i].CPEMI, U.getMaxDisp(), U.NegOk)) { - DEBUG(dbgs() << "Replacing CPE#" << CPI << " with CPE#" + LLVM_DEBUG(dbgs() << "Replacing CPE#" << CPI << " with CPE#" << CPEs[i].CPI << "\n"); // Point the CPUser node to the replacement U.CPEMI = CPEs[i].CPEMI; @@ -1265,7 +1265,7 @@ // This is the least amount of required padding seen so far. BestGrowth = Growth; WaterIter = IP; - DEBUG(dbgs() << "Found water after " << printMBBReference(*WaterBB) + LLVM_DEBUG(dbgs() << "Found water after " << printMBBReference(*WaterBB) << " Growth=" << Growth << '\n'); if (CloserWater && WaterBB == U.MI->getParent()) @@ -1309,7 +1309,7 @@ unsigned CPEOffset = UserBBI.postOffset(CPELogAlign) + Delta; if (isOffsetInRange(UserOffset, CPEOffset, U)) { - DEBUG(dbgs() << "Split at end of " << printMBBReference(*UserMBB) + LLVM_DEBUG(dbgs() << "Split at end of " << printMBBReference(*UserMBB) << format(", expected CPE offset %#x\n", CPEOffset)); NewMBB = &*++UserMBB->getIterator(); // Add an unconditional branch from UserMBB to fallthrough block. Record @@ -1353,7 +1353,7 @@ unsigned KnownBits = UserBBI.internalKnownBits(); unsigned UPad = UnknownPadding(LogAlign, KnownBits); unsigned BaseInsertOffset = UserOffset + U.getMaxDisp() - UPad; - DEBUG(dbgs() << format("Split in middle of big block before %#x", + LLVM_DEBUG(dbgs() << format("Split in middle of big block before %#x", BaseInsertOffset)); // The 4 in the following is for the unconditional branch we'll be inserting @@ -1361,7 +1361,7 @@ // inside isOffsetInRange. BaseInsertOffset -= 4; - DEBUG(dbgs() << format(", adjusted to %#x", BaseInsertOffset) + LLVM_DEBUG(dbgs() << format(", adjusted to %#x", BaseInsertOffset) << " la=" << LogAlign << " kb=" << KnownBits << " up=" << UPad << '\n'); @@ -1377,7 +1377,7 @@ BaseInsertOffset = std::max(UserBBI.postOffset() - UPad - 8, UserOffset + TII->getInstSizeInBytes(*UserMI) + 1); - DEBUG(dbgs() << format("Move inside block: %#x\n", BaseInsertOffset)); + LLVM_DEBUG(dbgs() << format("Move inside block: %#x\n", BaseInsertOffset)); } unsigned EndInsertOffset = BaseInsertOffset + 4 + UPad + CPEMI->getOperand(2).getImm(); @@ -1421,7 +1421,7 @@ } // We really must not split an IT block. - DEBUG(unsigned PredReg; + LLVM_DEBUG(unsigned PredReg; assert(!isThumb || getITInstrPredicate(*MI, PredReg) == ARMCC::AL)); NewMBB = splitBlockBeforeInstr(&*MI); @@ -1460,7 +1460,7 @@ MachineBasicBlock *NewMBB; water_iterator IP; if (findAvailableWater(U, UserOffset, IP, CloserWater)) { - DEBUG(dbgs() << "Found water in range\n"); + LLVM_DEBUG(dbgs() << "Found water in range\n"); MachineBasicBlock *WaterBB = *IP; // If the original WaterList entry was "new water" on this iteration, @@ -1473,7 +1473,7 @@ NewMBB = &*++WaterBB->getIterator(); } else { // No water found. - DEBUG(dbgs() << "No water found\n"); + LLVM_DEBUG(dbgs() << "No water found\n"); createNewWater(CPUserIndex, UserOffset, NewMBB); // splitBlockBeforeInstr adds to WaterList, which is important when it is @@ -1530,7 +1530,7 @@ break; } - DEBUG(dbgs() << " Moved CPE to #" << ID << " CPI=" << CPI + LLVM_DEBUG(dbgs() << " Moved CPE to #" << ID << " CPI=" << CPI << format(" offset=%#x\n", BBInfo[NewIsland->getNumber()].Offset)); return true; @@ -1586,7 +1586,7 @@ unsigned BrOffset = getOffsetOf(MI) + PCAdj; unsigned DestOffset = BBInfo[DestBB->getNumber()].Offset; - DEBUG(dbgs() << "Branch of destination " << printMBBReference(*DestBB) + LLVM_DEBUG(dbgs() << "Branch of destination " << printMBBReference(*DestBB) << " from " << printMBBReference(*MI->getParent()) << " max delta=" << MaxDisp << " from " << getOffsetOf(MI) << " to " << DestOffset << " offset " @@ -1637,7 +1637,7 @@ HasFarJump = true; ++NumUBrFixed; - DEBUG(dbgs() << " Changed B to long jump " << *MI); + LLVM_DEBUG(dbgs() << " Changed B to long jump " << *MI); return true; } @@ -1681,7 +1681,7 @@ // b L1 MachineBasicBlock *NewDest = BMI->getOperand(0).getMBB(); if (isBBInRange(MI, NewDest, Br.MaxDisp)) { - DEBUG(dbgs() << " Invert Bcc condition and swap its destination with " + LLVM_DEBUG(dbgs() << " Invert Bcc condition and swap its destination with " << *BMI); BMI->getOperand(0).setMBB(DestBB); MI->getOperand(0).setMBB(NewDest); @@ -1708,7 +1708,7 @@ } MachineBasicBlock *NextBB = &*++MBB->getIterator(); - DEBUG(dbgs() << " Insert B to " << printMBBReference(*DestBB) + LLVM_DEBUG(dbgs() << " Insert B to " << printMBBReference(*DestBB) << " also invert condition and change dest. to " << printMBBReference(*NextBB) << "\n"); @@ -1803,7 +1803,7 @@ // FIXME: Check if offset is multiple of scale if scale is not 4. if (isCPEntryInRange(U.MI, UserOffset, U.CPEMI, MaxOffs, false, true)) { - DEBUG(dbgs() << "Shrink: " << *U.MI); + LLVM_DEBUG(dbgs() << "Shrink: " << *U.MI); U.MI->setDesc(TII->get(NewOpc)); MachineBasicBlock *MBB = U.MI->getParent(); BBInfo[MBB->getNumber()].Size -= 2; @@ -1847,7 +1847,7 @@ unsigned MaxOffs = ((1 << (Bits-1))-1) * Scale; MachineBasicBlock *DestBB = Br.MI->getOperand(0).getMBB(); if (isBBInRange(Br.MI, DestBB, MaxOffs)) { - DEBUG(dbgs() << "Shrink branch: " << *Br.MI); + LLVM_DEBUG(dbgs() << "Shrink branch: " << *Br.MI); Br.MI->setDesc(TII->get(NewOpc)); MachineBasicBlock *MBB = Br.MI->getParent(); BBInfo[MBB->getNumber()].Size -= 2; @@ -1891,7 +1891,7 @@ CmpMI->getOperand(1).getImm() == 0 && isARMLowRegister(Reg)) { MachineBasicBlock *MBB = Br.MI->getParent(); - DEBUG(dbgs() << "Fold: " << *CmpMI << " and: " << *Br.MI); + LLVM_DEBUG(dbgs() << "Fold: " << *CmpMI << " and: " << *Br.MI); MachineInstr *NewBR = BuildMI(*MBB, CmpMI, Br.MI->getDebugLoc(), TII->get(NewOpc)) .addReg(Reg).addMBB(DestBB,Br.MI->getOperand(0).getTargetFlags()); @@ -2060,7 +2060,7 @@ } } - DEBUG(dbgs() << "Removing Dead Add: " << *RemovableAdd); + LLVM_DEBUG(dbgs() << "Removing Dead Add: " << *RemovableAdd); RemovableAdd->eraseFromParent(); DeadSize += 4; } @@ -2206,7 +2206,7 @@ DeadSize += 4; } - DEBUG(dbgs() << "Shrink JT: " << *MI); + LLVM_DEBUG(dbgs() << "Shrink JT: " << *MI); MachineInstr *CPEMI = User.CPEMI; unsigned Opc = ByteOk ? ARM::t2TBB_JT : ARM::t2TBH_JT; if (!isThumb2) @@ -2220,7 +2220,7 @@ .addReg(IdxReg, getKillRegState(IdxRegKill)) .addJumpTableIndex(JTI, JTOP.getTargetFlags()) .addImm(CPEMI->getOperand(0).getImm()); - DEBUG(dbgs() << printMBBReference(*MBB) << ": " << *NewJTMI); + LLVM_DEBUG(dbgs() << printMBBReference(*MBB) << ": " << *NewJTMI); unsigned JTOpc = ByteOk ? ARM::JUMPTABLE_TBB : ARM::JUMPTABLE_TBH; CPEMI->setDesc(TII->get(JTOpc)); Index: lib/Target/ARM/ARMFrameLowering.cpp =================================================================== --- lib/Target/ARM/ARMFrameLowering.cpp +++ lib/Target/ARM/ARMFrameLowering.cpp @@ -1797,7 +1797,7 @@ for (unsigned Reg : {ARM::R0, ARM::R1, ARM::R2, ARM::R3}) { if (!MF.getRegInfo().isLiveIn(Reg)) { --EntryRegDeficit; - DEBUG(dbgs() << printReg(Reg, TRI) + LLVM_DEBUG(dbgs() << printReg(Reg, TRI) << " is unused argument register, EntryRegDeficit = " << EntryRegDeficit << "\n"); } @@ -1805,24 +1805,24 @@ // Unused return registers can be clobbered in the epilogue for free. int ExitRegDeficit = AFI->getReturnRegsCount() - 4; - DEBUG(dbgs() << AFI->getReturnRegsCount() + LLVM_DEBUG(dbgs() << AFI->getReturnRegsCount() << " return regs used, ExitRegDeficit = " << ExitRegDeficit << "\n"); int RegDeficit = std::max(EntryRegDeficit, ExitRegDeficit); - DEBUG(dbgs() << "RegDeficit = " << RegDeficit << "\n"); + LLVM_DEBUG(dbgs() << "RegDeficit = " << RegDeficit << "\n"); // r4-r6 can be used in the prologue if they are pushed by the first push // instruction. for (unsigned Reg : {ARM::R4, ARM::R5, ARM::R6}) { if (SavedRegs.test(Reg)) { --RegDeficit; - DEBUG(dbgs() << printReg(Reg, TRI) + LLVM_DEBUG(dbgs() << printReg(Reg, TRI) << " is saved low register, RegDeficit = " << RegDeficit << "\n"); } else { AvailableRegs.push_back(Reg); - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << printReg(Reg, TRI) << " is non-saved low register, adding to AvailableRegs\n"); } @@ -1832,11 +1832,11 @@ if (!HasFP) { if (SavedRegs.test(ARM::R7)) { --RegDeficit; - DEBUG(dbgs() << "%r7 is saved low register, RegDeficit = " + LLVM_DEBUG(dbgs() << "%r7 is saved low register, RegDeficit = " << RegDeficit << "\n"); } else { AvailableRegs.push_back(ARM::R7); - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "%r7 is non-saved low register, adding to AvailableRegs\n"); } } @@ -1845,7 +1845,7 @@ for (unsigned Reg : {ARM::R8, ARM::R9, ARM::R10, ARM::R11}) { if (SavedRegs.test(Reg)) { ++RegDeficit; - DEBUG(dbgs() << printReg(Reg, TRI) + LLVM_DEBUG(dbgs() << printReg(Reg, TRI) << " is saved high register, RegDeficit = " << RegDeficit << "\n"); } @@ -1859,11 +1859,11 @@ MF.getFrameInfo().isReturnAddressTaken())) { if (SavedRegs.test(ARM::LR)) { --RegDeficit; - DEBUG(dbgs() << "%lr is saved register, RegDeficit = " << RegDeficit + LLVM_DEBUG(dbgs() << "%lr is saved register, RegDeficit = " << RegDeficit << "\n"); } else { AvailableRegs.push_back(ARM::LR); - DEBUG(dbgs() << "%lr is not saved, adding to AvailableRegs\n"); + LLVM_DEBUG(dbgs() << "%lr is not saved, adding to AvailableRegs\n"); } } @@ -1872,10 +1872,10 @@ // instructions. This might not reduce RegDeficit all the way to zero, // because we can only guarantee that r4-r6 are available, but r8-r11 may // need saving. - DEBUG(dbgs() << "Final RegDeficit = " << RegDeficit << "\n"); + LLVM_DEBUG(dbgs() << "Final RegDeficit = " << RegDeficit << "\n"); for (; RegDeficit > 0 && !AvailableRegs.empty(); --RegDeficit) { unsigned Reg = AvailableRegs.pop_back_val(); - DEBUG(dbgs() << "Spilling " << printReg(Reg, TRI) + LLVM_DEBUG(dbgs() << "Spilling " << printReg(Reg, TRI) << " to make up reg deficit\n"); SavedRegs.set(Reg); NumGPRSpills++; @@ -1887,7 +1887,7 @@ if (Reg == ARM::LR) LRSpilled = true; } - DEBUG(dbgs() << "After adding spills, RegDeficit = " << RegDeficit << "\n"); + LLVM_DEBUG(dbgs() << "After adding spills, RegDeficit = " << RegDeficit << "\n"); } // If LR is not spilled, but at least one of R4, R5, R6, and R7 is spilled. @@ -1908,7 +1908,7 @@ // If stack and double are 8-byte aligned and we are spilling an odd number // of GPRs, spill one extra callee save GPR so we won't have to pad between // the integer and double callee save areas. - DEBUG(dbgs() << "NumGPRSpills = " << NumGPRSpills << "\n"); + LLVM_DEBUG(dbgs() << "NumGPRSpills = " << NumGPRSpills << "\n"); unsigned TargetAlign = getStackAlignment(); if (TargetAlign >= 8 && (NumGPRSpills & 1)) { if (CS1Spilled && !UnspilledCS1GPRs.empty()) { @@ -1920,7 +1920,7 @@ (STI.isTargetWindows() && Reg == ARM::R11) || isARMLowRegister(Reg) || Reg == ARM::LR) { SavedRegs.set(Reg); - DEBUG(dbgs() << "Spilling " << printReg(Reg, TRI) + LLVM_DEBUG(dbgs() << "Spilling " << printReg(Reg, TRI) << " to make up alignment\n"); if (!MRI.isReserved(Reg) && !MRI.isPhysRegUsed(Reg)) ExtraCSSpill = true; @@ -1930,7 +1930,7 @@ } else if (!UnspilledCS2GPRs.empty() && !AFI->isThumb1OnlyFunction()) { unsigned Reg = UnspilledCS2GPRs.front(); SavedRegs.set(Reg); - DEBUG(dbgs() << "Spilling " << printReg(Reg, TRI) + LLVM_DEBUG(dbgs() << "Spilling " << printReg(Reg, TRI) << " to make up alignment\n"); if (!MRI.isReserved(Reg) && !MRI.isPhysRegUsed(Reg)) ExtraCSSpill = true; Index: lib/Target/ARM/ARMISelLowering.cpp =================================================================== --- lib/Target/ARM/ARMISelLowering.cpp +++ lib/Target/ARM/ARMISelLowering.cpp @@ -6742,7 +6742,7 @@ } // Final sanity check before we try to actually produce a shuffle. - DEBUG( + LLVM_DEBUG( for (auto Src : Sources) assert(Src.ShuffleVec.getValueType() == ShuffleVT); ); @@ -7992,7 +7992,7 @@ } SDValue ARMTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const { - DEBUG(dbgs() << "Lowering node: "; Op.dump()); + LLVM_DEBUG(dbgs() << "Lowering node: "; Op.dump()); switch (Op.getOpcode()) { default: llvm_unreachable("Don't know how to custom lower this!"); case ISD::WRITE_REGISTER: return LowerWRITE_REGISTER(Op, DAG); @@ -10405,7 +10405,7 @@ if (!C1ShlC2 || !C2) return SDValue(); - DEBUG(dbgs() << "Trying to simplify shl: "; N->dump()); + LLVM_DEBUG(dbgs() << "Trying to simplify shl: "; N->dump()); APInt C2Int = C2->getAPIntValue(); APInt C1Int = C1ShlC2->getAPIntValue(); @@ -14683,7 +14683,7 @@ HABaseType Base = HA_UNKNOWN; uint64_t Members = 0; bool IsHA = isHomogeneousAggregate(Ty, Base, Members); - DEBUG(dbgs() << "isHA: " << IsHA << " "; Ty->dump()); + LLVM_DEBUG(dbgs() << "isHA: " << IsHA << " "; Ty->dump()); bool IsIntArray = Ty->isArrayTy() && Ty->getArrayElementType()->isIntegerTy(); return IsHA || IsIntArray; Index: lib/Target/ARM/ARMInstructionSelector.cpp =================================================================== --- lib/Target/ARM/ARMInstructionSelector.cpp +++ lib/Target/ARM/ARMInstructionSelector.cpp @@ -154,7 +154,7 @@ // we hit another of its uses or its defs. // Copies do not have constraints. if (!RBI.constrainGenericRegister(DstReg, *RC, MRI)) { - DEBUG(dbgs() << "Failed to constrain " << TII.getName(I.getOpcode()) + LLVM_DEBUG(dbgs() << "Failed to constrain " << TII.getName(I.getOpcode()) << " operand\n"); return false; } @@ -399,12 +399,12 @@ unsigned ExpectedSize, unsigned ExpectedRegBankID) const { if (MRI.getType(Reg).getSizeInBits() != ExpectedSize) { - DEBUG(dbgs() << "Unexpected size for register"); + LLVM_DEBUG(dbgs() << "Unexpected size for register"); return false; } if (RBI.getRegBank(Reg, MRI, TRI)->getID() != ExpectedRegBankID) { - DEBUG(dbgs() << "Unexpected register bank for register"); + LLVM_DEBUG(dbgs() << "Unexpected register bank for register"); return false; } @@ -496,13 +496,13 @@ bool ARMInstructionSelector::selectGlobal(MachineInstrBuilder &MIB, MachineRegisterInfo &MRI) const { if ((STI.isROPI() || STI.isRWPI()) && !STI.isTargetELF()) { - DEBUG(dbgs() << "ROPI and RWPI only supported for ELF\n"); + LLVM_DEBUG(dbgs() << "ROPI and RWPI only supported for ELF\n"); return false; } auto GV = MIB->getOperand(1).getGlobal(); if (GV->isThreadLocal()) { - DEBUG(dbgs() << "TLS variables not supported yet\n"); + LLVM_DEBUG(dbgs() << "TLS variables not supported yet\n"); return false; } @@ -607,7 +607,7 @@ else MIB->setDesc(TII.get(ARM::LDRLIT_ga_abs)); } else { - DEBUG(dbgs() << "Object format not supported yet\n"); + LLVM_DEBUG(dbgs() << "Object format not supported yet\n"); return false; } @@ -691,7 +691,7 @@ LLT DstTy = MRI.getType(I.getOperand(0).getReg()); // FIXME: Smaller destination sizes coming soon! if (DstTy.getSizeInBits() != 32) { - DEBUG(dbgs() << "Unsupported destination size for extension"); + LLVM_DEBUG(dbgs() << "Unsupported destination size for extension"); return false; } @@ -733,7 +733,7 @@ break; } default: - DEBUG(dbgs() << "Unsupported source size for extension"); + LLVM_DEBUG(dbgs() << "Unsupported source size for extension"); return false; } break; @@ -774,12 +774,12 @@ } if (SrcRegBank.getID() != DstRegBank.getID()) { - DEBUG(dbgs() << "G_TRUNC/G_ANYEXT operands on different register banks\n"); + LLVM_DEBUG(dbgs() << "G_TRUNC/G_ANYEXT operands on different register banks\n"); return false; } if (SrcRegBank.getID() != ARM::GPRRegBankID) { - DEBUG(dbgs() << "G_TRUNC/G_ANYEXT on non-GPR not supported yet\n"); + LLVM_DEBUG(dbgs() << "G_TRUNC/G_ANYEXT on non-GPR not supported yet\n"); return false; } @@ -789,21 +789,21 @@ case G_CONSTANT: { if (!MRI.getType(I.getOperand(0).getReg()).isPointer()) { // Non-pointer constants should be handled by TableGen. - DEBUG(dbgs() << "Unsupported constant type\n"); + LLVM_DEBUG(dbgs() << "Unsupported constant type\n"); return false; } auto &Val = I.getOperand(1); if (Val.isCImm()) { if (!Val.getCImm()->isZero()) { - DEBUG(dbgs() << "Unsupported pointer constant value\n"); + LLVM_DEBUG(dbgs() << "Unsupported pointer constant value\n"); return false; } Val.ChangeToImmediate(0); } else { assert(Val.isImm() && "Unexpected operand for G_CONSTANT"); if (Val.getImm() != 0) { - DEBUG(dbgs() << "Unsupported pointer constant value\n"); + LLVM_DEBUG(dbgs() << "Unsupported pointer constant value\n"); return false; } } @@ -821,13 +821,13 @@ const auto &DstRegBank = *RBI.getRegBank(DstReg, MRI, TRI); if (SrcRegBank.getID() != DstRegBank.getID()) { - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "G_INTTOPTR/G_PTRTOINT operands on different register banks\n"); return false; } if (SrcRegBank.getID() != ARM::GPRRegBankID) { - DEBUG(dbgs() << "G_INTTOPTR/G_PTRTOINT on non-GPR not supported yet\n"); + LLVM_DEBUG(dbgs() << "G_INTTOPTR/G_PTRTOINT on non-GPR not supported yet\n"); return false; } @@ -848,11 +848,11 @@ unsigned Size = MRI.getType(OpReg).getSizeInBits(); if (Size == 64 && STI.isFPOnlySP()) { - DEBUG(dbgs() << "Subtarget only supports single precision"); + LLVM_DEBUG(dbgs() << "Subtarget only supports single precision"); return false; } if (Size != 32 && Size != 64) { - DEBUG(dbgs() << "Unsupported size for G_FCMP operand"); + LLVM_DEBUG(dbgs() << "Unsupported size for G_FCMP operand"); return false; } @@ -883,7 +883,7 @@ case G_LOAD: { const auto &MemOp = **I.memoperands_begin(); if (MemOp.getOrdering() != AtomicOrdering::NotAtomic) { - DEBUG(dbgs() << "Atomic load/store not supported yet\n"); + LLVM_DEBUG(dbgs() << "Atomic load/store not supported yet\n"); return false; } @@ -920,7 +920,7 @@ } case G_BRCOND: { if (!validReg(MRI, I.getOperand(0).getReg(), 1, ARM::GPRRegBankID)) { - DEBUG(dbgs() << "Unsupported condition register for G_BRCOND"); + LLVM_DEBUG(dbgs() << "Unsupported condition register for G_BRCOND"); return false; } Index: lib/Target/ARM/ARMLoadStoreOptimizer.cpp =================================================================== --- lib/Target/ARM/ARMLoadStoreOptimizer.cpp +++ lib/Target/ARM/ARMLoadStoreOptimizer.cpp @@ -2291,7 +2291,7 @@ MIB.addReg(0); MIB.addImm(Offset).addImm(Pred).addReg(PredReg); MIB.setMemRefs(Op0->mergeMemRefsWith(*Op1)); - DEBUG(dbgs() << "Formed " << *MIB << "\n"); + LLVM_DEBUG(dbgs() << "Formed " << *MIB << "\n"); ++NumLDRDFormed; } else { MachineInstrBuilder MIB = BuildMI(*MBB, InsertPos, dl, MCID) @@ -2305,7 +2305,7 @@ MIB.addReg(0); MIB.addImm(Offset).addImm(Pred).addReg(PredReg); MIB.setMemRefs(Op0->mergeMemRefsWith(*Op1)); - DEBUG(dbgs() << "Formed " << *MIB << "\n"); + LLVM_DEBUG(dbgs() << "Formed " << *MIB << "\n"); ++NumSTRDFormed; } MBB->erase(Op0); Index: lib/Target/ARM/ARMTargetTransformInfo.cpp =================================================================== --- lib/Target/ARM/ARMTargetTransformInfo.cpp +++ lib/Target/ARM/ARMTargetTransformInfo.cpp @@ -586,7 +586,7 @@ SmallVector ExitingBlocks; L->getExitingBlocks(ExitingBlocks); - DEBUG(dbgs() << "Loop has:\n" + LLVM_DEBUG(dbgs() << "Loop has:\n" << "Blocks: " << L->getNumBlocks() << "\n" << "Exit blocks: " << ExitingBlocks.size() << "\n"); @@ -619,7 +619,7 @@ } } - DEBUG(dbgs() << "Cost of loop: " << Cost << "\n"); + LLVM_DEBUG(dbgs() << "Cost of loop: " << Cost << "\n"); UP.Partial = true; UP.Runtime = true; Index: lib/Target/ARM/AsmParser/ARMAsmParser.cpp =================================================================== --- lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -10200,7 +10200,7 @@ Message.Message = "too many operands for instruction"; } else { Message.Message = "invalid operand for instruction"; - DEBUG(dbgs() << "Missing diagnostic string for operand class " << + LLVM_DEBUG(dbgs() << "Missing diagnostic string for operand class " << getMatchClassName((MatchClassKind)I.getOperandClass()) << I.getOperandClass() << ", error " << I.getOperandError() << ", opcode " << MII.getName(I.getOpcode()) << "\n"); Index: lib/Target/ARM/MLxExpansionPass.cpp =================================================================== --- lib/Target/ARM/MLxExpansionPass.cpp +++ lib/Target/ARM/MLxExpansionPass.cpp @@ -309,7 +309,7 @@ } MIB.addImm(Pred).addReg(PredReg); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Expanding: " << *MI; dbgs() << " to:\n"; MachineBasicBlock::iterator MII = MI; Index: lib/Target/ARM/Thumb2SizeReduction.cpp =================================================================== --- lib/Target/ARM/Thumb2SizeReduction.cpp +++ lib/Target/ARM/Thumb2SizeReduction.cpp @@ -610,7 +610,7 @@ // Transfer MI flags. MIB.setMIFlags(MI->getFlags()); - DEBUG(errs() << "Converted 32-bit: " << *MI << " to 16-bit: " << *MIB); + LLVM_DEBUG(errs() << "Converted 32-bit: " << *MI << " to 16-bit: " << *MIB); MBB.erase_instr(MI); ++NumLdSts; @@ -657,7 +657,7 @@ // Transfer MI flags. MIB.setMIFlags(MI->getFlags()); - DEBUG(errs() << "Converted 32-bit: " << *MI << " to 16-bit: " <<*MIB); + LLVM_DEBUG(errs() << "Converted 32-bit: " << *MI << " to 16-bit: " <<*MIB); MBB.erase_instr(MI); ++NumNarrows; @@ -826,7 +826,7 @@ // Transfer MI flags. MIB.setMIFlags(MI->getFlags()); - DEBUG(errs() << "Converted 32-bit: " << *MI << " to 16-bit: " << *MIB); + LLVM_DEBUG(errs() << "Converted 32-bit: " << *MI << " to 16-bit: " << *MIB); MBB.erase_instr(MI); ++Num2Addrs; @@ -933,7 +933,7 @@ // Transfer MI flags. MIB.setMIFlags(MI->getFlags()); - DEBUG(errs() << "Converted 32-bit: " << *MI << " to 16-bit: " << *MIB); + LLVM_DEBUG(errs() << "Converted 32-bit: " << *MI << " to 16-bit: " << *MIB); MBB.erase_instr(MI); ++NumNarrows; Index: lib/Target/AVR/AVRISelDAGToDAG.cpp =================================================================== --- lib/Target/AVR/AVRISelDAGToDAG.cpp +++ lib/Target/AVR/AVRISelDAGToDAG.cpp @@ -521,7 +521,7 @@ void AVRDAGToDAGISel::Select(SDNode *N) { // If we have a custom node, we already have selected! if (N->isMachineOpcode()) { - DEBUG(errs() << "== "; N->dump(CurDAG); errs() << "\n"); + LLVM_DEBUG(errs() << "== "; N->dump(CurDAG); errs() << "\n"); N->setNodeId(-1); return; } Index: lib/Target/AVR/AsmParser/AVRAsmParser.cpp =================================================================== --- lib/Target/AVR/AsmParser/AVRAsmParser.cpp +++ lib/Target/AVR/AsmParser/AVRAsmParser.cpp @@ -482,7 +482,7 @@ } bool AVRAsmParser::parseOperand(OperandVector &Operands) { - DEBUG(dbgs() << "parseOperand\n"); + LLVM_DEBUG(dbgs() << "parseOperand\n"); switch (getLexer().getKind()) { default: @@ -527,7 +527,7 @@ OperandMatchResultTy AVRAsmParser::parseMemriOperand(OperandVector &Operands) { - DEBUG(dbgs() << "parseMemriOperand()\n"); + LLVM_DEBUG(dbgs() << "parseMemriOperand()\n"); SMLoc E, S; MCExpr const *Expression; Index: lib/Target/BPF/BPFISelDAGToDAG.cpp =================================================================== --- lib/Target/BPF/BPFISelDAGToDAG.cpp +++ lib/Target/BPF/BPFISelDAGToDAG.cpp @@ -178,7 +178,7 @@ // If we have a custom node, we already have selected! if (Node->isMachineOpcode()) { - DEBUG(dbgs() << "== "; Node->dump(CurDAG); dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "== "; Node->dump(CurDAG); dbgs() << '\n'); return; } @@ -265,7 +265,7 @@ if (OP1N->getOpcode() <= ISD::BUILTIN_OP_END || OP1N->getNumOperands() == 0) return; - DEBUG(dbgs() << "Check candidate load: "; LD->dump(); dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "Check candidate load: "; LD->dump(); dbgs() << '\n'); const GlobalAddressSDNode *GADN = dyn_cast(OP1N->getOperand(0).getNode()); @@ -275,7 +275,7 @@ getConstantFieldValue(GADN, CDN->getZExtValue(), size, new_val.c); } else if (LDAddrNode->getOpcode() > ISD::BUILTIN_OP_END && LDAddrNode->getNumOperands() > 0) { - DEBUG(dbgs() << "Check candidate load: "; LD->dump(); dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "Check candidate load: "; LD->dump(); dbgs() << '\n'); SDValue OP1 = LDAddrNode->getOperand(0); if (const GlobalAddressSDNode *GADN = @@ -298,7 +298,7 @@ val = new_val.d; } - DEBUG(dbgs() << "Replacing load of size " << size << " with constant " << val + LLVM_DEBUG(dbgs() << "Replacing load of size " << size << " with constant " << val << '\n'); SDValue NVal = CurDAG->getConstant(val, DL, MVT::i64); @@ -415,7 +415,7 @@ if (const ConstantInt *CI = dyn_cast(CV)) { uint64_t val = CI->getZExtValue(); - DEBUG(dbgs() << "Byte array at offset " << Offset << " with value " << val + LLVM_DEBUG(dbgs() << "Byte array at offset " << Offset << " with value " << val << '\n'); if (Size > 8 || (Size & (Size - 1))) @@ -505,7 +505,7 @@ break; } - DEBUG(dbgs() << "Find Load Value to VReg " + LLVM_DEBUG(dbgs() << "Find Load Value to VReg " << TargetRegisterInfo::virtReg2Index(RegN->getReg()) << '\n'); load_to_vreg_[RegN->getReg()] = mem_load_op; } @@ -532,7 +532,7 @@ (IntNo == Intrinsic::bpf_load_word && MaskV == 0xFFFFFFFF))) return; - DEBUG(dbgs() << "Remove the redundant AND operation in: "; Node->dump(); + LLVM_DEBUG(dbgs() << "Remove the redundant AND operation in: "; Node->dump(); dbgs() << '\n'); I--; @@ -567,7 +567,7 @@ if (!RegN || !TargetRegisterInfo::isVirtualRegister(RegN->getReg())) return; unsigned AndOpReg = RegN->getReg(); - DEBUG(dbgs() << "Examine " << printReg(AndOpReg) << '\n'); + LLVM_DEBUG(dbgs() << "Examine " << printReg(AndOpReg) << '\n'); // Examine the PHI insns in the MachineBasicBlock to found out the // definitions of this virtual register. At this stage (DAG2DAG @@ -598,7 +598,7 @@ // Trace each incoming definition, e.g., (%0, %bb.1) and (%1, %bb.3) // The AND operation can be removed if both %0 in %bb.1 and %1 in // %bb.3 are defined with with a load matching the MaskN. - DEBUG(dbgs() << "Check PHI Insn: "; MII->dump(); dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "Check PHI Insn: "; MII->dump(); dbgs() << '\n'); unsigned PrevReg = -1; for (unsigned i = 0; i < MII->getNumOperands(); ++i) { const MachineOperand &MOP = MII->getOperand(i); @@ -614,7 +614,7 @@ } } - DEBUG(dbgs() << "Remove the redundant AND operation in: "; Node->dump(); + LLVM_DEBUG(dbgs() << "Remove the redundant AND operation in: "; Node->dump(); dbgs() << '\n'); I--; Index: lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp =================================================================== --- lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp +++ lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp @@ -462,9 +462,9 @@ } bool HexagonAsmParser::finishBundle(SMLoc IDLoc, MCStreamer &Out) { - DEBUG(dbgs() << "Bundle:"); - DEBUG(MCB.dump_pretty(dbgs())); - DEBUG(dbgs() << "--\n"); + LLVM_DEBUG(dbgs() << "Bundle:"); + LLVM_DEBUG(MCB.dump_pretty(dbgs())); + LLVM_DEBUG(dbgs() << "--\n"); MCB.setLoc(IDLoc); // Check the bundle for errors. @@ -554,9 +554,9 @@ canonicalizeImmediates(MCI); result = processInstruction(MCI, InstOperands, IDLoc); - DEBUG(dbgs() << "Insn:"); - DEBUG(MCI.dump_pretty(dbgs())); - DEBUG(dbgs() << "\n\n"); + LLVM_DEBUG(dbgs() << "Insn:"); + LLVM_DEBUG(MCI.dump_pretty(dbgs())); + LLVM_DEBUG(dbgs() << "\n\n"); MCI.setLoc(IDLoc); } @@ -1293,9 +1293,9 @@ return Match_Success; } - DEBUG(dbgs() << "Unmatched Operand:"); - DEBUG(Op->dump()); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Unmatched Operand:"); + LLVM_DEBUG(Op->dump()); + LLVM_DEBUG(dbgs() << "\n"); return Match_InvalidOperand; } Index: lib/Target/Hexagon/HexagonBitSimplify.cpp =================================================================== --- lib/Target/Hexagon/HexagonBitSimplify.cpp +++ lib/Target/Hexagon/HexagonBitSimplify.cpp @@ -2450,7 +2450,7 @@ if (Len == RW) return false; - DEBUG({ + LLVM_DEBUG({ dbgs() << __func__ << " on reg: " << printReg(RD.Reg, &HRI, RD.Sub) << ", MI: " << *MI; dbgs() << "Cell: " << RC << '\n'; @@ -2644,7 +2644,7 @@ const HexagonEvaluator HE(HRI, MRI, HII, MF); BitTracker BT(HE, MF); - DEBUG(BT.trace(true)); + LLVM_DEBUG(BT.trace(true)); BT.run(); MachineBasicBlock &Entry = MF.front(); @@ -2975,7 +2975,7 @@ } bool HexagonLoopRescheduling::processLoop(LoopCand &C) { - DEBUG(dbgs() << "Processing loop in " << printMBBReference(*C.LB) << "\n"); + LLVM_DEBUG(dbgs() << "Processing loop in " << printMBBReference(*C.LB) << "\n"); std::vector Phis; for (auto &I : *C.LB) { if (!I.isPHI()) @@ -2999,7 +2999,7 @@ Phis.push_back(PhiInfo(I, *C.LB)); } - DEBUG({ + LLVM_DEBUG({ dbgs() << "Phis: {"; for (auto &I : Phis) { dbgs() << ' ' << printReg(I.DefR, HRI) << "=phi(" @@ -3120,7 +3120,7 @@ Groups.push_back(G); } - DEBUG({ + LLVM_DEBUG({ for (unsigned i = 0, n = Groups.size(); i < n; ++i) { InstrGroup &G = Groups[i]; dbgs() << "Group[" << i << "] inp: " @@ -3188,7 +3188,7 @@ MRI = &MF.getRegInfo(); const HexagonEvaluator HE(*HRI, *MRI, *HII, MF); BitTracker BT(HE, MF); - DEBUG(BT.trace(true)); + LLVM_DEBUG(BT.trace(true)); BT.run(); BTP = &BT; Index: lib/Target/Hexagon/HexagonBlockRanges.cpp =================================================================== --- lib/Target/Hexagon/HexagonBlockRanges.cpp +++ lib/Target/Hexagon/HexagonBlockRanges.cpp @@ -422,9 +422,9 @@ HexagonBlockRanges::RegToRangeMap HexagonBlockRanges::computeLiveMap( InstrIndexMap &IndexMap) { RegToRangeMap LiveMap; - DEBUG(dbgs() << __func__ << ": index map\n" << IndexMap << '\n'); + LLVM_DEBUG(dbgs() << __func__ << ": index map\n" << IndexMap << '\n'); computeInitialLiveRanges(IndexMap, LiveMap); - DEBUG(dbgs() << __func__ << ": live map\n" + LLVM_DEBUG(dbgs() << __func__ << ": live map\n" << PrintRangeMap(LiveMap, TRI) << '\n'); return LiveMap; } @@ -486,7 +486,7 @@ if (TargetRegisterInfo::isVirtualRegister(P.first.Reg)) addDeadRanges(P.first); - DEBUG(dbgs() << __func__ << ": dead map\n" + LLVM_DEBUG(dbgs() << __func__ << ": dead map\n" << PrintRangeMap(DeadMap, TRI) << '\n'); return DeadMap; } Index: lib/Target/Hexagon/HexagonBranchRelaxation.cpp =================================================================== --- lib/Target/Hexagon/HexagonBranchRelaxation.cpp +++ lib/Target/Hexagon/HexagonBranchRelaxation.cpp @@ -90,7 +90,7 @@ } bool HexagonBranchRelaxation::runOnMachineFunction(MachineFunction &MF) { - DEBUG(dbgs() << "****** Hexagon Branch Relaxation ******\n"); + LLVM_DEBUG(dbgs() << "****** Hexagon Branch Relaxation ******\n"); auto &HST = MF.getSubtarget(); HII = HST.getInstrInfo(); @@ -193,14 +193,14 @@ for (auto &MI : B) { if (!MI.isBranch() || !isJumpOutOfRange(MI, BlockToInstOffset)) continue; - DEBUG(dbgs() << "Long distance jump. isExtendable(" + LLVM_DEBUG(dbgs() << "Long distance jump. isExtendable(" << HII->isExtendable(MI) << ") isConstExtended(" << HII->isConstExtended(MI) << ") " << MI); // Since we have not merged HW loops relaxation into // this code (yet), soften our approach for the moment. if (!HII->isExtendable(MI) && !HII->isExtended(MI)) { - DEBUG(dbgs() << "\tUnderimplemented relax branch instruction.\n"); + LLVM_DEBUG(dbgs() << "\tUnderimplemented relax branch instruction.\n"); } else { // Find which operand is expandable. int ExtOpNum = HII->getCExtOpNum(MI); Index: lib/Target/Hexagon/HexagonCommonGEP.cpp =================================================================== --- lib/Target/Hexagon/HexagonCommonGEP.cpp +++ lib/Target/Hexagon/HexagonCommonGEP.cpp @@ -342,7 +342,7 @@ void HexagonCommonGEP::processGepInst(GetElementPtrInst *GepI, ValueToNodeMap &NM) { - DEBUG(dbgs() << "Visiting GEP: " << *GepI << '\n'); + LLVM_DEBUG(dbgs() << "Visiting GEP: " << *GepI << '\n'); GepNode *N = new (*Mem) GepNode; Value *PtrOp = GepI->getPointerOperand(); uint32_t InBounds = GepI->isInBounds() ? GepNode::InBounds : 0; @@ -426,7 +426,7 @@ } } - DEBUG(dbgs() << "Gep nodes after initial collection:\n" << Nodes); + LLVM_DEBUG(dbgs() << "Gep nodes after initial collection:\n" << Nodes); } static void invert_find_roots(const NodeVect &Nodes, NodeChildrenMap &NCM, @@ -575,7 +575,7 @@ } } - DEBUG({ + LLVM_DEBUG({ dbgs() << "Gep node equality:\n"; for (NodePairSet::iterator I = Eq.begin(), E = Eq.end(); I != E; ++I) dbgs() << "{ " << I->first << ", " << I->second << " }\n"; @@ -642,7 +642,7 @@ N->Parent = Rep; } - DEBUG(dbgs() << "Gep nodes after commoning:\n" << Nodes); + LLVM_DEBUG(dbgs() << "Gep nodes after commoning:\n" << Nodes); // Finally, erase the nodes that are no longer used. NodeSet Erase; @@ -662,12 +662,12 @@ NodeVect::iterator NewE = remove_if(Nodes, in_set(Erase)); Nodes.resize(std::distance(Nodes.begin(), NewE)); - DEBUG(dbgs() << "Gep nodes after post-commoning cleanup:\n" << Nodes); + LLVM_DEBUG(dbgs() << "Gep nodes after post-commoning cleanup:\n" << Nodes); } template static BasicBlock *nearest_common_dominator(DominatorTree *DT, T &Blocks) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "NCD of {"; for (typename T::iterator I = Blocks.begin(), E = Blocks.end(); I != E; ++I) { @@ -690,7 +690,7 @@ if (!Dom) return nullptr; } - DEBUG(dbgs() << "computed:" << Dom->getName() << '\n'); + LLVM_DEBUG(dbgs() << "computed:" << Dom->getName() << '\n'); return Dom; } @@ -753,7 +753,7 @@ BasicBlock *HexagonCommonGEP::recalculatePlacement(GepNode *Node, NodeChildrenMap &NCM, NodeToValueMap &Loc) { - DEBUG(dbgs() << "Loc for node:" << Node << '\n'); + LLVM_DEBUG(dbgs() << "Loc for node:" << Node << '\n'); // Recalculate the placement for Node, assuming that the locations of // its children in Loc are valid. // Return nullptr if there is no valid placement for Node (for example, it @@ -820,7 +820,7 @@ BasicBlock *HexagonCommonGEP::recalculatePlacementRec(GepNode *Node, NodeChildrenMap &NCM, NodeToValueMap &Loc) { - DEBUG(dbgs() << "LocRec begin for node:" << Node << '\n'); + LLVM_DEBUG(dbgs() << "LocRec begin for node:" << Node << '\n'); // Recalculate the placement of Node, after recursively recalculating the // placements of all its children. NodeChildrenMap::iterator CF = NCM.find(Node); @@ -830,7 +830,7 @@ recalculatePlacementRec(*I, NCM, Loc); } BasicBlock *LB = recalculatePlacement(Node, NCM, Loc); - DEBUG(dbgs() << "LocRec end for node:" << Node << '\n'); + LLVM_DEBUG(dbgs() << "LocRec end for node:" << Node << '\n'); return LB; } @@ -952,7 +952,7 @@ void HexagonCommonGEP::separateChainForNode(GepNode *Node, Use *U, NodeToValueMap &Loc) { User *R = U->getUser(); - DEBUG(dbgs() << "Separating chain for node (" << Node << ") user: " + LLVM_DEBUG(dbgs() << "Separating chain for node (" << Node << ") user: " << *R << '\n'); BasicBlock *PB = cast(R)->getParent(); @@ -996,7 +996,7 @@ // Should at least have U in NewUs. NewNode->Flags |= GepNode::Used; - DEBUG(dbgs() << "new node: " << NewNode << " " << *NewNode << '\n'); + LLVM_DEBUG(dbgs() << "new node: " << NewNode << " " << *NewNode << '\n'); assert(!NewUs.empty()); Uses[NewNode] = NewUs; } @@ -1007,7 +1007,7 @@ NodeSet Ns; nodes_for_root(Node, NCM, Ns); - DEBUG(dbgs() << "Separating constant chains for node: " << Node << '\n'); + LLVM_DEBUG(dbgs() << "Separating constant chains for node: " << Node << '\n'); // Collect all used nodes together with the uses from loads and stores, // where the GEP node could be folded into the load/store instruction. NodeToUsesMap FNs; // Foldable nodes. @@ -1044,7 +1044,7 @@ FNs.insert(std::make_pair(N, LSs)); } - DEBUG(dbgs() << "Nodes with foldable users:\n" << FNs); + LLVM_DEBUG(dbgs() << "Nodes with foldable users:\n" << FNs); for (NodeToUsesMap::iterator I = FNs.begin(), E = FNs.end(); I != E; ++I) { GepNode *N = I->first; @@ -1066,31 +1066,31 @@ for (NodeVect::iterator I = Roots.begin(), E = Roots.end(); I != E; ++I) recalculatePlacementRec(*I, NCM, Loc); - DEBUG(dbgs() << "Initial node placement:\n" << LocationAsBlock(Loc)); + LLVM_DEBUG(dbgs() << "Initial node placement:\n" << LocationAsBlock(Loc)); if (OptEnableInv) { for (NodeVect::iterator I = Roots.begin(), E = Roots.end(); I != E; ++I) adjustForInvariance(*I, NCM, Loc); - DEBUG(dbgs() << "Node placement after adjustment for invariance:\n" + LLVM_DEBUG(dbgs() << "Node placement after adjustment for invariance:\n" << LocationAsBlock(Loc)); } if (OptEnableConst) { for (NodeVect::iterator I = Roots.begin(), E = Roots.end(); I != E; ++I) separateConstantChains(*I, NCM, Loc); } - DEBUG(dbgs() << "Node use information:\n" << Uses); + LLVM_DEBUG(dbgs() << "Node use information:\n" << Uses); // At the moment, there is no further refinement of the initial placement. // Such a refinement could include splitting the nodes if they are placed // too far from some of its users. - DEBUG(dbgs() << "Final node placement:\n" << LocationAsBlock(Loc)); + LLVM_DEBUG(dbgs() << "Final node placement:\n" << LocationAsBlock(Loc)); } Value *HexagonCommonGEP::fabricateGEP(NodeVect &NA, BasicBlock::iterator At, BasicBlock *LocB) { - DEBUG(dbgs() << "Fabricating GEP in " << LocB->getName() + LLVM_DEBUG(dbgs() << "Fabricating GEP in " << LocB->getName() << " for nodes:\n" << NA); unsigned Num = NA.size(); GepNode *RN = NA[0]; @@ -1128,7 +1128,7 @@ Type *ElTy = cast(InpTy->getScalarType())->getElementType(); NewInst = GetElementPtrInst::Create(ElTy, Input, A, "cgep", &*At); NewInst->setIsInBounds(RN->Flags & GepNode::InBounds); - DEBUG(dbgs() << "new GEP: " << *NewInst << '\n'); + LLVM_DEBUG(dbgs() << "new GEP: " << *NewInst << '\n'); Input = NewInst; } while (nax <= Num); @@ -1161,7 +1161,7 @@ } void HexagonCommonGEP::materialize(NodeToValueMap &Loc) { - DEBUG(dbgs() << "Nodes before materialization:\n" << Nodes << '\n'); + LLVM_DEBUG(dbgs() << "Nodes before materialization:\n" << Nodes << '\n'); NodeChildrenMap NCM; NodeVect Roots; // Compute the inversion again, since computing placement could alter Index: lib/Target/Hexagon/HexagonConstExtenders.cpp =================================================================== --- lib/Target/Hexagon/HexagonConstExtenders.cpp +++ lib/Target/Hexagon/HexagonConstExtenders.cpp @@ -1251,7 +1251,7 @@ if (!ED.IsDef) continue; ExtValue EV(ED); - DEBUG(dbgs() << " =" << I << ". " << EV << " " << ED << '\n'); + LLVM_DEBUG(dbgs() << " =" << I << ". " << EV << " " << ED << '\n'); assert(ED.Rd.Reg != 0); Ranges[I-Begin] = getOffsetRange(ED.Rd).shift(EV.Offset); // A2_tfrsi is a special case: it will be replaced with A2_addi, which @@ -1271,7 +1271,7 @@ if (ED.IsDef) continue; ExtValue EV(ED); - DEBUG(dbgs() << " " << I << ". " << EV << " " << ED << '\n'); + LLVM_DEBUG(dbgs() << " " << I << ". " << EV << " " << ED << '\n'); OffsetRange Dev = getOffsetRange(ED); Ranges[I-Begin].intersect(Dev.shift(EV.Offset)); } @@ -1283,7 +1283,7 @@ for (unsigned I = Begin; I != End; ++I) RangeMap[Ranges[I-Begin]].insert(I); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Ranges\n"; for (unsigned I = Begin; I != End; ++I) dbgs() << " " << I << ". " << Ranges[I-Begin] << '\n'; @@ -1377,7 +1377,7 @@ } } - DEBUG(dbgs() << "IMap (before fixup) = " << PrintIMap(IMap, *HRI)); + LLVM_DEBUG(dbgs() << "IMap (before fixup) = " << PrintIMap(IMap, *HRI)); // There is some ambiguity in what initializer should be used, if the // descriptor's subexpression is non-trivial: it can be the entire @@ -1407,7 +1407,7 @@ } } - DEBUG(dbgs() << "IMap (after fixup) = " << PrintIMap(IMap, *HRI)); + LLVM_DEBUG(dbgs() << "IMap (after fixup) = " << PrintIMap(IMap, *HRI)); } void HCE::calculatePlacement(const ExtenderInit &ExtI, const IndexList &Refs, @@ -1510,7 +1510,7 @@ assert(InitI); (void)InitI; - DEBUG(dbgs() << "Inserted def in bb#" << MBB.getNumber() + LLVM_DEBUG(dbgs() << "Inserted def in bb#" << MBB.getNumber() << " for initializer: " << PrintInit(ExtI, *HRI) << "\n " << *InitI); return { DefR, 0 }; @@ -1765,7 +1765,7 @@ ExtValue EV(ED); int32_t Diff = EV.Offset - DefV.Offset; const MachineInstr &MI = *ED.UseMI; - DEBUG(dbgs() << __func__ << " Idx:" << Idx << " ExtR:" + LLVM_DEBUG(dbgs() << __func__ << " Idx:" << Idx << " ExtR:" << PrintRegister(ExtR, *HRI) << " Diff:" << Diff << '\n'); // These two addressing modes must be converted into indexed forms @@ -1872,7 +1872,7 @@ bool HCE::runOnMachineFunction(MachineFunction &MF) { if (skipFunction(MF.getFunction())) return false; - DEBUG(MF.print(dbgs() << "Before " << getPassName() << '\n', nullptr)); + LLVM_DEBUG(MF.print(dbgs() << "Before " << getPassName() << '\n', nullptr)); HII = MF.getSubtarget().getInstrInfo(); HRI = MF.getSubtarget().getRegisterInfo(); @@ -1887,7 +1887,7 @@ }); bool Changed = false; - DEBUG(dbgs() << "Collected " << Extenders.size() << " extenders\n"); + LLVM_DEBUG(dbgs() << "Collected " << Extenders.size() << " extenders\n"); for (unsigned I = 0, E = Extenders.size(); I != E; ) { unsigned B = I; const ExtRoot &T = Extenders[B].getOp(); @@ -1899,7 +1899,7 @@ Changed |= replaceExtenders(IMap); } - DEBUG({ + LLVM_DEBUG({ if (Changed) MF.print(dbgs() << "After " << getPassName() << '\n', nullptr); else Index: lib/Target/Hexagon/HexagonConstPropagation.cpp =================================================================== --- lib/Target/Hexagon/HexagonConstPropagation.cpp +++ lib/Target/Hexagon/HexagonConstPropagation.cpp @@ -617,7 +617,7 @@ void MachineConstPropagator::visitPHI(const MachineInstr &PN) { const MachineBasicBlock *MB = PN.getParent(); unsigned MBN = MB->getNumber(); - DEBUG(dbgs() << "Visiting FI(" << printMBBReference(*MB) << "): " << PN); + LLVM_DEBUG(dbgs() << "Visiting FI(" << printMBBReference(*MB) << "): " << PN); const MachineOperand &MD = PN.getOperand(0); Register DefR(MD); @@ -642,7 +642,7 @@ const MachineBasicBlock *PB = PN.getOperand(i+1).getMBB(); unsigned PBN = PB->getNumber(); if (!EdgeExec.count(CFGEdge(PBN, MBN))) { - DEBUG(dbgs() << " edge " << printMBBReference(*PB) << "->" + LLVM_DEBUG(dbgs() << " edge " << printMBBReference(*PB) << "->" << printMBBReference(*MB) << " not executable\n"); continue; } @@ -658,7 +658,7 @@ LatticeCell SrcC; bool Eval = MCE.evaluate(UseR, Cells.get(UseR.Reg), SrcC); - DEBUG(dbgs() << " edge from " << printMBBReference(*PB) << ": " + LLVM_DEBUG(dbgs() << " edge from " << printMBBReference(*PB) << ": " << printReg(UseR.Reg, &MCE.TRI, UseR.SubReg) << SrcC << '\n'); Changed |= Eval ? DefC.meet(SrcC) : DefC.setBottom(); @@ -671,11 +671,11 @@ } void MachineConstPropagator::visitNonBranch(const MachineInstr &MI) { - DEBUG(dbgs() << "Visiting MI(" << printMBBReference(*MI.getParent()) + LLVM_DEBUG(dbgs() << "Visiting MI(" << printMBBReference(*MI.getParent()) << "): " << MI); CellMap Outputs; bool Eval = MCE.evaluate(MI, Cells, Outputs); - DEBUG({ + LLVM_DEBUG({ if (Eval) { dbgs() << " outputs:"; for (auto &I : Outputs) @@ -728,7 +728,7 @@ while (It != End) { const MachineInstr &MI = *It; InstrExec.insert(&MI); - DEBUG(dbgs() << "Visiting " << (EvalOk ? "BR" : "br") << "(" + LLVM_DEBUG(dbgs() << "Visiting " << (EvalOk ? "BR" : "br") << "(" << printMBBReference(B) << "): " << MI); // Do not evaluate subsequent branches if the evaluation of any of the // previous branches failed. Keep iterating over the branches only @@ -763,7 +763,7 @@ // last one set "FallsThru", then add an edge to the layout successor // to the targets. Targets.clear(); - DEBUG(dbgs() << " failed to evaluate a branch...adding all CFG " + LLVM_DEBUG(dbgs() << " failed to evaluate a branch...adding all CFG " "successors\n"); for (const MachineBasicBlock *SB : B.successors()) Targets.insert(SB); @@ -771,14 +771,14 @@ for (const MachineBasicBlock *TB : Targets) { unsigned TBN = TB->getNumber(); - DEBUG(dbgs() << " pushing edge " << printMBBReference(B) << " -> " + LLVM_DEBUG(dbgs() << " pushing edge " << printMBBReference(B) << " -> " << printMBBReference(*TB) << "\n"); FlowQ.push(CFGEdge(MBN, TBN)); } } void MachineConstPropagator::visitUsesOf(unsigned Reg) { - DEBUG(dbgs() << "Visiting uses of " << printReg(Reg, &MCE.TRI) + LLVM_DEBUG(dbgs() << "Visiting uses of " << printReg(Reg, &MCE.TRI) << Cells.get(Reg) << '\n'); for (MachineInstr &MI : MRI->use_nodbg_instructions(Reg)) { // Do not process non-executable instructions. They can become exceutable @@ -870,7 +870,7 @@ CFGEdge Edge = FlowQ.front(); FlowQ.pop(); - DEBUG(dbgs() << "Picked edge " + LLVM_DEBUG(dbgs() << "Picked edge " << printMBBReference(*MF.getBlockNumbered(Edge.first)) << "->" << printMBBReference(*MF.getBlockNumbered(Edge.second)) << '\n'); @@ -927,7 +927,7 @@ } } // while (FlowQ) - DEBUG({ + LLVM_DEBUG({ dbgs() << "Cells after propagation:\n"; Cells.print(dbgs(), MCE.TRI); dbgs() << "Dead CFG edges:\n"; @@ -1042,7 +1042,7 @@ // This is the constant propagation algorithm as described by Wegman-Zadeck. // Most of the terminology comes from there. bool MachineConstPropagator::run(MachineFunction &MF) { - DEBUG(MF.print(dbgs() << "Starting MachineConstPropagator\n", nullptr)); + LLVM_DEBUG(MF.print(dbgs() << "Starting MachineConstPropagator\n", nullptr)); MRI = &MF.getRegInfo(); @@ -1054,7 +1054,7 @@ propagate(MF); bool Changed = rewrite(MF); - DEBUG({ + LLVM_DEBUG({ dbgs() << "End of MachineConstPropagator (Changed=" << Changed << ")\n"; if (Changed) MF.print(dbgs(), nullptr); @@ -2775,7 +2775,7 @@ AllDefs = false; // Some diagnostics. - // DEBUG({...}) gets confused with all this code as an argument. + // LLVM_DEBUG({...}) gets confused with all this code as an argument. #ifndef NDEBUG bool Debugging = DebugFlag && isCurrentDebugType(DEBUG_TYPE); if (Debugging) { @@ -2920,7 +2920,7 @@ ChangedNum++; } - DEBUG({ + LLVM_DEBUG({ if (!NewInstrs.empty()) { MachineFunction &MF = *MI.getParent()->getParent(); dbgs() << "In function: " << MF.getName() << "\n"; @@ -3087,7 +3087,7 @@ MO.setIsKill(false); } - DEBUG({ + LLVM_DEBUG({ if (NewMI) { dbgs() << "Rewrite: for " << MI; if (NewMI != &MI) @@ -3127,7 +3127,7 @@ if (BrI.getOpcode() == Hexagon::J2_jump) return false; - DEBUG(dbgs() << "Rewrite(" << printMBBReference(B) << "):" << BrI); + LLVM_DEBUG(dbgs() << "Rewrite(" << printMBBReference(B) << "):" << BrI); bool Rewritten = false; if (NumTargets > 0) { assert(!FallsThru && "This should have been checked before"); Index: lib/Target/Hexagon/HexagonCopyToCombine.cpp =================================================================== --- lib/Target/Hexagon/HexagonCopyToCombine.cpp +++ lib/Target/Hexagon/HexagonCopyToCombine.cpp @@ -649,7 +649,7 @@ unsigned DoubleDestReg, MachineOperand &HiOperand, MachineOperand &LoOperand) { - DEBUG(dbgs() << "Found a CONST64\n"); + LLVM_DEBUG(dbgs() << "Found a CONST64\n"); DebugLoc DL = InsertPt->getDebugLoc(); MachineBasicBlock *BB = InsertPt->getParent(); Index: lib/Target/Hexagon/HexagonEarlyIfConv.cpp =================================================================== --- lib/Target/Hexagon/HexagonEarlyIfConv.cpp +++ lib/Target/Hexagon/HexagonEarlyIfConv.cpp @@ -238,7 +238,7 @@ bool HexagonEarlyIfConversion::matchFlowPattern(MachineBasicBlock *B, MachineLoop *L, FlowPattern &FP) { - DEBUG(dbgs() << "Checking flow pattern at " << printMBBReference(*B) << "\n"); + LLVM_DEBUG(dbgs() << "Checking flow pattern at " << printMBBReference(*B) << "\n"); // Interested only in conditional branches, no .new, no new-value, etc. // Check the terminators directly, it's easier than handling all responses @@ -325,13 +325,13 @@ } // Don't try to predicate loop preheaders. if ((TB && isPreheader(TB)) || (FB && isPreheader(FB))) { - DEBUG(dbgs() << "One of blocks " << PrintMB(TB) << ", " << PrintMB(FB) + LLVM_DEBUG(dbgs() << "One of blocks " << PrintMB(TB) << ", " << PrintMB(FB) << " is a loop preheader. Skipping.\n"); return false; } FP = FlowPattern(B, PredR, TB, FB, JB); - DEBUG(dbgs() << "Detected " << PrintFP(FP, *TRI) << "\n"); + LLVM_DEBUG(dbgs() << "Detected " << PrintFP(FP, *TRI) << "\n"); return true; } @@ -546,7 +546,7 @@ }; unsigned Spare = 0; unsigned TotalIn = TotalCount(FP.TrueB, Spare) + TotalCount(FP.FalseB, Spare); - DEBUG(dbgs() << "Total number of instructions to be predicated/speculated: " + LLVM_DEBUG(dbgs() << "Total number of instructions to be predicated/speculated: " << TotalIn << ", spare room: " << Spare << "\n"); if (TotalIn >= SizeLimit+Spare) return false; @@ -574,12 +574,12 @@ PredDefs += countPredicateDefs(SB); } } - DEBUG(dbgs() << "Total number of extra muxes from converted phis: " + LLVM_DEBUG(dbgs() << "Total number of extra muxes from converted phis: " << TotalPh << "\n"); if (TotalIn+TotalPh >= SizeLimit+Spare) return false; - DEBUG(dbgs() << "Total number of predicate registers: " << PredDefs << "\n"); + LLVM_DEBUG(dbgs() << "Total number of predicate registers: " << PredDefs << "\n"); if (PredDefs > 4) return false; @@ -620,11 +620,11 @@ return Changed; if (!isValid(FP)) { - DEBUG(dbgs() << "Conversion is not valid\n"); + LLVM_DEBUG(dbgs() << "Conversion is not valid\n"); return Changed; } if (!isProfitable(FP)) { - DEBUG(dbgs() << "Conversion is not profitable\n"); + LLVM_DEBUG(dbgs() << "Conversion is not profitable\n"); return Changed; } @@ -635,7 +635,7 @@ bool HexagonEarlyIfConversion::visitLoop(MachineLoop *L) { MachineBasicBlock *HB = L ? L->getHeader() : nullptr; - DEBUG((L ? dbgs() << "Visiting loop H:" << PrintMB(HB) + LLVM_DEBUG((L ? dbgs() << "Visiting loop H:" << PrintMB(HB) : dbgs() << "Visiting function") << "\n"); bool Changed = false; if (L) { @@ -745,7 +745,7 @@ void HexagonEarlyIfConversion::predicateBlockNB(MachineBasicBlock *ToB, MachineBasicBlock::iterator At, MachineBasicBlock *FromB, unsigned PredR, bool IfTrue) { - DEBUG(dbgs() << "Predicating block " << PrintMB(FromB) << "\n"); + LLVM_DEBUG(dbgs() << "Predicating block " << PrintMB(FromB) << "\n"); MachineBasicBlock::iterator End = FromB->getFirstTerminator(); MachineBasicBlock::iterator I, NextI; @@ -937,7 +937,7 @@ } void HexagonEarlyIfConversion::removeBlock(MachineBasicBlock *B) { - DEBUG(dbgs() << "Removing block " << PrintMB(B) << "\n"); + LLVM_DEBUG(dbgs() << "Removing block " << PrintMB(B) << "\n"); // Transfer the immediate dominator information from B to its descendants. MachineDomTreeNode *N = MDT->getNode(B); @@ -967,7 +967,7 @@ } void HexagonEarlyIfConversion::eliminatePhis(MachineBasicBlock *B) { - DEBUG(dbgs() << "Removing phi nodes from block " << PrintMB(B) << "\n"); + LLVM_DEBUG(dbgs() << "Removing phi nodes from block " << PrintMB(B) << "\n"); MachineBasicBlock::iterator I, NextI, NonPHI = B->getFirstNonPHI(); for (I = B->begin(); I != NonPHI; I = NextI) { NextI = std::next(I); @@ -1008,7 +1008,7 @@ void HexagonEarlyIfConversion::mergeBlocks(MachineBasicBlock *PredB, MachineBasicBlock *SuccB) { - DEBUG(dbgs() << "Merging blocks " << PrintMB(PredB) << " and " + LLVM_DEBUG(dbgs() << "Merging blocks " << PrintMB(PredB) << " and " << PrintMB(SuccB) << "\n"); bool TermOk = hasUncondBranch(SuccB); eliminatePhis(SuccB); Index: lib/Target/Hexagon/HexagonExpandCondsets.cpp =================================================================== --- lib/Target/Hexagon/HexagonExpandCondsets.cpp +++ lib/Target/Hexagon/HexagonExpandCondsets.cpp @@ -641,7 +641,7 @@ .add(SrcOp); } - DEBUG(dbgs() << "created an initial copy: " << *MIB); + LLVM_DEBUG(dbgs() << "created an initial copy: " << *MIB); return &*MIB; } @@ -654,7 +654,7 @@ return false; TfrCounter++; } - DEBUG(dbgs() << "\nsplitting " << printMBBReference(*MI.getParent()) << ": " + LLVM_DEBUG(dbgs() << "\nsplitting " << printMBBReference(*MI.getParent()) << ": " << MI); MachineOperand &MD = MI.getOperand(0); // Definition MachineOperand &MP = MI.getOperand(1); // Predicate register @@ -932,7 +932,7 @@ unsigned Opc = TfrI.getOpcode(); (void)Opc; assert(Opc == Hexagon::A2_tfrt || Opc == Hexagon::A2_tfrf); - DEBUG(dbgs() << "\nattempt to predicate if-" << (Cond ? "true" : "false") + LLVM_DEBUG(dbgs() << "\nattempt to predicate if-" << (Cond ? "true" : "false") << ": " << TfrI); MachineOperand &MD = TfrI.getOperand(0); @@ -954,7 +954,7 @@ if (!DefI || !isPredicable(DefI)) return false; - DEBUG(dbgs() << "Source def: " << *DefI); + LLVM_DEBUG(dbgs() << "Source def: " << *DefI); // Collect the information about registers defined and used between the // DefI and the TfrI. @@ -1039,7 +1039,7 @@ if (!canMoveMemTo(*DefI, TfrI, true)) CanDown = false; - DEBUG(dbgs() << "Can move up: " << (CanUp ? "yes" : "no") + LLVM_DEBUG(dbgs() << "Can move up: " << (CanUp ? "yes" : "no") << ", can move down: " << (CanDown ? "yes\n" : "no\n")); MachineBasicBlock::iterator PastDefIt = std::next(DefIt); if (CanUp) @@ -1135,7 +1135,7 @@ return false; bool Overlap = L1.overlaps(L2); - DEBUG(dbgs() << "compatible registers: (" + LLVM_DEBUG(dbgs() << "compatible registers: (" << (Overlap ? "overlap" : "disjoint") << ")\n " << printReg(R1.Reg, TRI, R1.Sub) << " " << L1 << "\n " << printReg(R2.Reg, TRI, R2.Sub) << " " << L2 << "\n"); @@ -1171,7 +1171,7 @@ LIS->removeInterval(R2.Reg); updateKillFlags(R1.Reg); - DEBUG(dbgs() << "coalesced: " << L1 << "\n"); + LLVM_DEBUG(dbgs() << "coalesced: " << L1 << "\n"); L1.verify(); return true; @@ -1252,7 +1252,7 @@ LIS = &getAnalysis(); MRI = &MF.getRegInfo(); - DEBUG(LIS->print(dbgs() << "Before expand-condsets\n", + LLVM_DEBUG(LIS->print(dbgs() << "Before expand-condsets\n", MF.getFunction().getParent())); bool Changed = false; @@ -1280,7 +1280,7 @@ if (!CoalUpd.count(Op.getReg())) KillUpd.insert(Op.getReg()); updateLiveness(KillUpd, false, true, false); - DEBUG(LIS->print(dbgs() << "After coalescing\n", + LLVM_DEBUG(LIS->print(dbgs() << "After coalescing\n", MF.getFunction().getParent())); // First, simply split all muxes into a pair of conditional transfers @@ -1297,7 +1297,7 @@ // predication, and after splitting they are difficult to recalculate // (because of predicated defs), so make sure they are left untouched. // Predication does not use live intervals. - DEBUG(LIS->print(dbgs() << "After splitting\n", + LLVM_DEBUG(LIS->print(dbgs() << "After splitting\n", MF.getFunction().getParent())); // Traverse all blocks and collapse predicable instructions feeding @@ -1306,13 +1306,13 @@ // cases that were not created in the previous step. for (auto &B : MF) Changed |= predicateInBlock(B, PredUpd); - DEBUG(LIS->print(dbgs() << "After predicating\n", + LLVM_DEBUG(LIS->print(dbgs() << "After predicating\n", MF.getFunction().getParent())); PredUpd.insert(CoalUpd.begin(), CoalUpd.end()); updateLiveness(PredUpd, true, true, true); - DEBUG({ + LLVM_DEBUG({ if (Changed) LIS->print(dbgs() << "After expand-condsets\n", MF.getFunction().getParent()); Index: lib/Target/Hexagon/HexagonFrameLowering.cpp =================================================================== --- lib/Target/Hexagon/HexagonFrameLowering.cpp +++ lib/Target/Hexagon/HexagonFrameLowering.cpp @@ -442,7 +442,7 @@ if (needsStackFrame(I, CSR, HRI)) SFBlocks.push_back(&I); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Blocks needing SF: {"; for (auto &B : SFBlocks) dbgs() << " " << printMBBReference(*B); @@ -465,7 +465,7 @@ if (!PDomB) break; } - DEBUG({ + LLVM_DEBUG({ dbgs() << "Computed dom block: "; if (DomB) dbgs() << printMBBReference(*DomB); @@ -483,11 +483,11 @@ // Make sure that DomB dominates PDomB and PDomB post-dominates DomB. if (!MDT.dominates(DomB, PDomB)) { - DEBUG(dbgs() << "Dom block does not dominate pdom block\n"); + LLVM_DEBUG(dbgs() << "Dom block does not dominate pdom block\n"); return; } if (!MPT.dominates(PDomB, DomB)) { - DEBUG(dbgs() << "PDom block does not post-dominate dom block\n"); + LLVM_DEBUG(dbgs() << "PDom block does not post-dominate dom block\n"); return; } @@ -1396,7 +1396,7 @@ bool HexagonFrameLowering::assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector &CSI) const { - DEBUG(dbgs() << __func__ << " on " << MF.getName() << '\n'); + LLVM_DEBUG(dbgs() << __func__ << " on " << MF.getName() << '\n'); MachineFrameInfo &MFI = MF.getFrameInfo(); BitVector SRegs(Hexagon::NUM_TARGET_REGS); @@ -1406,15 +1406,15 @@ // (1) For each callee-saved register, add that register and all of its // sub-registers to SRegs. - DEBUG(dbgs() << "Initial CS registers: {"); + LLVM_DEBUG(dbgs() << "Initial CS registers: {"); for (unsigned i = 0, n = CSI.size(); i < n; ++i) { unsigned R = CSI[i].getReg(); - DEBUG(dbgs() << ' ' << printReg(R, TRI)); + LLVM_DEBUG(dbgs() << ' ' << printReg(R, TRI)); for (MCSubRegIterator SR(R, TRI, true); SR.isValid(); ++SR) SRegs[*SR] = true; } - DEBUG(dbgs() << " }\n"); - DEBUG(dbgs() << "SRegs.1: "; dump_registers(SRegs, *TRI); dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " }\n"); + LLVM_DEBUG(dbgs() << "SRegs.1: "; dump_registers(SRegs, *TRI); dbgs() << "\n"); // (2) For each reserved register, remove that register and all of its // sub- and super-registers from SRegs. @@ -1424,8 +1424,8 @@ for (MCSuperRegIterator SR(R, TRI, true); SR.isValid(); ++SR) SRegs[*SR] = false; } - DEBUG(dbgs() << "Res: "; dump_registers(Reserved, *TRI); dbgs() << "\n"); - DEBUG(dbgs() << "SRegs.2: "; dump_registers(SRegs, *TRI); dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Res: "; dump_registers(Reserved, *TRI); dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "SRegs.2: "; dump_registers(SRegs, *TRI); dbgs() << "\n"); // (3) Collect all registers that have at least one sub-register in SRegs, // and also have no sub-registers that are reserved. These will be the can- @@ -1446,11 +1446,11 @@ break; } } - DEBUG(dbgs() << "TmpSup: "; dump_registers(TmpSup, *TRI); dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "TmpSup: "; dump_registers(TmpSup, *TRI); dbgs() << "\n"); // (4) Include all super-registers found in (3) into SRegs. SRegs |= TmpSup; - DEBUG(dbgs() << "SRegs.4: "; dump_registers(SRegs, *TRI); dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "SRegs.4: "; dump_registers(SRegs, *TRI); dbgs() << "\n"); // (5) For each register R in SRegs, if any super-register of R is in SRegs, // remove R from SRegs. @@ -1463,7 +1463,7 @@ break; } } - DEBUG(dbgs() << "SRegs.5: "; dump_registers(SRegs, *TRI); dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "SRegs.5: "; dump_registers(SRegs, *TRI); dbgs() << "\n"); // Now, for each register that has a fixed stack slot, create the stack // object for it. @@ -1501,7 +1501,7 @@ SRegs[R] = false; } - DEBUG({ + LLVM_DEBUG({ dbgs() << "CS information: {"; for (unsigned i = 0, n = CSI.size(); i < n; ++i) { int FI = CSI[i].getFrameIdx(); @@ -2026,7 +2026,7 @@ auto P = BlockIndexes.insert( std::make_pair(&B, HexagonBlockRanges::InstrIndexMap(B))); auto &IndexMap = P.first->second; - DEBUG(dbgs() << "Index map for " << printMBBReference(B) << "\n" + LLVM_DEBUG(dbgs() << "Index map for " << printMBBReference(B) << "\n" << IndexMap << '\n'); for (auto &In : B) { @@ -2134,7 +2134,7 @@ } } - DEBUG({ + LLVM_DEBUG({ for (auto &P : FIRangeMap) { dbgs() << "fi#" << P.first; if (BadFIs.count(P.first)) @@ -2173,7 +2173,7 @@ } } - DEBUG({ + LLVM_DEBUG({ dbgs() << "Block-to-FI map (* -- live-on-exit):\n"; for (auto &P : BlockFIMap) { auto &FIs = P.second; @@ -2200,16 +2200,16 @@ HexagonBlockRanges::InstrIndexMap &IM = F->second; HexagonBlockRanges::RegToRangeMap LM = HBR.computeLiveMap(IM); HexagonBlockRanges::RegToRangeMap DM = HBR.computeDeadMap(IM, LM); - DEBUG(dbgs() << printMBBReference(B) << " dead map\n" + LLVM_DEBUG(dbgs() << printMBBReference(B) << " dead map\n" << HexagonBlockRanges::PrintRangeMap(DM, HRI)); for (auto FI : BlockFIMap[&B]) { if (BadFIs.count(FI)) continue; - DEBUG(dbgs() << "Working on fi#" << FI << '\n'); + LLVM_DEBUG(dbgs() << "Working on fi#" << FI << '\n'); HexagonBlockRanges::RangeList &RL = FIRangeMap[FI].Map[&B]; for (auto &Range : RL) { - DEBUG(dbgs() << "--Examining range:" << RL << '\n'); + LLVM_DEBUG(dbgs() << "--Examining range:" << RL << '\n'); if (!IndexType::isInstr(Range.start()) || !IndexType::isInstr(Range.end())) continue; @@ -2224,7 +2224,7 @@ auto *RC = HII.getRegClass(SI.getDesc(), 2, &HRI, MF); // The this-> is needed to unconfuse MSVC. unsigned FoundR = this->findPhysReg(MF, Range, IM, DM, RC); - DEBUG(dbgs() << "Replacement reg:" << printReg(FoundR, &HRI) << '\n'); + LLVM_DEBUG(dbgs() << "Replacement reg:" << printReg(FoundR, &HRI) << '\n'); if (FoundR == 0) continue; #ifndef NDEBUG Index: lib/Target/Hexagon/HexagonGenPredicate.cpp =================================================================== --- lib/Target/Hexagon/HexagonGenPredicate.cpp +++ lib/Target/Hexagon/HexagonGenPredicate.cpp @@ -222,13 +222,13 @@ } void HexagonGenPredicate::processPredicateGPR(const Register &Reg) { - DEBUG(dbgs() << __func__ << ": " + LLVM_DEBUG(dbgs() << __func__ << ": " << printReg(Reg.R, TRI, Reg.S) << "\n"); using use_iterator = MachineRegisterInfo::use_iterator; use_iterator I = MRI->use_begin(Reg.R), E = MRI->use_end(); if (I == E) { - DEBUG(dbgs() << "Dead reg: " << printReg(Reg.R, TRI, Reg.S) << '\n'); + LLVM_DEBUG(dbgs() << "Dead reg: " << printReg(Reg.R, TRI, Reg.S) << '\n'); MachineInstr *DefI = MRI->getVRegDef(Reg.R); DefI->eraseFromParent(); return; @@ -250,7 +250,7 @@ if (F != G2P.end()) return F->second; - DEBUG(dbgs() << __func__ << ": " << PrintRegister(Reg, *TRI)); + LLVM_DEBUG(dbgs() << __func__ << ": " << PrintRegister(Reg, *TRI)); MachineInstr *DefI = MRI->getVRegDef(Reg.R); assert(DefI); unsigned Opc = DefI->getOpcode(); @@ -258,7 +258,7 @@ assert(DefI->getOperand(0).isDef() && DefI->getOperand(1).isUse()); Register PR = DefI->getOperand(1); G2P.insert(std::make_pair(Reg, PR)); - DEBUG(dbgs() << " -> " << PrintRegister(PR, *TRI) << '\n'); + LLVM_DEBUG(dbgs() << " -> " << PrintRegister(PR, *TRI) << '\n'); return PR; } @@ -274,7 +274,7 @@ BuildMI(B, std::next(DefIt), DL, TII->get(TargetOpcode::COPY), NewPR) .addReg(Reg.R, 0, Reg.S); G2P.insert(std::make_pair(Reg, Register(NewPR))); - DEBUG(dbgs() << " -> !" << PrintRegister(Register(NewPR), *TRI) << '\n'); + LLVM_DEBUG(dbgs() << " -> !" << PrintRegister(Register(NewPR), *TRI) << '\n'); return Register(NewPR); } @@ -364,7 +364,7 @@ } bool HexagonGenPredicate::convertToPredForm(MachineInstr *MI) { - DEBUG(dbgs() << __func__ << ": " << MI << " " << *MI); + LLVM_DEBUG(dbgs() << __func__ << ": " << MI << " " << *MI); unsigned Opc = MI->getOpcode(); assert(isConvertibleToPredForm(MI)); @@ -426,7 +426,7 @@ Register Pred = getPredRegFor(GPR); MIB.addReg(Pred.R, 0, Pred.S); } - DEBUG(dbgs() << "generated: " << *MIB); + LLVM_DEBUG(dbgs() << "generated: " << *MIB); // Generate a copy-out: NewGPR = NewPR, and replace all uses of OutR // with NewGPR. @@ -449,7 +449,7 @@ } bool HexagonGenPredicate::eliminatePredCopies(MachineFunction &MF) { - DEBUG(dbgs() << __func__ << "\n"); + LLVM_DEBUG(dbgs() << __func__ << "\n"); const TargetRegisterClass *PredRC = &Hexagon::PredRegsRegClass; bool Changed = false; VectOfInst Erase; Index: lib/Target/Hexagon/HexagonHardwareLoops.cpp =================================================================== --- lib/Target/Hexagon/HexagonHardwareLoops.cpp +++ lib/Target/Hexagon/HexagonHardwareLoops.cpp @@ -376,7 +376,7 @@ } bool HexagonHardwareLoops::runOnMachineFunction(MachineFunction &MF) { - DEBUG(dbgs() << "********* Hexagon Hardware Loops *********\n"); + LLVM_DEBUG(dbgs() << "********* Hexagon Hardware Loops *********\n"); if (skipFunction(MF.getFunction())) return false; @@ -1011,14 +1011,14 @@ bool HexagonHardwareLoops::containsInvalidInstruction(MachineLoop *L, bool IsInnerHWLoop) const { const std::vector &Blocks = L->getBlocks(); - DEBUG(dbgs() << "\nhw_loop head, " << printMBBReference(*Blocks[0])); + LLVM_DEBUG(dbgs() << "\nhw_loop head, " << printMBBReference(*Blocks[0])); for (unsigned i = 0, e = Blocks.size(); i != e; ++i) { MachineBasicBlock *MBB = Blocks[i]; for (MachineBasicBlock::iterator MII = MBB->begin(), E = MBB->end(); MII != E; ++MII) { const MachineInstr *MI = &*MII; if (isInvalidLoopOperation(MI, IsInnerHWLoop)) { - DEBUG(dbgs()<< "\nCannot convert to hw_loop due to:"; MI->dump();); + LLVM_DEBUG(dbgs()<< "\nCannot convert to hw_loop due to:"; MI->dump();); return true; } } @@ -1083,7 +1083,7 @@ SmallVector DeadPhis; if (isDead(MI, DeadPhis)) { - DEBUG(dbgs() << "HW looping will remove: " << *MI); + LLVM_DEBUG(dbgs() << "HW looping will remove: " << *MI); // It is possible that some DBG_VALUE instructions refer to this // instruction. Examine each def operand for such references; @@ -1237,7 +1237,7 @@ LoopStart = TopBlock; // Convert the loop to a hardware loop. - DEBUG(dbgs() << "Change to hardware loop at "; L->dump()); + LLVM_DEBUG(dbgs() << "Change to hardware loop at "; L->dump()); DebugLoc DL; if (InsertPos != Preheader->end()) DL = InsertPos->getDebugLoc(); @@ -1367,7 +1367,7 @@ LoopFeederMap &LoopFeederPhi) const { if (LoopFeederPhi.find(MO->getReg()) == LoopFeederPhi.end()) { const std::vector &Blocks = L->getBlocks(); - DEBUG(dbgs() << "\nhw_loop head, " << printMBBReference(*Blocks[0])); + LLVM_DEBUG(dbgs() << "\nhw_loop head, " << printMBBReference(*Blocks[0])); // Ignore all BBs that form Loop. for (unsigned i = 0, e = Blocks.size(); i != e; ++i) { MachineBasicBlock *MBB = Blocks[i]; @@ -1768,7 +1768,7 @@ for (unsigned i = 1, n = PredDef->getNumOperands(); i < n; ++i) { MachineOperand &MO = PredDef->getOperand(i); if (MO.isReg() && MO.getReg() == RB.first) { - DEBUG(dbgs() << "\n DefMI(" << i << ") = " + LLVM_DEBUG(dbgs() << "\n DefMI(" << i << ") = " << *(MRI->getVRegDef(I->first))); if (IndI) return false; @@ -1776,7 +1776,7 @@ IndI = MRI->getVRegDef(I->first); IndMO = &MO; } else if (MO.isReg()) { - DEBUG(dbgs() << "\n DefMI(" << i << ") = " + LLVM_DEBUG(dbgs() << "\n DefMI(" << i << ") = " << *(MRI->getVRegDef(MO.getReg()))); if (nonIndI) return false; Index: lib/Target/Hexagon/HexagonHazardRecognizer.cpp =================================================================== --- lib/Target/Hexagon/HexagonHazardRecognizer.cpp +++ lib/Target/Hexagon/HexagonHazardRecognizer.cpp @@ -26,7 +26,7 @@ #define DEBUG_TYPE "post-RA-sched" void HexagonHazardRecognizer::Reset() { - DEBUG(dbgs() << "Reset hazard recognizer\n"); + LLVM_DEBUG(dbgs() << "Reset hazard recognizer\n"); Resources->clearResources(); PacketNum = 0; UsesDotCur = nullptr; @@ -41,7 +41,7 @@ return NoHazard; if (!Resources->canReserveResources(*MI)) { - DEBUG(dbgs() << "*** Hazard in cycle " << PacketNum << ", " << *MI); + LLVM_DEBUG(dbgs() << "*** Hazard in cycle " << PacketNum << ", " << *MI); HazardType RetVal = Hazard; if (TII->mayBeNewStore(*MI)) { // Make sure the register to be stored is defined by an instruction in the @@ -57,14 +57,14 @@ MI->getDebugLoc()); if (Resources->canReserveResources(*NewMI)) RetVal = NoHazard; - DEBUG(dbgs() << "*** Try .new version? " << (RetVal == NoHazard) << "\n"); + LLVM_DEBUG(dbgs() << "*** Try .new version? " << (RetVal == NoHazard) << "\n"); MF->DeleteMachineInstr(NewMI); } return RetVal; } if (SU == UsesDotCur && DotCurPNum != (int)PacketNum) { - DEBUG(dbgs() << "*** .cur Hazard in cycle " << PacketNum << ", " << *MI); + LLVM_DEBUG(dbgs() << "*** .cur Hazard in cycle " << PacketNum << ", " << *MI); return Hazard; } @@ -72,7 +72,7 @@ } void HexagonHazardRecognizer::AdvanceCycle() { - DEBUG(dbgs() << "Advance cycle, clear state\n"); + LLVM_DEBUG(dbgs() << "Advance cycle, clear state\n"); Resources->clearResources(); if (DotCurPNum != -1 && DotCurPNum != (int)PacketNum) { UsesDotCur = nullptr; @@ -118,7 +118,7 @@ } else Resources->reserveResources(*MI); - DEBUG(dbgs() << " Add instruction " << *MI); + LLVM_DEBUG(dbgs() << " Add instruction " << *MI); // When scheduling a dot cur instruction, check if there is an instruction // that can use the dot cur in the same packet. If so, we'll attempt to Index: lib/Target/Hexagon/HexagonISelDAGToDAG.cpp =================================================================== --- lib/Target/Hexagon/HexagonISelDAGToDAG.cpp +++ lib/Target/Hexagon/HexagonISelDAGToDAG.cpp @@ -1729,15 +1729,15 @@ RootHeights[N] = std::max(getHeight(N->getOperand(0).getNode()), getHeight(N->getOperand(1).getNode())) + 1; - DEBUG(dbgs() << "--> No need to balance root (Weight=" << Weight + LLVM_DEBUG(dbgs() << "--> No need to balance root (Weight=" << Weight << " Height=" << RootHeights[N] << "): "); - DEBUG(N->dump()); + LLVM_DEBUG(N->dump()); return SDValue(N, 0); } - DEBUG(dbgs() << "** Balancing root node: "); - DEBUG(N->dump()); + LLVM_DEBUG(dbgs() << "** Balancing root node: "); + LLVM_DEBUG(N->dump()); unsigned NOpcode = N->getOpcode(); @@ -1785,7 +1785,7 @@ // Whoops, this node was RAUWd by one of the balanceSubTree calls we // made. Our worklist isn't up to date anymore. // Restart the whole process. - DEBUG(dbgs() << "--> Subtree was RAUWd. Restarting...\n"); + LLVM_DEBUG(dbgs() << "--> Subtree was RAUWd. Restarting...\n"); return balanceSubTree(N, TopLevel); } @@ -1856,7 +1856,7 @@ } } - DEBUG(dbgs() << "--> Current height=" << NodeHeights[SDValue(N, 0)] + LLVM_DEBUG(dbgs() << "--> Current height=" << NodeHeights[SDValue(N, 0)] << " weight=" << CurrentWeight << " imbalanced=" << Imbalanced << "\n"); @@ -1864,7 +1864,7 @@ // This factors out a shift in order to match memw(a< Found common factor for two MUL children!\n"); + LLVM_DEBUG(dbgs() << "--> Found common factor for two MUL children!\n"); int Weight = Mul1.Weight + Mul2.Weight; int Height = std::max(NodeHeights[Mul1.Value], NodeHeights[Mul2.Value]) + 1; SDValue Mul1Factored = factorOutPowerOf2(Mul1.Value, MaxPowerOf2); @@ -1898,9 +1898,9 @@ if (getUsesInFunction(GANode->getGlobal()) == 1 && Offset->hasOneUse() && getTargetLowering()->isOffsetFoldingLegal(GANode)) { - DEBUG(dbgs() << "--> Combining GA and offset (" << Offset->getSExtValue() + LLVM_DEBUG(dbgs() << "--> Combining GA and offset (" << Offset->getSExtValue() << "): "); - DEBUG(GANode->dump()); + LLVM_DEBUG(GANode->dump()); SDValue NewTGA = CurDAG->getTargetGlobalAddress(GANode->getGlobal(), SDLoc(GA.Value), @@ -1944,7 +1944,7 @@ // If this is the top level and we haven't factored out a shift, we should try // to move a constant to the bottom to match addressing modes like memw(rX+C) if (TopLevel && !CanFactorize && Leaves.hasConst()) { - DEBUG(dbgs() << "--> Pushing constant to tip of tree."); + LLVM_DEBUG(dbgs() << "--> Pushing constant to tip of tree."); Leaves.pushToBottom(Leaves.pop()); } @@ -1971,7 +1971,7 @@ // Make sure that none of these nodes have been RAUW'd if ((RootWeights.count(V0.getNode()) && RootWeights[V0.getNode()] == -2) || (RootWeights.count(V1.getNode()) && RootWeights[V1.getNode()] == -2)) { - DEBUG(dbgs() << "--> Subtree was RAUWd. Restarting...\n"); + LLVM_DEBUG(dbgs() << "--> Subtree was RAUWd. Restarting...\n"); return balanceSubTree(N, TopLevel); } @@ -2005,9 +2005,9 @@ int Weight = V0Weight + V1Weight; Leaves.push(WeightedLeaf(NewNode, Weight, L0.InsertionOrder)); - DEBUG(dbgs() << "--> Built new node (Weight=" << Weight << ",Height=" + LLVM_DEBUG(dbgs() << "--> Built new node (Weight=" << Weight << ",Height=" << Height << "):\n"); - DEBUG(NewNode.dump()); + LLVM_DEBUG(NewNode.dump()); } assert(Leaves.size() == 1); @@ -2031,15 +2031,15 @@ } if (N != NewRoot.getNode()) { - DEBUG(dbgs() << "--> Root is now: "); - DEBUG(NewRoot.dump()); + LLVM_DEBUG(dbgs() << "--> Root is now: "); + LLVM_DEBUG(NewRoot.dump()); // Replace all uses of old root by new root CurDAG->ReplaceAllUsesWith(N, NewRoot.getNode()); // Mark that we have RAUW'd N RootWeights[N] = -2; } else { - DEBUG(dbgs() << "--> Root unchanged.\n"); + LLVM_DEBUG(dbgs() << "--> Root unchanged.\n"); } RootWeights[NewRoot.getNode()] = Leaves.top().Weight; @@ -2062,8 +2062,8 @@ if (RootWeights.count(BasePtr.getNode())) continue; - DEBUG(dbgs() << "** Rebalancing address calculation in node: "); - DEBUG(N->dump()); + LLVM_DEBUG(dbgs() << "** Rebalancing address calculation in node: "); + LLVM_DEBUG(N->dump()); // FindRoots SmallVector Worklist; @@ -2103,8 +2103,8 @@ N = CurDAG->UpdateNodeOperands(N, N->getOperand(0), N->getOperand(1), NewBasePtr, N->getOperand(3)); - DEBUG(dbgs() << "--> Final node: "); - DEBUG(N->dump()); + LLVM_DEBUG(dbgs() << "--> Final node: "); + LLVM_DEBUG(N->dump()); } CurDAG->RemoveDeadNodes(); Index: lib/Target/Hexagon/HexagonISelLowering.cpp =================================================================== --- lib/Target/Hexagon/HexagonISelLowering.cpp +++ lib/Target/Hexagon/HexagonISelLowering.cpp @@ -354,7 +354,7 @@ break; } } - DEBUG(dbgs() << (CLI.IsTailCall ? "Eligible for Tail Call\n" + LLVM_DEBUG(dbgs() << (CLI.IsTailCall ? "Eligible for Tail Call\n" : "Argument must be passed on stack. " "Not eligible for Tail Call\n")); } @@ -428,7 +428,7 @@ } if (NeedsArgAlign && Subtarget.hasV60TOps()) { - DEBUG(dbgs() << "Function needs byte stack align due to call args\n"); + LLVM_DEBUG(dbgs() << "Function needs byte stack align due to call args\n"); unsigned VecAlign = HRI.getSpillAlignment(Hexagon::HvxVRRegClass); LargestAlignSeen = std::max(LargestAlignSeen, VecAlign); MFI.ensureMaxAlignment(LargestAlignSeen); @@ -664,7 +664,7 @@ if (A == 0) A = HFI.getStackAlignment(); - DEBUG({ + LLVM_DEBUG({ dbgs () << __func__ << " Align: " << A << " Size: "; Size.getNode()->dump(&DAG); dbgs() << "\n"; Index: lib/Target/Hexagon/HexagonInstrInfo.cpp =================================================================== --- lib/Target/Hexagon/HexagonInstrInfo.cpp +++ lib/Target/Hexagon/HexagonInstrInfo.cpp @@ -430,7 +430,7 @@ // Delete the J2_jump if it's equivalent to a fall-through. if (AllowModify && JumpToBlock && MBB.isLayoutSuccessor(I->getOperand(0).getMBB())) { - DEBUG(dbgs() << "\nErasing the jump to successor block\n";); + LLVM_DEBUG(dbgs() << "\nErasing the jump to successor block\n";); I->eraseFromParent(); I = MBB.instr_end(); if (I == MBB.instr_begin()) @@ -499,7 +499,7 @@ Cond.push_back(LastInst->getOperand(1)); return false; } - DEBUG(dbgs() << "\nCant analyze " << printMBBReference(MBB) + LLVM_DEBUG(dbgs() << "\nCant analyze " << printMBBReference(MBB) << " with one jump\n";); // Otherwise, don't know what this is. return true; @@ -547,7 +547,7 @@ FBB = LastInst->getOperand(0).getMBB(); return false; } - DEBUG(dbgs() << "\nCant analyze " << printMBBReference(MBB) + LLVM_DEBUG(dbgs() << "\nCant analyze " << printMBBReference(MBB) << " with two jumps";); // Otherwise, can't handle this. return true; @@ -557,7 +557,7 @@ int *BytesRemoved) const { assert(!BytesRemoved && "code size not handled"); - DEBUG(dbgs() << "\nRemoving branches out of " << printMBBReference(MBB)); + LLVM_DEBUG(dbgs() << "\nRemoving branches out of " << printMBBReference(MBB)); MachineBasicBlock::iterator I = MBB.end(); unsigned Count = 0; while (I != MBB.begin()) { @@ -629,7 +629,7 @@ // (ins IntRegs:$src1, IntRegs:$src2, brtarget:$offset) // (ins IntRegs:$src1, u5Imm:$src2, brtarget:$offset) unsigned Flags1 = getUndefRegState(Cond[1].isUndef()); - DEBUG(dbgs() << "\nInserting NVJump for " << printMBBReference(MBB);); + LLVM_DEBUG(dbgs() << "\nInserting NVJump for " << printMBBReference(MBB);); if (Cond[2].isReg()) { unsigned Flags2 = getUndefRegState(Cond[2].isUndef()); BuildMI(&MBB, DL, get(BccOpc)).addReg(Cond[1].getReg(), Flags1). @@ -1443,7 +1443,7 @@ MachineInstr &MI, ArrayRef Cond) const { if (Cond.empty() || isNewValueJump(Cond[0].getImm()) || isEndLoopN(Cond[0].getImm())) { - DEBUG(dbgs() << "\nCannot predicate:"; MI.dump();); + LLVM_DEBUG(dbgs() << "\nCannot predicate:"; MI.dump();); return false; } int Opc = MI.getOpcode(); @@ -2189,13 +2189,13 @@ bool isLate = isLateResultInstr(LRMI); bool isEarly = isEarlySourceInstr(ESMI); - DEBUG(dbgs() << "V60" << (isLate ? "-LR " : " -- ")); - DEBUG(LRMI.dump()); - DEBUG(dbgs() << "V60" << (isEarly ? "-ES " : " -- ")); - DEBUG(ESMI.dump()); + LLVM_DEBUG(dbgs() << "V60" << (isLate ? "-LR " : " -- ")); + LLVM_DEBUG(LRMI.dump()); + LLVM_DEBUG(dbgs() << "V60" << (isEarly ? "-ES " : " -- ")); + LLVM_DEBUG(ESMI.dump()); if (isLate && isEarly) { - DEBUG(dbgs() << "++Is Late Result feeding Early Source\n"); + LLVM_DEBUG(dbgs() << "++Is Late Result feeding Early Source\n"); return true; } @@ -4107,7 +4107,7 @@ return false; assert(Cond.size() == 2); if (isNewValueJump(Cond[0].getImm()) || Cond[1].isMBB()) { - DEBUG(dbgs() << "No predregs for new-value jumps/endloop"); + LLVM_DEBUG(dbgs() << "No predregs for new-value jumps/endloop"); return false; } PredReg = Cond[1].getReg(); @@ -4209,7 +4209,7 @@ bool HexagonInstrInfo::invertAndChangeJumpTarget( MachineInstr &MI, MachineBasicBlock *NewTarget) const { - DEBUG(dbgs() << "\n[invertAndChangeJumpTarget] to " + LLVM_DEBUG(dbgs() << "\n[invertAndChangeJumpTarget] to " << printMBBReference(*NewTarget); MI.dump();); assert(MI.isBranch()); @@ -4239,7 +4239,7 @@ for (unsigned insn = TargetOpcode::GENERIC_OP_END+1; insn < Hexagon::INSTRUCTION_LIST_END; ++insn) { NewMI = BuildMI(B, I, DL, get(insn)); - DEBUG(dbgs() << "\n" << getName(NewMI->getOpcode()) << + LLVM_DEBUG(dbgs() << "\n" << getName(NewMI->getOpcode()) << " Class: " << NewMI->getDesc().getSchedClass()); NewMI->eraseFromParent(); } @@ -4250,7 +4250,7 @@ // p -> NotP // NotP -> P bool HexagonInstrInfo::reversePredSense(MachineInstr &MI) const { - DEBUG(dbgs() << "\nTrying to reverse pred. sense of:"; MI.dump()); + LLVM_DEBUG(dbgs() << "\nTrying to reverse pred. sense of:"; MI.dump()); MI.setDesc(get(getInvertedPredicatedOpcode(MI.getOpcode()))); return true; } Index: lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp =================================================================== --- lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp +++ lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp @@ -1757,7 +1757,7 @@ } bool PolynomialMultiplyRecognize::recognize() { - DEBUG(dbgs() << "Starting PolynomialMultiplyRecognize on loop\n" + LLVM_DEBUG(dbgs() << "Starting PolynomialMultiplyRecognize on loop\n" << *CurLoop << '\n'); // Restrictions: // - The loop must consist of a single block. @@ -1765,7 +1765,7 @@ // - The loop must have an induction variable starting from 0, and // incremented in each iteration of the loop. BasicBlock *LoopB = CurLoop->getHeader(); - DEBUG(dbgs() << "Loop header:\n" << *LoopB); + LLVM_DEBUG(dbgs() << "Loop header:\n" << *LoopB); if (LoopB != CurLoop->getLoopLatch()) return false; @@ -1787,7 +1787,7 @@ ParsedValues PV; Simplifier PreSimp; PV.IterCount = IterCount; - DEBUG(dbgs() << "Loop IV: " << *CIV << "\nIterCount: " << IterCount << '\n'); + LLVM_DEBUG(dbgs() << "Loop IV: " << *CIV << "\nIterCount: " << IterCount << '\n'); setupPreSimplifier(PreSimp); @@ -1814,7 +1814,7 @@ Simplifier::Context C(SI); Value *T = PreSimp.simplify(C); SelectInst *SelI = (T && isa(T)) ? cast(T) : SI; - DEBUG(dbgs() << "scanSelect(pre-scan): " << PE(C, SelI) << '\n'); + LLVM_DEBUG(dbgs() << "scanSelect(pre-scan): " << PE(C, SelI) << '\n'); if (scanSelect(SelI, LoopB, EntryB, CIV, PV, true)) { FoundPreScan = true; if (SelI != SI) { @@ -1827,7 +1827,7 @@ } if (!FoundPreScan) { - DEBUG(dbgs() << "Have not found candidates for pmpy\n"); + LLVM_DEBUG(dbgs() << "Have not found candidates for pmpy\n"); return false; } @@ -1867,14 +1867,14 @@ SelectInst *SelI = dyn_cast(&In); if (!SelI) continue; - DEBUG(dbgs() << "scanSelect: " << *SelI << '\n'); + LLVM_DEBUG(dbgs() << "scanSelect: " << *SelI << '\n'); FoundScan = scanSelect(SelI, LoopB, EntryB, CIV, PV, false); if (FoundScan) break; } assert(FoundScan); - DEBUG({ + LLVM_DEBUG({ StringRef PP = (PV.M ? "(P+M)" : "P"); if (!PV.Inv) dbgs() << "Found pmpy idiom: R = " << PP << ".Q\n"; @@ -2286,7 +2286,7 @@ NewCall->setDebugLoc(DLoc); - DEBUG(dbgs() << " Formed " << (Overlap ? "memmove: " : "memcpy: ") + LLVM_DEBUG(dbgs() << " Formed " << (Overlap ? "memmove: " : "memcpy: ") << *NewCall << "\n" << " from load ptr=" << *LoadEv << " at: " << *LI << "\n" << " from store ptr=" << *StoreEv << " at: " << *SI << "\n"); Index: lib/Target/Hexagon/HexagonMachineScheduler.cpp =================================================================== --- lib/Target/Hexagon/HexagonMachineScheduler.cpp +++ lib/Target/Hexagon/HexagonMachineScheduler.cpp @@ -161,11 +161,11 @@ Packet.push_back(SU); #ifndef NDEBUG - DEBUG(dbgs() << "Packet[" << TotalPackets << "]:\n"); + LLVM_DEBUG(dbgs() << "Packet[" << TotalPackets << "]:\n"); for (unsigned i = 0, e = Packet.size(); i != e; ++i) { - DEBUG(dbgs() << "\t[" << i << "] SU("); - DEBUG(dbgs() << Packet[i]->NodeNum << ")\t"); - DEBUG(Packet[i]->getInstr()->dump()); + LLVM_DEBUG(dbgs() << "\t[" << i << "] SU("); + LLVM_DEBUG(dbgs() << Packet[i]->NodeNum << ")\t"); + LLVM_DEBUG(Packet[i]->getInstr()->dump()); } #endif @@ -186,7 +186,7 @@ /// after setting up the current scheduling region. [RegionBegin, RegionEnd) /// only includes instructions that have DAG nodes, not scheduling boundaries. void VLIWMachineScheduler::schedule() { - DEBUG(dbgs() << "********** MI Converging Scheduling VLIW " + LLVM_DEBUG(dbgs() << "********** MI Converging Scheduling VLIW " << printMBBReference(*BB) << " " << BB->getName() << " in_func " << BB->getParent()->getName() << " at loop depth " << MLI->getLoopDepth(BB) << " \n"); @@ -199,24 +199,24 @@ // Initialize the strategy before modifying the DAG. SchedImpl->initialize(this); - DEBUG(unsigned maxH = 0; + LLVM_DEBUG(unsigned maxH = 0; for (unsigned su = 0, e = SUnits.size(); su != e; ++su) if (SUnits[su].getHeight() > maxH) maxH = SUnits[su].getHeight(); dbgs() << "Max Height " << maxH << "\n";); - DEBUG(unsigned maxD = 0; + LLVM_DEBUG(unsigned maxD = 0; for (unsigned su = 0, e = SUnits.size(); su != e; ++su) if (SUnits[su].getDepth() > maxD) maxD = SUnits[su].getDepth(); dbgs() << "Max Depth " << maxD << "\n";); - DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su) + LLVM_DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su) SUnits[su].dumpAll(this)); initQueues(TopRoots, BotRoots); bool IsTopNode = false; while (true) { - DEBUG(dbgs() << "** VLIWMachineScheduler::schedule picking next node\n"); + LLVM_DEBUG(dbgs() << "** VLIWMachineScheduler::schedule picking next node\n"); SUnit *SU = SchedImpl->pickNode(IsTopNode); if (!SU) break; @@ -234,7 +234,7 @@ placeDebugValues(); - DEBUG({ + LLVM_DEBUG({ dbgs() << "*** Final schedule for " << printMBBReference(*begin()->getParent()) << " ***\n"; dumpSchedule(); @@ -364,7 +364,7 @@ } CheckPending = true; - DEBUG(dbgs() << "*** Next cycle " << Available.getName() << " cycle " + LLVM_DEBUG(dbgs() << "*** Next cycle " << Available.getName() << " cycle " << CurrCycle << '\n'); } @@ -389,11 +389,11 @@ // TODO: Check if this SU must end a dispatch group. IssueCount += SchedModel->getNumMicroOps(SU->getInstr()); if (startNewCycle) { - DEBUG(dbgs() << "*** Max instrs at cycle " << CurrCycle << '\n'); + LLVM_DEBUG(dbgs() << "*** Max instrs at cycle " << CurrCycle << '\n'); bumpCycle(); } else - DEBUG(dbgs() << "*** IssueCount " << IssueCount + LLVM_DEBUG(dbgs() << "*** IssueCount " << IssueCount << " at cycle " << CurrCycle << '\n'); } @@ -543,18 +543,18 @@ MachineInstr &Instr = *SU->getInstr(); - DEBUG(if (verbose) dbgs() << ((Q.getID() == TopQID) ? "(top|" : "(bot|")); + LLVM_DEBUG(if (verbose) dbgs() << ((Q.getID() == TopQID) ? "(top|" : "(bot|")); // Forced priority is high. if (SU->isScheduleHigh) { ResCount += PriorityOne; - DEBUG(dbgs() << "H|"); + LLVM_DEBUG(dbgs() << "H|"); } // Critical path first. if (Q.getID() == TopQID) { ResCount += (SU->getHeight() * ScaleTwo); - DEBUG(if (verbose) { + LLVM_DEBUG(if (verbose) { std::stringstream dbgstr; dbgstr << "h" << std::setw(3) << SU->getHeight() << "|"; dbgs() << dbgstr.str(); @@ -565,13 +565,13 @@ if (Top.ResourceModel->isResourceAvailable(SU)) { ResCount <<= FactorOne; ResCount += PriorityThree; - DEBUG(if (verbose) dbgs() << "A|"); + LLVM_DEBUG(if (verbose) dbgs() << "A|"); } else - DEBUG(if (verbose) dbgs() << " |"); + LLVM_DEBUG(if (verbose) dbgs() << " |"); } else { ResCount += (SU->getDepth() * ScaleTwo); - DEBUG(if (verbose) { + LLVM_DEBUG(if (verbose) { std::stringstream dbgstr; dbgstr << "d" << std::setw(3) << SU->getDepth() << "|"; dbgs() << dbgstr.str(); @@ -582,9 +582,9 @@ if (Bot.ResourceModel->isResourceAvailable(SU)) { ResCount <<= FactorOne; ResCount += PriorityThree; - DEBUG(if (verbose) dbgs() << "A|"); + LLVM_DEBUG(if (verbose) dbgs() << "A|"); } else - DEBUG(if (verbose) dbgs() << " |"); + LLVM_DEBUG(if (verbose) dbgs() << " |"); } unsigned NumNodesBlocking = 0; @@ -604,7 +604,7 @@ } ResCount += (NumNodesBlocking * ScaleTwo); - DEBUG(if (verbose) { + LLVM_DEBUG(if (verbose) { std::stringstream dbgstr; dbgstr << "blk " << std::setw(2) << NumNodesBlocking << ")|"; dbgs() << dbgstr.str(); @@ -619,7 +619,7 @@ // Decrease priority slightly if register pressure would increase over the // current maximum. ResCount -= (Delta.CurrentMax.getUnitInc()*PriorityTwo); - DEBUG(if (verbose) { + LLVM_DEBUG(if (verbose) { dbgs() << "RP " << Delta.Excess.getUnitInc() << "/" << Delta.CriticalMax.getUnitInc() <<"/" << Delta.CurrentMax.getUnitInc() << ")|"; @@ -633,11 +633,11 @@ if (SU->isInstr() && QII.mayBeCurLoad(*SU->getInstr())) { if (Q.getID() == TopQID && Top.ResourceModel->isResourceAvailable(SU)) { ResCount += PriorityTwo; - DEBUG(if (verbose) dbgs() << "C|"); + LLVM_DEBUG(if (verbose) dbgs() << "C|"); } else if (Q.getID() == BotQID && Bot.ResourceModel->isResourceAvailable(SU)) { ResCount += PriorityTwo; - DEBUG(if (verbose) dbgs() << "C|"); + LLVM_DEBUG(if (verbose) dbgs() << "C|"); } } @@ -649,7 +649,7 @@ PI.getLatency() == 0 && Top.ResourceModel->isInPacket(PI.getSUnit())) { ResCount += PriorityThree; - DEBUG(if (verbose) dbgs() << "Z|"); + LLVM_DEBUG(if (verbose) dbgs() << "Z|"); } } } else { @@ -658,7 +658,7 @@ SI.getLatency() == 0 && Bot.ResourceModel->isInPacket(SI.getSUnit())) { ResCount += PriorityThree; - DEBUG(if (verbose) dbgs() << "Z|"); + LLVM_DEBUG(if (verbose) dbgs() << "Z|"); } } } @@ -689,7 +689,7 @@ if (PI.getLatency() > 0 && Top.ResourceModel->isInPacket(PI.getSUnit())) { ResCount -= PriorityOne; - DEBUG(if (verbose) dbgs() << "D|"); + LLVM_DEBUG(if (verbose) dbgs() << "D|"); } } } else { @@ -697,13 +697,13 @@ if (SI.getLatency() > 0 && Bot.ResourceModel->isInPacket(SI.getSUnit())) { ResCount -= PriorityOne; - DEBUG(if (verbose) dbgs() << "D|"); + LLVM_DEBUG(if (verbose) dbgs() << "D|"); } } } } - DEBUG(if (verbose) { + LLVM_DEBUG(if (verbose) { std::stringstream dbgstr; dbgstr << "Total " << std::setw(4) << ResCount << ")"; dbgs() << dbgstr.str(); @@ -720,7 +720,7 @@ ConvergingVLIWScheduler::CandResult ConvergingVLIWScheduler:: pickNodeFromQueue(ReadyQueue &Q, const RegPressureTracker &RPTracker, SchedCandidate &Candidate) { - DEBUG(if (SchedDebugVerboseLevel > 1) + LLVM_DEBUG(if (SchedDebugVerboseLevel > 1) readyQueueVerboseDump(RPTracker, Candidate, Q); else Q.dump();); @@ -739,7 +739,7 @@ // Initialize the candidate if needed. if (!Candidate.SU) { - DEBUG(traceCandidate("DCAND", Q, *I, CurrentCost)); + LLVM_DEBUG(traceCandidate("DCAND", Q, *I, CurrentCost)); Candidate.SU = *I; Candidate.RPDelta = RPDelta; Candidate.SCost = CurrentCost; @@ -749,7 +749,7 @@ // Best cost. if (CurrentCost > Candidate.SCost) { - DEBUG(traceCandidate("CCAND", Q, *I, CurrentCost)); + LLVM_DEBUG(traceCandidate("CCAND", Q, *I, CurrentCost)); Candidate.SU = *I; Candidate.RPDelta = RPDelta; Candidate.SCost = CurrentCost; @@ -768,7 +768,7 @@ unsigned InstrLatency = QII.getInstrTimingClassLatency(InstrItins, *MI); unsigned CandLatency = QII.getInstrTimingClassLatency(InstrItins, *CandI); - DEBUG(dbgs() << "TC Tie Breaker Cand: " + LLVM_DEBUG(dbgs() << "TC Tie Breaker Cand: " << CandLatency << " Instr:" << InstrLatency << "\n" << *MI << *CandI << "\n"); if (Q.getID() == TopQID && CurrentCost == Candidate.SCost) { @@ -777,14 +777,14 @@ Candidate.RPDelta = RPDelta; Candidate.SCost = CurrentCost; FoundCandidate = BestCost; - DEBUG(dbgs() << "Used top shorter tie breaker\n"); + LLVM_DEBUG(dbgs() << "Used top shorter tie breaker\n"); continue; } else if (InstrLatency > CandLatency && !TopUseShorterTie) { Candidate.SU = *I; Candidate.RPDelta = RPDelta; Candidate.SCost = CurrentCost; FoundCandidate = BestCost; - DEBUG(dbgs() << "Used top longer tie breaker\n"); + LLVM_DEBUG(dbgs() << "Used top longer tie breaker\n"); continue; } } else if (Q.getID() == BotQID && CurrentCost == Candidate.SCost) { @@ -793,14 +793,14 @@ Candidate.RPDelta = RPDelta; Candidate.SCost = CurrentCost; FoundCandidate = BestCost; - DEBUG(dbgs() << "Used Bot shorter tie breaker\n"); + LLVM_DEBUG(dbgs() << "Used Bot shorter tie breaker\n"); continue; } else if (InstrLatency > CandLatency && !BotUseShorterTie) { Candidate.SU = *I; Candidate.RPDelta = RPDelta; Candidate.SCost = CurrentCost; FoundCandidate = BestCost; - DEBUG(dbgs() << "Used Bot longer tie breaker\n"); + LLVM_DEBUG(dbgs() << "Used Bot longer tie breaker\n"); continue; } } @@ -811,7 +811,7 @@ (*I)->Succs.size() > Candidate.SU->Succs.size()) || (Q.getID() == BotQID && (*I)->Preds.size() < Candidate.SU->Preds.size())) { - DEBUG(traceCandidate("SPCAND", Q, *I, CurrentCost)); + LLVM_DEBUG(traceCandidate("SPCAND", Q, *I, CurrentCost)); Candidate.SU = *I; Candidate.RPDelta = RPDelta; Candidate.SCost = CurrentCost; @@ -833,12 +833,12 @@ // Schedule as far as possible in the direction of no choice. This is most // efficient, but also provides the best heuristics for CriticalPSets. if (SUnit *SU = Bot.pickOnlyChoice()) { - DEBUG(dbgs() << "Picked only Bottom\n"); + LLVM_DEBUG(dbgs() << "Picked only Bottom\n"); IsTopNode = false; return SU; } if (SUnit *SU = Top.pickOnlyChoice()) { - DEBUG(dbgs() << "Picked only Top\n"); + LLVM_DEBUG(dbgs() << "Picked only Top\n"); IsTopNode = true; return SU; } @@ -856,7 +856,7 @@ // increase pressure for one of the excess PSets, then schedule in that // direction first to provide more freedom in the other direction. if (BotResult == SingleExcess || BotResult == SingleCritical) { - DEBUG(dbgs() << "Prefered Bottom Node\n"); + LLVM_DEBUG(dbgs() << "Prefered Bottom Node\n"); IsTopNode = false; return BotCand.SU; } @@ -867,29 +867,29 @@ assert(TopResult != NoCand && "failed to find the first candidate"); if (TopResult == SingleExcess || TopResult == SingleCritical) { - DEBUG(dbgs() << "Prefered Top Node\n"); + LLVM_DEBUG(dbgs() << "Prefered Top Node\n"); IsTopNode = true; return TopCand.SU; } // If either Q has a single candidate that minimizes pressure above the // original region's pressure pick it. if (BotResult == SingleMax) { - DEBUG(dbgs() << "Prefered Bottom Node SingleMax\n"); + LLVM_DEBUG(dbgs() << "Prefered Bottom Node SingleMax\n"); IsTopNode = false; return BotCand.SU; } if (TopResult == SingleMax) { - DEBUG(dbgs() << "Prefered Top Node SingleMax\n"); + LLVM_DEBUG(dbgs() << "Prefered Top Node SingleMax\n"); IsTopNode = true; return TopCand.SU; } if (TopCand.SCost > BotCand.SCost) { - DEBUG(dbgs() << "Prefered Top Node Cost\n"); + LLVM_DEBUG(dbgs() << "Prefered Top Node Cost\n"); IsTopNode = true; return TopCand.SU; } // Otherwise prefer the bottom candidate in node order. - DEBUG(dbgs() << "Prefered Bottom in Node order\n"); + LLVM_DEBUG(dbgs() << "Prefered Bottom in Node order\n"); IsTopNode = false; return BotCand.SU; } @@ -932,7 +932,7 @@ if (SU->isBottomReady()) Bot.removeReady(SU); - DEBUG(dbgs() << "*** " << (IsTopNode ? "Top" : "Bottom") + LLVM_DEBUG(dbgs() << "*** " << (IsTopNode ? "Top" : "Bottom") << " Scheduling Instruction in cycle " << (IsTopNode ? Top.CurrCycle : Bot.CurrCycle) << '\n'; SU->dump(DAG)); Index: lib/Target/Hexagon/HexagonNewValueJump.cpp =================================================================== --- lib/Target/Hexagon/HexagonNewValueJump.cpp +++ lib/Target/Hexagon/HexagonNewValueJump.cpp @@ -447,7 +447,7 @@ } bool HexagonNewValueJump::runOnMachineFunction(MachineFunction &MF) { - DEBUG(dbgs() << "********** Hexagon New Value Jump **********\n" + LLVM_DEBUG(dbgs() << "********** Hexagon New Value Jump **********\n" << "********** Function: " << MF.getName() << "\n"); if (skipFunction(MF.getFunction())) @@ -473,9 +473,9 @@ MBBb != MBBe; ++MBBb) { MachineBasicBlock *MBB = &*MBBb; - DEBUG(dbgs() << "** dumping bb ** " << MBB->getNumber() << "\n"); - DEBUG(MBB->dump()); - DEBUG(dbgs() << "\n" << "********** dumping instr bottom up **********\n"); + LLVM_DEBUG(dbgs() << "** dumping bb ** " << MBB->getNumber() << "\n"); + LLVM_DEBUG(MBB->dump()); + LLVM_DEBUG(dbgs() << "\n" << "********** dumping instr bottom up **********\n"); bool foundJump = false; bool foundCompare = false; bool invertPredicate = false; @@ -500,7 +500,7 @@ if ((nvjCount == 0) || (nvjCount > -1 && nvjCount <= nvjGenerated)) break; - DEBUG(dbgs() << "Instr: "; MI.dump(); dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Instr: "; MI.dump(); dbgs() << "\n"); if (!foundJump && (MI.getOpcode() == Hexagon::J2_jumpt || MI.getOpcode() == Hexagon::J2_jumptpt || Index: lib/Target/Hexagon/HexagonOptAddrMode.cpp =================================================================== --- lib/Target/Hexagon/HexagonOptAddrMode.cpp +++ lib/Target/Hexagon/HexagonOptAddrMode.cpp @@ -208,7 +208,7 @@ NodeSet Visited, Defs; const auto &P = LV->getAllReachingDefsRec(UR, UN, Visited, Defs); if (!P.second) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "*** Unable to collect all reaching defs for use ***\n" << PrintNode(UN, *DFG) << '\n' << "The program's complexity may exceed the limits.\n"; @@ -217,7 +217,7 @@ } const auto &ReachingDefs = P.first; if (ReachingDefs.size() > 1) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "*** Multiple Reaching Defs found!!! ***\n"; for (auto DI : ReachingDefs) { NodeAddr DA = DFG->addr(DI); @@ -235,7 +235,7 @@ void HexagonOptAddrMode::getAllRealUses(NodeAddr SA, NodeList &UNodeList) { for (NodeAddr DA : SA.Addr->members_if(DFG->IsDef, *DFG)) { - DEBUG(dbgs() << "\t\t[DefNode]: " << Print>(DA, *DFG) + LLVM_DEBUG(dbgs() << "\t\t[DefNode]: " << Print>(DA, *DFG) << "\n"); RegisterRef DR = DFG->getPRI().normalize(DA.Addr->getRegRef(*DFG)); @@ -243,7 +243,7 @@ for (auto UI : UseSet) { NodeAddr UA = DFG->addr(UI); - DEBUG({ + LLVM_DEBUG({ NodeAddr TempIA = UA.Addr->getOwner(*DFG); dbgs() << "\t\t\t[Reached Use]: " << Print>(TempIA, *DFG) << "\n"; @@ -253,7 +253,7 @@ NodeAddr PA = UA.Addr->getOwner(*DFG); NodeId id = PA.Id; const Liveness::RefMap &phiUse = LV->getRealUses(id); - DEBUG(dbgs() << "\t\t\t\tphi real Uses" + LLVM_DEBUG(dbgs() << "\t\t\t\tphi real Uses" << Print(phiUse, *DFG) << "\n"); if (!phiUse.empty()) { for (auto I : phiUse) { @@ -296,7 +296,7 @@ } else if (MI.getOpcode() == Hexagon::S2_addasl_rrri) { NodeList AddaslUseList; - DEBUG(dbgs() << "\nGetting ReachedUses for === " << MI << "\n"); + LLVM_DEBUG(dbgs() << "\nGetting ReachedUses for === " << MI << "\n"); getAllRealUses(SN, AddaslUseList); // Process phi nodes. if (allValidCandidates(SN, AddaslUseList) && @@ -360,8 +360,8 @@ } else Changed = false; - DEBUG(dbgs() << "[Changing]: " << *OldMI << "\n"); - DEBUG(dbgs() << "[TO]: " << *MIB << "\n"); + LLVM_DEBUG(dbgs() << "[Changing]: " << *OldMI << "\n"); + LLVM_DEBUG(dbgs() << "[TO]: " << *MIB << "\n"); } else if (ImmOpNum == 2 && OldMI->getOperand(3).getImm() == 0) { short NewOpCode = HII->changeAddrMode_rr_io(*OldMI); assert(NewOpCode >= 0 && "Invalid New opcode\n"); @@ -371,8 +371,8 @@ MIB.add(ImmOp); OpStart = 4; Changed = true; - DEBUG(dbgs() << "[Changing]: " << *OldMI << "\n"); - DEBUG(dbgs() << "[TO]: " << *MIB << "\n"); + LLVM_DEBUG(dbgs() << "[Changing]: " << *OldMI << "\n"); + LLVM_DEBUG(dbgs() << "[TO]: " << *MIB << "\n"); } if (Changed) @@ -413,8 +413,8 @@ OpStart = 3; } Changed = true; - DEBUG(dbgs() << "[Changing]: " << *OldMI << "\n"); - DEBUG(dbgs() << "[TO]: " << *MIB << "\n"); + LLVM_DEBUG(dbgs() << "[Changing]: " << *OldMI << "\n"); + LLVM_DEBUG(dbgs() << "[TO]: " << *MIB << "\n"); } else if (ImmOpNum == 1 && OldMI->getOperand(2).getImm() == 0) { short NewOpCode = HII->changeAddrMode_rr_io(*OldMI); assert(NewOpCode >= 0 && "Invalid New opcode\n"); @@ -423,8 +423,8 @@ MIB.add(ImmOp); OpStart = 3; Changed = true; - DEBUG(dbgs() << "[Changing]: " << *OldMI << "\n"); - DEBUG(dbgs() << "[TO]: " << *MIB << "\n"); + LLVM_DEBUG(dbgs() << "[Changing]: " << *OldMI << "\n"); + LLVM_DEBUG(dbgs() << "[TO]: " << *MIB << "\n"); } if (Changed) for (unsigned i = OpStart; i < OpEnd; ++i) @@ -447,7 +447,7 @@ unsigned ImmOpNum) { NodeAddr SA = AddAslUN.Addr->getOwner(*DFG); - DEBUG(dbgs() << "Processing addasl :" << *AddAslMI << "\n"); + LLVM_DEBUG(dbgs() << "Processing addasl :" << *AddAslMI << "\n"); NodeList UNodeList; getAllRealUses(SA, UNodeList); @@ -458,10 +458,10 @@ "Can't transform this 'AddAsl' instruction!"); NodeAddr UseIA = UseUN.Addr->getOwner(*DFG); - DEBUG(dbgs() << "[InstrNode]: " << Print>(UseIA, *DFG) + LLVM_DEBUG(dbgs() << "[InstrNode]: " << Print>(UseIA, *DFG) << "\n"); MachineInstr *UseMI = UseIA.Addr->getCode(); - DEBUG(dbgs() << "[MI <" << printMBBReference(*UseMI->getParent()) + LLVM_DEBUG(dbgs() << "[MI <" << printMBBReference(*UseMI->getParent()) << ">]: " << *UseMI << "\n"); const MCInstrDesc &UseMID = UseMI->getDesc(); assert(HII->getAddrMode(*UseMI) == HexagonII::BaseImmOffset); @@ -538,7 +538,7 @@ !MI->getOperand(1).isGlobal()) continue; - DEBUG(dbgs() << "[Analyzing " << HII->getName(MI->getOpcode()) << "]: " + LLVM_DEBUG(dbgs() << "[Analyzing " << HII->getName(MI->getOpcode()) << "]: " << *MI << "\n\t[InstrNode]: " << Print>(IA, *DFG) << '\n'); @@ -561,8 +561,8 @@ bool KeepTfr = false; - DEBUG(dbgs() << "\t[Total reached uses] : " << UNodeList.size() << "\n"); - DEBUG(dbgs() << "\t[Processing Reached Uses] ===\n"); + LLVM_DEBUG(dbgs() << "\t[Total reached uses] : " << UNodeList.size() << "\n"); + LLVM_DEBUG(dbgs() << "\t[Processing Reached Uses] ===\n"); for (auto I = UNodeList.rbegin(), E = UNodeList.rend(); I != E; ++I) { NodeAddr UseN = *I; assert(!(UseN.Addr->getFlags() & NodeAttrs::PhiRef) && @@ -570,7 +570,7 @@ NodeAddr OwnerN = UseN.Addr->getOwner(*DFG); MachineInstr *UseMI = OwnerN.Addr->getCode(); - DEBUG(dbgs() << "\t\t[MI <" << printMBBReference(*UseMI->getParent()) + LLVM_DEBUG(dbgs() << "\t\t[MI <" << printMBBReference(*UseMI->getParent()) << ">]: " << *UseMI << "\n"); int UseMOnum = -1; @@ -619,7 +619,7 @@ Deleted.clear(); NodeAddr FA = DFG->getFunc(); - DEBUG(dbgs() << "==== [RefMap#]=====:\n " + LLVM_DEBUG(dbgs() << "==== [RefMap#]=====:\n " << Print>(FA, *DFG) << "\n"); for (NodeAddr BA : FA.Addr->members(*DFG)) Index: lib/Target/Hexagon/HexagonSplitDouble.cpp =================================================================== --- lib/Target/Hexagon/HexagonSplitDouble.cpp +++ lib/Target/Hexagon/HexagonSplitDouble.cpp @@ -244,7 +244,7 @@ if (FixedRegs[x]) continue; unsigned R = TargetRegisterInfo::index2VirtReg(x); - DEBUG(dbgs() << printReg(R, TRI) << " ~~"); + LLVM_DEBUG(dbgs() << printReg(R, TRI) << " ~~"); USet &Asc = AssocMap[R]; for (auto U = MRI->use_nodbg_begin(R), Z = MRI->use_nodbg_end(); U != Z; ++U) { @@ -267,13 +267,13 @@ unsigned u = TargetRegisterInfo::virtReg2Index(T); if (FixedRegs[u]) continue; - DEBUG(dbgs() << ' ' << printReg(T, TRI)); + LLVM_DEBUG(dbgs() << ' ' << printReg(T, TRI)); Asc.insert(T); // Make it symmetric. AssocMap[T].insert(R); } } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); } UUMap R2P; @@ -442,7 +442,7 @@ if (FixedNum > 0 && LoopPhiNum > 0) TotalP -= 20*LoopPhiNum; - DEBUG(dbgs() << "Partition profit: " << TotalP << '\n'); + LLVM_DEBUG(dbgs() << "Partition profit: " << TotalP << '\n'); return TotalP > 0; } @@ -535,7 +535,7 @@ Rs.insert(CmpR1); Rs.insert(CmpR2); - DEBUG({ + LLVM_DEBUG({ dbgs() << "For loop at " << printMBBReference(*HB) << " ind regs: "; dump_partition(dbgs(), Rs, *TRI); dbgs() << '\n'; @@ -970,7 +970,7 @@ const UUPairMap &PairMap) { using namespace Hexagon; - DEBUG(dbgs() << "Splitting: " << *MI); + LLVM_DEBUG(dbgs() << "Splitting: " << *MI); bool Split = false; unsigned Opc = MI->getOpcode(); @@ -1104,7 +1104,7 @@ const TargetRegisterClass *IntRC = &Hexagon::IntRegsRegClass; bool Changed = false; - DEBUG(dbgs() << "Splitting partition: "; dump_partition(dbgs(), Part, *TRI); + LLVM_DEBUG(dbgs() << "Splitting partition: "; dump_partition(dbgs(), Part, *TRI); dbgs() << '\n'); UUPairMap PairMap; @@ -1122,7 +1122,7 @@ unsigned LoR = MRI->createVirtualRegister(IntRC); unsigned HiR = MRI->createVirtualRegister(IntRC); - DEBUG(dbgs() << "Created mapping: " << printReg(DR, TRI) << " -> " + LLVM_DEBUG(dbgs() << "Created mapping: " << printReg(DR, TRI) << " -> " << printReg(HiR, TRI) << ':' << printReg(LoR, TRI) << '\n'); PairMap.insert(std::make_pair(DR, UUPair(LoR, HiR))); } @@ -1160,7 +1160,7 @@ } bool HexagonSplitDoubleRegs::runOnMachineFunction(MachineFunction &MF) { - DEBUG(dbgs() << "Splitting double registers in function: " + LLVM_DEBUG(dbgs() << "Splitting double registers in function: " << MF.getName() << '\n'); if (skipFunction(MF.getFunction())) @@ -1178,7 +1178,7 @@ collectIndRegs(IRM); partitionRegisters(P2Rs); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Register partitioning: (partition #0 is fixed)\n"; for (UUSetMap::iterator I = P2Rs.begin(), E = P2Rs.end(); I != E; ++I) { dbgs() << '#' << I->first << " -> "; @@ -1196,7 +1196,7 @@ if (Limit >= 0 && Counter >= Limit) break; USet &Part = I->second; - DEBUG(dbgs() << "Calculating profit for partition #" << I->first << '\n'); + LLVM_DEBUG(dbgs() << "Calculating profit for partition #" << I->first << '\n'); if (!isProfitable(Part, IRM)) continue; Counter++; Index: lib/Target/Hexagon/HexagonStoreWidening.cpp =================================================================== --- lib/Target/Hexagon/HexagonStoreWidening.cpp +++ lib/Target/Hexagon/HexagonStoreWidening.cpp @@ -472,7 +472,7 @@ // from OG was (in the order in which they appeared in the basic block). // (The ordering in OG does not have to match the order in the basic block.) bool HexagonStoreWidening::replaceStores(InstrGroup &OG, InstrGroup &NG) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "Replacing:\n"; for (auto I : OG) dbgs() << " " << *I; Index: lib/Target/Hexagon/HexagonTargetObjectFile.cpp =================================================================== --- lib/Target/Hexagon/HexagonTargetObjectFile.cpp +++ lib/Target/Hexagon/HexagonTargetObjectFile.cpp @@ -74,7 +74,7 @@ if (TraceGVPlacement) { \ TRACE_TO(errs(), X); \ } else { \ - DEBUG(TRACE_TO(dbgs(), X)); \ + LLVM_DEBUG(TRACE_TO(dbgs(), X)); \ } \ } while (false) #endif @@ -200,11 +200,11 @@ bool HexagonTargetObjectFile::isGlobalInSmallSection(const GlobalObject *GO, const TargetMachine &TM) const { // Only global variables, not functions. - DEBUG(dbgs() << "Checking if value is in small-data, -G" + LLVM_DEBUG(dbgs() << "Checking if value is in small-data, -G" << SmallDataThreshold << ": \"" << GO->getName() << "\": "); const GlobalVariable *GVar = dyn_cast(GO); if (!GVar) { - DEBUG(dbgs() << "no, not a global variable\n"); + LLVM_DEBUG(dbgs() << "no, not a global variable\n"); return false; } @@ -213,19 +213,19 @@ // small data or not. This is how we can support mixing -G0/-G8 in LTO. if (GVar->hasSection()) { bool IsSmall = isSmallDataSection(GVar->getSection()); - DEBUG(dbgs() << (IsSmall ? "yes" : "no") << ", has section: " + LLVM_DEBUG(dbgs() << (IsSmall ? "yes" : "no") << ", has section: " << GVar->getSection() << '\n'); return IsSmall; } if (GVar->isConstant()) { - DEBUG(dbgs() << "no, is a constant\n"); + LLVM_DEBUG(dbgs() << "no, is a constant\n"); return false; } bool IsLocal = GVar->hasLocalLinkage(); if (!StaticsInSData && IsLocal) { - DEBUG(dbgs() << "no, is static\n"); + LLVM_DEBUG(dbgs() << "no, is static\n"); return false; } @@ -234,7 +234,7 @@ GType = PT->getElementType(); if (isa(GType)) { - DEBUG(dbgs() << "no, is an array\n"); + LLVM_DEBUG(dbgs() << "no, is an array\n"); return false; } @@ -244,22 +244,22 @@ // these objects end up in the sdata, the references will still be valid. if (StructType *ST = dyn_cast(GType)) { if (ST->isOpaque()) { - DEBUG(dbgs() << "no, has opaque type\n"); + LLVM_DEBUG(dbgs() << "no, has opaque type\n"); return false; } } unsigned Size = GVar->getParent()->getDataLayout().getTypeAllocSize(GType); if (Size == 0) { - DEBUG(dbgs() << "no, has size 0\n"); + LLVM_DEBUG(dbgs() << "no, has size 0\n"); return false; } if (Size > SmallDataThreshold) { - DEBUG(dbgs() << "no, size exceeds sdata threshold: " << Size << '\n'); + LLVM_DEBUG(dbgs() << "no, size exceeds sdata threshold: " << Size << '\n'); return false; } - DEBUG(dbgs() << "yes\n"); + LLVM_DEBUG(dbgs() << "yes\n"); return true; } Index: lib/Target/Hexagon/HexagonVLIWPacketizer.cpp =================================================================== --- lib/Target/Hexagon/HexagonVLIWPacketizer.cpp +++ lib/Target/Hexagon/HexagonVLIWPacketizer.cpp @@ -374,7 +374,7 @@ void HexagonPacketizerList::cleanUpDotCur() { MachineInstr *MI = nullptr; for (auto BI : CurrentPacketMIs) { - DEBUG(dbgs() << "Cleanup packet has "; BI->dump();); + LLVM_DEBUG(dbgs() << "Cleanup packet has "; BI->dump();); if (HII->isDotCurInst(*BI)) { MI = BI; continue; @@ -389,7 +389,7 @@ return; // We did not find a use of the CUR, so de-cur it. MI->setDesc(HII->get(HII->getNonDotCurOp(*MI))); - DEBUG(dbgs() << "Demoted CUR "; MI->dump();); + LLVM_DEBUG(dbgs() << "Demoted CUR "; MI->dump();); } // Check to see if an instruction can be dot cur. @@ -413,11 +413,11 @@ return false; // Make sure candidate instruction uses cur. - DEBUG(dbgs() << "Can we DOT Cur Vector MI\n"; + LLVM_DEBUG(dbgs() << "Can we DOT Cur Vector MI\n"; MI.dump(); dbgs() << "in packet\n";); MachineInstr &MJ = *MII; - DEBUG({ + LLVM_DEBUG({ dbgs() << "Checking CUR against "; MJ.dump(); }); @@ -432,12 +432,12 @@ // Check for existing uses of a vector register within the packet which // would be affected by converting a vector load into .cur formt. for (auto BI : CurrentPacketMIs) { - DEBUG(dbgs() << "packet has "; BI->dump();); + LLVM_DEBUG(dbgs() << "packet has "; BI->dump();); if (BI->readsRegister(DepReg, MF.getSubtarget().getRegisterInfo())) return false; } - DEBUG(dbgs() << "Can Dot CUR MI\n"; MI.dump();); + LLVM_DEBUG(dbgs() << "Can Dot CUR MI\n"; MI.dump();); // We can convert the opcode into a .cur. return true; } @@ -1754,7 +1754,7 @@ bool memShufDisabled = getmemShufDisabled(); if (memShufDisabled && !foundLSInPacket()) { setmemShufDisabled(false); - DEBUG(dbgs() << " Not added to NoShufPacket\n"); + LLVM_DEBUG(dbgs() << " Not added to NoShufPacket\n"); } memShufDisabled = getmemShufDisabled(); @@ -1773,7 +1773,7 @@ CurrentPacketMIs.clear(); ResourceTracker->clearResources(); - DEBUG(dbgs() << "End packet\n"); + LLVM_DEBUG(dbgs() << "End packet\n"); } bool HexagonPacketizerList::shouldAddToPacket(const MachineInstr &MI) { Index: lib/Target/Hexagon/HexagonVectorLoopCarriedReuse.cpp =================================================================== --- lib/Target/Hexagon/HexagonVectorLoopCarriedReuse.cpp +++ lib/Target/Hexagon/HexagonVectorLoopCarriedReuse.cpp @@ -363,16 +363,16 @@ if (II && (II->getIntrinsicID() == Intrinsic::hexagon_V6_hi || II->getIntrinsicID() == Intrinsic::hexagon_V6_lo)) { - DEBUG(dbgs() << "Not considering for reuse: " << *II << "\n"); + LLVM_DEBUG(dbgs() << "Not considering for reuse: " << *II << "\n"); return false; } return true; } void HexagonVectorLoopCarriedReuse::findValueToReuse() { for (auto *D : Dependences) { - DEBUG(dbgs() << "Processing dependence " << *(D->front()) << "\n"); + LLVM_DEBUG(dbgs() << "Processing dependence " << *(D->front()) << "\n"); if (D->iterations() > HexagonVLCRIterationLim) { - DEBUG(dbgs() << + LLVM_DEBUG(dbgs() << ".. Skipping because number of iterations > than the limit\n"); continue; } @@ -381,7 +381,7 @@ Instruction *BEInst = D->back(); int Iters = D->iterations(); BasicBlock *BB = PN->getParent(); - DEBUG(dbgs() << "Checking if any uses of " << *PN << " can be reused\n"); + LLVM_DEBUG(dbgs() << "Checking if any uses of " << *PN << " can be reused\n"); SmallVector PNUsers; for (auto UI = PN->use_begin(), E = PN->use_end(); UI != E; ++UI) { @@ -391,7 +391,7 @@ if (User->getParent() != BB) continue; if (ReplacedInsts.count(User)) { - DEBUG(dbgs() << *User << " has already been replaced. Skipping...\n"); + LLVM_DEBUG(dbgs() << *User << " has already been replaced. Skipping...\n"); continue; } if (isa(User)) @@ -403,7 +403,7 @@ PNUsers.push_back(User); } - DEBUG(dbgs() << PNUsers.size() << " use(s) of the PHI in the block\n"); + LLVM_DEBUG(dbgs() << PNUsers.size() << " use(s) of the PHI in the block\n"); // For each interesting use I of PN, find an Instruction BEUser that // performs the same operation as I on BEInst and whose other operands, @@ -439,7 +439,7 @@ } } if (BEUser) { - DEBUG(dbgs() << "Found Value for reuse.\n"); + LLVM_DEBUG(dbgs() << "Found Value for reuse.\n"); ReuseCandidate.Inst2Replace = I; ReuseCandidate.BackedgeInst = BEUser; return; @@ -460,7 +460,7 @@ } void HexagonVectorLoopCarriedReuse::reuseValue() { - DEBUG(dbgs() << ReuseCandidate); + LLVM_DEBUG(dbgs() << ReuseCandidate); Instruction *Inst2Replace = ReuseCandidate.Inst2Replace; Instruction *BEInst = ReuseCandidate.BackedgeInst; int NumOperands = Inst2Replace->getNumOperands(); @@ -485,7 +485,7 @@ } } - DEBUG(dbgs() << "reuseValue is making the following changes\n"); + LLVM_DEBUG(dbgs() << "reuseValue is making the following changes\n"); SmallVector InstsInPreheader; for (int i = 0; i < Iterations; ++i) { @@ -506,7 +506,7 @@ InstsInPreheader.push_back(InstInPreheader); InstInPreheader->setName(Inst2Replace->getName() + ".hexagon.vlcr"); InstInPreheader->insertBefore(LoopPH->getTerminator()); - DEBUG(dbgs() << "Added " << *InstInPreheader << " to " << LoopPH->getName() + LLVM_DEBUG(dbgs() << "Added " << *InstInPreheader << " to " << LoopPH->getName() << "\n"); } BasicBlock *BB = BEInst->getParent(); @@ -519,7 +519,7 @@ NewPhi = IRB.CreatePHI(InstInPreheader->getType(), 2); NewPhi->addIncoming(InstInPreheader, LoopPH); NewPhi->addIncoming(BEVal, BB); - DEBUG(dbgs() << "Adding " << *NewPhi << " to " << BB->getName() << "\n"); + LLVM_DEBUG(dbgs() << "Adding " << *NewPhi << " to " << BB->getName() << "\n"); BEVal = NewPhi; } // We are in LCSSA form. So, a value defined inside the Loop is used only @@ -538,7 +538,7 @@ bool Changed = false; bool Continue; - DEBUG(dbgs() << "Working on Loop: " << *CurLoop->getHeader() << "\n"); + LLVM_DEBUG(dbgs() << "Working on Loop: " << *CurLoop->getHeader() << "\n"); do { // Reset datastructures. Dependences.clear(); @@ -625,8 +625,8 @@ else delete D; } - DEBUG(dbgs() << "Found " << Dependences.size() << " dependences\n"); - DEBUG(for (size_t i = 0; i < Dependences.size(); ++i) { + LLVM_DEBUG(dbgs() << "Found " << Dependences.size() << " dependences\n"); + LLVM_DEBUG(for (size_t i = 0; i < Dependences.size(); ++i) { dbgs() << *Dependences[i] << "\n"; }); } Index: lib/Target/Hexagon/HexagonVectorPrint.cpp =================================================================== --- lib/Target/Hexagon/HexagonVectorPrint.cpp +++ lib/Target/Hexagon/HexagonVectorPrint.cpp @@ -144,14 +144,14 @@ unsigned Reg = 0; if (getInstrVecReg(*MII, Reg)) { VecPrintList.push_back((&*MII)); - DEBUG(dbgs() << "Found vector reg inside bundle \n"; MII->dump()); + LLVM_DEBUG(dbgs() << "Found vector reg inside bundle \n"; MII->dump()); } } } else { unsigned Reg = 0; if (getInstrVecReg(MI, Reg)) { VecPrintList.push_back(&MI); - DEBUG(dbgs() << "Found vector reg \n"; MI.dump()); + LLVM_DEBUG(dbgs() << "Found vector reg \n"; MI.dump()); } } } @@ -163,33 +163,33 @@ for (auto *I : VecPrintList) { DebugLoc DL = I->getDebugLoc(); MachineBasicBlock *MBB = I->getParent(); - DEBUG(dbgs() << "Evaluating V MI\n"; I->dump()); + LLVM_DEBUG(dbgs() << "Evaluating V MI\n"; I->dump()); unsigned Reg = 0; if (!getInstrVecReg(*I, Reg)) llvm_unreachable("Need a vector reg"); MachineBasicBlock::instr_iterator MII = I->getIterator(); if (I->isInsideBundle()) { - DEBUG(dbgs() << "add to end of bundle\n"; I->dump()); + LLVM_DEBUG(dbgs() << "add to end of bundle\n"; I->dump()); while (MBB->instr_end() != MII && MII->isInsideBundle()) MII++; } else { - DEBUG(dbgs() << "add after instruction\n"; I->dump()); + LLVM_DEBUG(dbgs() << "add after instruction\n"; I->dump()); MII++; } if (MBB->instr_end() == MII) continue; if (Reg >= Hexagon::V0 && Reg <= Hexagon::V31) { - DEBUG(dbgs() << "adding dump for V" << Reg-Hexagon::V0 << '\n'); + LLVM_DEBUG(dbgs() << "adding dump for V" << Reg-Hexagon::V0 << '\n'); addAsmInstr(MBB, Reg, MII, DL, QII, Fn); } else if (Reg >= Hexagon::W0 && Reg <= Hexagon::W15) { - DEBUG(dbgs() << "adding dump for W" << Reg-Hexagon::W0 << '\n'); + LLVM_DEBUG(dbgs() << "adding dump for W" << Reg-Hexagon::W0 << '\n'); addAsmInstr(MBB, Hexagon::V0 + (Reg - Hexagon::W0) * 2 + 1, MII, DL, QII, Fn); addAsmInstr(MBB, Hexagon::V0 + (Reg - Hexagon::W0) * 2, MII, DL, QII, Fn); } else if (Reg >= Hexagon::Q0 && Reg <= Hexagon::Q3) { - DEBUG(dbgs() << "adding dump for Q" << Reg-Hexagon::Q0 << '\n'); + LLVM_DEBUG(dbgs() << "adding dump for Q" << Reg-Hexagon::Q0 << '\n'); addAsmInstr(MBB, Reg, MII, DL, QII, Fn); } else llvm_unreachable("Bad Vector reg"); Index: lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp =================================================================== --- lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp +++ lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp @@ -510,9 +510,9 @@ break; } - DEBUG(dbgs() << "Name=" << getFixupKindInfo(Kind).Name << "(" << + LLVM_DEBUG(dbgs() << "Name=" << getFixupKindInfo(Kind).Name << "(" << (unsigned)Kind << ")\n"); - DEBUG(uint32_t OldData = 0; + LLVM_DEBUG(uint32_t OldData = 0; for (unsigned i = 0; i < NumBytes; i++) OldData |= (InstAddr[i] << (i * 8)) & (0xff << (i * 8)); dbgs() << "\tBValue=0x"; dbgs().write_hex(Value) << @@ -530,7 +530,7 @@ InstAddr[i] |= uint8_t(Reloc >> (i * 8)) & 0xff; // Apply new reloc } - DEBUG(uint32_t NewData = 0; + LLVM_DEBUG(uint32_t NewData = 0; for (unsigned i = 0; i < NumBytes; i++) NewData |= (InstAddr[i] << (i * 8)) & (0xff << (i * 8)); dbgs() << ": NInst=0x"; dbgs().write_hex(NewData) << "\n";); @@ -689,7 +689,7 @@ ParseEnd = 0x0000c000; // End of packet parse-bits. while(Count % HEXAGON_INSTR_SIZE) { - DEBUG(dbgs() << "Alignment not a multiple of the instruction size:" << + LLVM_DEBUG(dbgs() << "Alignment not a multiple of the instruction size:" << Count % HEXAGON_INSTR_SIZE << "/" << HEXAGON_INSTR_SIZE << "\n"); --Count; OW->write8(0); Index: lib/Target/Hexagon/MCTargetDesc/HexagonMCCodeEmitter.cpp =================================================================== --- lib/Target/Hexagon/MCTargetDesc/HexagonMCCodeEmitter.cpp +++ lib/Target/Hexagon/MCTargetDesc/HexagonMCCodeEmitter.cpp @@ -82,7 +82,7 @@ MCInst &HMB = const_cast(MI); assert(HexagonMCInstrInfo::isBundle(HMB)); - DEBUG(dbgs() << "Encoding bundle\n";); + LLVM_DEBUG(dbgs() << "Encoding bundle\n";); *Addend = 0; *Extended = false; *CurrentBundle = &MI; @@ -125,7 +125,7 @@ // in the first place! assert(!HexagonMCInstrInfo::getDesc(MCII, MI).isPseudo() && "pseudo-instruction found"); - DEBUG(dbgs() << "Encoding insn" + LLVM_DEBUG(dbgs() << "Encoding insn" " `" << HexagonMCInstrInfo::getName(MCII, MI) << "'" "\n"); @@ -135,7 +135,7 @@ if (!Binary && MI.getOpcode() != DuplexIClass0 && MI.getOpcode() != A4_ext) { - DEBUG(dbgs() << "Unimplemented inst: " + LLVM_DEBUG(dbgs() << "Unimplemented inst: " " `" << HexagonMCInstrInfo::getName(MCII, MI) << "'" "\n"); llvm_unreachable("Unimplemented Instruction"); @@ -368,13 +368,13 @@ HexagonMCInstrInfo::getExtentAlignment(MCII, MI); const MCSymbolRefExpr::VariantKind kind = MCSRE->getKind(); - DEBUG(dbgs() << "----------------------------------------\n"); - DEBUG(dbgs() << "Opcode Name: " << HexagonMCInstrInfo::getName(MCII, MI) + LLVM_DEBUG(dbgs() << "----------------------------------------\n"); + LLVM_DEBUG(dbgs() << "Opcode Name: " << HexagonMCInstrInfo::getName(MCII, MI) << "\n"); - DEBUG(dbgs() << "Opcode: " << MCID.getOpcode() << "\n"); - DEBUG(dbgs() << "Relocation bits: " << bits << "\n"); - DEBUG(dbgs() << "Addend: " << *Addend << "\n"); - DEBUG(dbgs() << "----------------------------------------\n"); + LLVM_DEBUG(dbgs() << "Opcode: " << MCID.getOpcode() << "\n"); + LLVM_DEBUG(dbgs() << "Relocation bits: " << bits << "\n"); + LLVM_DEBUG(dbgs() << "Addend: " << *Addend << "\n"); + LLVM_DEBUG(dbgs() << "----------------------------------------\n"); switch (bits) { default: Index: lib/Target/Hexagon/MCTargetDesc/HexagonMCCompound.cpp =================================================================== --- lib/Target/Hexagon/MCTargetDesc/HexagonMCCompound.cpp +++ lib/Target/Hexagon/MCTargetDesc/HexagonMCCompound.cpp @@ -205,7 +205,7 @@ switch (L.getOpcode()) { default: - DEBUG(dbgs() << "Possible compound ignored\n"); + LLVM_DEBUG(dbgs() << "Possible compound ignored\n"); return CompoundInsn; case Hexagon::A2_tfrsi: @@ -233,7 +233,7 @@ break; case Hexagon::C2_cmpeq: - DEBUG(dbgs() << "CX: C2_cmpeq\n"); + LLVM_DEBUG(dbgs() << "CX: C2_cmpeq\n"); Rs = L.getOperand(1); Rt = L.getOperand(2); @@ -246,7 +246,7 @@ break; case Hexagon::C2_cmpgt: - DEBUG(dbgs() << "CX: C2_cmpgt\n"); + LLVM_DEBUG(dbgs() << "CX: C2_cmpgt\n"); Rs = L.getOperand(1); Rt = L.getOperand(2); @@ -259,7 +259,7 @@ break; case Hexagon::C2_cmpgtu: - DEBUG(dbgs() << "CX: C2_cmpgtu\n"); + LLVM_DEBUG(dbgs() << "CX: C2_cmpgtu\n"); Rs = L.getOperand(1); Rt = L.getOperand(2); @@ -272,7 +272,7 @@ break; case Hexagon::C2_cmpeqi: - DEBUG(dbgs() << "CX: C2_cmpeqi\n"); + LLVM_DEBUG(dbgs() << "CX: C2_cmpeqi\n"); Success = L.getOperand(2).getExpr()->evaluateAsAbsolute(Value); (void)Success; assert(Success); @@ -290,7 +290,7 @@ break; case Hexagon::C2_cmpgti: - DEBUG(dbgs() << "CX: C2_cmpgti\n"); + LLVM_DEBUG(dbgs() << "CX: C2_cmpgti\n"); Success = L.getOperand(2).getExpr()->evaluateAsAbsolute(Value); (void)Success; assert(Success); @@ -308,7 +308,7 @@ break; case Hexagon::C2_cmpgtui: - DEBUG(dbgs() << "CX: C2_cmpgtui\n"); + LLVM_DEBUG(dbgs() << "CX: C2_cmpgtui\n"); Rs = L.getOperand(1); compoundOpcode = cmpgtuiBitOpcode[getCompoundOp(R)]; CompoundInsn = new (Context) MCInst; @@ -319,7 +319,7 @@ break; case Hexagon::S2_tstbit_i: - DEBUG(dbgs() << "CX: S2_tstbit_i\n"); + LLVM_DEBUG(dbgs() << "CX: S2_tstbit_i\n"); Rs = L.getOperand(1); compoundOpcode = tstBitOpcode[getCompoundOp(R)]; CompoundInsn = new (Context) MCInst; @@ -372,12 +372,12 @@ BExtended = true; continue; } - DEBUG(dbgs() << "J,B: " << JumpInst->getOpcode() << "," + LLVM_DEBUG(dbgs() << "J,B: " << JumpInst->getOpcode() << "," << Inst->getOpcode() << "\n"); if (isOrderedCompoundPair(*Inst, BExtended, *JumpInst, JExtended)) { MCInst *CompoundInsn = getCompoundInsn(Context, *Inst, *JumpInst); if (CompoundInsn) { - DEBUG(dbgs() << "B: " << Inst->getOpcode() << "," + LLVM_DEBUG(dbgs() << "B: " << Inst->getOpcode() << "," << JumpInst->getOpcode() << " Compounds to " << CompoundInsn->getOpcode() << "\n"); J->setInst(CompoundInsn); @@ -422,7 +422,7 @@ if (StartedValid && !llvm::HexagonMCShuffle(Context, false, MCII, STI, MCI)) { - DEBUG(dbgs() << "Found ERROR\n"); + LLVM_DEBUG(dbgs() << "Found ERROR\n"); MCI = OriginalBundle; } } Index: lib/Target/Hexagon/MCTargetDesc/HexagonMCDuplexInfo.cpp =================================================================== --- lib/Target/Hexagon/MCTargetDesc/HexagonMCDuplexInfo.cpp +++ lib/Target/Hexagon/MCTargetDesc/HexagonMCDuplexInfo.cpp @@ -1045,7 +1045,7 @@ bool bisReversable = true; if (isStoreInst(MCB.getOperand(j).getInst()->getOpcode()) && isStoreInst(MCB.getOperand(k).getInst()->getOpcode())) { - DEBUG(dbgs() << "skip out of order write pair: " << k << "," << j + LLVM_DEBUG(dbgs() << "skip out of order write pair: " << k << "," << j << "\n"); bisReversable = false; } @@ -1066,12 +1066,12 @@ // Save off pairs for duplex checking. duplexToTry.push_back(DuplexCandidate(j, k, iClass)); - DEBUG(dbgs() << "adding pair: " << j << "," << k << ":" + LLVM_DEBUG(dbgs() << "adding pair: " << j << "," << k << ":" << MCB.getOperand(j).getInst()->getOpcode() << "," << MCB.getOperand(k).getInst()->getOpcode() << "\n"); continue; } else { - DEBUG(dbgs() << "skipping pair: " << j << "," << k << ":" + LLVM_DEBUG(dbgs() << "skipping pair: " << j << "," << k << ":" << MCB.getOperand(j).getInst()->getOpcode() << "," << MCB.getOperand(k).getInst()->getOpcode() << "\n"); } @@ -1091,11 +1091,11 @@ // Save off pairs for duplex checking. duplexToTry.push_back(DuplexCandidate(k, j, iClass)); - DEBUG(dbgs() << "adding pair:" << k << "," << j << ":" + LLVM_DEBUG(dbgs() << "adding pair:" << k << "," << j << ":" << MCB.getOperand(j).getInst()->getOpcode() << "," << MCB.getOperand(k).getInst()->getOpcode() << "\n"); } else { - DEBUG(dbgs() << "skipping pair: " << k << "," << j << ":" + LLVM_DEBUG(dbgs() << "skipping pair: " << k << "," << j << ":" << MCB.getOperand(j).getInst()->getOpcode() << "," << MCB.getOperand(k).getInst()->getOpcode() << "\n"); } Index: lib/Target/Hexagon/MCTargetDesc/HexagonMCShuffler.cpp =================================================================== --- lib/Target/Hexagon/MCTargetDesc/HexagonMCShuffler.cpp +++ lib/Target/Hexagon/MCTargetDesc/HexagonMCShuffler.cpp @@ -38,7 +38,7 @@ // Copy the bundle for the shuffling. for (const auto &I : HexagonMCInstrInfo::bundleInstructions(MCB)) { MCInst &MI = *const_cast(I.getInst()); - DEBUG(dbgs() << "Shuffling: " << MCII.getName(MI.getOpcode()) << '\n'); + LLVM_DEBUG(dbgs() << "Shuffling: " << MCII.getName(MI.getOpcode()) << '\n'); assert(!HexagonMCInstrInfo::getDesc(MCII, MI).isPseudo()); if (!HexagonMCInstrInfo::isImmext(MI)) { @@ -98,7 +98,7 @@ copyTo(MCB); return true; } - DEBUG(MCB.dump()); + LLVM_DEBUG(MCB.dump()); return false; } @@ -119,10 +119,10 @@ // * %d7 = IMPLICIT_DEF; flags: // After the IMPLICIT_DEFs were removed by the asm printer, the bundle // became empty. - DEBUG(dbgs() << "Skipping empty bundle"); + LLVM_DEBUG(dbgs() << "Skipping empty bundle"); return false; } else if (!HexagonMCInstrInfo::isBundle(MCB)) { - DEBUG(dbgs() << "Skipping stand-alone insn"); + LLVM_DEBUG(dbgs() << "Skipping stand-alone insn"); return false; } @@ -144,10 +144,10 @@ // * %d7 = IMPLICIT_DEF; flags: // After the IMPLICIT_DEFs were removed by the asm printer, the bundle // became empty. - DEBUG(dbgs() << "Skipping empty bundle"); + LLVM_DEBUG(dbgs() << "Skipping empty bundle"); return false; } else if (!HexagonMCInstrInfo::isBundle(MCB)) { - DEBUG(dbgs() << "Skipping stand-alone insn"); + LLVM_DEBUG(dbgs() << "Skipping stand-alone insn"); return false; } Index: lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.cpp =================================================================== --- lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.cpp +++ lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.cpp @@ -641,14 +641,14 @@ } for (iterator ISJ = begin(); ISJ != end(); ++ISJ) - DEBUG(dbgs().write_hex(ISJ->Core.getUnits()); if (ISJ->CVI.isValid()) { + LLVM_DEBUG(dbgs().write_hex(ISJ->Core.getUnits()); if (ISJ->CVI.isValid()) { dbgs() << '/'; dbgs().write_hex(ISJ->CVI.getUnits()) << '|'; dbgs() << ISJ->CVI.getLanes(); } dbgs() << ':' << HexagonMCInstrInfo::getDesc(MCII, ISJ->getDesc()).getOpcode(); dbgs() << '\n'); - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); return Ok; } Index: lib/Target/Lanai/LanaiISelDAGToDAG.cpp =================================================================== --- lib/Target/Lanai/LanaiISelDAGToDAG.cpp +++ lib/Target/Lanai/LanaiISelDAGToDAG.cpp @@ -275,7 +275,7 @@ // If we have a custom node, we already have selected! if (Node->isMachineOpcode()) { - DEBUG(errs() << "== "; Node->dump(CurDAG); errs() << "\n"); + LLVM_DEBUG(errs() << "== "; Node->dump(CurDAG); errs() << "\n"); return; } Index: lib/Target/Lanai/LanaiISelLowering.cpp =================================================================== --- lib/Target/Lanai/LanaiISelLowering.cpp +++ lib/Target/Lanai/LanaiISelLowering.cpp @@ -484,7 +484,7 @@ break; } default: - DEBUG(dbgs() << "LowerFormalArguments Unhandled argument type: " + LLVM_DEBUG(dbgs() << "LowerFormalArguments Unhandled argument type: " << RegVT.getEVTString() << "\n"); llvm_unreachable("unhandled argument type"); } Index: lib/Target/MSP430/MSP430BranchSelector.cpp =================================================================== --- lib/Target/MSP430/MSP430BranchSelector.cpp +++ lib/Target/MSP430/MSP430BranchSelector.cpp @@ -138,14 +138,14 @@ continue; } - DEBUG(dbgs() << " Found a branch that needs expanding, " + LLVM_DEBUG(dbgs() << " Found a branch that needs expanding, " << printMBBReference(*DestBB) << ", Distance " << BranchDistance << "\n"); // If JCC is not the last instruction we need to split the MBB. if (MI->getOpcode() == MSP430::JCC && std::next(MI) != EE) { - DEBUG(dbgs() << " Found a basic block that needs to be split, " + LLVM_DEBUG(dbgs() << " Found a basic block that needs to be split, " << printMBBReference(*MBB) << "\n"); // Create a new basic block. @@ -229,7 +229,7 @@ if (!BranchSelectEnabled) return false; - DEBUG(dbgs() << "\n********** " << getPassName() << " **********\n"); + LLVM_DEBUG(dbgs() << "\n********** " << getPassName() << " **********\n"); // BlockOffsets - Contains the distance from the beginning of the function to // the beginning of each basic block. Index: lib/Target/MSP430/MSP430ISelDAGToDAG.cpp =================================================================== --- lib/Target/MSP430/MSP430ISelDAGToDAG.cpp +++ lib/Target/MSP430/MSP430ISelDAGToDAG.cpp @@ -179,7 +179,7 @@ } bool MSP430DAGToDAGISel::MatchAddress(SDValue N, MSP430ISelAddressMode &AM) { - DEBUG(errs() << "MatchAddress: "; AM.dump()); + LLVM_DEBUG(errs() << "MatchAddress: "; AM.dump()); switch (N.getOpcode()) { default: break; @@ -383,7 +383,7 @@ // If we have a custom node, we already have selected! if (Node->isMachineOpcode()) { - DEBUG(errs() << "== "; + LLVM_DEBUG(errs() << "== "; Node->dump(CurDAG); errs() << "\n"); Node->setNodeId(-1); Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp =================================================================== --- lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -1471,7 +1471,7 @@ static std::unique_ptr createNumericReg(unsigned Index, StringRef Str, const MCRegisterInfo *RegInfo, SMLoc S, SMLoc E, MipsAsmParser &Parser) { - DEBUG(dbgs() << "createNumericReg(" << Index << ", ...)\n"); + LLVM_DEBUG(dbgs() << "createNumericReg(" << Index << ", ...)\n"); return CreateReg(Index, Str, RegKind_Numeric, RegInfo, S, E, Parser); } @@ -5654,7 +5654,7 @@ bool MipsAsmParser::parseOperand(OperandVector &Operands, StringRef Mnemonic) { MCAsmParser &Parser = getParser(); - DEBUG(dbgs() << "parseOperand\n"); + LLVM_DEBUG(dbgs() << "parseOperand\n"); // Check if the current operand has a custom associated parser, if so, try to // custom parse the operand, or fallback to the general approach. @@ -5667,7 +5667,7 @@ if (ResTy == MatchOperand_ParseFail) return true; - DEBUG(dbgs() << ".. Generic Parser\n"); + LLVM_DEBUG(dbgs() << ".. Generic Parser\n"); switch (getLexer().getKind()) { case AsmToken::Dollar: { @@ -5697,7 +5697,7 @@ return false; } default: { - DEBUG(dbgs() << ".. generic integer expression\n"); + LLVM_DEBUG(dbgs() << ".. generic integer expression\n"); const MCExpr *Expr; SMLoc S = Parser.getTok().getLoc(); // Start location of the operand. @@ -5770,7 +5770,7 @@ OperandMatchResultTy MipsAsmParser::parseMemOperand(OperandVector &Operands) { MCAsmParser &Parser = getParser(); - DEBUG(dbgs() << "parseMemOperand\n"); + LLVM_DEBUG(dbgs() << "parseMemOperand\n"); const MCExpr *IdVal = nullptr; SMLoc S; bool isParenExpr = false; @@ -6000,20 +6000,20 @@ auto Token = Parser.getLexer().peekTok(false); if (Token.is(AsmToken::Identifier)) { - DEBUG(dbgs() << ".. identifier\n"); + LLVM_DEBUG(dbgs() << ".. identifier\n"); StringRef Identifier = Token.getIdentifier(); OperandMatchResultTy ResTy = matchAnyRegisterNameWithoutDollar(Operands, Identifier, S); return ResTy; } else if (Token.is(AsmToken::Integer)) { - DEBUG(dbgs() << ".. integer\n"); + LLVM_DEBUG(dbgs() << ".. integer\n"); Operands.push_back(MipsOperand::createNumericReg( Token.getIntVal(), Token.getString(), getContext().getRegisterInfo(), S, Token.getLoc(), *this)); return MatchOperand_Success; } - DEBUG(dbgs() << Parser.getTok().getKind() << "\n"); + LLVM_DEBUG(dbgs() << Parser.getTok().getKind() << "\n"); return MatchOperand_NoMatch; } @@ -6021,22 +6021,22 @@ OperandMatchResultTy MipsAsmParser::parseAnyRegister(OperandVector &Operands) { MCAsmParser &Parser = getParser(); - DEBUG(dbgs() << "parseAnyRegister\n"); + LLVM_DEBUG(dbgs() << "parseAnyRegister\n"); auto Token = Parser.getTok(); SMLoc S = Token.getLoc(); if (Token.isNot(AsmToken::Dollar)) { - DEBUG(dbgs() << ".. !$ -> try sym aliasing\n"); + LLVM_DEBUG(dbgs() << ".. !$ -> try sym aliasing\n"); if (Token.is(AsmToken::Identifier)) { if (searchSymbolAlias(Operands)) return MatchOperand_Success; } - DEBUG(dbgs() << ".. !symalias -> NoMatch\n"); + LLVM_DEBUG(dbgs() << ".. !symalias -> NoMatch\n"); return MatchOperand_NoMatch; } - DEBUG(dbgs() << ".. $\n"); + LLVM_DEBUG(dbgs() << ".. $\n"); OperandMatchResultTy ResTy = matchAnyRegisterWithoutDollar(Operands, S); if (ResTy == MatchOperand_Success) { @@ -6049,7 +6049,7 @@ OperandMatchResultTy MipsAsmParser::parseJumpTarget(OperandVector &Operands) { MCAsmParser &Parser = getParser(); - DEBUG(dbgs() << "parseJumpTarget\n"); + LLVM_DEBUG(dbgs() << "parseJumpTarget\n"); SMLoc S = getLexer().getLoc(); @@ -6293,7 +6293,7 @@ bool MipsAsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name, SMLoc NameLoc, OperandVector &Operands) { MCAsmParser &Parser = getParser(); - DEBUG(dbgs() << "ParseInstruction\n"); + LLVM_DEBUG(dbgs() << "ParseInstruction\n"); // We have reached first instruction, module directive are now forbidden. getTargetStreamer().forbidModuleDirective(); Index: lib/Target/Mips/Disassembler/MipsDisassembler.cpp =================================================================== --- lib/Target/Mips/Disassembler/MipsDisassembler.cpp +++ lib/Target/Mips/Disassembler/MipsDisassembler.cpp @@ -1200,7 +1200,7 @@ return MCDisassembler::Fail; if (hasMips32r6()) { - DEBUG(dbgs() << "Trying MicroMipsR616 table (16-bit instructions):\n"); + LLVM_DEBUG(dbgs() << "Trying MicroMipsR616 table (16-bit instructions):\n"); // Calling the auto-generated decoder function for microMIPS32R6 // 16-bit instructions. Result = decodeInstruction(DecoderTableMicroMipsR616, Instr, Insn, @@ -1211,7 +1211,7 @@ } } - DEBUG(dbgs() << "Trying MicroMips16 table (16-bit instructions):\n"); + LLVM_DEBUG(dbgs() << "Trying MicroMips16 table (16-bit instructions):\n"); // Calling the auto-generated decoder function for microMIPS 16-bit // instructions. Result = decodeInstruction(DecoderTableMicroMips16, Instr, Insn, Address, @@ -1226,7 +1226,7 @@ return MCDisassembler::Fail; if (hasMips32r6()) { - DEBUG(dbgs() << "Trying MicroMips32r632 table (32-bit instructions):\n"); + LLVM_DEBUG(dbgs() << "Trying MicroMips32r632 table (32-bit instructions):\n"); // Calling the auto-generated decoder function. Result = decodeInstruction(DecoderTableMicroMipsR632, Instr, Insn, Address, this, STI); @@ -1236,7 +1236,7 @@ } } - DEBUG(dbgs() << "Trying MicroMips32 table (32-bit instructions):\n"); + LLVM_DEBUG(dbgs() << "Trying MicroMips32 table (32-bit instructions):\n"); // Calling the auto-generated decoder function. Result = decodeInstruction(DecoderTableMicroMips32, Instr, Insn, Address, this, STI); @@ -1246,7 +1246,7 @@ } if (isFP64()) { - DEBUG(dbgs() << "Trying MicroMipsFP64 table (32-bit opcodes):\n"); + LLVM_DEBUG(dbgs() << "Trying MicroMipsFP64 table (32-bit opcodes):\n"); Result = decodeInstruction(DecoderTableMicroMipsFP6432, Instr, Insn, Address, this, STI); if (Result != MCDisassembler::Fail) { @@ -1275,7 +1275,7 @@ Size = 4; if (hasCOP3()) { - DEBUG(dbgs() << "Trying COP3_ table (32-bit opcodes):\n"); + LLVM_DEBUG(dbgs() << "Trying COP3_ table (32-bit opcodes):\n"); Result = decodeInstruction(DecoderTableCOP3_32, Instr, Insn, Address, this, STI); if (Result != MCDisassembler::Fail) @@ -1283,7 +1283,7 @@ } if (hasMips32r6() && isGP64()) { - DEBUG(dbgs() << "Trying Mips32r6_64r6 (GPR64) table (32-bit opcodes):\n"); + LLVM_DEBUG(dbgs() << "Trying Mips32r6_64r6 (GPR64) table (32-bit opcodes):\n"); Result = decodeInstruction(DecoderTableMips32r6_64r6_GP6432, Instr, Insn, Address, this, STI); if (Result != MCDisassembler::Fail) @@ -1291,7 +1291,7 @@ } if (hasMips32r6() && isPTR64()) { - DEBUG(dbgs() << "Trying Mips32r6_64r6 (PTR64) table (32-bit opcodes):\n"); + LLVM_DEBUG(dbgs() << "Trying Mips32r6_64r6 (PTR64) table (32-bit opcodes):\n"); Result = decodeInstruction(DecoderTableMips32r6_64r6_PTR6432, Instr, Insn, Address, this, STI); if (Result != MCDisassembler::Fail) @@ -1299,7 +1299,7 @@ } if (hasMips32r6()) { - DEBUG(dbgs() << "Trying Mips32r6_64r6 table (32-bit opcodes):\n"); + LLVM_DEBUG(dbgs() << "Trying Mips32r6_64r6 table (32-bit opcodes):\n"); Result = decodeInstruction(DecoderTableMips32r6_64r632, Instr, Insn, Address, this, STI); if (Result != MCDisassembler::Fail) @@ -1307,7 +1307,7 @@ } if (hasMips2() && isPTR64()) { - DEBUG(dbgs() << "Trying Mips32r6_64r6 (PTR64) table (32-bit opcodes):\n"); + LLVM_DEBUG(dbgs() << "Trying Mips32r6_64r6 (PTR64) table (32-bit opcodes):\n"); Result = decodeInstruction(DecoderTableMips32_64_PTR6432, Instr, Insn, Address, this, STI); if (Result != MCDisassembler::Fail) @@ -1315,7 +1315,7 @@ } if (hasCnMips()) { - DEBUG(dbgs() << "Trying CnMips table (32-bit opcodes):\n"); + LLVM_DEBUG(dbgs() << "Trying CnMips table (32-bit opcodes):\n"); Result = decodeInstruction(DecoderTableCnMips32, Instr, Insn, Address, this, STI); if (Result != MCDisassembler::Fail) @@ -1323,7 +1323,7 @@ } if (isGP64()) { - DEBUG(dbgs() << "Trying Mips64 (GPR64) table (32-bit opcodes):\n"); + LLVM_DEBUG(dbgs() << "Trying Mips64 (GPR64) table (32-bit opcodes):\n"); Result = decodeInstruction(DecoderTableMips6432, Instr, Insn, Address, this, STI); if (Result != MCDisassembler::Fail) @@ -1331,14 +1331,14 @@ } if (isFP64()) { - DEBUG(dbgs() << "Trying MipsFP64 (64 bit FPU) table (32-bit opcodes):\n"); + LLVM_DEBUG(dbgs() << "Trying MipsFP64 (64 bit FPU) table (32-bit opcodes):\n"); Result = decodeInstruction(DecoderTableMipsFP6432, Instr, Insn, Address, this, STI); if (Result != MCDisassembler::Fail) return Result; } - DEBUG(dbgs() << "Trying Mips table (32-bit opcodes):\n"); + LLVM_DEBUG(dbgs() << "Trying Mips table (32-bit opcodes):\n"); // Calling the auto-generated decoder function. Result = decodeInstruction(DecoderTableMips32, Instr, Insn, Address, this, STI); Index: lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp +++ lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp @@ -116,15 +116,15 @@ for (InputIt I = First; I != Last; ++I) { unsigned Matched = Predicate(*I); if (Matched != FindBest_NoMatch) { - DEBUG(dbgs() << std::distance(First, I) << " is a match ("; + LLVM_DEBUG(dbgs() << std::distance(First, I) << " is a match ("; I->print(dbgs()); dbgs() << ")\n"); if (Best == Last || BetterThan(*I, *Best)) { - DEBUG(dbgs() << ".. and it beats the last one\n"); + LLVM_DEBUG(dbgs() << ".. and it beats the last one\n"); Best = I; } } if (Matched == FindBest_PerfectMatch) { - DEBUG(dbgs() << ".. and it is unbeatable\n"); + LLVM_DEBUG(dbgs() << ".. and it is unbeatable\n"); break; } } @@ -444,7 +444,7 @@ std::list Sorted; std::list Remainder; - DEBUG(dumpRelocs("R: ", Relocs)); + LLVM_DEBUG(dumpRelocs("R: ", Relocs)); // Separate the movable relocations (AHL relocations using the high bits) from // the immobile relocations (everything else). This does not preserve high/low @@ -455,7 +455,7 @@ }); for (auto &R : Remainder) { - DEBUG(dbgs() << "Matching: " << R << "\n"); + LLVM_DEBUG(dbgs() << "Matching: " << R << "\n"); unsigned MatchingType = getMatchingLoType(R); assert(MatchingType != ELF::R_MIPS_NONE && @@ -490,7 +490,7 @@ Sorted.insert(InsertionPoint, R)->Matched = true; } - DEBUG(dumpRelocs("S: ", Sorted)); + LLVM_DEBUG(dumpRelocs("S: ", Sorted)); assert(Relocs.size() == Sorted.size() && "Some relocs were not consumed"); Index: lib/Target/Mips/MicroMipsSizeReduction.cpp =================================================================== --- lib/Target/Mips/MicroMipsSizeReduction.cpp +++ lib/Target/Mips/MicroMipsSizeReduction.cpp @@ -444,12 +444,12 @@ enum OperandTransfer OpTransfer = Entry.TransferOperands(); - DEBUG(dbgs() << "Converting 32-bit: " << *MI); + LLVM_DEBUG(dbgs() << "Converting 32-bit: " << *MI); ++NumReduced; if (OpTransfer == OT_OperandsAll) { MI->setDesc(MipsII->get(Entry.NarrowOpc())); - DEBUG(dbgs() << " to 16-bit: " << *MI); + LLVM_DEBUG(dbgs() << " to 16-bit: " << *MI); return true; } else { MachineBasicBlock &MBB = *MI->getParent(); @@ -484,7 +484,7 @@ // Transfer MI flags. MIB.setMIFlags(MI->getFlags()); - DEBUG(dbgs() << " to 16-bit: " << *MIB); + LLVM_DEBUG(dbgs() << " to 16-bit: " << *MIB); MBB.erase_instr(MI); return true; } Index: lib/Target/Mips/Mips16HardFloat.cpp =================================================================== --- lib/Target/Mips/Mips16HardFloat.cpp +++ lib/Target/Mips/Mips16HardFloat.cpp @@ -482,11 +482,11 @@ // remove the use-soft-float attribute static void removeUseSoftFloat(Function &F) { AttrBuilder B; - DEBUG(errs() << "removing -use-soft-float\n"); + LLVM_DEBUG(errs() << "removing -use-soft-float\n"); B.addAttribute("use-soft-float", "false"); F.removeAttributes(AttributeList::FunctionIndex, B); if (F.hasFnAttribute("use-soft-float")) { - DEBUG(errs() << "still has -use-soft-float\n"); + LLVM_DEBUG(errs() << "still has -use-soft-float\n"); } F.addAttributes(AttributeList::FunctionIndex, B); } @@ -510,7 +510,7 @@ bool Mips16HardFloat::runOnModule(Module &M) { auto &TM = static_cast( getAnalysis().getTM()); - DEBUG(errs() << "Run on Module Mips16HardFloat\n"); + LLVM_DEBUG(errs() << "Run on Module Mips16HardFloat\n"); bool Modified = false; for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) { if (F->hasFnAttribute("nomips16") && Index: lib/Target/Mips/Mips16RegisterInfo.cpp =================================================================== --- lib/Target/Mips/Mips16RegisterInfo.cpp +++ lib/Target/Mips/Mips16RegisterInfo.cpp @@ -128,7 +128,7 @@ Offset += MI.getOperand(OpNo + 1).getImm(); - DEBUG(errs() << "Offset : " << Offset << "\n" << "<--------->\n"); + LLVM_DEBUG(errs() << "Offset : " << Offset << "\n" << "<--------->\n"); if (!MI.isDebugValue() && !Mips16InstrInfo::validImmediate(MI.getOpcode(), FrameReg, Offset)) { Index: lib/Target/Mips/MipsConstantIslandPass.cpp =================================================================== --- lib/Target/Mips/MipsConstantIslandPass.cpp +++ lib/Target/Mips/MipsConstantIslandPass.cpp @@ -442,13 +442,13 @@ MF = &mf; MCP = mf.getConstantPool(); STI = &static_cast(mf.getSubtarget()); - DEBUG(dbgs() << "constant island machine function " << "\n"); + LLVM_DEBUG(dbgs() << "constant island machine function " << "\n"); if (!STI->inMips16Mode() || !MipsSubtarget::useConstantIslands()) { return false; } TII = (const Mips16InstrInfo *)STI->getInstrInfo(); MFI = MF->getInfo(); - DEBUG(dbgs() << "constant island processing " << "\n"); + LLVM_DEBUG(dbgs() << "constant island processing " << "\n"); // // will need to make predermination if there is any constants we need to // put in constant islands. TBD. @@ -479,7 +479,7 @@ // constant pool users. initializeFunctionInfo(CPEMIs); CPEMIs.clear(); - DEBUG(dumpBBs()); + LLVM_DEBUG(dumpBBs()); /// Remove dead constant pool entries. MadeChange |= removeUnusedCPEntries(); @@ -489,31 +489,31 @@ unsigned NoCPIters = 0, NoBRIters = 0; (void)NoBRIters; while (true) { - DEBUG(dbgs() << "Beginning CP iteration #" << NoCPIters << '\n'); + LLVM_DEBUG(dbgs() << "Beginning CP iteration #" << NoCPIters << '\n'); bool CPChange = false; for (unsigned i = 0, e = CPUsers.size(); i != e; ++i) CPChange |= handleConstantPoolUser(i); if (CPChange && ++NoCPIters > 30) report_fatal_error("Constant Island pass failed to converge!"); - DEBUG(dumpBBs()); + LLVM_DEBUG(dumpBBs()); // Clear NewWaterList now. If we split a block for branches, it should // appear as "new water" for the next iteration of constant pool placement. NewWaterList.clear(); - DEBUG(dbgs() << "Beginning BR iteration #" << NoBRIters << '\n'); + LLVM_DEBUG(dbgs() << "Beginning BR iteration #" << NoBRIters << '\n'); bool BRChange = false; for (unsigned i = 0, e = ImmBranches.size(); i != e; ++i) BRChange |= fixupImmediateBr(ImmBranches[i]); if (BRChange && ++NoBRIters > 30) report_fatal_error("Branch Fix Up pass failed to converge!"); - DEBUG(dumpBBs()); + LLVM_DEBUG(dumpBBs()); if (!CPChange && !BRChange) break; MadeChange = true; } - DEBUG(dbgs() << '\n'; dumpBBs()); + LLVM_DEBUG(dbgs() << '\n'; dumpBBs()); BBInfo.clear(); WaterList.clear(); @@ -580,10 +580,10 @@ // Add a new CPEntry, but no corresponding CPUser yet. CPEntries.emplace_back(1, CPEntry(CPEMI, i)); ++NumCPEs; - DEBUG(dbgs() << "Moved CPI#" << i << " to end of function, size = " + LLVM_DEBUG(dbgs() << "Moved CPI#" << i << " to end of function, size = " << Size << ", align = " << Align <<'\n'); } - DEBUG(BB->dump()); + LLVM_DEBUG(BB->dump()); } /// BBHasFallthrough - Return true if the specified basic block can fallthrough @@ -986,7 +986,7 @@ unsigned CPEOffset = getOffsetOf(CPEMI); if (DoDump) { - DEBUG({ + LLVM_DEBUG({ unsigned Block = MI->getParent()->getNumber(); const BasicBlockInfo &BBI = BBInfo[Block]; dbgs() << "User of CPE#" << CPEMI->getOperand(0).getImm() @@ -1059,7 +1059,7 @@ // Check to see if the CPE is already in-range. if (isCPEntryInRange(UserMI, UserOffset, CPEMI, U.getMaxDisp(), U.NegOk, true)) { - DEBUG(dbgs() << "In range\n"); + LLVM_DEBUG(dbgs() << "In range\n"); return 1; } @@ -1075,7 +1075,7 @@ continue; if (isCPEntryInRange(UserMI, UserOffset, CPEs[i].CPEMI, U.getMaxDisp(), U.NegOk)) { - DEBUG(dbgs() << "Replacing CPE#" << CPI << " with CPE#" + LLVM_DEBUG(dbgs() << "Replacing CPE#" << CPI << " with CPE#" << CPEs[i].CPI << "\n"); // Point the CPUser node to the replacement U.CPEMI = CPEs[i].CPEMI; @@ -1113,7 +1113,7 @@ if (isCPEntryInRange(UserMI, UserOffset, CPEMI, U.getLongFormMaxDisp(), U.NegOk, true)) { - DEBUG(dbgs() << "In range\n"); + LLVM_DEBUG(dbgs() << "In range\n"); UserMI->setDesc(TII->get(U.getLongFormOpcode())); U.setMaxDisp(U.getLongFormMaxDisp()); return 2; // instruction is longer length now @@ -1131,7 +1131,7 @@ continue; if (isCPEntryInRange(UserMI, UserOffset, CPEs[i].CPEMI, U.getLongFormMaxDisp(), U.NegOk)) { - DEBUG(dbgs() << "Replacing CPE#" << CPI << " with CPE#" + LLVM_DEBUG(dbgs() << "Replacing CPE#" << CPI << " with CPE#" << CPEs[i].CPI << "\n"); // Point the CPUser node to the replacement U.CPEMI = CPEs[i].CPEMI; @@ -1197,7 +1197,7 @@ // This is the least amount of required padding seen so far. BestGrowth = Growth; WaterIter = IP; - DEBUG(dbgs() << "Found water after " << printMBBReference(*WaterBB) + LLVM_DEBUG(dbgs() << "Found water after " << printMBBReference(*WaterBB) << " Growth=" << Growth << '\n'); // Keep looking unless it is perfect. @@ -1236,7 +1236,7 @@ unsigned CPEOffset = UserBBI.postOffset(CPELogAlign) + Delta; if (isOffsetInRange(UserOffset, CPEOffset, U)) { - DEBUG(dbgs() << "Split at end of " << printMBBReference(*UserMBB) + LLVM_DEBUG(dbgs() << "Split at end of " << printMBBReference(*UserMBB) << format(", expected CPE offset %#x\n", CPEOffset)); NewMBB = &*++UserMBB->getIterator(); // Add an unconditional branch from UserMBB to fallthrough block. Record @@ -1263,7 +1263,7 @@ unsigned LogAlign = MF->getAlignment(); assert(LogAlign >= CPELogAlign && "Over-aligned constant pool entry"); unsigned BaseInsertOffset = UserOffset + U.getMaxDisp(); - DEBUG(dbgs() << format("Split in middle of big block before %#x", + LLVM_DEBUG(dbgs() << format("Split in middle of big block before %#x", BaseInsertOffset)); // The 4 in the following is for the unconditional branch we'll be inserting @@ -1271,7 +1271,7 @@ // inside isOffsetInRange. BaseInsertOffset -= 4; - DEBUG(dbgs() << format(", adjusted to %#x", BaseInsertOffset) + LLVM_DEBUG(dbgs() << format(", adjusted to %#x", BaseInsertOffset) << " la=" << LogAlign << '\n'); // This could point off the end of the block if we've already got constant @@ -1280,7 +1280,7 @@ // long unconditional). if (BaseInsertOffset + 8 >= UserBBI.postOffset()) { BaseInsertOffset = UserBBI.postOffset() - 8; - DEBUG(dbgs() << format("Move inside block: %#x\n", BaseInsertOffset)); + LLVM_DEBUG(dbgs() << format("Move inside block: %#x\n", BaseInsertOffset)); } unsigned EndInsertOffset = BaseInsertOffset + 4 + CPEMI->getOperand(2).getImm(); @@ -1336,7 +1336,7 @@ MachineBasicBlock *NewMBB; water_iterator IP; if (findAvailableWater(U, UserOffset, IP)) { - DEBUG(dbgs() << "Found water in range\n"); + LLVM_DEBUG(dbgs() << "Found water in range\n"); MachineBasicBlock *WaterBB = *IP; // If the original WaterList entry was "new water" on this iteration, @@ -1355,7 +1355,7 @@ result = findLongFormInRangeCPEntry(U, UserOffset); if (result != 0) return true; } - DEBUG(dbgs() << "No water found\n"); + LLVM_DEBUG(dbgs() << "No water found\n"); createNewWater(CPUserIndex, UserOffset, NewMBB); // splitBlockBeforeInstr adds to WaterList, which is important when it is @@ -1414,7 +1414,7 @@ break; } - DEBUG(dbgs() << " Moved CPE to #" << ID << " CPI=" << CPI + LLVM_DEBUG(dbgs() << " Moved CPE to #" << ID << " CPI=" << CPI << format(" offset=%#x\n", BBInfo[NewIsland->getNumber()].Offset)); return true; @@ -1470,7 +1470,7 @@ unsigned BrOffset = getOffsetOf(MI) + PCAdj; unsigned DestOffset = BBInfo[DestBB->getNumber()].Offset; - DEBUG(dbgs() << "Branch of destination " << printMBBReference(*DestBB) + LLVM_DEBUG(dbgs() << "Branch of destination " << printMBBReference(*DestBB) << " from " << printMBBReference(*MI->getParent()) << " max delta=" << MaxDisp << " from " << getOffsetOf(MI) << " to " << DestOffset << " offset " @@ -1539,7 +1539,7 @@ HasFarJump = true; ++NumUBrFixed; - DEBUG(dbgs() << " Changed B to long jump " << *MI); + LLVM_DEBUG(dbgs() << " Changed B to long jump " << *MI); return true; } @@ -1594,7 +1594,7 @@ MachineBasicBlock *NewDest = BMI->getOperand(BMITargetOperand).getMBB(); if (isBBInRange(MI, NewDest, Br.MaxDisp)) { - DEBUG(dbgs() << " Invert Bcc condition and swap its destination with " + LLVM_DEBUG(dbgs() << " Invert Bcc condition and swap its destination with " << *BMI); MI->setDesc(TII->get(OppositeBranchOpcode)); BMI->getOperand(BMITargetOperand).setMBB(DestBB); @@ -1615,7 +1615,7 @@ } MachineBasicBlock *NextBB = &*++MBB->getIterator(); - DEBUG(dbgs() << " Insert B to " << printMBBReference(*DestBB) + LLVM_DEBUG(dbgs() << " Insert B to " << printMBBReference(*DestBB) << " also invert condition and change dest. to " << printMBBReference(*NextBB) << "\n"); @@ -1653,19 +1653,19 @@ switch(I->getDesc().getOpcode()) { case Mips::LwConstant32: { PrescannedForConstants = true; - DEBUG(dbgs() << "constant island constant " << *I << "\n"); + LLVM_DEBUG(dbgs() << "constant island constant " << *I << "\n"); J = I->getNumOperands(); - DEBUG(dbgs() << "num operands " << J << "\n"); + LLVM_DEBUG(dbgs() << "num operands " << J << "\n"); MachineOperand& Literal = I->getOperand(1); if (Literal.isImm()) { int64_t V = Literal.getImm(); - DEBUG(dbgs() << "literal " << V << "\n"); + LLVM_DEBUG(dbgs() << "literal " << V << "\n"); Type *Int32Ty = Type::getInt32Ty(MF->getFunction().getContext()); const Constant *C = ConstantInt::get(Int32Ty, V); unsigned index = MCP->getConstantPoolIndex(C, 4); I->getOperand(2).ChangeToImmediate(index); - DEBUG(dbgs() << "constant island constant " << *I << "\n"); + LLVM_DEBUG(dbgs() << "constant island constant " << *I << "\n"); I->setDesc(TII->get(Mips::LwRxPcTcp16)); I->RemoveOperand(1); I->RemoveOperand(1); Index: lib/Target/Mips/MipsFastISel.cpp =================================================================== --- lib/Target/Mips/MipsFastISel.cpp +++ lib/Target/Mips/MipsFastISel.cpp @@ -1000,11 +1000,11 @@ bool MipsFastISel::selectSelect(const Instruction *I) { assert(isa(I) && "Expected a select instruction."); - DEBUG(dbgs() << "selectSelect\n"); + LLVM_DEBUG(dbgs() << "selectSelect\n"); MVT VT; if (!isTypeSupported(I->getType(), VT) || UnsupportedFPMode) { - DEBUG(dbgs() << ".. .. gave up (!isTypeSupported || UnsupportedFPMode)\n"); + LLVM_DEBUG(dbgs() << ".. .. gave up (!isTypeSupported || UnsupportedFPMode)\n"); return false; } @@ -1287,22 +1287,22 @@ } bool MipsFastISel::fastLowerArguments() { - DEBUG(dbgs() << "fastLowerArguments\n"); + LLVM_DEBUG(dbgs() << "fastLowerArguments\n"); if (!FuncInfo.CanLowerReturn) { - DEBUG(dbgs() << ".. gave up (!CanLowerReturn)\n"); + LLVM_DEBUG(dbgs() << ".. gave up (!CanLowerReturn)\n"); return false; } const Function *F = FuncInfo.Fn; if (F->isVarArg()) { - DEBUG(dbgs() << ".. gave up (varargs)\n"); + LLVM_DEBUG(dbgs() << ".. gave up (varargs)\n"); return false; } CallingConv::ID CC = F->getCallingConv(); if (CC != CallingConv::C) { - DEBUG(dbgs() << ".. gave up (calling convention is not C)\n"); + LLVM_DEBUG(dbgs() << ".. gave up (calling convention is not C)\n"); return false; } @@ -1328,21 +1328,21 @@ if (FormalArg.hasAttribute(Attribute::InReg) || FormalArg.hasAttribute(Attribute::StructRet) || FormalArg.hasAttribute(Attribute::ByVal)) { - DEBUG(dbgs() << ".. gave up (inreg, structret, byval)\n"); + LLVM_DEBUG(dbgs() << ".. gave up (inreg, structret, byval)\n"); return false; } Type *ArgTy = FormalArg.getType(); if (ArgTy->isStructTy() || ArgTy->isArrayTy() || ArgTy->isVectorTy()) { - DEBUG(dbgs() << ".. gave up (struct, array, or vector)\n"); + LLVM_DEBUG(dbgs() << ".. gave up (struct, array, or vector)\n"); return false; } EVT ArgVT = TLI.getValueType(DL, ArgTy); - DEBUG(dbgs() << ".. " << FormalArg.getArgNo() << ": " + LLVM_DEBUG(dbgs() << ".. " << FormalArg.getArgNo() << ": " << ArgVT.getEVTString() << "\n"); if (!ArgVT.isSimple()) { - DEBUG(dbgs() << ".. .. gave up (not a simple type)\n"); + LLVM_DEBUG(dbgs() << ".. .. gave up (not a simple type)\n"); return false; } @@ -1354,16 +1354,16 @@ !FormalArg.hasAttribute(Attribute::ZExt)) { // It must be any extend, this shouldn't happen for clang-generated IR // so just fall back on SelectionDAG. - DEBUG(dbgs() << ".. .. gave up (i8/i16 arg is not extended)\n"); + LLVM_DEBUG(dbgs() << ".. .. gave up (i8/i16 arg is not extended)\n"); return false; } if (NextGPR32 == GPR32ArgRegs.end()) { - DEBUG(dbgs() << ".. .. gave up (ran out of GPR32 arguments)\n"); + LLVM_DEBUG(dbgs() << ".. .. gave up (ran out of GPR32 arguments)\n"); return false; } - DEBUG(dbgs() << ".. .. GPR32(" << *NextGPR32 << ")\n"); + LLVM_DEBUG(dbgs() << ".. .. GPR32(" << *NextGPR32 << ")\n"); Allocation.emplace_back(&Mips::GPR32RegClass, *NextGPR32++); // Allocating any GPR32 prohibits further use of floating point arguments. @@ -1374,16 +1374,16 @@ case MVT::i32: if (FormalArg.hasAttribute(Attribute::ZExt)) { // The O32 ABI does not permit a zero-extended i32. - DEBUG(dbgs() << ".. .. gave up (i32 arg is zero extended)\n"); + LLVM_DEBUG(dbgs() << ".. .. gave up (i32 arg is zero extended)\n"); return false; } if (NextGPR32 == GPR32ArgRegs.end()) { - DEBUG(dbgs() << ".. .. gave up (ran out of GPR32 arguments)\n"); + LLVM_DEBUG(dbgs() << ".. .. gave up (ran out of GPR32 arguments)\n"); return false; } - DEBUG(dbgs() << ".. .. GPR32(" << *NextGPR32 << ")\n"); + LLVM_DEBUG(dbgs() << ".. .. GPR32(" << *NextGPR32 << ")\n"); Allocation.emplace_back(&Mips::GPR32RegClass, *NextGPR32++); // Allocating any GPR32 prohibits further use of floating point arguments. @@ -1393,14 +1393,14 @@ case MVT::f32: if (UnsupportedFPMode) { - DEBUG(dbgs() << ".. .. gave up (UnsupportedFPMode)\n"); + LLVM_DEBUG(dbgs() << ".. .. gave up (UnsupportedFPMode)\n"); return false; } if (NextFGR32 == FGR32ArgRegs.end()) { - DEBUG(dbgs() << ".. .. gave up (ran out of FGR32 arguments)\n"); + LLVM_DEBUG(dbgs() << ".. .. gave up (ran out of FGR32 arguments)\n"); return false; } - DEBUG(dbgs() << ".. .. FGR32(" << *NextFGR32 << ")\n"); + LLVM_DEBUG(dbgs() << ".. .. FGR32(" << *NextFGR32 << ")\n"); Allocation.emplace_back(&Mips::FGR32RegClass, *NextFGR32++); // Allocating an FGR32 also allocates the super-register AFGR64, and // ABI rules require us to skip the corresponding GPR32. @@ -1412,14 +1412,14 @@ case MVT::f64: if (UnsupportedFPMode) { - DEBUG(dbgs() << ".. .. gave up (UnsupportedFPMode)\n"); + LLVM_DEBUG(dbgs() << ".. .. gave up (UnsupportedFPMode)\n"); return false; } if (NextAFGR64 == AFGR64ArgRegs.end()) { - DEBUG(dbgs() << ".. .. gave up (ran out of AFGR64 arguments)\n"); + LLVM_DEBUG(dbgs() << ".. .. gave up (ran out of AFGR64 arguments)\n"); return false; } - DEBUG(dbgs() << ".. .. AFGR64(" << *NextAFGR64 << ")\n"); + LLVM_DEBUG(dbgs() << ".. .. AFGR64(" << *NextAFGR64 << ")\n"); Allocation.emplace_back(&Mips::AFGR64RegClass, *NextAFGR64++); // Allocating an FGR32 also allocates the super-register AFGR64, and // ABI rules require us to skip the corresponding GPR32 pair. @@ -1432,7 +1432,7 @@ break; default: - DEBUG(dbgs() << ".. .. gave up (unknown type)\n"); + LLVM_DEBUG(dbgs() << ".. .. gave up (unknown type)\n"); return false; } } @@ -1647,7 +1647,7 @@ const Function &F = *I->getParent()->getParent(); const ReturnInst *Ret = cast(I); - DEBUG(dbgs() << "selectRet\n"); + LLVM_DEBUG(dbgs() << "selectRet\n"); if (!FuncInfo.CanLowerReturn) return false; @@ -1711,7 +1711,7 @@ // Do not handle FGR64 returns for now. if (RVVT == MVT::f64 && UnsupportedFPMode) { - DEBUG(dbgs() << ".. .. gave up (UnsupportedFPMode\n"); + LLVM_DEBUG(dbgs() << ".. .. gave up (UnsupportedFPMode\n"); return false; } Index: lib/Target/Mips/MipsISelDAGToDAG.cpp =================================================================== --- lib/Target/Mips/MipsISelDAGToDAG.cpp +++ lib/Target/Mips/MipsISelDAGToDAG.cpp @@ -217,7 +217,7 @@ // If we have a custom node, we already have selected! if (Node->isMachineOpcode()) { - DEBUG(errs() << "== "; Node->dump(CurDAG); errs() << "\n"); + LLVM_DEBUG(errs() << "== "; Node->dump(CurDAG); errs() << "\n"); Node->setNodeId(-1); return; } Index: lib/Target/Mips/MipsModuleISelDAGToDAG.cpp =================================================================== --- lib/Target/Mips/MipsModuleISelDAGToDAG.cpp +++ lib/Target/Mips/MipsModuleISelDAGToDAG.cpp @@ -42,7 +42,7 @@ } bool MipsModuleDAGToDAGISel::runOnMachineFunction(MachineFunction &MF) { - DEBUG(errs() << "In MipsModuleDAGToDAGISel::runMachineFunction\n"); + LLVM_DEBUG(errs() << "In MipsModuleDAGToDAGISel::runMachineFunction\n"); auto &TPC = getAnalysis(); auto &TM = TPC.getTM(); TM.resetSubtarget(&MF); Index: lib/Target/Mips/MipsOs16.cpp =================================================================== --- lib/Target/Mips/MipsOs16.cpp +++ lib/Target/Mips/MipsOs16.cpp @@ -96,7 +96,7 @@ ; } if (const CallInst *CI = dyn_cast(I)) { - DEBUG(dbgs() << "Working on call" << "\n"); + LLVM_DEBUG(dbgs() << "Working on call" << "\n"); Function &F_ = *CI->getCalledFunction(); if (needsFPFromSig(F_)) return true; @@ -110,9 +110,9 @@ bool usingMask = Mips32FunctionMask.length() > 0; bool doneUsingMask = false; // this will make it stop repeating - DEBUG(dbgs() << "Run on Module MipsOs16 \n" << Mips32FunctionMask << "\n"); + LLVM_DEBUG(dbgs() << "Run on Module MipsOs16 \n" << Mips32FunctionMask << "\n"); if (usingMask) - DEBUG(dbgs() << "using mask \n" << Mips32FunctionMask << "\n"); + LLVM_DEBUG(dbgs() << "using mask \n" << Mips32FunctionMask << "\n"); unsigned int functionIndex = 0; bool modified = false; @@ -121,14 +121,14 @@ if (F.isDeclaration()) continue; - DEBUG(dbgs() << "Working on " << F.getName() << "\n"); + LLVM_DEBUG(dbgs() << "Working on " << F.getName() << "\n"); if (usingMask) { if (!doneUsingMask) { if (functionIndex == Mips32FunctionMask.length()) functionIndex = 0; switch (Mips32FunctionMask[functionIndex]) { case '1': - DEBUG(dbgs() << "mask forced mips32: " << F.getName() << "\n"); + LLVM_DEBUG(dbgs() << "mask forced mips32: " << F.getName() << "\n"); F.addFnAttr("nomips16"); break; case '.': @@ -142,11 +142,11 @@ } else { if (needsFP(F)) { - DEBUG(dbgs() << "os16 forced mips32: " << F.getName() << "\n"); + LLVM_DEBUG(dbgs() << "os16 forced mips32: " << F.getName() << "\n"); F.addFnAttr("nomips16"); } else { - DEBUG(dbgs() << "os16 forced mips16: " << F.getName() << "\n"); + LLVM_DEBUG(dbgs() << "os16 forced mips16: " << F.getName() << "\n"); F.addFnAttr("mips16"); } } Index: lib/Target/Mips/MipsRegisterInfo.cpp =================================================================== --- lib/Target/Mips/MipsRegisterInfo.cpp +++ lib/Target/Mips/MipsRegisterInfo.cpp @@ -275,14 +275,14 @@ MachineInstr &MI = *II; MachineFunction &MF = *MI.getParent()->getParent(); - DEBUG(errs() << "\nFunction : " << MF.getName() << "\n"; + LLVM_DEBUG(errs() << "\nFunction : " << MF.getName() << "\n"; errs() << "<--------->\n" << MI); int FrameIndex = MI.getOperand(FIOperandNum).getIndex(); uint64_t stackSize = MF.getFrameInfo().getStackSize(); int64_t spOffset = MF.getFrameInfo().getObjectOffset(FrameIndex); - DEBUG(errs() << "FrameIndex : " << FrameIndex << "\n" + LLVM_DEBUG(errs() << "FrameIndex : " << FrameIndex << "\n" << "spOffset : " << spOffset << "\n" << "stackSize : " << stackSize << "\n" << "alignment : " Index: lib/Target/Mips/MipsSEISelLowering.cpp =================================================================== --- lib/Target/Mips/MipsSEISelLowering.cpp +++ lib/Target/Mips/MipsSEISelLowering.cpp @@ -967,7 +967,7 @@ } if (Val.getNode()) { - DEBUG(dbgs() << "\nMipsSE DAG Combine:\n"; + LLVM_DEBUG(dbgs() << "\nMipsSE DAG Combine:\n"; N->printrWithDepth(dbgs(), &DAG); dbgs() << "\n=> \n"; Val.getNode()->printrWithDepth(dbgs(), &DAG); Index: lib/Target/Mips/MipsSERegisterInfo.cpp =================================================================== --- lib/Target/Mips/MipsSERegisterInfo.cpp +++ lib/Target/Mips/MipsSERegisterInfo.cpp @@ -202,7 +202,7 @@ Offset = SPOffset + (int64_t)StackSize; Offset += MI.getOperand(OpNo + 1).getImm(); - DEBUG(errs() << "Offset : " << Offset << "\n" << "<--------->\n"); + LLVM_DEBUG(errs() << "Offset : " << Offset << "\n" << "<--------->\n"); if (!MI.isDebugValue()) { // Make sure Offset fits within the field available. Index: lib/Target/Mips/MipsSubtarget.cpp =================================================================== --- lib/Target/Mips/MipsSubtarget.cpp +++ lib/Target/Mips/MipsSubtarget.cpp @@ -222,7 +222,7 @@ } bool MipsSubtarget::useConstantIslands() { - DEBUG(dbgs() << "use constant islands " << Mips16ConstantIslands << "\n"); + LLVM_DEBUG(dbgs() << "use constant islands " << Mips16ConstantIslands << "\n"); return Mips16ConstantIslands; } Index: lib/Target/Mips/MipsTargetMachine.cpp =================================================================== --- lib/Target/Mips/MipsTargetMachine.cpp +++ lib/Target/Mips/MipsTargetMachine.cpp @@ -198,7 +198,7 @@ } void MipsTargetMachine::resetSubtarget(MachineFunction *MF) { - DEBUG(dbgs() << "resetSubtarget\n"); + LLVM_DEBUG(dbgs() << "resetSubtarget\n"); Subtarget = const_cast(getSubtargetImpl(MF->getFunction())); MF->setSubtarget(Subtarget); @@ -262,12 +262,12 @@ TargetTransformInfo MipsTargetMachine::getTargetTransformInfo(const Function &F) { if (Subtarget->allowMixed16_32()) { - DEBUG(errs() << "No Target Transform Info Pass Added\n"); + LLVM_DEBUG(errs() << "No Target Transform Info Pass Added\n"); // FIXME: This is no longer necessary as the TTI returned is per-function. return TargetTransformInfo(F.getParent()->getDataLayout()); } - DEBUG(errs() << "Target Transform Info Pass Added\n"); + LLVM_DEBUG(errs() << "Target Transform Info Pass Added\n"); return TargetTransformInfo(BasicTTIImpl(this, F)); } Index: lib/Target/NVPTX/NVPTXPrologEpilogPass.cpp =================================================================== --- lib/Target/NVPTX/NVPTXPrologEpilogPass.cpp +++ lib/Target/NVPTX/NVPTXPrologEpilogPass.cpp @@ -97,10 +97,10 @@ Offset = (Offset + Align - 1) / Align * Align; if (StackGrowsDown) { - DEBUG(dbgs() << "alloc FI(" << FrameIdx << ") at SP[" << -Offset << "]\n"); + LLVM_DEBUG(dbgs() << "alloc FI(" << FrameIdx << ") at SP[" << -Offset << "]\n"); MFI.setObjectOffset(FrameIdx, -Offset); // Set the computed offset } else { - DEBUG(dbgs() << "alloc FI(" << FrameIdx << ") at SP[" << Offset << "]\n"); + LLVM_DEBUG(dbgs() << "alloc FI(" << FrameIdx << ") at SP[" << Offset << "]\n"); MFI.setObjectOffset(FrameIdx, Offset); Offset += MFI.getObjectSize(FrameIdx); } @@ -163,13 +163,13 @@ // Adjust to alignment boundary. Offset = (Offset + Align - 1) / Align * Align; - DEBUG(dbgs() << "Local frame base offset: " << Offset << "\n"); + LLVM_DEBUG(dbgs() << "Local frame base offset: " << Offset << "\n"); // Resolve offsets for objects in the local block. for (unsigned i = 0, e = MFI.getLocalFrameObjectCount(); i != e; ++i) { std::pair Entry = MFI.getLocalFrameObjectMap(i); int64_t FIOffset = (StackGrowsDown ? -Offset : Offset) + Entry.second; - DEBUG(dbgs() << "alloc FI(" << Entry.first << ") at SP[" << + LLVM_DEBUG(dbgs() << "alloc FI(" << Entry.first << ") at SP[" << FIOffset << "]\n"); MFI.setObjectOffset(Entry.first, FIOffset); } Index: lib/Target/NVPTX/NVVMReflect.cpp =================================================================== --- lib/Target/NVPTX/NVVMReflect.cpp +++ lib/Target/NVPTX/NVVMReflect.cpp @@ -153,7 +153,7 @@ StringRef ReflectArg = cast(Operand)->getAsString(); ReflectArg = ReflectArg.substr(0, ReflectArg.size() - 1); - DEBUG(dbgs() << "Arg of _reflect : " << ReflectArg << "\n"); + LLVM_DEBUG(dbgs() << "Arg of _reflect : " << ReflectArg << "\n"); int ReflectVal = 0; // The default value is 0 if (ReflectArg == "__CUDA_FTZ") { Index: lib/Target/Nios2/Nios2ISelDAGToDAG.cpp =================================================================== --- lib/Target/Nios2/Nios2ISelDAGToDAG.cpp +++ lib/Target/Nios2/Nios2ISelDAGToDAG.cpp @@ -61,7 +61,7 @@ // If we have a custom node, we already have selected! if (Node->isMachineOpcode()) { - DEBUG(errs() << "== "; Node->dump(CurDAG); errs() << "\n"); + LLVM_DEBUG(errs() << "== "; Node->dump(CurDAG); errs() << "\n"); Node->setNodeId(-1); return; } Index: lib/Target/PowerPC/PPCAsmPrinter.cpp =================================================================== --- lib/Target/PowerPC/PPCAsmPrinter.cpp +++ lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -741,7 +741,7 @@ else if (MO.isGlobal()) { const GlobalValue *GV = MO.getGlobal(); MOSymbol = getSymbol(GV); - DEBUG( + LLVM_DEBUG( unsigned char GVFlags = Subtarget->classifyGlobalReference(GV); assert((GVFlags & PPCII::MO_NLP_FLAG) && "LDtocL used on symbol that could be accessed directly is " @@ -770,7 +770,7 @@ if (MO.isGlobal()) { const GlobalValue *GV = MO.getGlobal(); - DEBUG( + LLVM_DEBUG( unsigned char GVFlags = Subtarget->classifyGlobalReference(GV); assert ( !(GVFlags & PPCII::MO_NLP_FLAG) && Index: lib/Target/PowerPC/PPCBranchCoalescing.cpp =================================================================== --- lib/Target/PowerPC/PPCBranchCoalescing.cpp +++ lib/Target/PowerPC/PPCBranchCoalescing.cpp @@ -236,18 +236,18 @@ ///\return true if and only if the branch can be coalesced, false otherwise /// bool PPCBranchCoalescing::canCoalesceBranch(CoalescingCandidateInfo &Cand) { - DEBUG(dbgs() << "Determine if branch block " << Cand.BranchBlock->getNumber() + LLVM_DEBUG(dbgs() << "Determine if branch block " << Cand.BranchBlock->getNumber() << " can be coalesced:"); MachineBasicBlock *FalseMBB = nullptr; if (TII->analyzeBranch(*Cand.BranchBlock, Cand.BranchTargetBlock, FalseMBB, Cand.Cond)) { - DEBUG(dbgs() << "TII unable to Analyze Branch - skip\n"); + LLVM_DEBUG(dbgs() << "TII unable to Analyze Branch - skip\n"); return false; } for (auto &I : Cand.BranchBlock->terminators()) { - DEBUG(dbgs() << "Looking at terminator : " << I << "\n"); + LLVM_DEBUG(dbgs() << "Looking at terminator : " << I << "\n"); if (!I.isBranch()) continue; @@ -265,14 +265,14 @@ // must then be extended to prove that none of the implicit operands are // changed in the blocks that are combined during coalescing. if (I.getNumOperands() != I.getNumExplicitOperands()) { - DEBUG(dbgs() << "Terminator contains implicit operands - skip : " << I + LLVM_DEBUG(dbgs() << "Terminator contains implicit operands - skip : " << I << "\n"); return false; } } if (Cand.BranchBlock->isEHPad() || Cand.BranchBlock->hasEHPadSuccessor()) { - DEBUG(dbgs() << "EH Pad - skip\n"); + LLVM_DEBUG(dbgs() << "EH Pad - skip\n"); return false; } @@ -280,13 +280,13 @@ // FalseMBB is null, and BranchTargetBlock is a successor to BranchBlock) if (!Cand.BranchTargetBlock || FalseMBB || !Cand.BranchBlock->isSuccessor(Cand.BranchTargetBlock)) { - DEBUG(dbgs() << "Does not form a triangle - skip\n"); + LLVM_DEBUG(dbgs() << "Does not form a triangle - skip\n"); return false; } // Ensure there are only two successors if (Cand.BranchBlock->succ_size() != 2) { - DEBUG(dbgs() << "Does not have 2 successors - skip\n"); + LLVM_DEBUG(dbgs() << "Does not have 2 successors - skip\n"); return false; } @@ -305,18 +305,18 @@ assert(Succ && "Expecting a valid fall-through block\n"); if (!Succ->empty()) { - DEBUG(dbgs() << "Fall-through block contains code -- skip\n"); + LLVM_DEBUG(dbgs() << "Fall-through block contains code -- skip\n"); return false; } if (!Succ->isSuccessor(Cand.BranchTargetBlock)) { - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "Successor of fall through block is not branch taken block\n"); return false; } Cand.FallThroughBlock = Succ; - DEBUG(dbgs() << "Valid Candidate\n"); + LLVM_DEBUG(dbgs() << "Valid Candidate\n"); return true; } @@ -331,7 +331,7 @@ ArrayRef OpList1, ArrayRef OpList2) const { if (OpList1.size() != OpList2.size()) { - DEBUG(dbgs() << "Operand list is different size\n"); + LLVM_DEBUG(dbgs() << "Operand list is different size\n"); return false; } @@ -339,7 +339,7 @@ const MachineOperand &Op1 = OpList1[i]; const MachineOperand &Op2 = OpList2[i]; - DEBUG(dbgs() << "Op1: " << Op1 << "\n" + LLVM_DEBUG(dbgs() << "Op1: " << Op1 << "\n" << "Op2: " << Op2 << "\n"); if (Op1.isIdenticalTo(Op2)) { @@ -348,10 +348,10 @@ // If the physical register is constant then we can assume the value // has not changed between uses. && !(Op1.isUse() && MRI->isConstantPhysReg(Op1.getReg()))) { - DEBUG(dbgs() << "The operands are not provably identical.\n"); + LLVM_DEBUG(dbgs() << "The operands are not provably identical.\n"); return false; } - DEBUG(dbgs() << "Op1 and Op2 are identical!\n"); + LLVM_DEBUG(dbgs() << "Op1 and Op2 are identical!\n"); continue; } @@ -364,14 +364,14 @@ MachineInstr *Op1Def = MRI->getVRegDef(Op1.getReg()); MachineInstr *Op2Def = MRI->getVRegDef(Op2.getReg()); if (TII->produceSameValue(*Op1Def, *Op2Def, MRI)) { - DEBUG(dbgs() << "Op1Def: " << *Op1Def << " and " << *Op2Def + LLVM_DEBUG(dbgs() << "Op1Def: " << *Op1Def << " and " << *Op2Def << " produce the same value!\n"); } else { - DEBUG(dbgs() << "Operands produce different values\n"); + LLVM_DEBUG(dbgs() << "Operands produce different values\n"); return false; } } else { - DEBUG(dbgs() << "The operands are not provably identical.\n"); + LLVM_DEBUG(dbgs() << "The operands are not provably identical.\n"); return false; } } @@ -395,7 +395,7 @@ MachineBasicBlock::iterator ME = SourceMBB->getFirstNonPHI(); if (MI == ME) { - DEBUG(dbgs() << "SourceMBB contains no PHI instructions.\n"); + LLVM_DEBUG(dbgs() << "SourceMBB contains no PHI instructions.\n"); return; } @@ -425,19 +425,19 @@ const MachineBasicBlock &TargetMBB ) const { - DEBUG(dbgs() << "Checking if " << MI << " can move to beginning of " + LLVM_DEBUG(dbgs() << "Checking if " << MI << " can move to beginning of " << TargetMBB.getNumber() << "\n"); for (auto &Def : MI.defs()) { // Looking at Def for (auto &Use : MRI->use_instructions(Def.getReg())) { if (Use.isPHI() && Use.getParent() == &TargetMBB) { - DEBUG(dbgs() << " *** used in a PHI -- cannot move ***\n"); + LLVM_DEBUG(dbgs() << " *** used in a PHI -- cannot move ***\n"); return false; } } } - DEBUG(dbgs() << " Safe to move to the beginning.\n"); + LLVM_DEBUG(dbgs() << " Safe to move to the beginning.\n"); return true; } @@ -456,22 +456,22 @@ const MachineBasicBlock &TargetMBB ) const { - DEBUG(dbgs() << "Checking if " << MI << " can move to end of " + LLVM_DEBUG(dbgs() << "Checking if " << MI << " can move to end of " << TargetMBB.getNumber() << "\n"); for (auto &Use : MI.uses()) { if (Use.isReg() && TargetRegisterInfo::isVirtualRegister(Use.getReg())) { MachineInstr *DefInst = MRI->getVRegDef(Use.getReg()); if (DefInst->isPHI() && DefInst->getParent() == MI.getParent()) { - DEBUG(dbgs() << " *** Cannot move this instruction ***\n"); + LLVM_DEBUG(dbgs() << " *** Cannot move this instruction ***\n"); return false; } else { - DEBUG(dbgs() << " *** def is in another block -- safe to move!\n"); + LLVM_DEBUG(dbgs() << " *** def is in another block -- safe to move!\n"); } } } - DEBUG(dbgs() << " Safe to move to the end.\n"); + LLVM_DEBUG(dbgs() << " Safe to move to the end.\n"); return true; } @@ -541,13 +541,13 @@ for (auto &Def : I->defs()) for (auto &Use : MRI->use_instructions(Def.getReg())) { if (Use.isPHI() && Use.getParent() == SourceRegion.BranchTargetBlock) { - DEBUG(dbgs() << "PHI " << *I << " defines register used in another " + LLVM_DEBUG(dbgs() << "PHI " << *I << " defines register used in another " "PHI within branch target block -- can't merge\n"); NumPHINotMoved++; return false; } if (Use.getParent() == SourceRegion.BranchBlock) { - DEBUG(dbgs() << "PHI " << *I + LLVM_DEBUG(dbgs() << "PHI " << *I << " defines register used in this " "block -- all must move down\n"); SourceRegion.MustMoveDown = true; @@ -562,12 +562,12 @@ E = SourceRegion.BranchBlock->end(); I != E; ++I) { if (!canMoveToBeginning(*I, *SourceRegion.BranchTargetBlock)) { - DEBUG(dbgs() << "Instruction " << *I + LLVM_DEBUG(dbgs() << "Instruction " << *I << " cannot move down - must move up!\n"); SourceRegion.MustMoveUp = true; } if (!canMoveToEnd(*I, *TargetRegion.BranchBlock)) { - DEBUG(dbgs() << "Instruction " << *I + LLVM_DEBUG(dbgs() << "Instruction " << *I << " cannot move up - must move down!\n"); SourceRegion.MustMoveDown = true; } @@ -719,10 +719,10 @@ bool didSomething = false; - DEBUG(dbgs() << "******** Branch Coalescing ********\n"); + LLVM_DEBUG(dbgs() << "******** Branch Coalescing ********\n"); initialize(MF); - DEBUG(dbgs() << "Function: "; MF.dump(); dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Function: "; MF.dump(); dbgs() << "\n"); CoalescingCandidateInfo Cand1, Cand2; // Walk over blocks and find candidates to merge @@ -752,24 +752,24 @@ "Branch-taken block should post-dominate first candidate"); if (!identicalOperands(Cand1.Cond, Cand2.Cond)) { - DEBUG(dbgs() << "Blocks " << Cand1.BranchBlock->getNumber() << " and " + LLVM_DEBUG(dbgs() << "Blocks " << Cand1.BranchBlock->getNumber() << " and " << Cand2.BranchBlock->getNumber() << " have different branches\n"); break; } if (!canMerge(Cand2, Cand1)) { - DEBUG(dbgs() << "Cannot merge blocks " << Cand1.BranchBlock->getNumber() + LLVM_DEBUG(dbgs() << "Cannot merge blocks " << Cand1.BranchBlock->getNumber() << " and " << Cand2.BranchBlock->getNumber() << "\n"); NumBlocksNotCoalesced++; continue; } - DEBUG(dbgs() << "Merging blocks " << Cand1.BranchBlock->getNumber() + LLVM_DEBUG(dbgs() << "Merging blocks " << Cand1.BranchBlock->getNumber() << " and " << Cand1.BranchTargetBlock->getNumber() << "\n"); MergedCandidates = mergeCandidates(Cand2, Cand1); if (MergedCandidates) didSomething = true; - DEBUG(dbgs() << "Function after merging: "; MF.dump(); dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Function after merging: "; MF.dump(); dbgs() << "\n"); } while (MergedCandidates); } @@ -779,6 +779,6 @@ MF.verify(nullptr, "Error in code produced by branch coalescing"); #endif // NDEBUG - DEBUG(dbgs() << "Finished Branch Coalescing\n"); + LLVM_DEBUG(dbgs() << "Finished Branch Coalescing\n"); return didSomething; } Index: lib/Target/PowerPC/PPCCTRLoops.cpp =================================================================== --- lib/Target/PowerPC/PPCCTRLoops.cpp +++ lib/Target/PowerPC/PPCCTRLoops.cpp @@ -501,7 +501,7 @@ // Process nested loops first. for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I) { MadeChange |= convertToCTRLoop(*I); - DEBUG(dbgs() << "Nested loop converted\n"); + LLVM_DEBUG(dbgs() << "Nested loop converted\n"); } // If a nested loop has been converted, then we can't convert this loop. @@ -555,7 +555,7 @@ for (SmallVectorImpl::iterator I = ExitingBlocks.begin(), IE = ExitingBlocks.end(); I != IE; ++I) { const SCEV *EC = SE->getExitCount(L, *I); - DEBUG(dbgs() << "Exit Count for " << *L << " from block " << + LLVM_DEBUG(dbgs() << "Exit Count for " << *L << " from block " << (*I)->getName() << ": " << *EC << "\n"); if (isa(EC)) continue; @@ -624,7 +624,7 @@ if (!Preheader) return MadeChange; - DEBUG(dbgs() << "Preheader for exit count: " << Preheader->getName() << "\n"); + LLVM_DEBUG(dbgs() << "Preheader for exit count: " << Preheader->getName() << "\n"); // Insert the count into the preheader and replace the condition used by the // selected branch. @@ -712,7 +712,7 @@ } if (I != BI && clobbersCTR(*I)) { - DEBUG(dbgs() << printMBBReference(*MBB) << " (" << MBB->getFullName() + LLVM_DEBUG(dbgs() << printMBBReference(*MBB) << " (" << MBB->getFullName() << ") instruction " << *I << " clobbers CTR, invalidating " << printMBBReference(*BI->getParent()) << " (" << BI->getParent()->getFullName() << ") instruction " << *BI @@ -730,7 +730,7 @@ if (CheckPreds) { queue_preds: if (MachineFunction::iterator(MBB) == MBB->getParent()->begin()) { - DEBUG(dbgs() << "Unable to find a MTCTR instruction for " + LLVM_DEBUG(dbgs() << "Unable to find a MTCTR instruction for " << printMBBReference(*BI->getParent()) << " (" << BI->getParent()->getFullName() << ") instruction " << *BI << "\n"); Index: lib/Target/PowerPC/PPCExpandISEL.cpp =================================================================== --- lib/Target/PowerPC/PPCExpandISEL.cpp +++ lib/Target/PowerPC/PPCExpandISEL.cpp @@ -126,11 +126,11 @@ #endif bool runOnMachineFunction(MachineFunction &MF) override { - DEBUG(dbgs() << "Function: "; MF.dump(); dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Function: "; MF.dump(); dbgs() << "\n"); initialize(MF); if (!collectISELInstructions()) { - DEBUG(dbgs() << "No ISEL instructions in this function\n"); + LLVM_DEBUG(dbgs() << "No ISEL instructions in this function\n"); return false; } @@ -170,9 +170,9 @@ #ifndef NDEBUG void PPCExpandISEL::DumpISELInstructions() const { for (const auto &I : ISELInstructions) { - DEBUG(dbgs() << printMBBReference(*MF->getBlockNumbered(I.first)) << ":\n"); + LLVM_DEBUG(dbgs() << printMBBReference(*MF->getBlockNumbered(I.first)) << ":\n"); for (const auto &VI : I.second) - DEBUG(dbgs() << " "; VI->print(dbgs())); + LLVM_DEBUG(dbgs() << " "; VI->print(dbgs())); } } #endif @@ -192,7 +192,7 @@ bool ExpandISELEnabled = isExpandISELEnabled(*MF); for (auto &BlockList : ISELInstructions) { - DEBUG(dbgs() << "Expanding ISEL instructions in " + LLVM_DEBUG(dbgs() << "Expanding ISEL instructions in " << printMBBReference(*MF->getBlockNumbered(BlockList.first)) << "\n"); BlockISELList &CurrentISELList = BlockList.second; @@ -210,7 +210,7 @@ // as it would be ISEL %R0, %ZERO, %R0, %CRN. if (useSameRegister(Dest, TrueValue) && useSameRegister(Dest, FalseValue)) { - DEBUG(dbgs() << "Remove redudant ISEL instruction: " << **I << "\n"); + LLVM_DEBUG(dbgs() << "Remove redudant ISEL instruction: " << **I << "\n"); // FIXME: if the CR field used has no other uses, we could eliminate the // instruction that defines it. This would have to be done manually // since this pass runs too late to run DCE after it. @@ -223,8 +223,8 @@ // condition as it would be ISEL %RX, %ZERO, %R0, %CRN, which makes it // safe to fold ISEL to MR(OR) instead of ADDI. MachineBasicBlock *MBB = (*I)->getParent(); - DEBUG(dbgs() << "Fold the ISEL instruction to an unconditonal copy:\n"); - DEBUG(dbgs() << "ISEL: " << **I << "\n"); + LLVM_DEBUG(dbgs() << "Fold the ISEL instruction to an unconditonal copy:\n"); + LLVM_DEBUG(dbgs() << "ISEL: " << **I << "\n"); NumFolded++; // Note: we're using both the TrueValue and FalseValue operands so as // not to lose the kill flag if it is set on either of them. @@ -235,8 +235,8 @@ (*I)->eraseFromParent(); I++; } else if (ExpandISELEnabled) { // Normal cases expansion enabled - DEBUG(dbgs() << "Expand ISEL instructions:\n"); - DEBUG(dbgs() << "ISEL: " << **I << "\n"); + LLVM_DEBUG(dbgs() << "Expand ISEL instructions:\n"); + LLVM_DEBUG(dbgs() << "ISEL: " << **I << "\n"); BlockISELList SubISELList; SubISELList.push_back(*I++); // Collect the ISELs that can be merged together. @@ -244,7 +244,7 @@ // may be redundant or foldable to a register copy. So we still keep // the handleSpecialCases() downstream to handle them. while (I != E && canMerge(SubISELList.back(), *I)) { - DEBUG(dbgs() << "ISEL: " << **I << "\n"); + LLVM_DEBUG(dbgs() << "ISEL: " << **I << "\n"); SubISELList.push_back(*I++); } @@ -264,7 +264,7 @@ auto MI = BIL.begin(); while (MI != BIL.end()) { assert(isISEL(**MI) && "Expecting an ISEL instruction"); - DEBUG(dbgs() << "ISEL: " << **MI << "\n"); + LLVM_DEBUG(dbgs() << "ISEL: " << **MI << "\n"); MachineOperand &Dest = (*MI)->getOperand(0); MachineOperand &TrueValue = (*MI)->getOperand(1); @@ -281,7 +281,7 @@ // Special case 1, all registers used by ISEL are the same one. if (!IsADDIInstRequired && !IsORIInstRequired) { - DEBUG(dbgs() << "Remove redudant ISEL instruction."); + LLVM_DEBUG(dbgs() << "Remove redudant ISEL instruction."); // FIXME: if the CR field used has no other uses, we could eliminate the // instruction that defines it. This would have to be done manually // since this pass runs too late to run DCE after it. @@ -300,7 +300,7 @@ // be zero. In this case, the useSameRegister method will return false, // thereby preventing this ISEL from being folded. if (useSameRegister(TrueValue, FalseValue) && (BIL.size() == 1)) { - DEBUG(dbgs() << "Fold the ISEL instruction to an unconditonal copy."); + LLVM_DEBUG(dbgs() << "Fold the ISEL instruction to an unconditonal copy."); NumFolded++; // Note: we're using both the TrueValue and FalseValue operands so as // not to lose the kill flag if it is set on either of them. @@ -439,10 +439,10 @@ // condition is false MachineOperand &ConditionRegister = MI->getOperand(3); // Condition - DEBUG(dbgs() << "Dest: " << Dest << "\n"); - DEBUG(dbgs() << "TrueValue: " << TrueValue << "\n"); - DEBUG(dbgs() << "FalseValue: " << FalseValue << "\n"); - DEBUG(dbgs() << "ConditionRegister: " << ConditionRegister << "\n"); + LLVM_DEBUG(dbgs() << "Dest: " << Dest << "\n"); + LLVM_DEBUG(dbgs() << "TrueValue: " << TrueValue << "\n"); + LLVM_DEBUG(dbgs() << "FalseValue: " << FalseValue << "\n"); + LLVM_DEBUG(dbgs() << "ConditionRegister: " << ConditionRegister << "\n"); // If the Dest Register and True Value Register are not the same one, we Index: lib/Target/PowerPC/PPCHazardRecognizers.cpp =================================================================== --- lib/Target/PowerPC/PPCHazardRecognizers.cpp +++ lib/Target/PowerPC/PPCHazardRecognizers.cpp @@ -180,9 +180,9 @@ CurGroup.clear(); CurSlots = CurBranches = 0; } else { - DEBUG(dbgs() << "**** Adding to dispatch group: SU(" << + LLVM_DEBUG(dbgs() << "**** Adding to dispatch group: SU(" << SU->NodeNum << "): "); - DEBUG(DAG->dumpNode(SU)); + LLVM_DEBUG(DAG->dumpNode(SU)); unsigned NSlots; bool MustBeFirst = mustComeFirst(MCID, NSlots); @@ -268,7 +268,7 @@ } void PPCHazardRecognizer970::EndDispatchGroup() { - DEBUG(errs() << "=== Start of dispatch group\n"); + LLVM_DEBUG(errs() << "=== Start of dispatch group\n"); NumIssued = 0; // Structural hazard info. Index: lib/Target/PowerPC/PPCISelDAGToDAG.cpp =================================================================== --- lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -494,7 +494,7 @@ if (std::max(TProb, FProb) / Threshold < std::min(TProb, FProb)) return PPC::BR_NO_HINT; - DEBUG(dbgs() << "Use branch hint for '" << FuncInfo->Fn->getName() << "::" + LLVM_DEBUG(dbgs() << "Use branch hint for '" << FuncInfo->Fn->getName() << "::" << BB->getName() << "'\n" << " -> " << TBB->getName() << ": " << TProb << "\n" << " -> " << FBB->getName() << ": " << FProb << "\n"); @@ -1023,7 +1023,7 @@ BitGroup(SDValue V, unsigned R, unsigned S, unsigned E) : V(V), RLAmt(R), StartIdx(S), EndIdx(E), Repl32(false), Repl32CR(false), Repl32Coalesced(false) { - DEBUG(dbgs() << "\tbit group for " << V.getNode() << " RLAmt = " << R << + LLVM_DEBUG(dbgs() << "\tbit group for " << V.getNode() << " RLAmt = " << R << " [" << S << ", " << E << "]\n"); } }; @@ -1258,7 +1258,7 @@ BitGroups[BitGroups.size()-1].EndIdx == Bits.size()-1 && BitGroups[0].V == BitGroups[BitGroups.size()-1].V && BitGroups[0].RLAmt == BitGroups[BitGroups.size()-1].RLAmt) { - DEBUG(dbgs() << "\tcombining final bit group with initial one\n"); + LLVM_DEBUG(dbgs() << "\tcombining final bit group with initial one\n"); BitGroups[BitGroups.size()-1].EndIdx = BitGroups[0].EndIdx; BitGroups.erase(BitGroups.begin()); } @@ -1345,7 +1345,7 @@ BG.Repl32 = true; - DEBUG(dbgs() << "\t32-bit replicated bit group for " << + LLVM_DEBUG(dbgs() << "\t32-bit replicated bit group for " << BG.V.getNode() << " RLAmt = " << BG.RLAmt << " [" << BG.StartIdx << ", " << BG.EndIdx << "]\n"); } @@ -1361,7 +1361,7 @@ if (I->Repl32 && IP->Repl32 && I->V == IP->V && I->RLAmt == IP->RLAmt && I->StartIdx == (IP->EndIdx + 1) % 64 && I != IP) { - DEBUG(dbgs() << "\tcombining 32-bit replicated bit group for " << + LLVM_DEBUG(dbgs() << "\tcombining 32-bit replicated bit group for " << I->V.getNode() << " RLAmt = " << I->RLAmt << " [" << I->StartIdx << ", " << I->EndIdx << "] with group with range [" << @@ -1389,7 +1389,7 @@ IP->EndIdx == 31 && IN->StartIdx == 0 && I != IP && IsAllLow32(*I)) { - DEBUG(dbgs() << "\tcombining bit group for " << + LLVM_DEBUG(dbgs() << "\tcombining bit group for " << I->V.getNode() << " RLAmt = " << I->RLAmt << " [" << I->StartIdx << ", " << I->EndIdx << "] with 32-bit replicated groups with ranges [" << @@ -1503,7 +1503,7 @@ (unsigned) (ANDIMask != 0 && ANDISMask != 0) + (unsigned) (bool) Res; - DEBUG(dbgs() << "\t\trotation groups for " << VRI.V.getNode() << + LLVM_DEBUG(dbgs() << "\t\trotation groups for " << VRI.V.getNode() << " RL: " << VRI.RLAmt << ":" << "\n\t\t\tisel using masking: " << NumAndInsts << " using rotates: " << VRI.NumGroups << "\n"); @@ -1511,7 +1511,7 @@ if (NumAndInsts >= VRI.NumGroups) continue; - DEBUG(dbgs() << "\t\t\t\tusing masking\n"); + LLVM_DEBUG(dbgs() << "\t\t\t\tusing masking\n"); if (InstCnt) *InstCnt += NumAndInsts; @@ -1859,7 +1859,7 @@ FirstBG = false; } - DEBUG(dbgs() << "\t\trotation groups for " << VRI.V.getNode() << + LLVM_DEBUG(dbgs() << "\t\trotation groups for " << VRI.V.getNode() << " RL: " << VRI.RLAmt << (VRI.Repl32 ? " (32):" : ":") << "\n\t\t\tisel using masking: " << NumAndInsts << " using rotates: " << NumRLInsts << "\n"); @@ -1876,7 +1876,7 @@ if ((Use32BitInsts || MoreBG) && NumAndInsts == NumRLInsts) continue; - DEBUG(dbgs() << "\t\t\t\tusing masking\n"); + LLVM_DEBUG(dbgs() << "\t\t\t\tusing masking\n"); if (InstCnt) *InstCnt += NumAndInsts; @@ -2127,9 +2127,9 @@ return nullptr; Bits = std::move(*Result.second); - DEBUG(dbgs() << "Considering bit-permutation-based instruction" + LLVM_DEBUG(dbgs() << "Considering bit-permutation-based instruction" " selection for: "); - DEBUG(N->dump(CurDAG)); + LLVM_DEBUG(N->dump(CurDAG)); // Fill it RLAmt and set HasZeros. computeRotationAmounts(); @@ -2146,21 +2146,21 @@ // masking, we only insert the non-zero parts of the result at every step. unsigned InstCnt, InstCntLateMask; - DEBUG(dbgs() << "\tEarly masking:\n"); + LLVM_DEBUG(dbgs() << "\tEarly masking:\n"); SDNode *RN = Select(N, false, &InstCnt); - DEBUG(dbgs() << "\t\tisel would use " << InstCnt << " instructions\n"); + LLVM_DEBUG(dbgs() << "\t\tisel would use " << InstCnt << " instructions\n"); - DEBUG(dbgs() << "\tLate masking:\n"); + LLVM_DEBUG(dbgs() << "\tLate masking:\n"); SDNode *RNLM = Select(N, true, &InstCntLateMask); - DEBUG(dbgs() << "\t\tisel would use " << InstCntLateMask << + LLVM_DEBUG(dbgs() << "\t\tisel would use " << InstCntLateMask << " instructions\n"); if (InstCnt <= InstCntLateMask) { - DEBUG(dbgs() << "\tUsing early-masking for isel\n"); + LLVM_DEBUG(dbgs() << "\tUsing early-masking for isel\n"); return RN; } - DEBUG(dbgs() << "\tUsing late-masking for isel\n"); + LLVM_DEBUG(dbgs() << "\tUsing late-masking for isel\n"); return RNLM; } }; @@ -4945,11 +4945,11 @@ foldBoolExts(Res, N); if (Res) { - DEBUG(dbgs() << "PPC DAG preprocessing replacing:\nOld: "); - DEBUG(N->dump(CurDAG)); - DEBUG(dbgs() << "\nNew: "); - DEBUG(Res.getNode()->dump(CurDAG)); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "PPC DAG preprocessing replacing:\nOld: "); + LLVM_DEBUG(N->dump(CurDAG)); + LLVM_DEBUG(dbgs() << "\nNew: "); + LLVM_DEBUG(Res.getNode()->dump(CurDAG)); + LLVM_DEBUG(dbgs() << "\n"); CurDAG->ReplaceAllUsesOfValueWith(SDValue(N, 0), Res); MadeChange = true; @@ -5026,11 +5026,11 @@ User->getOperand(2), User->getOperand(1)); - DEBUG(dbgs() << "CR Peephole replacing:\nOld: "); - DEBUG(User->dump(CurDAG)); - DEBUG(dbgs() << "\nNew: "); - DEBUG(ResNode->dump(CurDAG)); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "CR Peephole replacing:\nOld: "); + LLVM_DEBUG(User->dump(CurDAG)); + LLVM_DEBUG(dbgs() << "\nNew: "); + LLVM_DEBUG(ResNode->dump(CurDAG)); + LLVM_DEBUG(dbgs() << "\n"); ReplaceUses(User, ResNode); } @@ -5440,11 +5440,11 @@ SwapAllSelectUsers(MachineNode); if (ResNode != MachineNode) { - DEBUG(dbgs() << "CR Peephole replacing:\nOld: "); - DEBUG(MachineNode->dump(CurDAG)); - DEBUG(dbgs() << "\nNew: "); - DEBUG(ResNode->dump(CurDAG)); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "CR Peephole replacing:\nOld: "); + LLVM_DEBUG(MachineNode->dump(CurDAG)); + LLVM_DEBUG(dbgs() << "\nNew: "); + LLVM_DEBUG(ResNode->dump(CurDAG)); + LLVM_DEBUG(dbgs() << "\n"); ReplaceUses(MachineNode, ResNode); IsModified = true; @@ -5739,25 +5739,25 @@ else NewVTs.push_back(VTs.VTs[i]); - DEBUG(dbgs() << "PPC64 ZExt Peephole morphing:\nOld: "); - DEBUG(PN->dump(CurDAG)); + LLVM_DEBUG(dbgs() << "PPC64 ZExt Peephole morphing:\nOld: "); + LLVM_DEBUG(PN->dump(CurDAG)); CurDAG->SelectNodeTo(PN, NewOpcode, CurDAG->getVTList(NewVTs), Ops); - DEBUG(dbgs() << "\nNew: "); - DEBUG(PN->dump(CurDAG)); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\nNew: "); + LLVM_DEBUG(PN->dump(CurDAG)); + LLVM_DEBUG(dbgs() << "\n"); } // Now we replace the original zero extend and its associated INSERT_SUBREG // with the value feeding the INSERT_SUBREG (which has now been promoted to // return an i64). - DEBUG(dbgs() << "PPC64 ZExt Peephole replacing:\nOld: "); - DEBUG(N->dump(CurDAG)); - DEBUG(dbgs() << "\nNew: "); - DEBUG(Op32.getNode()->dump(CurDAG)); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "PPC64 ZExt Peephole replacing:\nOld: "); + LLVM_DEBUG(N->dump(CurDAG)); + LLVM_DEBUG(dbgs() << "\nNew: "); + LLVM_DEBUG(Op32.getNode()->dump(CurDAG)); + LLVM_DEBUG(dbgs() << "\n"); ReplaceUses(N, Op32.getNode()); } @@ -5932,11 +5932,11 @@ // immediate and substitute them into the load or store. If // needed, update the target flags for the immediate operand to // reflect the necessary relocation information. - DEBUG(dbgs() << "Folding add-immediate into mem-op:\nBase: "); - DEBUG(Base->dump(CurDAG)); - DEBUG(dbgs() << "\nN: "); - DEBUG(N->dump(CurDAG)); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Folding add-immediate into mem-op:\nBase: "); + LLVM_DEBUG(Base->dump(CurDAG)); + LLVM_DEBUG(dbgs() << "\nN: "); + LLVM_DEBUG(N->dump(CurDAG)); + LLVM_DEBUG(dbgs() << "\n"); // If the relocation information isn't already present on the // immediate operand, add it now. @@ -5949,7 +5949,7 @@ if (GV->getAlignment() < 4 && (StorageOpcode == PPC::LD || StorageOpcode == PPC::STD || StorageOpcode == PPC::LWA || (Offset % 4) != 0)) { - DEBUG(dbgs() << "Rejected this candidate for alignment.\n\n"); + LLVM_DEBUG(dbgs() << "Rejected this candidate for alignment.\n\n"); continue; } ImmOpnd = CurDAG->getTargetGlobalAddress(GV, dl, MVT::i64, Offset, Flags); Index: lib/Target/PowerPC/PPCISelLowering.cpp =================================================================== --- lib/Target/PowerPC/PPCISelLowering.cpp +++ lib/Target/PowerPC/PPCISelLowering.cpp @@ -5112,7 +5112,7 @@ assert(isa(Callee) && "Callee should be an llvm::Function object."); - DEBUG( + LLVM_DEBUG( const GlobalValue *GV = cast(Callee)->getGlobal(); const unsigned Width = 80 - strlen("TCO caller: ") - strlen(", callee linkage: 0, 0"); Index: lib/Target/PowerPC/PPCInstrInfo.cpp =================================================================== --- lib/Target/PowerPC/PPCInstrInfo.cpp +++ lib/Target/PowerPC/PPCInstrInfo.cpp @@ -2391,16 +2391,16 @@ CompareUseMI.RemoveOperand(2); continue; } - DEBUG(dbgs() << "Found LI -> CMPI -> ISEL, replacing with a copy.\n"); - DEBUG(DefMI->dump(); MI.dump(); CompareUseMI.dump()); - DEBUG(dbgs() << "Is converted to:\n"); + LLVM_DEBUG(dbgs() << "Found LI -> CMPI -> ISEL, replacing with a copy.\n"); + LLVM_DEBUG(DefMI->dump(); MI.dump(); CompareUseMI.dump()); + LLVM_DEBUG(dbgs() << "Is converted to:\n"); // Convert to copy and remove unneeded operands. CompareUseMI.setDesc(get(PPC::COPY)); CompareUseMI.RemoveOperand(3); CompareUseMI.RemoveOperand(RegToCopy == TrueReg ? 2 : 1); CmpIselsConverted++; Changed = true; - DEBUG(CompareUseMI.dump()); + LLVM_DEBUG(CompareUseMI.dump()); } if (Changed) return true; @@ -2500,10 +2500,10 @@ } if (ReplaceWithLI) { - DEBUG(dbgs() << "Replacing instruction:\n"); - DEBUG(MI.dump()); - DEBUG(dbgs() << "Fed by:\n"); - DEBUG(DefMI->dump()); + LLVM_DEBUG(dbgs() << "Replacing instruction:\n"); + LLVM_DEBUG(MI.dump()); + LLVM_DEBUG(dbgs() << "Fed by:\n"); + LLVM_DEBUG(DefMI->dump()); LoadImmediateInfo LII; LII.Imm = NewImm; LII.Is64Bit = Is64BitLI; @@ -2513,8 +2513,8 @@ if (KilledDef && SetCR) *KilledDef = nullptr; replaceInstrWithLI(MI, LII); - DEBUG(dbgs() << "With:\n"); - DEBUG(MI.dump()); + LLVM_DEBUG(dbgs() << "With:\n"); + LLVM_DEBUG(MI.dump()); return true; } return false; Index: lib/Target/PowerPC/PPCLoopPreIncPrep.cpp =================================================================== --- lib/Target/PowerPC/PPCLoopPreIncPrep.cpp +++ lib/Target/PowerPC/PPCLoopPreIncPrep.cpp @@ -246,7 +246,7 @@ if (!L->empty()) return MadeChange; - DEBUG(dbgs() << "PIP: Examining: " << *L << "\n"); + LLVM_DEBUG(dbgs() << "PIP: Examining: " << *L << "\n"); BasicBlock *Header = L->getHeader(); @@ -332,7 +332,7 @@ if (!LoopPredecessor) return MadeChange; - DEBUG(dbgs() << "PIP: Found " << Buckets.size() << " buckets\n"); + LLVM_DEBUG(dbgs() << "PIP: Found " << Buckets.size() << " buckets\n"); SmallSet BBChanged; for (unsigned i = 0, e = Buckets.size(); i != e; ++i) { @@ -381,7 +381,7 @@ if (!BasePtrSCEV->isAffine()) continue; - DEBUG(dbgs() << "PIP: Transforming: " << *BasePtrSCEV << "\n"); + LLVM_DEBUG(dbgs() << "PIP: Transforming: " << *BasePtrSCEV << "\n"); assert(BasePtrSCEV->getLoop() == L && "AddRec for the wrong loop?"); @@ -407,7 +407,7 @@ if (!isSafeToExpand(BasePtrStartSCEV, *SE)) continue; - DEBUG(dbgs() << "PIP: New start is: " << *BasePtrStartSCEV << "\n"); + LLVM_DEBUG(dbgs() << "PIP: New start is: " << *BasePtrStartSCEV << "\n"); if (alreadyPrepared(L, MemI, BasePtrStartSCEV, BasePtrIncSCEV)) continue; Index: lib/Target/PowerPC/PPCMIPeephole.cpp =================================================================== --- lib/Target/PowerPC/PPCMIPeephole.cpp +++ lib/Target/PowerPC/PPCMIPeephole.cpp @@ -119,8 +119,8 @@ MRI = &MF->getRegInfo(); MDT = &getAnalysis(); TII = MF->getSubtarget().getInstrInfo(); - DEBUG(dbgs() << "*** PowerPC MI peephole pass ***\n\n"); - DEBUG(MF->dump()); + LLVM_DEBUG(dbgs() << "*** PowerPC MI peephole pass ***\n\n"); + LLVM_DEBUG(MF->dump()); } static MachineInstr *getVRegDefOrNull(MachineOperand *Op, @@ -238,8 +238,8 @@ if (TII->convertToImmediateForm(MI)) { // We don't erase anything in case the def has other uses. Let DCE // remove it if it can be removed. - DEBUG(dbgs() << "Converted instruction to imm form: "); - DEBUG(MI.dump()); + LLVM_DEBUG(dbgs() << "Converted instruction to imm form: "); + LLVM_DEBUG(MI.dump()); NumConvertedToImmediateForm++; SomethingChanged = true; Simplified = true; @@ -324,10 +324,10 @@ }; if (DefMI && (Immed == 0 || Immed == 3)) { if (DefOpc == PPC::LXVDSX || isConversionOfLoadAndSplat()) { - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "Optimizing load-and-splat/splat " "to load-and-splat/copy: "); - DEBUG(MI.dump()); + LLVM_DEBUG(MI.dump()); BuildMI(MBB, &MI, MI.getDebugLoc(), TII->get(PPC::COPY), MI.getOperand(0).getReg()) .add(MI.getOperand(1)); @@ -346,10 +346,10 @@ TII->lookThruCopyLike(DefMI->getOperand(2).getReg(), MRI); if ((FeedImmed == 0 || FeedImmed == 3) && FeedReg1 == FeedReg2) { - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "Optimizing splat/swap or splat/splat " "to splat/copy: "); - DEBUG(MI.dump()); + LLVM_DEBUG(MI.dump()); BuildMI(MBB, &MI, MI.getDebugLoc(), TII->get(PPC::COPY), MI.getOperand(0).getReg()) .add(MI.getOperand(1)); @@ -362,8 +362,8 @@ // parameter. else if ((Immed == 0 || Immed == 3) && FeedImmed == 2 && FeedReg1 == FeedReg2) { - DEBUG(dbgs() << "Optimizing swap/splat => splat: "); - DEBUG(MI.dump()); + LLVM_DEBUG(dbgs() << "Optimizing swap/splat => splat: "); + LLVM_DEBUG(MI.dump()); MI.getOperand(1).setReg(DefMI->getOperand(1).getReg()); MI.getOperand(2).setReg(DefMI->getOperand(2).getReg()); MI.getOperand(3).setImm(3 - Immed); @@ -373,8 +373,8 @@ // If this is a swap fed by a swap, we can replace it // with a copy from the first swap's input. else if (Immed == 2 && FeedImmed == 2 && FeedReg1 == FeedReg2) { - DEBUG(dbgs() << "Optimizing swap/swap => copy: "); - DEBUG(MI.dump()); + LLVM_DEBUG(dbgs() << "Optimizing swap/swap => copy: "); + LLVM_DEBUG(MI.dump()); BuildMI(MBB, &MI, MI.getDebugLoc(), TII->get(PPC::COPY), MI.getOperand(0).getReg()) .add(DefMI->getOperand(1)); @@ -389,8 +389,8 @@ DefMI->getOperand(0).setReg(MI.getOperand(0).getReg()); ToErase = &MI; Simplified = true; - DEBUG(dbgs() << "Removing redundant splat: "); - DEBUG(MI.dump()); + LLVM_DEBUG(dbgs() << "Removing redundant splat: "); + LLVM_DEBUG(MI.dump()); } } } @@ -429,8 +429,8 @@ // If the instruction[s] that feed this splat have already splat // the value, this splat is redundant. if (AlreadySplat) { - DEBUG(dbgs() << "Changing redundant splat to a copy: "); - DEBUG(MI.dump()); + LLVM_DEBUG(dbgs() << "Changing redundant splat to a copy: "); + LLVM_DEBUG(MI.dump()); BuildMI(MBB, &MI, MI.getDebugLoc(), TII->get(PPC::COPY), MI.getOperand(0).getReg()) .add(MI.getOperand(OpNo)); @@ -448,14 +448,14 @@ if (ShiftOp1 == ShiftOp2) { unsigned NewElem = (SplatImm + ShiftImm) & 0x3; if (MRI->hasOneNonDBGUse(ShiftRes)) { - DEBUG(dbgs() << "Removing redundant shift: "); - DEBUG(DefMI->dump()); + LLVM_DEBUG(dbgs() << "Removing redundant shift: "); + LLVM_DEBUG(DefMI->dump()); ToErase = DefMI; } Simplified = true; - DEBUG(dbgs() << "Changing splat immediate from " << SplatImm << + LLVM_DEBUG(dbgs() << "Changing splat immediate from " << SplatImm << " to " << NewElem << " in instruction: "); - DEBUG(MI.dump()); + LLVM_DEBUG(MI.dump()); MI.getOperand(1).setReg(ShiftOp1); MI.getOperand(2).setImm(NewElem); } @@ -499,12 +499,12 @@ if (Use.getOperand(i).isReg() && Use.getOperand(i).getReg() == FRSPDefines) Use.getOperand(i).setReg(ConvReg1); - DEBUG(dbgs() << "Removing redundant FRSP:\n"); - DEBUG(RoundInstr->dump()); - DEBUG(dbgs() << "As it feeds instruction:\n"); - DEBUG(MI.dump()); - DEBUG(dbgs() << "Through instruction:\n"); - DEBUG(DefMI->dump()); + LLVM_DEBUG(dbgs() << "Removing redundant FRSP:\n"); + LLVM_DEBUG(RoundInstr->dump()); + LLVM_DEBUG(dbgs() << "As it feeds instruction:\n"); + LLVM_DEBUG(MI.dump()); + LLVM_DEBUG(dbgs() << "Through instruction:\n"); + LLVM_DEBUG(DefMI->dump()); RoundInstr->eraseFromParent(); } }; @@ -552,11 +552,11 @@ }; unsigned Opc = getSextLoadOp(is64Bit(MI.getOpcode()), isXForm(SrcMI->getOpcode())); - DEBUG(dbgs() << "Zero-extending load\n"); - DEBUG(SrcMI->dump()); - DEBUG(dbgs() << "and sign-extension\n"); - DEBUG(MI.dump()); - DEBUG(dbgs() << "are merged into sign-extending load\n"); + LLVM_DEBUG(dbgs() << "Zero-extending load\n"); + LLVM_DEBUG(SrcMI->dump()); + LLVM_DEBUG(dbgs() << "and sign-extension\n"); + LLVM_DEBUG(MI.dump()); + LLVM_DEBUG(dbgs() << "are merged into sign-extending load\n"); SrcMI->setDesc(TII->get(Opc)); SrcMI->getOperand(0).setReg(MI.getOperand(0).getReg()); ToErase = &MI; @@ -596,11 +596,11 @@ }; unsigned Opc = getSextLoadOp(is64Bit(MI.getOpcode()), isXForm(SrcMI->getOpcode())); - DEBUG(dbgs() << "Zero-extending load\n"); - DEBUG(SrcMI->dump()); - DEBUG(dbgs() << "and sign-extension\n"); - DEBUG(MI.dump()); - DEBUG(dbgs() << "are merged into sign-extending load\n"); + LLVM_DEBUG(dbgs() << "Zero-extending load\n"); + LLVM_DEBUG(SrcMI->dump()); + LLVM_DEBUG(dbgs() << "and sign-extension\n"); + LLVM_DEBUG(MI.dump()); + LLVM_DEBUG(dbgs() << "are merged into sign-extending load\n"); SrcMI->setDesc(TII->get(Opc)); SrcMI->getOperand(0).setReg(MI.getOperand(0).getReg()); ToErase = &MI; @@ -610,7 +610,7 @@ TII->isSignExtended(*SrcMI)) { // We can eliminate EXTSW if the input is known to be already // sign-extended. - DEBUG(dbgs() << "Removing redundant sign-extension\n"); + LLVM_DEBUG(dbgs() << "Removing redundant sign-extension\n"); unsigned TmpReg = MF->getRegInfo().createVirtualRegister(&PPC::G8RCRegClass); BuildMI(MBB, &MI, MI.getDebugLoc(), TII->get(PPC::IMPLICIT_DEF), @@ -661,7 +661,7 @@ unsigned KnownZeroCount = getKnownLeadingZeroCount(SrcMI, TII); if (MI.getOperand(3).getImm() <= KnownZeroCount) { - DEBUG(dbgs() << "Removing redundant zero-extension\n"); + LLVM_DEBUG(dbgs() << "Removing redundant zero-extension\n"); BuildMI(MBB, &MI, MI.getDebugLoc(), TII->get(PPC::COPY), MI.getOperand(0).getReg()) .addReg(SrcReg); @@ -727,8 +727,8 @@ MachineInstr *DefPhiMI = getVRegDefOrNull(&Op1, MRI); for (unsigned i = 1; i < DefPhiMI->getNumOperands(); i += 2) { MachineInstr *LiMI = getVRegDefOrNull(&DefPhiMI->getOperand(i), MRI); - DEBUG(dbgs() << "Optimizing LI to ADDI: "); - DEBUG(LiMI->dump()); + LLVM_DEBUG(dbgs() << "Optimizing LI to ADDI: "); + LLVM_DEBUG(LiMI->dump()); // There could be repeated registers in the PHI, e.g: %1 = // PHI %6, <%bb.2>, %8, <%bb.3>, %8, <%bb.6>; So if we've @@ -746,12 +746,12 @@ MachineInstrBuilder(*LiMI->getParent()->getParent(), *LiMI) .addReg(DominatorReg) .addImm(LiImm); // restore the imm of LI - DEBUG(LiMI->dump()); + LLVM_DEBUG(LiMI->dump()); } // Replace ADD with COPY - DEBUG(dbgs() << "Optimizing ADD to COPY: "); - DEBUG(MI.dump()); + LLVM_DEBUG(dbgs() << "Optimizing ADD to COPY: "); + LLVM_DEBUG(MI.dump()); BuildMI(MBB, &MI, MI.getDebugLoc(), TII->get(PPC::COPY), MI.getOperand(0).getReg()) .add(Op1); @@ -1197,11 +1197,11 @@ continue; } - DEBUG(dbgs() << "Optimize two pairs of compare and branch:\n"); - DEBUG(CMPI1->dump()); - DEBUG(BI1->dump()); - DEBUG(CMPI2->dump()); - DEBUG(BI2->dump()); + LLVM_DEBUG(dbgs() << "Optimize two pairs of compare and branch:\n"); + LLVM_DEBUG(CMPI1->dump()); + LLVM_DEBUG(BI1->dump()); + LLVM_DEBUG(CMPI2->dump()); + LLVM_DEBUG(BI2->dump()); // We adjust opcode, predicates and immediate as we determined above. if (NewOpCode != 0 && NewOpCode != CMPI1->getOpcode()) { @@ -1260,15 +1260,15 @@ BI2->getOperand(1).setIsKill(true); BI1->getOperand(1).setIsKill(false); - DEBUG(dbgs() << "into a compare and two branches:\n"); - DEBUG(CMPI1->dump()); - DEBUG(BI1->dump()); - DEBUG(BI2->dump()); + LLVM_DEBUG(dbgs() << "into a compare and two branches:\n"); + LLVM_DEBUG(CMPI1->dump()); + LLVM_DEBUG(BI1->dump()); + LLVM_DEBUG(BI2->dump()); if (IsPartiallyRedundant) { - DEBUG(dbgs() << "The following compare is moved into " + LLVM_DEBUG(dbgs() << "The following compare is moved into " << printMBBReference(*MBBtoMoveCmp) << " to handle partial redundancy.\n"); - DEBUG(CMPI2->dump()); + LLVM_DEBUG(CMPI2->dump()); } Simplified = true; Index: lib/Target/PowerPC/PPCPreEmitPeephole.cpp =================================================================== --- lib/Target/PowerPC/PPCPreEmitPeephole.cpp +++ lib/Target/PowerPC/PPCPreEmitPeephole.cpp @@ -67,8 +67,8 @@ if (TII->convertToImmediateForm(MI, &DefMIToErase)) { Changed = true; NumRRConvertedInPreEmit++; - DEBUG(dbgs() << "Converted instruction to imm form: "); - DEBUG(MI.dump()); + LLVM_DEBUG(dbgs() << "Converted instruction to imm form: "); + LLVM_DEBUG(MI.dump()); if (DefMIToErase) { InstrsToErase.push_back(DefMIToErase); } @@ -76,8 +76,8 @@ } } for (MachineInstr *MI : InstrsToErase) { - DEBUG(dbgs() << "PPC pre-emit peephole: erasing instruction: "); - DEBUG(MI->dump()); + LLVM_DEBUG(dbgs() << "PPC pre-emit peephole: erasing instruction: "); + LLVM_DEBUG(MI->dump()); MI->eraseFromParent(); NumRemovedInPreEmit++; } Index: lib/Target/PowerPC/PPCReduceCRLogicals.cpp =================================================================== --- lib/Target/PowerPC/PPCReduceCRLogicals.cpp +++ lib/Target/PowerPC/PPCReduceCRLogicals.cpp @@ -149,7 +149,7 @@ MachineRegisterInfo *MRI = &MF->getRegInfo(); assert(MRI->isSSA() && "Can only do this while the function is in SSA form."); if (ThisMBB->succ_size() != 2) { - DEBUG(dbgs() << "Don't know how to handle blocks that don't have exactly" + LLVM_DEBUG(dbgs() << "Don't know how to handle blocks that don't have exactly" << " two succesors.\n"); return false; } @@ -217,9 +217,9 @@ } addIncomingValuesToPHIs(NewBRTarget, ThisMBB, NewMBB, MRI); - DEBUG(dbgs() << "After splitting, ThisMBB:\n"; ThisMBB->dump()); - DEBUG(dbgs() << "NewMBB:\n"; NewMBB->dump()); - DEBUG(dbgs() << "New branch-to block:\n"; NewBRTarget->dump()); + LLVM_DEBUG(dbgs() << "After splitting, ThisMBB:\n"; ThisMBB->dump()); + LLVM_DEBUG(dbgs() << "NewMBB:\n"; NewMBB->dump()); + LLVM_DEBUG(dbgs() << "New branch-to block:\n"; NewBRTarget->dump()); return true; } @@ -490,7 +490,7 @@ Ret.ContainedInBlock &= (MIParam.getParent() == Ret.TrueDefs.second->getParent()); } - DEBUG(Ret.dump()); + LLVM_DEBUG(Ret.dump()); if (Ret.IsBinary && Ret.ContainedInBlock && Ret.SingleUse) { NumContainedSingleUseBinOps++; if (Ret.FeedsBR && Ret.DefsSingleUse) @@ -584,13 +584,13 @@ /// BC %vr9, ; CRBITRC:%vr9 bool PPCReduceCRLogicals::splitBlockOnBinaryCROp(CRLogicalOpInfo &CRI) { if (CRI.CopyDefs.first == CRI.CopyDefs.second) { - DEBUG(dbgs() << "Unable to split as the two operands are the same\n"); + LLVM_DEBUG(dbgs() << "Unable to split as the two operands are the same\n"); NumNotSplitIdenticalOperands++; return false; } if (CRI.TrueDefs.first->isCopy() || CRI.TrueDefs.second->isCopy() || CRI.TrueDefs.first->isPHI() || CRI.TrueDefs.second->isPHI()) { - DEBUG(dbgs() << "Unable to split because one of the operands is a PHI or " + LLVM_DEBUG(dbgs() << "Unable to split because one of the operands is a PHI or " "chain of copies.\n"); NumNotSplitChainCopies++; return false; @@ -602,11 +602,11 @@ CRI.MI->getOpcode() != PPC::CRNAND && CRI.MI->getOpcode() != PPC::CRORC && CRI.MI->getOpcode() != PPC::CRANDC) { - DEBUG(dbgs() << "Unable to split blocks on this opcode.\n"); + LLVM_DEBUG(dbgs() << "Unable to split blocks on this opcode.\n"); NumNotSplitWrongOpcode++; return false; } - DEBUG(dbgs() << "Splitting the following CR op:\n"; CRI.dump()); + LLVM_DEBUG(dbgs() << "Splitting the following CR op:\n"; CRI.dump()); MachineBasicBlock::iterator Def1It = CRI.TrueDefs.first; MachineBasicBlock::iterator Def2It = CRI.TrueDefs.second; @@ -620,9 +620,9 @@ } } - DEBUG(dbgs() << "We will split the following block:\n";); - DEBUG(CRI.MI->getParent()->dump()); - DEBUG(dbgs() << "Before instruction:\n"; SplitBefore->dump()); + LLVM_DEBUG(dbgs() << "We will split the following block:\n";); + LLVM_DEBUG(CRI.MI->getParent()->dump()); + LLVM_DEBUG(dbgs() << "Before instruction:\n"; SplitBefore->dump()); // Get the branch instruction. MachineInstr *Branch = @@ -655,10 +655,10 @@ TargetIsFallThrough); MachineInstr *SplitCond = UsingDef1 ? CRI.CopyDefs.second : CRI.CopyDefs.first; - DEBUG(dbgs() << "We will " << (InvertNewBranch ? "invert" : "copy")); - DEBUG(dbgs() << " the original branch and the target is the " << + LLVM_DEBUG(dbgs() << "We will " << (InvertNewBranch ? "invert" : "copy")); + LLVM_DEBUG(dbgs() << " the original branch and the target is the " << (TargetIsFallThrough ? "fallthrough block\n" : "orig. target block\n")); - DEBUG(dbgs() << "Original branch instruction: "; Branch->dump()); + LLVM_DEBUG(dbgs() << "Original branch instruction: "; Branch->dump()); BlockSplitInfo BSI { Branch, SplitBefore, SplitCond, InvertNewBranch, InvertOrigBranch, TargetIsFallThrough, MBPI, CRI.MI, UsingDef1 ? CRI.CopyDefs.first : CRI.CopyDefs.second }; Index: lib/Target/PowerPC/PPCTLSDynamicCall.cpp =================================================================== --- lib/Target/PowerPC/PPCTLSDynamicCall.cpp +++ lib/Target/PowerPC/PPCTLSDynamicCall.cpp @@ -77,7 +77,7 @@ continue; } - DEBUG(dbgs() << "TLS Dynamic Call Fixup:\n " << MI); + LLVM_DEBUG(dbgs() << "TLS Dynamic Call Fixup:\n " << MI); unsigned OutReg = MI.getOperand(0).getReg(); unsigned InReg = MI.getOperand(1).getReg(); Index: lib/Target/PowerPC/PPCVSXFMAMutate.cpp =================================================================== --- lib/Target/PowerPC/PPCVSXFMAMutate.cpp +++ lib/Target/PowerPC/PPCVSXFMAMutate.cpp @@ -241,7 +241,7 @@ assert(OldFMAReg == AddendMI->getOperand(0).getReg() && "Addend copy not tied to old FMA output!"); - DEBUG(dbgs() << "VSX FMA Mutation:\n " << MI); + LLVM_DEBUG(dbgs() << "VSX FMA Mutation:\n " << MI); MI.getOperand(0).setReg(KilledProdReg); MI.getOperand(1).setReg(KilledProdReg); @@ -273,7 +273,7 @@ MI.getOperand(2).setIsUndef(OtherProdRegUndef); } - DEBUG(dbgs() << " -> " << MI); + LLVM_DEBUG(dbgs() << " -> " << MI); // The killed product operand was killed here, so we can reuse it now // for the result of the fma. @@ -310,7 +310,7 @@ NewFMAInt.addSegment(LiveInterval::Segment(AI->start, AI->end, NewFMAValNo)); } - DEBUG(dbgs() << " extended: " << NewFMAInt << '\n'); + LLVM_DEBUG(dbgs() << " extended: " << NewFMAInt << '\n'); // Extend the live interval of the addend source (it might end at the // copy to be removed, or somewhere in between there and here). This @@ -323,15 +323,15 @@ LiveRange &AddendSrcRange = LIS->getRegUnit(Unit); AddendSrcRange.extendInBlock(LIS->getMBBStartIdx(&MBB), FMAIdx.getRegSlot()); - DEBUG(dbgs() << " extended: " << AddendSrcRange << '\n'); + LLVM_DEBUG(dbgs() << " extended: " << AddendSrcRange << '\n'); } FMAInt.removeValNo(FMAValNo); - DEBUG(dbgs() << " trimmed: " << FMAInt << '\n'); + LLVM_DEBUG(dbgs() << " trimmed: " << FMAInt << '\n'); // Remove the (now unused) copy. - DEBUG(dbgs() << " removing: " << *AddendMI << '\n'); + LLVM_DEBUG(dbgs() << " removing: " << *AddendMI << '\n'); LIS->RemoveMachineInstrFromMaps(*AddendMI); AddendMI->eraseFromParent(); Index: lib/Target/PowerPC/PPCVSXSwapRemoval.cpp =================================================================== --- lib/Target/PowerPC/PPCVSXSwapRemoval.cpp +++ lib/Target/PowerPC/PPCVSXSwapRemoval.cpp @@ -527,8 +527,8 @@ } if (RelevantFunction) { - DEBUG(dbgs() << "Swap vector when first built\n\n"); - DEBUG(dumpSwapVector()); + LLVM_DEBUG(dbgs() << "Swap vector when first built\n\n"); + LLVM_DEBUG(dumpSwapVector()); } return RelevantFunction; @@ -587,14 +587,14 @@ // as such so their containing webs will not be optimized. void PPCVSXSwapRemoval::formWebs() { - DEBUG(dbgs() << "\n*** Forming webs for swap removal ***\n\n"); + LLVM_DEBUG(dbgs() << "\n*** Forming webs for swap removal ***\n\n"); for (unsigned EntryIdx = 0; EntryIdx < SwapVector.size(); ++EntryIdx) { MachineInstr *MI = SwapVector[EntryIdx].VSEMI; - DEBUG(dbgs() << "\n" << SwapVector[EntryIdx].VSEId << " "); - DEBUG(MI->dump()); + LLVM_DEBUG(dbgs() << "\n" << SwapVector[EntryIdx].VSEId << " "); + LLVM_DEBUG(MI->dump()); // It's sufficient to walk vector uses and join them to their unique // definitions. In addition, check full vector register operands @@ -624,10 +624,10 @@ (void)EC->unionSets(SwapVector[DefIdx].VSEId, SwapVector[EntryIdx].VSEId); - DEBUG(dbgs() << format("Unioning %d with %d\n", SwapVector[DefIdx].VSEId, + LLVM_DEBUG(dbgs() << format("Unioning %d with %d\n", SwapVector[DefIdx].VSEId, SwapVector[EntryIdx].VSEId)); - DEBUG(dbgs() << " Def: "); - DEBUG(DefMI->dump()); + LLVM_DEBUG(dbgs() << " Def: "); + LLVM_DEBUG(DefMI->dump()); } } } @@ -638,7 +638,7 @@ // as rejected. void PPCVSXSwapRemoval::recordUnoptimizableWebs() { - DEBUG(dbgs() << "\n*** Rejecting webs for swap removal ***\n\n"); + LLVM_DEBUG(dbgs() << "\n*** Rejecting webs for swap removal ***\n\n"); for (unsigned EntryIdx = 0; EntryIdx < SwapVector.size(); ++EntryIdx) { int Repr = EC->getLeaderValue(SwapVector[EntryIdx].VSEId); @@ -656,12 +656,12 @@ SwapVector[Repr].WebRejected = 1; - DEBUG(dbgs() << + LLVM_DEBUG(dbgs() << format("Web %d rejected for physreg, partial reg, or not " "swap[pable]\n", Repr)); - DEBUG(dbgs() << " in " << EntryIdx << ": "); - DEBUG(SwapVector[EntryIdx].VSEMI->dump()); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " in " << EntryIdx << ": "); + LLVM_DEBUG(SwapVector[EntryIdx].VSEMI->dump()); + LLVM_DEBUG(dbgs() << "\n"); } // Reject webs than contain swapping loads that feed something other @@ -682,13 +682,13 @@ SwapVector[Repr].WebRejected = 1; - DEBUG(dbgs() << + LLVM_DEBUG(dbgs() << format("Web %d rejected for load not feeding swap\n", Repr)); - DEBUG(dbgs() << " def " << EntryIdx << ": "); - DEBUG(MI->dump()); - DEBUG(dbgs() << " use " << UseIdx << ": "); - DEBUG(UseMI.dump()); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " def " << EntryIdx << ": "); + LLVM_DEBUG(MI->dump()); + LLVM_DEBUG(dbgs() << " use " << UseIdx << ": "); + LLVM_DEBUG(UseMI.dump()); + LLVM_DEBUG(dbgs() << "\n"); } } @@ -706,13 +706,13 @@ SwapVector[Repr].WebRejected = 1; - DEBUG(dbgs() << + LLVM_DEBUG(dbgs() << format("Web %d rejected for store not fed by swap\n", Repr)); - DEBUG(dbgs() << " def " << DefIdx << ": "); - DEBUG(DefMI->dump()); - DEBUG(dbgs() << " use " << EntryIdx << ": "); - DEBUG(MI->dump()); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " def " << DefIdx << ": "); + LLVM_DEBUG(DefMI->dump()); + LLVM_DEBUG(dbgs() << " use " << EntryIdx << ": "); + LLVM_DEBUG(MI->dump()); + LLVM_DEBUG(dbgs() << "\n"); } // Ensure all uses of the register defined by DefMI feed store @@ -723,21 +723,21 @@ if (SwapVector[UseIdx].VSEMI->getOpcode() != MI->getOpcode()) { SwapVector[Repr].WebRejected = 1; - DEBUG(dbgs() << + LLVM_DEBUG(dbgs() << format("Web %d rejected for swap not feeding only stores\n", Repr)); - DEBUG(dbgs() << " def " << " : "); - DEBUG(DefMI->dump()); - DEBUG(dbgs() << " use " << UseIdx << ": "); - DEBUG(SwapVector[UseIdx].VSEMI->dump()); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " def " << " : "); + LLVM_DEBUG(DefMI->dump()); + LLVM_DEBUG(dbgs() << " use " << UseIdx << ": "); + LLVM_DEBUG(SwapVector[UseIdx].VSEMI->dump()); + LLVM_DEBUG(dbgs() << "\n"); } } } } - DEBUG(dbgs() << "Swap vector after web analysis:\n\n"); - DEBUG(dumpSwapVector()); + LLVM_DEBUG(dbgs() << "Swap vector after web analysis:\n\n"); + LLVM_DEBUG(dumpSwapVector()); } // Walk the swap vector entries looking for swaps fed by permuting loads @@ -747,7 +747,7 @@ // such that multiple loads feed the same swap, etc.) void PPCVSXSwapRemoval::markSwapsForRemoval() { - DEBUG(dbgs() << "\n*** Marking swaps for removal ***\n\n"); + LLVM_DEBUG(dbgs() << "\n*** Marking swaps for removal ***\n\n"); for (unsigned EntryIdx = 0; EntryIdx < SwapVector.size(); ++EntryIdx) { @@ -762,8 +762,8 @@ int UseIdx = SwapMap[&UseMI]; SwapVector[UseIdx].WillRemove = 1; - DEBUG(dbgs() << "Marking swap fed by load for removal: "); - DEBUG(UseMI.dump()); + LLVM_DEBUG(dbgs() << "Marking swap fed by load for removal: "); + LLVM_DEBUG(UseMI.dump()); } } @@ -777,8 +777,8 @@ int DefIdx = SwapMap[DefMI]; SwapVector[DefIdx].WillRemove = 1; - DEBUG(dbgs() << "Marking swap feeding store for removal: "); - DEBUG(DefMI->dump()); + LLVM_DEBUG(dbgs() << "Marking swap feeding store for removal: "); + LLVM_DEBUG(DefMI->dump()); } } else if (SwapVector[EntryIdx].IsSwappable && @@ -823,8 +823,8 @@ MachineInstr *MI = SwapVector[EntryIdx].VSEMI; unsigned NElts; - DEBUG(dbgs() << "Changing splat: "); - DEBUG(MI->dump()); + LLVM_DEBUG(dbgs() << "Changing splat: "); + LLVM_DEBUG(MI->dump()); switch (MI->getOpcode()) { default: @@ -847,8 +847,8 @@ else MI->getOperand(1).setImm(EltNo); - DEBUG(dbgs() << " Into: "); - DEBUG(MI->dump()); + LLVM_DEBUG(dbgs() << " Into: "); + LLVM_DEBUG(MI->dump()); break; } @@ -861,8 +861,8 @@ case SHValues::SH_XXPERMDI: { MachineInstr *MI = SwapVector[EntryIdx].VSEMI; - DEBUG(dbgs() << "Changing XXPERMDI: "); - DEBUG(MI->dump()); + LLVM_DEBUG(dbgs() << "Changing XXPERMDI: "); + LLVM_DEBUG(MI->dump()); unsigned Selector = MI->getOperand(3).getImm(); if (Selector == 0 || Selector == 3) @@ -874,8 +874,8 @@ MI->getOperand(1).setReg(Reg2); MI->getOperand(2).setReg(Reg1); - DEBUG(dbgs() << " Into: "); - DEBUG(MI->dump()); + LLVM_DEBUG(dbgs() << " Into: "); + LLVM_DEBUG(MI->dump()); break; } @@ -885,16 +885,16 @@ case SHValues::SH_COPYWIDEN: { MachineInstr *MI = SwapVector[EntryIdx].VSEMI; - DEBUG(dbgs() << "Changing SUBREG_TO_REG: "); - DEBUG(MI->dump()); + LLVM_DEBUG(dbgs() << "Changing SUBREG_TO_REG: "); + LLVM_DEBUG(MI->dump()); unsigned DstReg = MI->getOperand(0).getReg(); const TargetRegisterClass *DstRC = MRI->getRegClass(DstReg); unsigned NewVReg = MRI->createVirtualRegister(DstRC); MI->getOperand(0).setReg(NewVReg); - DEBUG(dbgs() << " Into: "); - DEBUG(MI->dump()); + LLVM_DEBUG(dbgs() << " Into: "); + LLVM_DEBUG(MI->dump()); auto InsertPoint = ++MachineBasicBlock::iterator(MI); @@ -910,19 +910,19 @@ BuildMI(*MI->getParent(), InsertPoint, MI->getDebugLoc(), TII->get(PPC::COPY), VSRCTmp1) .addReg(NewVReg); - DEBUG(std::prev(InsertPoint)->dump()); + LLVM_DEBUG(std::prev(InsertPoint)->dump()); insertSwap(MI, InsertPoint, VSRCTmp2, VSRCTmp1); - DEBUG(std::prev(InsertPoint)->dump()); + LLVM_DEBUG(std::prev(InsertPoint)->dump()); BuildMI(*MI->getParent(), InsertPoint, MI->getDebugLoc(), TII->get(PPC::COPY), DstReg) .addReg(VSRCTmp2); - DEBUG(std::prev(InsertPoint)->dump()); + LLVM_DEBUG(std::prev(InsertPoint)->dump()); } else { insertSwap(MI, InsertPoint, DstReg, NewVReg); - DEBUG(std::prev(InsertPoint)->dump()); + LLVM_DEBUG(std::prev(InsertPoint)->dump()); } break; } @@ -933,7 +933,7 @@ // a copy operation. bool PPCVSXSwapRemoval::removeSwaps() { - DEBUG(dbgs() << "\n*** Removing swaps ***\n\n"); + LLVM_DEBUG(dbgs() << "\n*** Removing swaps ***\n\n"); bool Changed = false; @@ -946,9 +946,9 @@ MI->getOperand(0).getReg()) .add(MI->getOperand(1)); - DEBUG(dbgs() << format("Replaced %d with copy: ", + LLVM_DEBUG(dbgs() << format("Replaced %d with copy: ", SwapVector[EntryIdx].VSEId)); - DEBUG(MI->dump()); + LLVM_DEBUG(MI->dump()); MI->eraseFromParent(); } Index: lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp =================================================================== --- lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp +++ lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp @@ -247,14 +247,14 @@ // It's a 32 bit instruction if bit 0 and 1 are 1. if ((Bytes[0] & 0x3) == 0x3) { Insn = support::endian::read32le(Bytes.data()); - DEBUG(dbgs() << "Trying RISCV32 table :\n"); + LLVM_DEBUG(dbgs() << "Trying RISCV32 table :\n"); Result = decodeInstruction(DecoderTable32, MI, Insn, Address, this, STI); Size = 4; } else { Insn = support::endian::read16le(Bytes.data()); if (!STI.getFeatureBits()[RISCV::Feature64Bit]) { - DEBUG(dbgs() << "Trying RISCV32Only_16 table (16-bit Instruction):\n"); + LLVM_DEBUG(dbgs() << "Trying RISCV32Only_16 table (16-bit Instruction):\n"); // Calling the auto-generated decoder function. Result = decodeInstruction(DecoderTableRISCV32Only_16, MI, Insn, Address, this, STI); @@ -264,7 +264,7 @@ } } - DEBUG(dbgs() << "Trying RISCV_C table (16-bit Instruction):\n"); + LLVM_DEBUG(dbgs() << "Trying RISCV_C table (16-bit Instruction):\n"); // Calling the auto-generated decoder function. Result = decodeInstruction(DecoderTable16, MI, Insn, Address, this, STI); Size = 2; Index: lib/Target/RISCV/RISCVISelDAGToDAG.cpp =================================================================== --- lib/Target/RISCV/RISCVISelDAGToDAG.cpp +++ lib/Target/RISCV/RISCVISelDAGToDAG.cpp @@ -60,7 +60,7 @@ // If we have a custom node, we have already selected if (Node->isMachineOpcode()) { - DEBUG(dbgs() << "== "; Node->dump(CurDAG); dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "== "; Node->dump(CurDAG); dbgs() << "\n"); Node->setNodeId(-1); return; } Index: lib/Target/RISCV/RISCVISelLowering.cpp =================================================================== --- lib/Target/RISCV/RISCVISelLowering.cpp +++ lib/Target/RISCV/RISCVISelLowering.cpp @@ -600,7 +600,7 @@ if (CC_RISCV(MF.getDataLayout(), i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, CCInfo, /*IsRet=*/true, IsRet, ArgTy)) { - DEBUG(dbgs() << "InputArg #" << i << " has unhandled type " + LLVM_DEBUG(dbgs() << "InputArg #" << i << " has unhandled type " << EVT(ArgVT).getEVTString() << '\n'); llvm_unreachable(nullptr); } @@ -620,7 +620,7 @@ if (CC_RISCV(MF.getDataLayout(), i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, CCInfo, Outs[i].IsFixed, IsRet, OrigTy)) { - DEBUG(dbgs() << "OutputArg #" << i << " has unhandled type " + LLVM_DEBUG(dbgs() << "OutputArg #" << i << " has unhandled type " << EVT(ArgVT).getEVTString() << "\n"); llvm_unreachable(nullptr); } Index: lib/Target/SystemZ/SystemZHazardRecognizer.cpp =================================================================== --- lib/Target/SystemZ/SystemZHazardRecognizer.cpp +++ lib/Target/SystemZ/SystemZHazardRecognizer.cpp @@ -77,7 +77,7 @@ GrpCount = 0; LastFPdOpCycleIdx = UINT_MAX; LastEmittedMI = nullptr; - DEBUG(CurGroupDbg = "";); + LLVM_DEBUG(CurGroupDbg = "";); } bool @@ -102,8 +102,8 @@ void SystemZHazardRecognizer::nextGroup(bool DbgOutput) { if (CurrGroupSize > 0) { - DEBUG(dumpCurrGroup("Completed decode group")); - DEBUG(CurGroupDbg = "";); + LLVM_DEBUG(dumpCurrGroup("Completed decode group")); + LLVM_DEBUG(CurGroupDbg = "";); GrpCount++; @@ -122,7 +122,7 @@ CriticalResourceIdx = UINT_MAX; } - DEBUG(if (DbgOutput) + LLVM_DEBUG(if (DbgOutput) dumpProcResourceCounters();); } @@ -213,14 +213,14 @@ void SystemZHazardRecognizer:: EmitInstruction(SUnit *SU) { const MCSchedClassDesc *SC = getSchedClass(SU); - DEBUG( dumpCurrGroup("Decode group before emission");); + LLVM_DEBUG( dumpCurrGroup("Decode group before emission");); // If scheduling an SU that must begin a new decoder group, move on // to next group. if (!fitsIntoCurrentGroup(SU)) nextGroup(); - DEBUG( dbgs() << "+++ HazardRecognizer emitting "; dumpSU(SU, dbgs()); + LLVM_DEBUG( dbgs() << "+++ HazardRecognizer emitting "; dumpSU(SU, dbgs()); dbgs() << "\n"; raw_string_ostream cgd(CurGroupDbg); if (CurGroupDbg.length()) @@ -231,7 +231,7 @@ // After returning from a call, we don't know much about the state. if (SU->isCall) { - DEBUG (dbgs() << "+++ Clearing state after call.\n";); + LLVM_DEBUG(dbgs() << "+++ Clearing state after call.\n";); clearProcResCounters(); LastFPdOpCycleIdx = UINT_MAX; CurrGroupSize += getNumDecoderSlots(SU); @@ -256,7 +256,7 @@ (PI->ProcResourceIdx != CriticalResourceIdx && CurrCounter > ProcResourceCounters[CriticalResourceIdx]))) { - DEBUG( dbgs() << "+++ New critical resource: " + LLVM_DEBUG( dbgs() << "+++ New critical resource: " << SchedModel->getProcResource(PI->ProcResourceIdx)->Name << "\n";); CriticalResourceIdx = PI->ProcResourceIdx; @@ -266,7 +266,7 @@ // Make note of an instruction that uses a blocking resource (FPd). if (SU->isUnbuffered) { LastFPdOpCycleIdx = getCurrCycleIdx(); - DEBUG (dbgs() << "+++ Last FPd cycle index: " + LLVM_DEBUG(dbgs() << "+++ Last FPd cycle index: " << LastFPdOpCycleIdx << "\n";); } @@ -386,7 +386,7 @@ copyState(SystemZHazardRecognizer *Incoming) { // Current decoder group CurrGroupSize = Incoming->CurrGroupSize; - DEBUG (CurGroupDbg = Incoming->CurGroupDbg;); + LLVM_DEBUG(CurGroupDbg = Incoming->CurGroupDbg;); // Processor resources ProcResourceCounters = Incoming->ProcResourceCounters; Index: lib/Target/SystemZ/SystemZISelDAGToDAG.cpp =================================================================== --- lib/Target/SystemZ/SystemZISelDAGToDAG.cpp +++ lib/Target/SystemZ/SystemZISelDAGToDAG.cpp @@ -583,7 +583,7 @@ if (AM.isDynAlloc() && !AM.IncludesDynAlloc) return false; - DEBUG(AM.dump()); + LLVM_DEBUG(AM.dump()); return true; } @@ -1251,7 +1251,7 @@ void SystemZDAGToDAGISel::Select(SDNode *Node) { // If we have a custom node, we already have selected! if (Node->isMachineOpcode()) { - DEBUG(errs() << "== "; Node->dump(CurDAG); errs() << "\n"); + LLVM_DEBUG(errs() << "== "; Node->dump(CurDAG); errs() << "\n"); Node->setNodeId(-1); return; } @@ -1603,11 +1603,11 @@ } if (Res) { - DEBUG(dbgs() << "SystemZ DAG preprocessing replacing:\nOld: "); - DEBUG(N->dump(CurDAG)); - DEBUG(dbgs() << "\nNew: "); - DEBUG(Res.getNode()->dump(CurDAG)); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "SystemZ DAG preprocessing replacing:\nOld: "); + LLVM_DEBUG(N->dump(CurDAG)); + LLVM_DEBUG(dbgs() << "\nNew: "); + LLVM_DEBUG(Res.getNode()->dump(CurDAG)); + LLVM_DEBUG(dbgs() << "\n"); CurDAG->ReplaceAllUsesOfValueWith(SDValue(N, 0), Res); MadeChange = true; Index: lib/Target/SystemZ/SystemZMachineScheduler.cpp =================================================================== --- lib/Target/SystemZ/SystemZMachineScheduler.cpp +++ lib/Target/SystemZ/SystemZMachineScheduler.cpp @@ -74,13 +74,13 @@ void SystemZPostRASchedStrategy::enterMBB(MachineBasicBlock *NextMBB) { assert ((SchedStates.find(NextMBB) == SchedStates.end()) && "Entering MBB twice?"); - DEBUG(dbgs() << "+++ Entering " << printMBBReference(*NextMBB)); + LLVM_DEBUG(dbgs() << "+++ Entering " << printMBBReference(*NextMBB)); MBB = NextMBB; /// Create a HazardRec for MBB, save it in SchedStates and set HazardRec to /// point to it. HazardRec = SchedStates[MBB] = new SystemZHazardRecognizer(TII, &SchedModel); - DEBUG (const MachineLoop *Loop = MLI->getLoopFor(MBB); + LLVM_DEBUG(const MachineLoop *Loop = MLI->getLoopFor(MBB); if(Loop && Loop->getHeader() == MBB) dbgs() << " (Loop header)"; dbgs() << ":\n";); @@ -93,7 +93,7 @@ SchedStates.find(SinglePredMBB) == SchedStates.end()) return; - DEBUG(dbgs() << "+++ Continued scheduling from " + LLVM_DEBUG(dbgs() << "+++ Continued scheduling from " << printMBBReference(*SinglePredMBB) << "\n";); HazardRec->copyState(SchedStates[SinglePredMBB]); @@ -102,7 +102,7 @@ // prediction will generally do "the right thing". for (MachineBasicBlock::iterator I = SinglePredMBB->getFirstTerminator(); I != SinglePredMBB->end(); I++) { - DEBUG (dbgs() << "+++ Emitting incoming branch: "; I->dump();); + LLVM_DEBUG(dbgs() << "+++ Emitting incoming branch: "; I->dump();); bool TakenBranch = (I->isBranch() && (TII->getBranchInfo(*I).Target->isReg() || // Relative branch TII->getBranchInfo(*I).Target->getMBB() == MBB)); @@ -113,7 +113,7 @@ } void SystemZPostRASchedStrategy::leaveMBB() { - DEBUG(dbgs() << "+++ Leaving " << printMBBReference(*MBB) << "\n";); + LLVM_DEBUG(dbgs() << "+++ Leaving " << printMBBReference(*MBB) << "\n";); // Advance to first terminator. The successor block will handle terminators // dependent on CFG layout (T/NT branch etc). @@ -159,14 +159,14 @@ // If only one choice, return it. if (Available.size() == 1) { - DEBUG (dbgs() << "+++ Only one: "; + LLVM_DEBUG(dbgs() << "+++ Only one: "; HazardRec->dumpSU(*Available.begin(), dbgs()); dbgs() << "\n";); return *Available.begin(); } // All nodes that are possible to schedule are stored by in the // Available set. - DEBUG(dbgs() << "+++ Available: "; Available.dump(*HazardRec);); + LLVM_DEBUG(dbgs() << "+++ Available: "; Available.dump(*HazardRec);); Candidate Best; for (auto *SU : Available) { @@ -177,7 +177,7 @@ // Remeber which SU is the best candidate. if (Best.SU == nullptr || c < Best) { Best = c; - DEBUG(dbgs() << "+++ Best sofar: "; + LLVM_DEBUG(dbgs() << "+++ Best sofar: "; HazardRec->dumpSU(Best.SU, dbgs()); if (Best.GroupingCost != 0) dbgs() << "\tGrouping cost:" << Best.GroupingCost; @@ -239,7 +239,7 @@ } void SystemZPostRASchedStrategy::schedNode(SUnit *SU, bool IsTopNode) { - DEBUG(dbgs() << "+++ Scheduling SU(" << SU->NodeNum << ")\n";); + LLVM_DEBUG(dbgs() << "+++ Scheduling SU(" << SU->NodeNum << ")\n";); // Remove SU from Available set and update HazardRec. Available.erase(SU); Index: lib/Target/WebAssembly/WebAssemblyArgumentMove.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyArgumentMove.cpp +++ lib/Target/WebAssembly/WebAssemblyArgumentMove.cpp @@ -65,7 +65,7 @@ } bool WebAssemblyArgumentMove::runOnMachineFunction(MachineFunction &MF) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "********** Argument Move **********\n" << "********** Function: " << MF.getName() << '\n'; }); Index: lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp +++ lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp @@ -53,7 +53,7 @@ MVT::v4i32, MVT::v4f32}) if (TRI->isTypeLegalForClass(*TRC, T)) return T; - DEBUG(errs() << "Unknown type for register number: " << RegNo); + LLVM_DEBUG(errs() << "Unknown type for register number: " << RegNo); llvm_unreachable("Unknown register type"); return MVT::Other; } @@ -170,7 +170,7 @@ } void WebAssemblyAsmPrinter::EmitInstruction(const MachineInstr *MI) { - DEBUG(dbgs() << "EmitInstruction: " << *MI << '\n'); + LLVM_DEBUG(dbgs() << "EmitInstruction: " << *MI << '\n'); switch (MI->getOpcode()) { case WebAssembly::ARGUMENT_I32: Index: lib/Target/WebAssembly/WebAssemblyCFGSort.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyCFGSort.cpp +++ lib/Target/WebAssembly/WebAssemblyCFGSort.cpp @@ -261,7 +261,7 @@ } bool WebAssemblyCFGSort::runOnMachineFunction(MachineFunction &MF) { - DEBUG(dbgs() << "********** CFG Sorting **********\n" + LLVM_DEBUG(dbgs() << "********** CFG Sorting **********\n" "********** Function: " << MF.getName() << '\n'); Index: lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp +++ lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp @@ -354,7 +354,7 @@ } bool WebAssemblyCFGStackify::runOnMachineFunction(MachineFunction &MF) { - DEBUG(dbgs() << "********** CFG Stackifying **********\n" + LLVM_DEBUG(dbgs() << "********** CFG Stackifying **********\n" "********** Function: " << MF.getName() << '\n'); Index: lib/Target/WebAssembly/WebAssemblyCallIndirectFixup.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyCallIndirectFixup.cpp +++ lib/Target/WebAssembly/WebAssemblyCallIndirectFixup.cpp @@ -80,7 +80,7 @@ } bool WebAssemblyCallIndirectFixup::runOnMachineFunction(MachineFunction &MF) { - DEBUG(dbgs() << "********** Fixing up CALL_INDIRECTs **********\n" + LLVM_DEBUG(dbgs() << "********** Fixing up CALL_INDIRECTs **********\n" << MF.getName() << '\n'); bool Changed = false; @@ -90,7 +90,7 @@ for (MachineBasicBlock &MBB : MF) { for (MachineInstr &MI : MBB) { if (IsPseudoCallIndirect(MI)) { - DEBUG(dbgs() << "Found call_indirect: " << MI << '\n'); + LLVM_DEBUG(dbgs() << "Found call_indirect: " << MI << '\n'); // Rewrite pseudo to non-pseudo const MCInstrDesc &Desc = TII->get(GetNonPseudoCallIndirectOpcode(MI)); @@ -120,13 +120,13 @@ for (const MachineOperand &MO : Ops) MI.addOperand(MO); - DEBUG(dbgs() << " After transform: " << MI); + LLVM_DEBUG(dbgs() << " After transform: " << MI); Changed = true; } } } - DEBUG(dbgs() << "\nDone fixing up CALL_INDIRECTs\n\n"); + LLVM_DEBUG(dbgs() << "\nDone fixing up CALL_INDIRECTs\n\n"); return Changed; } Index: lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp +++ lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp @@ -168,7 +168,7 @@ } bool WebAssemblyExplicitLocals::runOnMachineFunction(MachineFunction &MF) { - DEBUG(dbgs() << "********** Make Locals Explicit **********\n" + LLVM_DEBUG(dbgs() << "********** Make Locals Explicit **********\n" "********** Function: " << MF.getName() << '\n'); Index: lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp +++ lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp @@ -174,7 +174,7 @@ if (LLVM_LIKELY(RewriteSuccs.empty())) return false; - DEBUG(dbgs() << "Irreducible control flow detected!\n"); + LLVM_DEBUG(dbgs() << "Irreducible control flow detected!\n"); // Ok. We have irreducible control flow! Create a dispatch block which will // contains a jump table to any block in the problematic set of blocks. @@ -205,7 +205,7 @@ continue; unsigned Index = MIB.getInstr()->getNumExplicitOperands() - 1; - DEBUG(dbgs() << printMBBReference(*MBB) << " has index " << Index << "\n"); + LLVM_DEBUG(dbgs() << printMBBReference(*MBB) << " has index " << Index << "\n"); Pair.first->second = Index; for (auto Pred : MBB->predecessors()) @@ -264,7 +264,7 @@ bool WebAssemblyFixIrreducibleControlFlow::runOnMachineFunction( MachineFunction &MF) { - DEBUG(dbgs() << "********** Fixing Irreducible Control Flow **********\n" + LLVM_DEBUG(dbgs() << "********** Fixing Irreducible Control Flow **********\n" "********** Function: " << MF.getName() << '\n'); @@ -284,7 +284,7 @@ // If we made any changes, completely recompute everything. if (LLVM_UNLIKELY(Changed)) { - DEBUG(dbgs() << "Recomputing dominators and loops.\n"); + LLVM_DEBUG(dbgs() << "Recomputing dominators and loops.\n"); MF.getRegInfo().invalidateLiveness(); MF.RenumberBlocks(); getAnalysis().runOnMachineFunction(MF); Index: lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp +++ lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp @@ -70,7 +70,7 @@ void WebAssemblyDAGToDAGISel::Select(SDNode *Node) { // If we have a custom node, we already have selected! if (Node->isMachineOpcode()) { - DEBUG(errs() << "== "; Node->dump(CurDAG); errs() << "\n"); + LLVM_DEBUG(errs() << "== "; Node->dump(CurDAG); errs() << "\n"); Node->setNodeId(-1); return; } Index: lib/Target/WebAssembly/WebAssemblyLowerBrUnless.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyLowerBrUnless.cpp +++ lib/Target/WebAssembly/WebAssemblyLowerBrUnless.cpp @@ -52,7 +52,7 @@ } bool WebAssemblyLowerBrUnless::runOnMachineFunction(MachineFunction &MF) { - DEBUG(dbgs() << "********** Lowering br_unless **********\n" + LLVM_DEBUG(dbgs() << "********** Lowering br_unless **********\n" "********** Function: " << MF.getName() << '\n'); Index: lib/Target/WebAssembly/WebAssemblyOptimizeLiveIntervals.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyOptimizeLiveIntervals.cpp +++ lib/Target/WebAssembly/WebAssemblyOptimizeLiveIntervals.cpp @@ -63,7 +63,7 @@ } bool WebAssemblyOptimizeLiveIntervals::runOnMachineFunction(MachineFunction &MF) { - DEBUG(dbgs() << "********** Optimize LiveIntervals **********\n" + LLVM_DEBUG(dbgs() << "********** Optimize LiveIntervals **********\n" "********** Function: " << MF.getName() << '\n'); Index: lib/Target/WebAssembly/WebAssemblyPeephole.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyPeephole.cpp +++ lib/Target/WebAssembly/WebAssemblyPeephole.cpp @@ -113,7 +113,7 @@ } bool WebAssemblyPeephole::runOnMachineFunction(MachineFunction &MF) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "********** Peephole **********\n" << "********** Function: " << MF.getName() << '\n'; }); Index: lib/Target/WebAssembly/WebAssemblyPrepareForLiveIntervals.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyPrepareForLiveIntervals.cpp +++ lib/Target/WebAssembly/WebAssemblyPrepareForLiveIntervals.cpp @@ -68,7 +68,7 @@ } bool WebAssemblyPrepareForLiveIntervals::runOnMachineFunction(MachineFunction &MF) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "********** Prepare For LiveIntervals **********\n" << "********** Function: " << MF.getName() << '\n'; }); Index: lib/Target/WebAssembly/WebAssemblyRegColoring.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyRegColoring.cpp +++ lib/Target/WebAssembly/WebAssemblyRegColoring.cpp @@ -71,7 +71,7 @@ } bool WebAssemblyRegColoring::runOnMachineFunction(MachineFunction &MF) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "********** Register Coloring **********\n" << "********** Function: " << MF.getName() << '\n'; }); @@ -94,7 +94,7 @@ SmallVector SortedIntervals; SortedIntervals.reserve(NumVRegs); - DEBUG(dbgs() << "Interesting register intervals:\n"); + LLVM_DEBUG(dbgs() << "Interesting register intervals:\n"); for (unsigned i = 0; i < NumVRegs; ++i) { unsigned VReg = TargetRegisterInfo::index2VirtReg(i); if (MFI.isVRegStackified(VReg)) @@ -106,10 +106,10 @@ LiveInterval *LI = &Liveness->getInterval(VReg); assert(LI->weight == 0.0f); LI->weight = computeWeight(MRI, MBFI, VReg); - DEBUG(LI->dump()); + LLVM_DEBUG(LI->dump()); SortedIntervals.push_back(LI); } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); // Sort them to put arguments first (since we don't want to rename live-in // registers), by weight next, and then by position. @@ -126,7 +126,7 @@ return *LHS < *RHS; }); - DEBUG(dbgs() << "Coloring register intervals:\n"); + LLVM_DEBUG(dbgs() << "Coloring register intervals:\n"); SmallVector SlotMapping(SortedIntervals.size(), -1u); SmallVector, 16> Assignments( SortedIntervals.size()); @@ -156,7 +156,7 @@ Changed |= Old != New; UsedColors.set(Color); Assignments[Color].push_back(LI); - DEBUG(dbgs() << "Assigning vreg" + LLVM_DEBUG(dbgs() << "Assigning vreg" << TargetRegisterInfo::virtReg2Index(LI->reg) << " to vreg" << TargetRegisterInfo::virtReg2Index(New) << "\n"); } Index: lib/Target/WebAssembly/WebAssemblyRegNumbering.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyRegNumbering.cpp +++ lib/Target/WebAssembly/WebAssemblyRegNumbering.cpp @@ -56,7 +56,7 @@ } bool WebAssemblyRegNumbering::runOnMachineFunction(MachineFunction &MF) { - DEBUG(dbgs() << "********** Register Numbering **********\n" + LLVM_DEBUG(dbgs() << "********** Register Numbering **********\n" "********** Function: " << MF.getName() << '\n'); @@ -73,7 +73,7 @@ break; int64_t Imm = MI.getOperand(1).getImm(); - DEBUG(dbgs() << "Arg VReg " << MI.getOperand(0).getReg() << " -> WAReg " + LLVM_DEBUG(dbgs() << "Arg VReg " << MI.getOperand(0).getReg() << " -> WAReg " << Imm << "\n"); MFI.setWAReg(MI.getOperand(0).getReg(), Imm); } @@ -92,13 +92,13 @@ continue; // Handle stackified registers. if (MFI.isVRegStackified(VReg)) { - DEBUG(dbgs() << "VReg " << VReg << " -> WAReg " + LLVM_DEBUG(dbgs() << "VReg " << VReg << " -> WAReg " << (INT32_MIN | NumStackRegs) << "\n"); MFI.setWAReg(VReg, INT32_MIN | NumStackRegs++); continue; } if (MFI.getWAReg(VReg) == WebAssemblyFunctionInfo::UnusedReg) { - DEBUG(dbgs() << "VReg " << VReg << " -> WAReg " << CurReg << "\n"); + LLVM_DEBUG(dbgs() << "VReg " << VReg << " -> WAReg " << CurReg << "\n"); MFI.setWAReg(VReg, CurReg++); } } Index: lib/Target/WebAssembly/WebAssemblyRegStackify.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyRegStackify.cpp +++ lib/Target/WebAssembly/WebAssemblyRegStackify.cpp @@ -469,7 +469,7 @@ MachineInstr *Insert, LiveIntervals &LIS, WebAssemblyFunctionInfo &MFI, MachineRegisterInfo &MRI) { - DEBUG(dbgs() << "Move for single use: "; Def->dump()); + LLVM_DEBUG(dbgs() << "Move for single use: "; Def->dump()); MBB.splice(Insert, &MBB, Def); LIS.handleMove(*Def); @@ -496,7 +496,7 @@ MFI.stackifyVReg(NewReg); - DEBUG(dbgs() << " - Replaced register: "; Def->dump()); + LLVM_DEBUG(dbgs() << " - Replaced register: "; Def->dump()); } ImposeStackOrdering(Def); @@ -510,8 +510,8 @@ MachineBasicBlock::instr_iterator Insert, LiveIntervals &LIS, WebAssemblyFunctionInfo &MFI, MachineRegisterInfo &MRI, const WebAssemblyInstrInfo *TII, const WebAssemblyRegisterInfo *TRI) { - DEBUG(dbgs() << "Rematerializing cheap def: "; Def.dump()); - DEBUG(dbgs() << " - for use in "; Op.getParent()->dump()); + LLVM_DEBUG(dbgs() << "Rematerializing cheap def: "; Def.dump()); + LLVM_DEBUG(dbgs() << " - for use in "; Op.getParent()->dump()); unsigned NewReg = MRI.createVirtualRegister(MRI.getRegClass(Reg)); TII->reMaterialize(MBB, Insert, NewReg, 0, Def, *TRI); @@ -522,7 +522,7 @@ MFI.stackifyVReg(NewReg); ImposeStackOrdering(Clone); - DEBUG(dbgs() << " - Cloned to "; Clone->dump()); + LLVM_DEBUG(dbgs() << " - Cloned to "; Clone->dump()); // Shrink the interval. bool IsDead = MRI.use_empty(Reg); @@ -534,7 +534,7 @@ // If that was the last use of the original, delete the original. if (IsDead) { - DEBUG(dbgs() << " - Deleting original\n"); + LLVM_DEBUG(dbgs() << " - Deleting original\n"); SlotIndex Idx = LIS.getInstructionIndex(Def).getRegSlot(); LIS.removePhysRegDefAt(WebAssembly::ARGUMENTS, Idx); LIS.removeInterval(Reg); @@ -569,7 +569,7 @@ unsigned Reg, MachineOperand &Op, MachineInstr *Def, MachineBasicBlock &MBB, MachineInstr *Insert, LiveIntervals &LIS, WebAssemblyFunctionInfo &MFI, MachineRegisterInfo &MRI, const WebAssemblyInstrInfo *TII) { - DEBUG(dbgs() << "Move and tee for multi-use:"; Def->dump()); + LLVM_DEBUG(dbgs() << "Move and tee for multi-use:"; Def->dump()); // Move Def into place. MBB.splice(Insert, &MBB, Def); @@ -605,8 +605,8 @@ ImposeStackOrdering(Def); ImposeStackOrdering(Tee); - DEBUG(dbgs() << " - Replaced register: "; Def->dump()); - DEBUG(dbgs() << " - Tee instruction: "; Tee->dump()); + LLVM_DEBUG(dbgs() << " - Replaced register: "; Def->dump()); + LLVM_DEBUG(dbgs() << " - Tee instruction: "; Tee->dump()); return Def; } @@ -733,7 +733,7 @@ } // end anonymous namespace bool WebAssemblyRegStackify::runOnMachineFunction(MachineFunction &MF) { - DEBUG(dbgs() << "********** Register Stackifying **********\n" + LLVM_DEBUG(dbgs() << "********** Register Stackifying **********\n" "********** Function: " << MF.getName() << '\n'); Index: lib/Target/WebAssembly/WebAssemblyReplacePhysRegs.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyReplacePhysRegs.cpp +++ lib/Target/WebAssembly/WebAssemblyReplacePhysRegs.cpp @@ -58,7 +58,7 @@ } bool WebAssemblyReplacePhysRegs::runOnMachineFunction(MachineFunction &MF) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "********** Replace Physical Registers **********\n" << "********** Function: " << MF.getName() << '\n'; }); Index: lib/Target/WebAssembly/WebAssemblySetP2AlignOperands.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblySetP2AlignOperands.cpp +++ lib/Target/WebAssembly/WebAssemblySetP2AlignOperands.cpp @@ -72,7 +72,7 @@ } bool WebAssemblySetP2AlignOperands::runOnMachineFunction(MachineFunction &MF) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "********** Set p2align Operands **********\n" << "********** Function: " << MF.getName() << '\n'; }); Index: lib/Target/WebAssembly/WebAssemblyStoreResults.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyStoreResults.cpp +++ lib/Target/WebAssembly/WebAssemblyStoreResults.cpp @@ -108,7 +108,7 @@ continue; Changed = true; - DEBUG(dbgs() << "Setting operand " << O << " in " << *Where << " from " + LLVM_DEBUG(dbgs() << "Setting operand " << O << " in " << *Where << " from " << MI << "\n"); O.setReg(ToReg); @@ -167,7 +167,7 @@ } bool WebAssemblyStoreResults::runOnMachineFunction(MachineFunction &MF) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "********** Store Results **********\n" << "********** Function: " << MF.getName() << '\n'; }); @@ -186,7 +186,7 @@ assert(MRI.tracksLiveness() && "StoreResults expects liveness tracking"); for (auto &MBB : MF) { - DEBUG(dbgs() << "Basic Block: " << MBB.getName() << '\n'); + LLVM_DEBUG(dbgs() << "Basic Block: " << MBB.getName() << '\n'); for (auto &MI : MBB) switch (MI.getOpcode()) { default: Index: lib/Target/X86/Disassembler/X86Disassembler.cpp =================================================================== --- lib/Target/X86/Disassembler/X86Disassembler.cpp +++ lib/Target/X86/Disassembler/X86Disassembler.cpp @@ -103,7 +103,7 @@ return MII->getName(Opcode); } -#define debug(s) DEBUG(Debug(__FILE__, __LINE__, s)); +#define debug(s) LLVM_DEBUG(Debug(__FILE__, __LINE__, s)); namespace llvm { Index: lib/Target/X86/X86CmovConversion.cpp =================================================================== --- lib/Target/X86/X86CmovConversion.cpp +++ lib/Target/X86/X86CmovConversion.cpp @@ -169,7 +169,7 @@ if (!EnableCmovConverter) return false; - DEBUG(dbgs() << "********** " << getPassName() << " : " << MF.getName() + LLVM_DEBUG(dbgs() << "********** " << getPassName() << " : " << MF.getName() << "**********\n"); bool Changed = false; @@ -776,7 +776,7 @@ auto *NewCMOV = NewMIs.pop_back_val(); assert(X86::getCondFromCMovOpc(NewCMOV->getOpcode()) == OppCC && "Last new instruction isn't the expected CMOV!"); - DEBUG(dbgs() << "\tRewritten cmov: "; NewCMOV->dump()); + LLVM_DEBUG(dbgs() << "\tRewritten cmov: "; NewCMOV->dump()); MBB->insert(MachineBasicBlock::iterator(MI), NewCMOV); if (&*MIItBegin == &MI) MIItBegin = MachineBasicBlock::iterator(NewCMOV); @@ -784,7 +784,7 @@ // Sink whatever instructions were needed to produce the unfolded operand // into the false block. for (auto *NewMI : NewMIs) { - DEBUG(dbgs() << "\tRewritten load instr: "; NewMI->dump()); + LLVM_DEBUG(dbgs() << "\tRewritten load instr: "; NewMI->dump()); FalseMBB->insert(FalseInsertionPoint, NewMI); // Re-map any operands that are from other cmovs to the inputs for this block. for (auto &MOp : NewMI->uses()) { @@ -846,8 +846,8 @@ .addReg(Op2Reg) .addMBB(MBB); (void)MIB; - DEBUG(dbgs() << "\tFrom: "; MIIt->dump()); - DEBUG(dbgs() << "\tTo: "; MIB->dump()); + LLVM_DEBUG(dbgs() << "\tFrom: "; MIIt->dump()); + LLVM_DEBUG(dbgs() << "\tTo: "; MIB->dump()); // Add this PHI to the rewrite table. RegRewriteTable[DestReg] = std::make_pair(Op1Reg, Op2Reg); Index: lib/Target/X86/X86DomainReassignment.cpp =================================================================== --- lib/Target/X86/X86DomainReassignment.cpp +++ lib/Target/X86/X86DomainReassignment.cpp @@ -701,8 +701,8 @@ if (DisableX86DomainReassignment) return false; - DEBUG(dbgs() << "***** Machine Function before Domain Reassignment *****\n"); - DEBUG(MF.print(dbgs())); + LLVM_DEBUG(dbgs() << "***** Machine Function before Domain Reassignment *****\n"); + LLVM_DEBUG(MF.print(dbgs())); STI = &MF.getSubtarget(); // GPR->K is the only transformation currently supported, bail out early if no @@ -753,8 +753,8 @@ for (auto I : Converters) delete I.second; - DEBUG(dbgs() << "***** Machine Function after Domain Reassignment *****\n"); - DEBUG(MF.print(dbgs())); + LLVM_DEBUG(dbgs() << "***** Machine Function after Domain Reassignment *****\n"); + LLVM_DEBUG(MF.print(dbgs())); return Changed; } Index: lib/Target/X86/X86FixupBWInsts.cpp =================================================================== --- lib/Target/X86/X86FixupBWInsts.cpp +++ lib/Target/X86/X86FixupBWInsts.cpp @@ -155,13 +155,13 @@ MLI = &getAnalysis(); LiveRegs.init(TII->getRegisterInfo()); - DEBUG(dbgs() << "Start X86FixupBWInsts\n";); + LLVM_DEBUG(dbgs() << "Start X86FixupBWInsts\n";); // Process all basic blocks. for (auto &MBB : MF) processBasicBlock(MF, MBB); - DEBUG(dbgs() << "End X86FixupBWInsts\n";); + LLVM_DEBUG(dbgs() << "End X86FixupBWInsts\n";); return true; } Index: lib/Target/X86/X86FixupLEAs.cpp =================================================================== --- lib/Target/X86/X86FixupLEAs.cpp +++ lib/Target/X86/X86FixupLEAs.cpp @@ -204,11 +204,11 @@ TII = ST.getInstrInfo(); - DEBUG(dbgs() << "Start X86FixupLEAs\n";); + LLVM_DEBUG(dbgs() << "Start X86FixupLEAs\n";); // Process all basic blocks. for (MachineFunction::iterator I = Func.begin(), E = Func.end(); I != E; ++I) processBasicBlock(Func, I); - DEBUG(dbgs() << "End X86FixupLEAs\n";); + LLVM_DEBUG(dbgs() << "End X86FixupLEAs\n";); return true; } @@ -407,9 +407,9 @@ MachineInstr *NewMI = postRAConvertToLEA(MFI, MBI); if (NewMI) { ++NumLEAs; - DEBUG(dbgs() << "FixLEA: Candidate to replace:"; MBI->dump();); + LLVM_DEBUG(dbgs() << "FixLEA: Candidate to replace:"; MBI->dump();); // now to replace with an equivalent LEA... - DEBUG(dbgs() << "FixLEA: Replaced by: "; NewMI->dump();); + LLVM_DEBUG(dbgs() << "FixLEA: Replaced by: "; NewMI->dump();); MFI->erase(MBI); MachineBasicBlock::iterator J = static_cast(NewMI); @@ -434,8 +434,8 @@ return; if (MI.getOperand(2).getImm() > 1) return; - DEBUG(dbgs() << "FixLEA: Candidate to replace:"; I->dump();); - DEBUG(dbgs() << "FixLEA: Replaced by: ";); + LLVM_DEBUG(dbgs() << "FixLEA: Candidate to replace:"; I->dump();); + LLVM_DEBUG(dbgs() << "FixLEA: Replaced by: ";); MachineInstr *NewMI = nullptr; // Make ADD instruction for two registers writing to LEA's destination if (SrcR1 != 0 && SrcR2 != 0) { @@ -443,7 +443,7 @@ const MachineOperand &Src = MI.getOperand(SrcR1 == DstR ? 3 : 1); NewMI = BuildMI(*MFI, I, MI.getDebugLoc(), ADDrr, DstR).addReg(DstR).add(Src); - DEBUG(NewMI->dump();); + LLVM_DEBUG(NewMI->dump();); } // Make ADD instruction for immediate if (MI.getOperand(4).getImm() != 0) { @@ -453,7 +453,7 @@ NewMI = BuildMI(*MFI, I, MI.getDebugLoc(), ADDri, DstR) .add(SrcR) .addImm(MI.getOperand(4).getImm()); - DEBUG(NewMI->dump();); + LLVM_DEBUG(NewMI->dump();); } if (NewMI) { MFI->erase(I); @@ -503,8 +503,8 @@ const MCInstrDesc &ADDrr = TII->get(getADDrrFromLEA(LEAOpcode)); const MCInstrDesc &ADDri = TII->get(getADDriFromLEA(LEAOpcode, Offset)); - DEBUG(dbgs() << "FixLEA: Candidate to replace:"; MI.dump();); - DEBUG(dbgs() << "FixLEA: Replaced by: ";); + LLVM_DEBUG(dbgs() << "FixLEA: Candidate to replace:"; MI.dump();); + LLVM_DEBUG(dbgs() << "FixLEA: Replaced by: ";); // First try to replace LEA with one or two (for the 3-op LEA case) // add instructions: @@ -514,11 +514,11 @@ const MachineOperand &Src = DstR == BaseR ? Index : Base; MachineInstr *NewMI = BuildMI(*MFI, MI, DL, ADDrr, DstR).addReg(DstR).add(Src); - DEBUG(NewMI->dump();); + LLVM_DEBUG(NewMI->dump();); // Create ADD instruction for the Offset in case of 3-Ops LEA. if (hasLEAOffset(Offset)) { NewMI = BuildMI(*MFI, MI, DL, ADDri, DstR).addReg(DstR).add(Offset); - DEBUG(NewMI->dump();); + LLVM_DEBUG(NewMI->dump();); } return NewMI; } @@ -534,11 +534,11 @@ .add(IsInefficientBase ? Base : Index) .addImm(0) .add(Segment); - DEBUG(NewMI->dump();); + LLVM_DEBUG(NewMI->dump();); // Create ADD instruction for the Offset in case of 3-Ops LEA. if (hasLEAOffset(Offset)) { NewMI = BuildMI(*MFI, MI, DL, ADDri, DstR).addReg(DstR).add(Offset); - DEBUG(NewMI->dump();); + LLVM_DEBUG(NewMI->dump();); } return NewMI; } @@ -550,11 +550,11 @@ if (IsScale1 && !hasLEAOffset(Offset)) { bool BIK = Base.isKill() && BaseR != IndexR; TII->copyPhysReg(*MFI, MI, DL, DstR, BaseR, BIK); - DEBUG(MI.getPrevNode()->dump();); + LLVM_DEBUG(MI.getPrevNode()->dump();); MachineInstr *NewMI = BuildMI(*MFI, MI, DL, ADDrr, DstR).addReg(DstR).add(Index); - DEBUG(NewMI->dump();); + LLVM_DEBUG(NewMI->dump();); return NewMI; } // lea offset(%base,%index,scale), %dst => @@ -566,10 +566,10 @@ .add(Index) .add(Offset) .add(Segment); - DEBUG(NewMI->dump();); + LLVM_DEBUG(NewMI->dump();); NewMI = BuildMI(*MFI, MI, DL, ADDrr, DstR).addReg(DstR).add(Base); - DEBUG(NewMI->dump();); + LLVM_DEBUG(NewMI->dump();); return NewMI; } Index: lib/Target/X86/X86FixupSFB.cpp =================================================================== --- lib/Target/X86/X86FixupSFB.cpp +++ lib/Target/X86/X86FixupSFB.cpp @@ -336,7 +336,7 @@ .addReg(X86::NoRegister) .addMemOperand( MBB->getParent()->getMachineMemOperand(LMMO, LMMOffset, Size)); - DEBUG(LoadInst->getPrevNode()->dump()); + LLVM_DEBUG(LoadInst->getPrevNode()->dump()); // If the load and store are consecutive, use the loadInst location to // reduce register pressure. MachineInstr *StInst = StoreInst; @@ -351,7 +351,7 @@ .addReg(Reg1) .addMemOperand( MBB->getParent()->getMachineMemOperand(SMMO, SMMOffset, Size)); - DEBUG(StInst->getPrevNode()->dump()); + LLVM_DEBUG(StInst->getPrevNode()->dump()); } void FixupSFBPass::buildCopies(int Size, MachineInstr *LoadInst, @@ -508,7 +508,7 @@ TII = MF.getSubtarget().getInstrInfo(); TRI = MF.getSubtarget().getRegisterInfo(); Is64Bit = MF.getSubtarget().is64Bit(); - DEBUG(dbgs() << "Start X86FixupSFB\n";); + LLVM_DEBUG(dbgs() << "Start X86FixupSFB\n";); // Look for a load then a store to XMM/YMM which look like a memcpy findPotentiallylBlockedCopies(MF); @@ -560,10 +560,10 @@ // into smaller copies such that each smaller store that was causing // a store block would now be copied separately. MachineInstr *StoreInst = LoadStoreInst.second; - DEBUG(dbgs() << "Blocked load and store instructions: \n"); - DEBUG(LoadInst->dump()); - DEBUG(StoreInst->dump()); - DEBUG(dbgs() << "Replaced with:\n"); + LLVM_DEBUG(dbgs() << "Blocked load and store instructions: \n"); + LLVM_DEBUG(LoadInst->dump()); + LLVM_DEBUG(StoreInst->dump()); + LLVM_DEBUG(dbgs() << "Replaced with:\n"); breakBlockedCopies(LoadInst, StoreInst, BlockingStoresDisp); updateKillStatus(LoadInst, StoreInst); ForRemoval.push_back(LoadInst); @@ -574,7 +574,7 @@ } ForRemoval.clear(); BlockedLoadsStores.clear(); - DEBUG(dbgs() << "End X86FixupSFB\n";); + LLVM_DEBUG(dbgs() << "End X86FixupSFB\n";); return Changed; } Index: lib/Target/X86/X86FloatingPoint.cpp =================================================================== --- lib/Target/X86/X86FloatingPoint.cpp +++ lib/Target/X86/X86FloatingPoint.cpp @@ -434,7 +434,7 @@ PrevMI = &*std::prev(I); ++NumFP; // Keep track of # of pseudo instrs - DEBUG(dbgs() << "\nFPInst:\t" << MI); + LLVM_DEBUG(dbgs() << "\nFPInst:\t" << MI); // Get dead variables list now because the MI pointer may be deleted as part // of processing! @@ -464,13 +464,13 @@ // is in the clobber list and marked dead might not be live on the stack. static_assert(X86::FP7 - X86::FP0 == 7, "sequential FP regnumbers"); if (Reg >= X86::FP0 && Reg <= X86::FP6 && isLive(Reg-X86::FP0)) { - DEBUG(dbgs() << "Register FP#" << Reg-X86::FP0 << " is dead!\n"); + LLVM_DEBUG(dbgs() << "Register FP#" << Reg-X86::FP0 << " is dead!\n"); freeStackSlotAfter(I, Reg-X86::FP0); } } // Print out all of the instructions expanded to if -debug - DEBUG({ + LLVM_DEBUG({ MachineBasicBlock::iterator PrevI = PrevMI; if (I == PrevI) { dbgs() << "Just deleted pseudo instruction\n"; @@ -499,7 +499,7 @@ /// setupBlockStack - Use the live bundles to set up our model of the stack /// to match predecessors' live out stack. void FPS::setupBlockStack() { - DEBUG(dbgs() << "\nSetting up live-ins for " << printMBBReference(*MBB) + LLVM_DEBUG(dbgs() << "\nSetting up live-ins for " << printMBBReference(*MBB) << " derived from " << MBB->getName() << ".\n"); StackTop = 0; // Get the live-in bundle for MBB. @@ -507,7 +507,7 @@ LiveBundles[Bundles->getBundle(MBB->getNumber(), false)]; if (!Bundle.Mask) { - DEBUG(dbgs() << "Block has no FP live-ins.\n"); + LLVM_DEBUG(dbgs() << "Block has no FP live-ins.\n"); return; } @@ -516,7 +516,7 @@ // Push the fixed live-in registers. for (unsigned i = Bundle.FixCount; i > 0; --i) { - DEBUG(dbgs() << "Live-in st(" << (i-1) << "): %fp" + LLVM_DEBUG(dbgs() << "Live-in st(" << (i-1) << "): %fp" << unsigned(Bundle.FixStack[i-1]) << '\n'); pushReg(Bundle.FixStack[i-1]); } @@ -526,7 +526,7 @@ // to be revived at the end of a short block. It might save a few instrs. unsigned Mask = calcLiveInMask(MBB, /*RemoveFPs=*/true); adjustLiveRegs(Mask, MBB->begin()); - DEBUG(MBB->dump()); + LLVM_DEBUG(MBB->dump()); } /// finishBlockStack - Revive live-outs that are implicitly defined out of @@ -538,7 +538,7 @@ if (MBB->succ_empty()) return; - DEBUG(dbgs() << "Setting up live-outs for " << printMBBReference(*MBB) + LLVM_DEBUG(dbgs() << "Setting up live-outs for " << printMBBReference(*MBB) << " derived from " << MBB->getName() << ".\n"); // Get MBB's live-out bundle. @@ -551,18 +551,18 @@ adjustLiveRegs(Bundle.Mask, Term); if (!Bundle.Mask) { - DEBUG(dbgs() << "No live-outs.\n"); + LLVM_DEBUG(dbgs() << "No live-outs.\n"); return; } // Has the stack order been fixed yet? - DEBUG(dbgs() << "LB#" << BundleIdx << ": "); + LLVM_DEBUG(dbgs() << "LB#" << BundleIdx << ": "); if (Bundle.isFixed()) { - DEBUG(dbgs() << "Shuffling stack to match.\n"); + LLVM_DEBUG(dbgs() << "Shuffling stack to match.\n"); shuffleStackTop(Bundle.FixStack, Bundle.FixCount, Term); } else { // Not fixed yet, we get to choose. - DEBUG(dbgs() << "Fixing stack order now.\n"); + LLVM_DEBUG(dbgs() << "Fixing stack order now.\n"); Bundle.FixCount = StackTop; for (unsigned i = 0; i < StackTop; ++i) Bundle.FixStack[i] = getStackEntry(i); @@ -893,7 +893,7 @@ while (Kills && Defs) { unsigned KReg = countTrailingZeros(Kills); unsigned DReg = countTrailingZeros(Defs); - DEBUG(dbgs() << "Renaming %fp" << KReg << " as imp %fp" << DReg << "\n"); + LLVM_DEBUG(dbgs() << "Renaming %fp" << KReg << " as imp %fp" << DReg << "\n"); std::swap(Stack[getSlot(KReg)], Stack[getSlot(DReg)]); std::swap(RegMap[KReg], RegMap[DReg]); Kills &= ~(1 << KReg); @@ -907,7 +907,7 @@ unsigned KReg = getStackEntry(0); if (!(Kills & (1 << KReg))) break; - DEBUG(dbgs() << "Popping %fp" << KReg << "\n"); + LLVM_DEBUG(dbgs() << "Popping %fp" << KReg << "\n"); popStackAfter(I2); Kills &= ~(1 << KReg); } @@ -916,7 +916,7 @@ // Manually kill the rest. while (Kills) { unsigned KReg = countTrailingZeros(Kills); - DEBUG(dbgs() << "Killing %fp" << KReg << "\n"); + LLVM_DEBUG(dbgs() << "Killing %fp" << KReg << "\n"); freeStackSlotBefore(I, KReg); Kills &= ~(1 << KReg); } @@ -924,14 +924,14 @@ // Load zeros for all the imp-defs. while(Defs) { unsigned DReg = countTrailingZeros(Defs); - DEBUG(dbgs() << "Defining %fp" << DReg << " as 0\n"); + LLVM_DEBUG(dbgs() << "Defining %fp" << DReg << " as 0\n"); BuildMI(*MBB, I, DebugLoc(), TII->get(X86::LD_F0)); pushReg(DReg); Defs &= ~(1 << DReg); } // Now we should have the correct registers live. - DEBUG(dumpStack()); + LLVM_DEBUG(dumpStack()); assert(StackTop == countPopulation(Mask) && "Live count mismatch"); } @@ -954,7 +954,7 @@ if (FixCount > 0) moveToTop(OldReg, I); } - DEBUG(dumpStack()); + LLVM_DEBUG(dumpStack()); } @@ -1468,7 +1468,7 @@ case TargetOpcode::IMPLICIT_DEF: { // All FP registers must be explicitly defined, so load a 0 instead. unsigned Reg = MI.getOperand(0).getReg() - X86::FP0; - DEBUG(dbgs() << "Emitting LD_F0 for implicit FP" << Reg << '\n'); + LLVM_DEBUG(dbgs() << "Emitting LD_F0 for implicit FP" << Reg << '\n'); BuildMI(*MBB, Inst, MI.getDebugLoc(), TII->get(X86::LD_F0)); pushReg(Reg); break; @@ -1573,7 +1573,7 @@ MI.emitError("implicitly popped regs must be last on the x87 stack"); unsigned NumSTPopped = countTrailingOnes(STPopped); - DEBUG(dbgs() << "Asm uses " << NumSTUses << " fixed regs, pops " + LLVM_DEBUG(dbgs() << "Asm uses " << NumSTUses << " fixed regs, pops " << NumSTPopped << ", and defines " << NumSTDefs << " regs.\n"); #ifndef NDEBUG @@ -1612,7 +1612,7 @@ STUsesArray[I] = I; shuffleStackTop(STUsesArray, NumSTUses, Inst); - DEBUG({dbgs() << "Before asm: "; dumpStack();}); + LLVM_DEBUG({dbgs() << "Before asm: "; dumpStack();}); // With the stack layout fixed, rewrite the FP registers. for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) { @@ -1661,7 +1661,7 @@ // We want to leave I pointing to the previous instruction, but what if we // just erased the first instruction? if (Inst == MBB->begin()) { - DEBUG(dbgs() << "Inserting dummy KILL\n"); + LLVM_DEBUG(dbgs() << "Inserting dummy KILL\n"); Inst = BuildMI(*MBB, Inst, DebugLoc(), TII->get(TargetOpcode::KILL)); } else --Inst; Index: lib/Target/X86/X86ISelDAGToDAG.cpp =================================================================== --- lib/Target/X86/X86ISelDAGToDAG.cpp +++ lib/Target/X86/X86ISelDAGToDAG.cpp @@ -1209,7 +1209,7 @@ bool X86DAGToDAGISel::matchAddressRecursively(SDValue N, X86ISelAddressMode &AM, unsigned Depth) { SDLoc dl(N); - DEBUG({ + LLVM_DEBUG({ dbgs() << "MatchAddress: "; AM.dump(); }); @@ -2518,7 +2518,7 @@ SDLoc dl(Node); if (Node->isMachineOpcode()) { - DEBUG(dbgs() << "== "; Node->dump(CurDAG); dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "== "; Node->dump(CurDAG); dbgs() << '\n'); Node->setNodeId(-1); return; // Already selected. } @@ -2832,7 +2832,7 @@ InFlag = ResLo.getValue(2); } ReplaceUses(SDValue(Node, 0), ResLo); - DEBUG(dbgs() << "=> "; ResLo.getNode()->dump(CurDAG); dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "=> "; ResLo.getNode()->dump(CurDAG); dbgs() << '\n'); } // Copy the high half of the result, if it is needed. if (!SDValue(Node, 1).use_empty()) { @@ -2843,7 +2843,7 @@ InFlag = ResHi.getValue(2); } ReplaceUses(SDValue(Node, 1), ResHi); - DEBUG(dbgs() << "=> "; ResHi.getNode()->dump(CurDAG); dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "=> "; ResHi.getNode()->dump(CurDAG); dbgs() << '\n'); } CurDAG->RemoveDeadNode(Node); @@ -3005,7 +3005,7 @@ CurDAG->getTargetExtractSubreg(X86::sub_8bit, dl, MVT::i8, Result); } ReplaceUses(SDValue(Node, 1), Result); - DEBUG(dbgs() << "=> "; Result.getNode()->dump(CurDAG); dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "=> "; Result.getNode()->dump(CurDAG); dbgs() << '\n'); } // Copy the division (low) result, if it is needed. if (!SDValue(Node, 0).use_empty()) { @@ -3013,7 +3013,7 @@ LoReg, NVT, InFlag); InFlag = Result.getValue(2); ReplaceUses(SDValue(Node, 0), Result); - DEBUG(dbgs() << "=> "; Result.getNode()->dump(CurDAG); dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "=> "; Result.getNode()->dump(CurDAG); dbgs() << '\n'); } // Copy the remainder (high) result, if it is needed. if (!SDValue(Node, 1).use_empty()) { @@ -3021,7 +3021,7 @@ HiReg, NVT, InFlag); InFlag = Result.getValue(2); ReplaceUses(SDValue(Node, 1), Result); - DEBUG(dbgs() << "=> "; Result.getNode()->dump(CurDAG); dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "=> "; Result.getNode()->dump(CurDAG); dbgs() << '\n'); } CurDAG->RemoveDeadNode(Node); return; Index: lib/Target/X86/X86InstrInfo.cpp =================================================================== --- lib/Target/X86/X86InstrInfo.cpp +++ lib/Target/X86/X86InstrInfo.cpp @@ -6894,7 +6894,7 @@ return; } - DEBUG(dbgs() << "Cannot copy " << RI.getName(SrcReg) + LLVM_DEBUG(dbgs() << "Cannot copy " << RI.getName(SrcReg) << " to " << RI.getName(DestReg) << '\n'); llvm_unreachable("Cannot emit physreg copy instruction"); } Index: lib/Target/X86/X86InstructionSelector.cpp =================================================================== --- lib/Target/X86/X86InstructionSelector.cpp +++ lib/Target/X86/X86InstructionSelector.cpp @@ -292,7 +292,7 @@ const TargetRegisterClass *OldRC = MRI.getRegClassOrNull(DstReg); if (!OldRC || !DstRC->hasSubClassEq(OldRC)) { if (!RBI.constrainGenericRegister(DstReg, *DstRC, MRI)) { - DEBUG(dbgs() << "Failed to constrain " << TII.getName(I.getOpcode()) + LLVM_DEBUG(dbgs() << "Failed to constrain " << TII.getName(I.getOpcode()) << " operand\n"); return false; } @@ -329,7 +329,7 @@ if (selectImpl(I, CoverageInfo)) return true; - DEBUG(dbgs() << " C++ instruction selection: "; I.print(dbgs())); + LLVM_DEBUG(dbgs() << " C++ instruction selection: "; I.print(dbgs())); // TODO: This should be implemented by tblgen. switch (I.getOpcode()) { @@ -490,7 +490,7 @@ auto &MemOp = **I.memoperands_begin(); if (MemOp.getOrdering() != AtomicOrdering::NotAtomic) { - DEBUG(dbgs() << "Atomic load/store not supported yet\n"); + LLVM_DEBUG(dbgs() << "Atomic load/store not supported yet\n"); return false; } @@ -662,7 +662,7 @@ if (!RBI.constrainGenericRegister(SrcReg, *SrcRC, MRI) || !RBI.constrainGenericRegister(DstReg, *DstRC, MRI)) { - DEBUG(dbgs() << "Failed to constrain " << TII.getName(I.getOpcode()) + LLVM_DEBUG(dbgs() << "Failed to constrain " << TII.getName(I.getOpcode()) << " operand\n"); return false; } @@ -685,7 +685,7 @@ const RegisterBank &SrcRB = *RBI.getRegBank(SrcReg, MRI, TRI); if (DstRB.getID() != SrcRB.getID()) { - DEBUG(dbgs() << "G_TRUNC input/output on different banks\n"); + LLVM_DEBUG(dbgs() << "G_TRUNC input/output on different banks\n"); return false; } @@ -722,7 +722,7 @@ if (!RBI.constrainGenericRegister(SrcReg, *SrcRC, MRI) || !RBI.constrainGenericRegister(DstReg, *DstRC, MRI)) { - DEBUG(dbgs() << "Failed to constrain G_TRUNC\n"); + LLVM_DEBUG(dbgs() << "Failed to constrain G_TRUNC\n"); return false; } @@ -813,7 +813,7 @@ if (!RBI.constrainGenericRegister(SrcReg, *SrcRC, MRI) || !RBI.constrainGenericRegister(DstReg, *DstRC, MRI)) { - DEBUG(dbgs() << "Failed to constrain " << TII.getName(I.getOpcode()) + LLVM_DEBUG(dbgs() << "Failed to constrain " << TII.getName(I.getOpcode()) << " operand\n"); return false; } @@ -1030,7 +1030,7 @@ if (!RBI.constrainGenericRegister(SrcReg, *SrcRC, MRI) || !RBI.constrainGenericRegister(DstReg, *DstRC, MRI)) { - DEBUG(dbgs() << "Failed to constrain G_TRUNC\n"); + LLVM_DEBUG(dbgs() << "Failed to constrain G_TRUNC\n"); return false; } @@ -1067,7 +1067,7 @@ if (!RBI.constrainGenericRegister(SrcReg, *SrcRC, MRI) || !RBI.constrainGenericRegister(DstReg, *DstRC, MRI)) { - DEBUG(dbgs() << "Failed to constrain INSERT_SUBREG\n"); + LLVM_DEBUG(dbgs() << "Failed to constrain INSERT_SUBREG\n"); return false; } @@ -1311,7 +1311,7 @@ const TargetRegisterClass *RC = getRegClass(DstTy, DstReg, MRI); if (!RBI.constrainGenericRegister(DstReg, *RC, MRI)) { - DEBUG(dbgs() << "Failed to constrain " << TII.getName(I.getOpcode()) + LLVM_DEBUG(dbgs() << "Failed to constrain " << TII.getName(I.getOpcode()) << " operand\n"); return false; } Index: lib/Target/X86/X86OptimizeLEAs.cpp =================================================================== --- lib/Target/X86/X86OptimizeLEAs.cpp +++ lib/Target/X86/X86OptimizeLEAs.cpp @@ -541,7 +541,7 @@ MRI->clearKillFlags(DefMI->getOperand(0).getReg()); ++NumSubstLEAs; - DEBUG(dbgs() << "OptimizeLEAs: Candidate to replace: "; MI.dump();); + LLVM_DEBUG(dbgs() << "OptimizeLEAs: Candidate to replace: "; MI.dump();); // Change instruction operands. MI.getOperand(MemOpNo + X86::AddrBaseReg) @@ -553,7 +553,7 @@ MI.getOperand(MemOpNo + X86::AddrSegmentReg) .ChangeToRegister(X86::NoRegister, false); - DEBUG(dbgs() << "OptimizeLEAs: Replaced by: "; MI.dump();); + LLVM_DEBUG(dbgs() << "OptimizeLEAs: Replaced by: "; MI.dump();); Changed = true; } @@ -649,7 +649,7 @@ MRI->clearKillFlags(FirstVReg); ++NumRedundantLEAs; - DEBUG(dbgs() << "OptimizeLEAs: Remove redundant LEA: "; Last.dump();); + LLVM_DEBUG(dbgs() << "OptimizeLEAs: Remove redundant LEA: "; Last.dump();); // By this moment, all of the Last LEA's uses must be replaced. So we // can freely remove it. Index: lib/Target/X86/X86RetpolineThunks.cpp =================================================================== --- lib/Target/X86/X86RetpolineThunks.cpp +++ lib/Target/X86/X86RetpolineThunks.cpp @@ -91,7 +91,7 @@ } bool X86RetpolineThunks::runOnMachineFunction(MachineFunction &MF) { - DEBUG(dbgs() << getPassName() << '\n'); + LLVM_DEBUG(dbgs() << getPassName() << '\n'); TM = &MF.getTarget();; STI = &MF.getSubtarget(); Index: lib/Target/X86/X86Subtarget.cpp =================================================================== --- lib/Target/X86/X86Subtarget.cpp +++ lib/Target/X86/X86Subtarget.cpp @@ -230,7 +230,7 @@ else llvm_unreachable("Not 16-bit, 32-bit or 64-bit mode!"); - DEBUG(dbgs() << "Subtarget features: SSELevel " << X86SSELevel + LLVM_DEBUG(dbgs() << "Subtarget features: SSELevel " << X86SSELevel << ", 3DNowLevel " << X863DNowLevel << ", 64bit " << HasX86_64 << "\n"); assert((!In64BitMode || HasX86_64) && Index: lib/Target/X86/X86VZeroUpper.cpp =================================================================== --- lib/Target/X86/X86VZeroUpper.cpp +++ lib/Target/X86/X86VZeroUpper.cpp @@ -264,7 +264,7 @@ } } - DEBUG(dbgs() << "MBB #" << MBB.getNumber() << " exit state: " + LLVM_DEBUG(dbgs() << "MBB #" << MBB.getNumber() << " exit state: " << getBlockExitStateName(CurState) << '\n'); if (CurState == EXITS_DIRTY) @@ -341,7 +341,7 @@ // successors need to be added to the worklist (if they haven't been // already). if (BBState.ExitState == PASS_THROUGH) { - DEBUG(dbgs() << "MBB #" << MBB.getNumber() + LLVM_DEBUG(dbgs() << "MBB #" << MBB.getNumber() << " was Pass-through, is now Dirty-out.\n"); for (MachineBasicBlock *Succ : MBB.successors()) addDirtySuccessor(*Succ); Index: lib/Target/X86/X86WinEHState.cpp =================================================================== --- lib/Target/X86/X86WinEHState.cpp +++ lib/Target/X86/X86WinEHState.cpp @@ -695,9 +695,9 @@ Worklist.push_back(BB); continue; } - DEBUG(dbgs() << "X86WinEHState: " << BB->getName() + LLVM_DEBUG(dbgs() << "X86WinEHState: " << BB->getName() << " InitialState=" << InitialState << '\n'); - DEBUG(dbgs() << "X86WinEHState: " << BB->getName() + LLVM_DEBUG(dbgs() << "X86WinEHState: " << BB->getName() << " FinalState=" << FinalState << '\n'); InitialStates.insert({BB, InitialState}); FinalStates.insert({BB, FinalState}); @@ -743,7 +743,7 @@ continue; int PrevState = getPredState(FinalStates, F, ParentBaseState, BB); - DEBUG(dbgs() << "X86WinEHState: " << BB->getName() + LLVM_DEBUG(dbgs() << "X86WinEHState: " << BB->getName() << " PrevState=" << PrevState << '\n'); for (Instruction &I : *BB) { Index: lib/Target/XCore/XCoreRegisterInfo.cpp =================================================================== --- lib/Target/XCore/XCoreRegisterInfo.cpp +++ lib/Target/XCore/XCoreRegisterInfo.cpp @@ -274,13 +274,13 @@ int StackSize = MF.getFrameInfo().getStackSize(); #ifndef NDEBUG - DEBUG(errs() << "\nFunction : " + LLVM_DEBUG(errs() << "\nFunction : " << MF.getName() << "\n"); - DEBUG(errs() << "<--------->\n"); - DEBUG(MI.print(errs())); - DEBUG(errs() << "FrameIndex : " << FrameIndex << "\n"); - DEBUG(errs() << "FrameOffset : " << Offset << "\n"); - DEBUG(errs() << "StackSize : " << StackSize << "\n"); + LLVM_DEBUG(errs() << "<--------->\n"); + LLVM_DEBUG(MI.print(errs())); + LLVM_DEBUG(errs() << "FrameIndex : " << FrameIndex << "\n"); + LLVM_DEBUG(errs() << "FrameOffset : " << Offset << "\n"); + LLVM_DEBUG(errs() << "StackSize : " << StackSize << "\n"); #endif Offset += StackSize; @@ -299,7 +299,7 @@ MI.getOperand(FIOperandNum + 1).ChangeToImmediate(0); assert(Offset%4 == 0 && "Misaligned stack offset"); - DEBUG(errs() << "Offset : " << Offset << "\n" << "<--------->\n"); + LLVM_DEBUG(errs() << "Offset : " << Offset << "\n" << "<--------->\n"); Offset/=4; unsigned Reg = MI.getOperand(0).getReg(); Index: lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp =================================================================== --- lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp +++ lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp @@ -405,7 +405,7 @@ CurrentTruncInst = Worklist.pop_back_val(); if (Type *NewDstSclTy = getBestTruncatedType()) { - DEBUG(dbgs() << "ICE: TruncInstCombine reducing type of expression dag " + LLVM_DEBUG(dbgs() << "ICE: TruncInstCombine reducing type of expression dag " "dominated by: " << CurrentTruncInst << '\n'); ReduceExpressionDag(NewDstSclTy); Index: lib/Transforms/Coroutines/CoroFrame.cpp =================================================================== --- lib/Transforms/Coroutines/CoroFrame.cpp +++ lib/Transforms/Coroutines/CoroFrame.cpp @@ -105,7 +105,7 @@ assert(Block[UseIndex].Consumes[DefIndex] && "use must consume def"); bool const Result = Block[UseIndex].Kills[DefIndex]; - DEBUG(dbgs() << UseBB->getName() << " => " << DefBB->getName() + LLVM_DEBUG(dbgs() << UseBB->getName() << " => " << DefBB->getName() << " answer is " << Result << "\n"); return Result; } @@ -194,8 +194,8 @@ bool Changed; do { - DEBUG(dbgs() << "iteration " << ++Iteration); - DEBUG(dbgs() << "==============\n"); + LLVM_DEBUG(dbgs() << "iteration " << ++Iteration); + LLVM_DEBUG(dbgs() << "==============\n"); Changed = false; for (size_t I = 0; I < N; ++I) { @@ -239,20 +239,20 @@ Changed |= (S.Kills != SavedKills) || (S.Consumes != SavedConsumes); if (S.Kills != SavedKills) { - DEBUG(dbgs() << "\nblock " << I << " follower " << SI->getName() + LLVM_DEBUG(dbgs() << "\nblock " << I << " follower " << SI->getName() << "\n"); - DEBUG(dump("S.Kills", S.Kills)); - DEBUG(dump("SavedKills", SavedKills)); + LLVM_DEBUG(dump("S.Kills", S.Kills)); + LLVM_DEBUG(dump("SavedKills", SavedKills)); } if (S.Consumes != SavedConsumes) { - DEBUG(dbgs() << "\nblock " << I << " follower " << SI << "\n"); - DEBUG(dump("S.Consume", S.Consumes)); - DEBUG(dump("SavedCons", SavedConsumes)); + LLVM_DEBUG(dbgs() << "\nblock " << I << " follower " << SI << "\n"); + LLVM_DEBUG(dump("S.Consume", S.Consumes)); + LLVM_DEBUG(dump("SavedCons", SavedConsumes)); } } } } while (Changed); - DEBUG(dump()); + LLVM_DEBUG(dump()); } #undef DEBUG_TYPE // "coro-suspend-crossing" @@ -739,7 +739,7 @@ for (User *U : CurrentValue->users()) { Instruction *I = cast(U); if (!DT.dominates(CoroBegin, I)) { - DEBUG(dbgs() << "will move: " << *I << "\n"); + LLVM_DEBUG(dbgs() << "will move: " << *I << "\n"); // TODO: Make this more robust. Currently if we run into a situation // where simple instruction move won't work we panic and @@ -824,7 +824,7 @@ break; // Rewrite materializable instructions to be materialized at the use point. - DEBUG(dump("Materializations", Spills)); + LLVM_DEBUG(dump("Materializations", Spills)); rewriteMaterializableInstructions(Builder, Spills); Spills.clear(); } @@ -854,7 +854,7 @@ Spills.emplace_back(&I, U); } } - DEBUG(dump("Spills", Spills)); + LLVM_DEBUG(dump("Spills", Spills)); moveSpillUsesAfterCoroBegin(F, Spills, Shape.CoroBegin); Shape.FrameTy = buildFrameType(F, Shape, Spills); Shape.FramePtr = insertSpills(Spills, Shape); Index: lib/Transforms/Coroutines/CoroSplit.cpp =================================================================== --- lib/Transforms/Coroutines/CoroSplit.cpp +++ lib/Transforms/Coroutines/CoroSplit.cpp @@ -654,7 +654,7 @@ // set. do { Instruction *Current = Work.pop_back_val(); - DEBUG(dbgs() << "CoroSplit: Will not relocate: " << *Current << "\n"); + LLVM_DEBUG(dbgs() << "CoroSplit: Will not relocate: " << *Current << "\n"); DoNotRelocate.insert(Current); for (Value *U : Current->operands()) { auto *I = dyn_cast(U); @@ -850,7 +850,7 @@ for (Function *F : Coroutines) { Attribute Attr = F->getFnAttribute(CORO_PRESPLIT_ATTR); StringRef Value = Attr.getValueAsString(); - DEBUG(dbgs() << "CoroSplit: Processing coroutine '" << F->getName() + LLVM_DEBUG(dbgs() << "CoroSplit: Processing coroutine '" << F->getName() << "' state: " << Value << "\n"); if (Value == UNPREPARED_FOR_SPLIT) { prepareForSplit(*F, CG); Index: lib/Transforms/IPO/ArgumentPromotion.cpp =================================================================== --- lib/Transforms/IPO/ArgumentPromotion.cpp +++ lib/Transforms/IPO/ArgumentPromotion.cpp @@ -220,7 +220,7 @@ NF->setSubprogram(F->getSubprogram()); F->setSubprogram(nullptr); - DEBUG(dbgs() << "ARG PROMOTION: Promoting to:" << *NF << "\n" + LLVM_DEBUG(dbgs() << "ARG PROMOTION: Promoting to:" << *NF << "\n" << "From: " << *F); // Recompute the parameter attributes list based on the new arguments for @@ -426,7 +426,7 @@ I2->setName(I->getName() + ".val"); LI->replaceAllUsesWith(&*I2); LI->eraseFromParent(); - DEBUG(dbgs() << "*** Promoted load of argument '" << I->getName() + LLVM_DEBUG(dbgs() << "*** Promoted load of argument '" << I->getName() << "' in function '" << F->getName() << "'\n"); } else { GetElementPtrInst *GEP = cast(I->user_back()); @@ -453,7 +453,7 @@ NewName += ".val"; TheArg->setName(NewName); - DEBUG(dbgs() << "*** Promoted agg argument '" << TheArg->getName() + LLVM_DEBUG(dbgs() << "*** Promoted agg argument '" << TheArg->getName() << "' of function '" << NF->getName() << "'\n"); // All of the uses must be load instructions. Replace them all with @@ -688,7 +688,7 @@ // to do. if (ToPromote.find(Operands) == ToPromote.end()) { if (MaxElements > 0 && ToPromote.size() == MaxElements) { - DEBUG(dbgs() << "argpromotion not promoting argument '" + LLVM_DEBUG(dbgs() << "argpromotion not promoting argument '" << Arg->getName() << "' because it would require adding more " << "than " << MaxElements @@ -885,7 +885,7 @@ if (isSafeToPromote) { if (StructType *STy = dyn_cast(AgTy)) { if (MaxElements > 0 && STy->getNumElements() > MaxElements) { - DEBUG(dbgs() << "argpromotion disable promoting argument '" + LLVM_DEBUG(dbgs() << "argpromotion disable promoting argument '" << PtrArg->getName() << "' because it would require adding more" << " than " << MaxElements Index: lib/Transforms/IPO/BlockExtractor.cpp =================================================================== --- lib/Transforms/IPO/BlockExtractor.cpp +++ lib/Transforms/IPO/BlockExtractor.cpp @@ -147,7 +147,7 @@ // Check if the module contains BB. if (BB->getParent()->getParent() != &M) report_fatal_error("Invalid basic block"); - DEBUG(dbgs() << "BlockExtractor: Extracting " << BB->getParent()->getName() + LLVM_DEBUG(dbgs() << "BlockExtractor: Extracting " << BB->getParent()->getName() << ":" << BB->getName() << "\n"); SmallVector BlocksToExtractVec; BlocksToExtractVec.push_back(BB); @@ -161,7 +161,7 @@ // Erase the functions. if (EraseFunctions || BlockExtractorEraseFuncs) { for (Function *F : Functions) { - DEBUG(dbgs() << "BlockExtractor: Deleting " << F->getName() << "\n"); + LLVM_DEBUG(dbgs() << "BlockExtractor: Deleting " << F->getName() << "\n"); F->eraseFromParent(); } // Set linkage as ExternalLinkage to avoid erasing unreachable functions. Index: lib/Transforms/IPO/DeadArgumentElimination.cpp =================================================================== --- lib/Transforms/IPO/DeadArgumentElimination.cpp +++ lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -521,7 +521,7 @@ return; } - DEBUG(dbgs() << "DeadArgumentEliminationPass - Inspecting callers for fn: " + LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - Inspecting callers for fn: " << F.getName() << "\n"); // Keep track of the number of live retvals, so we can skip checks once all // of them turn out to be live. @@ -584,7 +584,7 @@ for (unsigned i = 0; i != RetCount; ++i) MarkValue(CreateRet(&F, i), RetValLiveness[i], MaybeLiveRetUses[i]); - DEBUG(dbgs() << "DeadArgumentEliminationPass - Inspecting args for fn: " + LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - Inspecting args for fn: " << F.getName() << "\n"); // Now, check all of our arguments. @@ -637,7 +637,7 @@ /// mark any values that are used as this function's parameters or by its return /// values (according to Uses) live as well. void DeadArgumentEliminationPass::MarkLive(const Function &F) { - DEBUG(dbgs() << "DeadArgumentEliminationPass - Intrinsically live fn: " + LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - Intrinsically live fn: " << F.getName() << "\n"); // Mark the function as live. LiveFunctions.insert(&F); @@ -659,7 +659,7 @@ if (!LiveValues.insert(RA).second) return; // We were already marked Live. - DEBUG(dbgs() << "DeadArgumentEliminationPass - Marking " + LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - Marking " << RA.getDescription() << " live\n"); PropagateLiveness(RA); } @@ -718,7 +718,7 @@ HasLiveReturnedArg |= PAL.hasParamAttribute(i, Attribute::Returned); } else { ++NumArgumentsEliminated; - DEBUG(dbgs() << "DeadArgumentEliminationPass - Removing argument " << i + LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - Removing argument " << i << " (" << I->getName() << ") from " << F->getName() << "\n"); } @@ -763,7 +763,7 @@ NewRetIdxs[i] = RetTypes.size() - 1; } else { ++NumRetValsEliminated; - DEBUG(dbgs() << "DeadArgumentEliminationPass - Removing return value " + LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - Removing return value " << i << " from " << F->getName() << "\n"); } } @@ -1034,7 +1034,7 @@ // removed. We can do this if they never call va_start. This loop cannot be // fused with the next loop, because deleting a function invalidates // information computed while surveying other functions. - DEBUG(dbgs() << "DeadArgumentEliminationPass - Deleting dead varargs\n"); + LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - Deleting dead varargs\n"); for (Module::iterator I = M.begin(), E = M.end(); I != E; ) { Function &F = *I++; if (F.getFunctionType()->isVarArg()) @@ -1045,7 +1045,7 @@ // We assume all arguments are dead unless proven otherwise (allowing us to // determine that dead arguments passed into recursive functions are dead). // - DEBUG(dbgs() << "DeadArgumentEliminationPass - Determining liveness\n"); + LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - Determining liveness\n"); for (auto &F : M) SurveyFunction(F); Index: lib/Transforms/IPO/ForceFunctionAttrs.cpp =================================================================== --- lib/Transforms/IPO/ForceFunctionAttrs.cpp +++ lib/Transforms/IPO/ForceFunctionAttrs.cpp @@ -72,7 +72,7 @@ auto Kind = parseAttrKind(KV.second); if (Kind == Attribute::None) { - DEBUG(dbgs() << "ForcedAttribute: " << KV.second + LLVM_DEBUG(dbgs() << "ForcedAttribute: " << KV.second << " unknown or not handled!\n"); continue; } Index: lib/Transforms/IPO/FunctionAttrs.cpp =================================================================== --- lib/Transforms/IPO/FunctionAttrs.cpp +++ lib/Transforms/IPO/FunctionAttrs.cpp @@ -1008,7 +1008,7 @@ if (!Speculative) { // Mark the function eagerly since we may discover a function // which prevents us from speculating about the entire SCC - DEBUG(dbgs() << "Eagerly marking " << F->getName() << " as nonnull\n"); + LLVM_DEBUG(dbgs() << "Eagerly marking " << F->getName() << " as nonnull\n"); F->addAttribute(AttributeList::ReturnIndex, Attribute::NonNull); ++NumNonNullReturn; MadeChange = true; @@ -1027,7 +1027,7 @@ !F->getReturnType()->isPointerTy()) continue; - DEBUG(dbgs() << "SCC marking " << F->getName() << " as nonnull\n"); + LLVM_DEBUG(dbgs() << "SCC marking " << F->getName() << " as nonnull\n"); F->addAttribute(AttributeList::ReturnIndex, Attribute::NonNull); ++NumNonNullReturn; MadeChange = true; @@ -1073,7 +1073,7 @@ for (Function *F : SCCNodes) { if (!F->isConvergent()) continue; - DEBUG(dbgs() << "Removing convergent attr from fn " << F->getName() + LLVM_DEBUG(dbgs() << "Removing convergent attr from fn " << F->getName() << "\n"); F->setNotConvergent(); } Index: lib/Transforms/IPO/FunctionImport.cpp =================================================================== --- lib/Transforms/IPO/FunctionImport.cpp +++ lib/Transforms/IPO/FunctionImport.cpp @@ -132,7 +132,7 @@ static std::unique_ptr loadFile(const std::string &FileName, LLVMContext &Context) { SMDiagnostic Err; - DEBUG(dbgs() << "Loading '" << FileName << "'\n"); + LLVM_DEBUG(dbgs() << "Loading '" << FileName << "'\n"); // Metadata isn't loaded until functions are imported, to minimize // the memory overhead. std::unique_ptr Result = @@ -245,11 +245,11 @@ StringMap *ExportLists) { for (auto &VI : Summary.refs()) { if (DefinedGVSummaries.count(VI.getGUID())) { - DEBUG(dbgs() << "Ref ignored! Target already in destination module.\n"); + LLVM_DEBUG(dbgs() << "Ref ignored! Target already in destination module.\n"); continue; } - DEBUG(dbgs() << " ref -> " << VI.getGUID() << "\n"); + LLVM_DEBUG(dbgs() << " ref -> " << VI.getGUID() << "\n"); for (auto &RefSummary : VI.getSummaryList()) if (RefSummary->getSummaryKind() == GlobalValueSummary::GlobalVarKind && @@ -279,7 +279,7 @@ ExportLists); for (auto &Edge : Summary.calls()) { ValueInfo VI = Edge.first; - DEBUG(dbgs() << " edge -> " << VI.getGUID() << " Threshold:" << Threshold + LLVM_DEBUG(dbgs() << " edge -> " << VI.getGUID() << " Threshold:" << Threshold << "\n"); VI = updateValueInfoForIndirectCalls(Index, VI); @@ -287,7 +287,7 @@ continue; if (DefinedGVSummaries.count(VI.getGUID())) { - DEBUG(dbgs() << "ignored! Target already in destination module.\n"); + LLVM_DEBUG(dbgs() << "ignored! Target already in destination module.\n"); continue; } @@ -307,7 +307,7 @@ auto *CalleeSummary = selectCallee(Index, VI.getSummaryList(), NewThreshold, Summary.modulePath()); if (!CalleeSummary) { - DEBUG(dbgs() << "ignored! No qualifying callee with summary found.\n"); + LLVM_DEBUG(dbgs() << "ignored! No qualifying callee with summary found.\n"); continue; } @@ -336,7 +336,7 @@ /// a second time with a higher threshold. In this case, it is added back to /// the worklist with the new threshold. if (ProcessedThreshold && ProcessedThreshold >= AdjThreshold) { - DEBUG(dbgs() << "ignored! Target was already seen with Threshold " + LLVM_DEBUG(dbgs() << "ignored! Target was already seen with Threshold " << ProcessedThreshold << "\n"); continue; } @@ -386,7 +386,7 @@ // module for (auto &GVSummary : DefinedGVSummaries) { if (!Index.isGlobalValueLive(GVSummary.second)) { - DEBUG(dbgs() << "Ignores Dead GUID: " << GVSummary.first << "\n"); + LLVM_DEBUG(dbgs() << "Ignores Dead GUID: " << GVSummary.first << "\n"); continue; } auto *FuncSummary = @@ -394,7 +394,7 @@ if (!FuncSummary) // Skip import for global variables continue; - DEBUG(dbgs() << "Initialize import for " << GVSummary.first << "\n"); + LLVM_DEBUG(dbgs() << "Initialize import for " << GVSummary.first << "\n"); computeImportForFunction(*FuncSummary, Index, ImportInstrLimit, DefinedGVSummaries, Worklist, ImportList, ExportLists); @@ -456,7 +456,7 @@ // For each module that has function defined, compute the import/export lists. for (auto &DefinedGVSummaries : ModuleToDefinedGVSummaries) { auto &ImportList = ImportLists[DefinedGVSummaries.first()]; - DEBUG(dbgs() << "Computing import for Module '" + LLVM_DEBUG(dbgs() << "Computing import for Module '" << DefinedGVSummaries.first() << "'\n"); ComputeImportForModule(DefinedGVSummaries.second, Index, ImportList, &ExportLists); @@ -479,22 +479,22 @@ } #ifndef NDEBUG - DEBUG(dbgs() << "Import/Export lists for " << ImportLists.size() + LLVM_DEBUG(dbgs() << "Import/Export lists for " << ImportLists.size() << " modules:\n"); for (auto &ModuleImports : ImportLists) { auto ModName = ModuleImports.first(); auto &Exports = ExportLists[ModName]; unsigned NumGVS = numGlobalVarSummaries(Index, Exports); - DEBUG(dbgs() << "* Module " << ModName << " exports " + LLVM_DEBUG(dbgs() << "* Module " << ModName << " exports " << Exports.size() - NumGVS << " functions and " << NumGVS << " vars. Imports from " << ModuleImports.second.size() << " modules.\n"); for (auto &Src : ModuleImports.second) { auto SrcModName = Src.first(); unsigned NumGVSPerMod = numGlobalVarSummaries(Index, Src.second); - DEBUG(dbgs() << " - " << Src.second.size() - NumGVSPerMod + LLVM_DEBUG(dbgs() << " - " << Src.second.size() - NumGVSPerMod << " functions imported from " << SrcModName << "\n"); - DEBUG(dbgs() << " - " << NumGVSPerMod << " global vars imported from " + LLVM_DEBUG(dbgs() << " - " << NumGVSPerMod << " global vars imported from " << SrcModName << "\n"); } } @@ -505,14 +505,14 @@ static void dumpImportListForModule(const ModuleSummaryIndex &Index, StringRef ModulePath, FunctionImporter::ImportMapTy &ImportList) { - DEBUG(dbgs() << "* Module " << ModulePath << " imports from " + LLVM_DEBUG(dbgs() << "* Module " << ModulePath << " imports from " << ImportList.size() << " modules.\n"); for (auto &Src : ImportList) { auto SrcModName = Src.first(); unsigned NumGVSPerMod = numGlobalVarSummaries(Index, Src.second); - DEBUG(dbgs() << " - " << Src.second.size() - NumGVSPerMod + LLVM_DEBUG(dbgs() << " - " << Src.second.size() - NumGVSPerMod << " functions imported from " << SrcModName << "\n"); - DEBUG(dbgs() << " - " << NumGVSPerMod << " vars imported from " + LLVM_DEBUG(dbgs() << " - " << NumGVSPerMod << " vars imported from " << SrcModName << "\n"); } } @@ -528,7 +528,7 @@ Index.collectDefinedFunctionsForModule(ModulePath, FunctionSummaryMap); // Compute the import list for this module. - DEBUG(dbgs() << "Computing import for Module '" << ModulePath << "'\n"); + LLVM_DEBUG(dbgs() << "Computing import for Module '" << ModulePath << "'\n"); ComputeImportForModule(FunctionSummaryMap, Index, ImportList); #ifndef NDEBUG @@ -588,7 +588,7 @@ for (const auto &Entry : Index) for (auto &S : Entry.second.SummaryList) if (S->isLive()) { - DEBUG(dbgs() << "Live root: " << Entry.first << "\n"); + LLVM_DEBUG(dbgs() << "Live root: " << Entry.first << "\n"); Worklist.push_back(ValueInfo(/*IsAnalysis=*/false, &Entry)); ++LiveSymbols; break; @@ -637,7 +637,7 @@ Index.setWithGlobalValueDeadStripping(); unsigned DeadSymbols = Index.size() - LiveSymbols; - DEBUG(dbgs() << LiveSymbols << " symbols Live, and " << DeadSymbols + LLVM_DEBUG(dbgs() << LiveSymbols << " symbols Live, and " << DeadSymbols << " symbols Dead \n"); NumDeadSymbols += DeadSymbols; NumLiveSymbols += LiveSymbols; @@ -681,7 +681,7 @@ } bool llvm::convertToDeclaration(GlobalValue &GV) { - DEBUG(dbgs() << "Converting to a declaration: `" << GV.getName() << "\n"); + LLVM_DEBUG(dbgs() << "Converting to a declaration: `" << GV.getName() << "\n"); if (Function *F = dyn_cast(&GV)) { F->deleteBody(); F->clearMetadata(); @@ -757,7 +757,7 @@ NewLinkage == GlobalValue::WeakODRLinkage) GV.setVisibility(GlobalValue::HiddenVisibility); - DEBUG(dbgs() << "ODR fixing up linkage for `" << GV.getName() << "` from " + LLVM_DEBUG(dbgs() << "ODR fixing up linkage for `" << GV.getName() << "` from " << GV.getLinkage() << " to " << NewLinkage << "\n"); GV.setLinkage(NewLinkage); } @@ -835,7 +835,7 @@ // index. Expected FunctionImporter::importFunctions( Module &DestModule, const FunctionImporter::ImportMapTy &ImportList) { - DEBUG(dbgs() << "Starting import for Module " + LLVM_DEBUG(dbgs() << "Starting import for Module " << DestModule.getModuleIdentifier() << "\n"); unsigned ImportedCount = 0, ImportedGVCount = 0; @@ -869,7 +869,7 @@ continue; auto GUID = F.getGUID(); auto Import = ImportGUIDs.count(GUID); - DEBUG(dbgs() << (Import ? "Is" : "Not") << " importing function " << GUID + LLVM_DEBUG(dbgs() << (Import ? "Is" : "Not") << " importing function " << GUID << " " << F.getName() << " from " << SrcModule->getSourceFileName() << "\n"); if (Import) { @@ -891,7 +891,7 @@ continue; auto GUID = GV.getGUID(); auto Import = ImportGUIDs.count(GUID); - DEBUG(dbgs() << (Import ? "Is" : "Not") << " importing global " << GUID + LLVM_DEBUG(dbgs() << (Import ? "Is" : "Not") << " importing global " << GUID << " " << GV.getName() << " from " << SrcModule->getSourceFileName() << "\n"); if (Import) { @@ -905,7 +905,7 @@ continue; auto GUID = GA.getGUID(); auto Import = ImportGUIDs.count(GUID); - DEBUG(dbgs() << (Import ? "Is" : "Not") << " importing alias " << GUID + LLVM_DEBUG(dbgs() << (Import ? "Is" : "Not") << " importing alias " << GUID << " " << GA.getName() << " from " << SrcModule->getSourceFileName() << "\n"); if (Import) { @@ -916,7 +916,7 @@ if (Error Err = Base->materialize()) return std::move(Err); auto *Fn = replaceAliasWithAliasee(SrcModule.get(), &GA); - DEBUG(dbgs() << "Is importing aliasee fn " << Base->getGUID() + LLVM_DEBUG(dbgs() << "Is importing aliasee fn " << Base->getGUID() << " " << Base->getName() << " from " << SrcModule->getSourceFileName() << "\n"); if (EnableImportMetadata) { @@ -957,10 +957,10 @@ NumImportedFunctions += (ImportedCount - ImportedGVCount); NumImportedGlobalVars += ImportedGVCount; - DEBUG(dbgs() << "Imported " << ImportedCount - ImportedGVCount + LLVM_DEBUG(dbgs() << "Imported " << ImportedCount - ImportedGVCount << " functions for Module " << DestModule.getModuleIdentifier() << "\n"); - DEBUG(dbgs() << "Imported " << ImportedGVCount + LLVM_DEBUG(dbgs() << "Imported " << ImportedGVCount << " global variables for Module " << DestModule.getModuleIdentifier() << "\n"); return ImportedCount; Index: lib/Transforms/IPO/GlobalOpt.cpp =================================================================== --- lib/Transforms/IPO/GlobalOpt.cpp +++ lib/Transforms/IPO/GlobalOpt.cpp @@ -567,7 +567,7 @@ if (NewGlobals.empty()) return nullptr; - DEBUG(dbgs() << "PERFORMING GLOBAL SRA ON: " << *GV << "\n"); + LLVM_DEBUG(dbgs() << "PERFORMING GLOBAL SRA ON: " << *GV << "\n"); Constant *NullInt =Constant::getNullValue(Type::getInt32Ty(GV->getContext())); @@ -799,7 +799,7 @@ } if (Changed) { - DEBUG(dbgs() << "OPTIMIZED LOADS FROM STORED ONCE POINTER: " << *GV << "\n"); + LLVM_DEBUG(dbgs() << "OPTIMIZED LOADS FROM STORED ONCE POINTER: " << *GV << "\n"); ++NumGlobUses; } @@ -813,7 +813,7 @@ CleanupConstantGlobalUsers(GV, nullptr, DL, TLI); } if (GV->use_empty()) { - DEBUG(dbgs() << " *** GLOBAL NOW DEAD!\n"); + LLVM_DEBUG(dbgs() << " *** GLOBAL NOW DEAD!\n"); Changed = true; GV->eraseFromParent(); ++NumDeleted; @@ -849,7 +849,7 @@ OptimizeGlobalAddressOfMalloc(GlobalVariable *GV, CallInst *CI, Type *AllocTy, ConstantInt *NElements, const DataLayout &DL, TargetLibraryInfo *TLI) { - DEBUG(errs() << "PROMOTING GLOBAL: " << *GV << " CALL = " << *CI << '\n'); + LLVM_DEBUG(errs() << "PROMOTING GLOBAL: " << *GV << " CALL = " << *CI << '\n'); Type *GlobalType; if (NElements->getZExtValue() == 1) @@ -1285,7 +1285,7 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, CallInst *CI, Value *NElems, const DataLayout &DL, const TargetLibraryInfo *TLI) { - DEBUG(dbgs() << "SROA HEAP ALLOC: " << *GV << " MALLOC = " << *CI << '\n'); + LLVM_DEBUG(dbgs() << "SROA HEAP ALLOC: " << *GV << " MALLOC = " << *CI << '\n'); Type *MAT = getMallocAllocatedType(CI, TLI); StructType *STy = cast(MAT); @@ -1624,7 +1624,7 @@ if (!isa(U) && !isa(U)) return false; - DEBUG(dbgs() << " *** SHRINKING TO BOOL: " << *GV << "\n"); + LLVM_DEBUG(dbgs() << " *** SHRINKING TO BOOL: " << *GV << "\n"); // Create the new global, initializing it to false. GlobalVariable *NewGV = new GlobalVariable(Type::getInt1Ty(GV->getContext()), @@ -1767,7 +1767,7 @@ if (!Dead) return false; - DEBUG(dbgs() << "GLOBAL DEAD: " << GV << "\n"); + LLVM_DEBUG(dbgs() << "GLOBAL DEAD: " << GV << "\n"); GV.eraseFromParent(); ++NumDeleted; return true; @@ -1933,7 +1933,7 @@ LookupDomTree)) { const DataLayout &DL = GV->getParent()->getDataLayout(); - DEBUG(dbgs() << "LOCALIZING GLOBAL: " << *GV << "\n"); + LLVM_DEBUG(dbgs() << "LOCALIZING GLOBAL: " << *GV << "\n"); Instruction &FirstI = const_cast(*GS.AccessingFunction ->getEntryBlock().begin()); Type *ElemTy = GV->getValueType(); @@ -1954,7 +1954,7 @@ // If the global is never loaded (but may be stored to), it is dead. // Delete it now. if (!GS.IsLoaded) { - DEBUG(dbgs() << "GLOBAL NEVER LOADED: " << *GV << "\n"); + LLVM_DEBUG(dbgs() << "GLOBAL NEVER LOADED: " << *GV << "\n"); bool Changed; if (isLeakCheckerRoot(GV)) { @@ -1976,7 +1976,7 @@ } if (GS.StoredType <= GlobalStatus::InitializerStored) { - DEBUG(dbgs() << "MARKING CONSTANT: " << *GV << "\n"); + LLVM_DEBUG(dbgs() << "MARKING CONSTANT: " << *GV << "\n"); GV->setConstant(true); // Clean up any obviously simplifiable users now. @@ -1984,7 +1984,7 @@ // If the global is dead now, just nuke it. if (GV->use_empty()) { - DEBUG(dbgs() << " *** Marking constant allowed us to simplify " + LLVM_DEBUG(dbgs() << " *** Marking constant allowed us to simplify " << "all users and delete global!\n"); GV->eraseFromParent(); ++NumDeleted; @@ -2013,7 +2013,7 @@ CleanupConstantGlobalUsers(GV, GV->getInitializer(), DL, TLI); if (GV->use_empty()) { - DEBUG(dbgs() << " *** Substituting initializer allowed us to " + LLVM_DEBUG(dbgs() << " *** Substituting initializer allowed us to " << "simplify all users and delete global!\n"); GV->eraseFromParent(); ++NumDeleted; @@ -2521,7 +2521,7 @@ ++NumCtorsEvaluated; // We succeeded at evaluation: commit the result. - DEBUG(dbgs() << "FULLY EVALUATED GLOBAL CTOR FUNCTION '" + LLVM_DEBUG(dbgs() << "FULLY EVALUATED GLOBAL CTOR FUNCTION '" << F->getName() << "' to " << Eval.getMutatedMemory().size() << " stores.\n"); BatchCommitValueTo(Eval.getMutatedMemory()); Index: lib/Transforms/IPO/Inliner.cpp =================================================================== --- lib/Transforms/IPO/Inliner.cpp +++ lib/Transforms/IPO/Inliner.cpp @@ -208,7 +208,7 @@ // Otherwise, we *can* reuse it, RAUW AI into AvailableAlloca and declare // success! - DEBUG(dbgs() << " ***MERGED ALLOCA: " << *AI + LLVM_DEBUG(dbgs() << " ***MERGED ALLOCA: " << *AI << "\n\t\tINTO: " << *AvailableAlloca << '\n'); // Move affected dbg.declare calls immediately after the new alloca to @@ -379,13 +379,13 @@ Function *Caller = CS.getCaller(); if (IC.isAlways()) { - DEBUG(dbgs() << " Inlining: cost=always" + LLVM_DEBUG(dbgs() << " Inlining: cost=always" << ", Call: " << *CS.getInstruction() << "\n"); return IC; } if (IC.isNever()) { - DEBUG(dbgs() << " NOT Inlining: cost=never" + LLVM_DEBUG(dbgs() << " NOT Inlining: cost=never" << ", Call: " << *CS.getInstruction() << "\n"); ORE.emit([&]() { return OptimizationRemarkMissed(DEBUG_TYPE, "NeverInline", Call) @@ -397,7 +397,7 @@ } if (!IC) { - DEBUG(dbgs() << " NOT Inlining: cost=" << IC.getCost() + LLVM_DEBUG(dbgs() << " NOT Inlining: cost=" << IC.getCost() << ", thres=" << IC.getThreshold() << ", Call: " << *CS.getInstruction() << "\n"); ORE.emit([&]() { @@ -412,7 +412,7 @@ int TotalSecondaryCost = 0; if (shouldBeDeferred(Caller, CS, IC, TotalSecondaryCost, GetInlineCost)) { - DEBUG(dbgs() << " NOT Inlining: " << *CS.getInstruction() + LLVM_DEBUG(dbgs() << " NOT Inlining: " << *CS.getInstruction() << " Cost = " << IC.getCost() << ", outer Cost = " << TotalSecondaryCost << '\n'); ORE.emit([&]() { @@ -428,7 +428,7 @@ return None; } - DEBUG(dbgs() << " Inlining: cost=" << IC.getCost() + LLVM_DEBUG(dbgs() << " Inlining: cost=" << IC.getCost() << ", thres=" << IC.getThreshold() << ", Call: " << *CS.getInstruction() << '\n'); return IC; @@ -470,12 +470,12 @@ function_ref AARGetter, ImportedFunctionsInliningStatistics &ImportedFunctionsStats) { SmallPtrSet SCCFunctions; - DEBUG(dbgs() << "Inliner visiting SCC:"); + LLVM_DEBUG(dbgs() << "Inliner visiting SCC:"); for (CallGraphNode *Node : SCC) { Function *F = Node->getFunction(); if (F) SCCFunctions.insert(F); - DEBUG(dbgs() << " " << (F ? F->getName() : "INDIRECTNODE")); + LLVM_DEBUG(dbgs() << " " << (F ? F->getName() : "INDIRECTNODE")); } // Scan through and identify all call sites ahead of time so that we only @@ -524,7 +524,7 @@ } } - DEBUG(dbgs() << ": " << CallSites.size() << " call sites.\n"); + LLVM_DEBUG(dbgs() << ": " << CallSites.size() << " call sites.\n"); // If there are no calls in this function, exit early. if (CallSites.empty()) @@ -593,7 +593,7 @@ // size. This happens because IPSCCP propagates the result out of the // call and then we're left with the dead call. if (IsTriviallyDead) { - DEBUG(dbgs() << " -> Deleting dead call: " << *Instr << "\n"); + LLVM_DEBUG(dbgs() << " -> Deleting dead call: " << *Instr << "\n"); // Update the call graph by deleting the edge from Callee to Caller. CG[Caller]->removeCallEdgeFor(CS); Instr->eraseFromParent(); @@ -657,7 +657,7 @@ // callgraph references to the node, we cannot delete it yet, this // could invalidate the CGSCC iterator. CG[Callee]->getNumReferences() == 0) { - DEBUG(dbgs() << " -> Deleting dead function: " << Callee->getName() + LLVM_DEBUG(dbgs() << " -> Deleting dead function: " << Callee->getName() << "\n"); CallGraphNode *CalleeNode = CG[Callee]; @@ -879,7 +879,7 @@ if (F.hasFnAttribute(Attribute::OptimizeNone)) continue; - DEBUG(dbgs() << "Inlining calls in: " << F.getName() << "\n"); + LLVM_DEBUG(dbgs() << "Inlining calls in: " << F.getName() << "\n"); // Get a FunctionAnalysisManager via a proxy for this particular node. We // do this each time we visit a node as the SCC may have changed and as @@ -931,7 +931,7 @@ // and thus hidden from the full inline history. if (CG.lookupSCC(*CG.lookup(Callee)) == C && UR.InlinedInternalEdges.count({&N, C})) { - DEBUG(dbgs() << "Skipping inlining internal SCC edge from a node " + LLVM_DEBUG(dbgs() << "Skipping inlining internal SCC edge from a node " "previously split out of this SCC by inlining: " << F.getName() << " -> " << Callee.getName() << "\n"); continue; @@ -1052,7 +1052,7 @@ // change. LazyCallGraph::SCC *OldC = C; C = &updateCGAndAnalysisManagerForFunctionPass(CG, *C, N, AM, UR); - DEBUG(dbgs() << "Updated inlining SCC: " << *C << "\n"); + LLVM_DEBUG(dbgs() << "Updated inlining SCC: " << *C << "\n"); RC = &C->getOuterRefSCC(); // If this causes an SCC to split apart into multiple smaller SCCs, there @@ -1070,7 +1070,7 @@ if (C != OldC && llvm::any_of(InlinedCallees, [&](Function *Callee) { return CG.lookupSCC(*CG.lookup(*Callee)) == OldC; })) { - DEBUG(dbgs() << "Inlined an internal call edge and split an SCC, " + LLVM_DEBUG(dbgs() << "Inlined an internal call edge and split an SCC, " "retaining this to avoid infinite inlining.\n"); UR.InlinedInternalEdges.insert({&N, OldC}); } Index: lib/Transforms/IPO/Internalize.cpp =================================================================== --- lib/Transforms/IPO/Internalize.cpp +++ lib/Transforms/IPO/Internalize.cpp @@ -192,7 +192,7 @@ ExternalNode->removeOneAbstractEdgeTo((*CG)[&I]); ++NumFunctions; - DEBUG(dbgs() << "Internalizing func " << I.getName() << "\n"); + LLVM_DEBUG(dbgs() << "Internalizing func " << I.getName() << "\n"); } // Never internalize the llvm.used symbol. It is used to implement @@ -221,7 +221,7 @@ Changed = true; ++NumGlobals; - DEBUG(dbgs() << "Internalized gvar " << GV.getName() << "\n"); + LLVM_DEBUG(dbgs() << "Internalized gvar " << GV.getName() << "\n"); } // Mark all aliases that are not in the api as internal as well. @@ -231,7 +231,7 @@ Changed = true; ++NumAliases; - DEBUG(dbgs() << "Internalized alias " << GA.getName() << "\n"); + LLVM_DEBUG(dbgs() << "Internalized alias " << GA.getName() << "\n"); } return Changed; Index: lib/Transforms/IPO/LowerTypeTests.cpp =================================================================== --- lib/Transforms/IPO/LowerTypeTests.cpp +++ lib/Transforms/IPO/LowerTypeTests.cpp @@ -995,7 +995,7 @@ for (Metadata *TypeId : TypeIds) { // Build the bitset. BitSetInfo BSI = buildBitSet(TypeId, GlobalLayout); - DEBUG({ + LLVM_DEBUG({ if (auto MDS = dyn_cast(TypeId)) dbgs() << MDS->getString() << ": "; else Index: lib/Transforms/IPO/MergeFunctions.cpp =================================================================== --- lib/Transforms/IPO/MergeFunctions.cpp +++ lib/Transforms/IPO/MergeFunctions.cpp @@ -407,10 +407,10 @@ std::vector Worklist; Deferred.swap(Worklist); - DEBUG(doSanityCheck(Worklist)); + LLVM_DEBUG(doSanityCheck(Worklist)); - DEBUG(dbgs() << "size of module: " << M.size() << '\n'); - DEBUG(dbgs() << "size of worklist: " << Worklist.size() << '\n'); + LLVM_DEBUG(dbgs() << "size of module: " << M.size() << '\n'); + LLVM_DEBUG(dbgs() << "size of worklist: " << Worklist.size() << '\n'); // Insert functions and merge them. for (WeakTrackingVH &I : Worklist) { @@ -421,7 +421,7 @@ Changed |= insert(F); } } - DEBUG(dbgs() << "size of FnTree: " << FnTree.size() << '\n'); + LLVM_DEBUG(dbgs() << "size of FnTree: " << FnTree.size() << '\n'); } while (!Deferred.empty()); FnTree.clear(); @@ -498,18 +498,18 @@ // parameter debug info, from the entry block. void MergeFunctions::eraseInstsUnrelatedToPDI( std::vector &PDIUnrelatedWL) { - DEBUG(dbgs() << " Erasing instructions (in reverse order of appearance in " + LLVM_DEBUG(dbgs() << " Erasing instructions (in reverse order of appearance in " "entry block) unrelated to parameter debug info from entry " "block: {\n"); while (!PDIUnrelatedWL.empty()) { Instruction *I = PDIUnrelatedWL.back(); - DEBUG(dbgs() << " Deleting Instruction: "); - DEBUG(I->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " Deleting Instruction: "); + LLVM_DEBUG(I->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); I->eraseFromParent(); PDIUnrelatedWL.pop_back(); } - DEBUG(dbgs() << " } // Done erasing instructions unrelated to parameter " + LLVM_DEBUG(dbgs() << " } // Done erasing instructions unrelated to parameter " "debug info from entry block. \n"); } @@ -543,99 +543,99 @@ for (BasicBlock::iterator BI = GEntryBlock->begin(), BIE = GEntryBlock->end(); BI != BIE; ++BI) { if (auto *DVI = dyn_cast(&*BI)) { - DEBUG(dbgs() << " Deciding: "); - DEBUG(BI->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " Deciding: "); + LLVM_DEBUG(BI->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); DILocalVariable *DILocVar = DVI->getVariable(); if (DILocVar->isParameter()) { - DEBUG(dbgs() << " Include (parameter): "); - DEBUG(BI->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " Include (parameter): "); + LLVM_DEBUG(BI->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); PDIRelated.insert(&*BI); } else { - DEBUG(dbgs() << " Delete (!parameter): "); - DEBUG(BI->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " Delete (!parameter): "); + LLVM_DEBUG(BI->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); } } else if (auto *DDI = dyn_cast(&*BI)) { - DEBUG(dbgs() << " Deciding: "); - DEBUG(BI->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " Deciding: "); + LLVM_DEBUG(BI->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); DILocalVariable *DILocVar = DDI->getVariable(); if (DILocVar->isParameter()) { - DEBUG(dbgs() << " Parameter: "); - DEBUG(DILocVar->print(dbgs())); + LLVM_DEBUG(dbgs() << " Parameter: "); + LLVM_DEBUG(DILocVar->print(dbgs())); AllocaInst *AI = dyn_cast_or_null(DDI->getAddress()); if (AI) { - DEBUG(dbgs() << " Processing alloca users: "); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " Processing alloca users: "); + LLVM_DEBUG(dbgs() << "\n"); for (User *U : AI->users()) { if (StoreInst *SI = dyn_cast(U)) { if (Value *Arg = SI->getValueOperand()) { if (dyn_cast(Arg)) { - DEBUG(dbgs() << " Include: "); - DEBUG(AI->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " Include: "); + LLVM_DEBUG(AI->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); PDIRelated.insert(AI); - DEBUG(dbgs() << " Include (parameter): "); - DEBUG(SI->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " Include (parameter): "); + LLVM_DEBUG(SI->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); PDIRelated.insert(SI); - DEBUG(dbgs() << " Include: "); - DEBUG(BI->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " Include: "); + LLVM_DEBUG(BI->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); PDIRelated.insert(&*BI); } else { - DEBUG(dbgs() << " Delete (!parameter): "); - DEBUG(SI->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " Delete (!parameter): "); + LLVM_DEBUG(SI->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); } } } else { - DEBUG(dbgs() << " Defer: "); - DEBUG(U->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " Defer: "); + LLVM_DEBUG(U->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); } } } else { - DEBUG(dbgs() << " Delete (alloca NULL): "); - DEBUG(BI->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " Delete (alloca NULL): "); + LLVM_DEBUG(BI->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); } } else { - DEBUG(dbgs() << " Delete (!parameter): "); - DEBUG(BI->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " Delete (!parameter): "); + LLVM_DEBUG(BI->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); } } else if (dyn_cast(BI) == GEntryBlock->getTerminator()) { - DEBUG(dbgs() << " Will Include Terminator: "); - DEBUG(BI->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " Will Include Terminator: "); + LLVM_DEBUG(BI->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); PDIRelated.insert(&*BI); } else { - DEBUG(dbgs() << " Defer: "); - DEBUG(BI->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " Defer: "); + LLVM_DEBUG(BI->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); } } - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << " Report parameter debug info related/related instructions: {\n"); for (BasicBlock::iterator BI = GEntryBlock->begin(), BE = GEntryBlock->end(); BI != BE; ++BI) { Instruction *I = &*BI; if (PDIRelated.find(I) == PDIRelated.end()) { - DEBUG(dbgs() << " !PDIRelated: "); - DEBUG(I->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " !PDIRelated: "); + LLVM_DEBUG(I->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); PDIUnrelatedWL.push_back(I); } else { - DEBUG(dbgs() << " PDIRelated: "); - DEBUG(I->print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " PDIRelated: "); + LLVM_DEBUG(I->print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); } } - DEBUG(dbgs() << " }\n"); + LLVM_DEBUG(dbgs() << " }\n"); } // Replace G with a simple tail call to bitcast(F). Also (unless @@ -674,7 +674,7 @@ // making the function larger. if (F->size() == 1) { if (F->front().size() <= 2) { - DEBUG(dbgs() << "writeThunk: " << F->getName() + LLVM_DEBUG(dbgs() << "writeThunk: " << F->getName() << " is too small to bother creating a thunk for\n"); return; } @@ -685,11 +685,11 @@ BasicBlock *BB = nullptr; Function *NewG = nullptr; if (MergeFunctionsPDI) { - DEBUG(dbgs() << "writeThunk: (MergeFunctionsPDI) Do not create a new " + LLVM_DEBUG(dbgs() << "writeThunk: (MergeFunctionsPDI) Do not create a new " "function as thunk; retain original: " << G->getName() << "()\n"); GEntryBlock = &G->getEntryBlock(); - DEBUG(dbgs() << "writeThunk: (MergeFunctionsPDI) filter parameter related " + LLVM_DEBUG(dbgs() << "writeThunk: (MergeFunctionsPDI) filter parameter related " "debug info for " << G->getName() << "() {\n"); filterInstsUnrelatedToPDI(GEntryBlock, PDIUnrelatedWL); @@ -730,12 +730,12 @@ CI->setDebugLoc(CIDbgLoc); RI->setDebugLoc(RIDbgLoc); } else { - DEBUG(dbgs() << "writeThunk: (MergeFunctionsPDI) No DISubprogram for " + LLVM_DEBUG(dbgs() << "writeThunk: (MergeFunctionsPDI) No DISubprogram for " << G->getName() << "()\n"); } eraseTail(G); eraseInstsUnrelatedToPDI(PDIUnrelatedWL); - DEBUG(dbgs() << "} // End of parameter related debug info filtering for: " + LLVM_DEBUG(dbgs() << "} // End of parameter related debug info filtering for: " << G->getName() << "()\n"); } else { NewG->copyAttributesFrom(G); @@ -745,7 +745,7 @@ G->eraseFromParent(); } - DEBUG(dbgs() << "writeThunk: " << H->getName() << '\n'); + LLVM_DEBUG(dbgs() << "writeThunk: " << H->getName() << '\n'); ++NumThunksWritten; } @@ -806,7 +806,7 @@ if (Result.second) { assert(FNodesInTree.count(NewFunction) == 0); FNodesInTree.insert({NewFunction, Result.first}); - DEBUG(dbgs() << "Inserting as unique: " << NewFunction->getName() << '\n'); + LLVM_DEBUG(dbgs() << "Inserting as unique: " << NewFunction->getName() << '\n'); return false; } @@ -827,7 +827,7 @@ assert(OldF.getFunc() != F && "Must have swapped the functions."); } - DEBUG(dbgs() << " " << OldF.getFunc()->getName() + LLVM_DEBUG(dbgs() << " " << OldF.getFunc()->getName() << " == " << NewFunction->getName() << '\n'); Function *DeleteF = NewFunction; @@ -840,7 +840,7 @@ void MergeFunctions::remove(Function *F) { auto I = FNodesInTree.find(F); if (I != FNodesInTree.end()) { - DEBUG(dbgs() << "Deferred " << F->getName()<< ".\n"); + LLVM_DEBUG(dbgs() << "Deferred " << F->getName()<< ".\n"); FnTree.erase(I->second); // I->second has been invalidated, remove it from the FNodesInTree map to // preserve the invariant. Index: lib/Transforms/IPO/SampleProfile.cpp =================================================================== --- lib/Transforms/IPO/SampleProfile.cpp +++ lib/Transforms/IPO/SampleProfile.cpp @@ -569,7 +569,7 @@ return Remark; }); } - DEBUG(dbgs() << " " << DLoc.getLine() << "." + LLVM_DEBUG(dbgs() << " " << DLoc.getLine() << "." << DIL->getBaseDiscriminator() << ":" << Inst << " (line offset: " << LineOffset << "." << DIL->getBaseDiscriminator() << " - weight: " << R.get() @@ -607,7 +607,7 @@ /// \param F The function to query. bool SampleProfileLoader::computeBlockWeights(Function &F) { bool Changed = false; - DEBUG(dbgs() << "Block weights\n"); + LLVM_DEBUG(dbgs() << "Block weights\n"); for (const auto &BB : F) { ErrorOr Weight = getBlockWeight(&BB); if (Weight) { @@ -615,7 +615,7 @@ VisitedBlocks.insert(&BB); Changed = true; } - DEBUG(printBlockWeight(dbgs(), &BB)); + LLVM_DEBUG(printBlockWeight(dbgs(), &BB)); } return Changed; @@ -836,7 +836,7 @@ inlineCallInstruction(DI)) LocalChanged = true; } else { - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "\nFailed to promote indirect call to " << CalleeFunctionName << " because " << Reason << "\n"); } @@ -928,14 +928,14 @@ /// \param F The function to query. void SampleProfileLoader::findEquivalenceClasses(Function &F) { SmallVector DominatedBBs; - DEBUG(dbgs() << "\nBlock equivalence classes\n"); + LLVM_DEBUG(dbgs() << "\nBlock equivalence classes\n"); // Find equivalence sets based on dominance and post-dominance information. for (auto &BB : F) { BasicBlock *BB1 = &BB; // Compute BB1's equivalence class once. if (EquivalenceClass.count(BB1)) { - DEBUG(printBlockEquivalence(dbgs(), BB1)); + LLVM_DEBUG(printBlockEquivalence(dbgs(), BB1)); continue; } @@ -956,7 +956,7 @@ DT->getDescendants(BB1, DominatedBBs); findEquivalencesFor(BB1, DominatedBBs, PDT.get()); - DEBUG(printBlockEquivalence(dbgs(), BB1)); + LLVM_DEBUG(printBlockEquivalence(dbgs(), BB1)); } // Assign weights to equivalence classes. @@ -965,13 +965,13 @@ // the same number of times. Since we know that the head block in // each equivalence class has the largest weight, assign that weight // to all the blocks in that equivalence class. - DEBUG(dbgs() << "\nAssign the same weight to all blocks in the same class\n"); + LLVM_DEBUG(dbgs() << "\nAssign the same weight to all blocks in the same class\n"); for (auto &BI : F) { const BasicBlock *BB = &BI; const BasicBlock *EquivBB = EquivalenceClass[BB]; if (BB != EquivBB) BlockWeights[BB] = BlockWeights[EquivBB]; - DEBUG(printBlockWeight(dbgs(), BB)); + LLVM_DEBUG(printBlockWeight(dbgs(), BB)); } } @@ -1012,7 +1012,7 @@ bool SampleProfileLoader::propagateThroughEdges(Function &F, bool UpdateBlockCount) { bool Changed = false; - DEBUG(dbgs() << "\nPropagation through edges\n"); + LLVM_DEBUG(dbgs() << "\nPropagation through edges\n"); for (const auto &BI : F) { const BasicBlock *BB = &BI; const BasicBlock *EC = EquivalenceClass[BB]; @@ -1084,7 +1084,7 @@ if (TotalWeight > BBWeight) { BBWeight = TotalWeight; Changed = true; - DEBUG(dbgs() << "All edge weights for " << BB->getName() + LLVM_DEBUG(dbgs() << "All edge weights for " << BB->getName() << " known. Set weight for block: "; printBlockWeight(dbgs(), BB);); } @@ -1113,7 +1113,7 @@ EdgeWeights[UnknownEdge] = BlockWeights[OtherEC]; VisitedEdges.insert(UnknownEdge); Changed = true; - DEBUG(dbgs() << "Set weight for edge: "; + LLVM_DEBUG(dbgs() << "Set weight for edge: "; printEdgeWeight(dbgs(), UnknownEdge)); } } else if (VisitedBlocks.count(EC) && BlockWeights[EC] == 0) { @@ -1140,7 +1140,7 @@ EdgeWeights[SelfReferentialEdge] = 0; VisitedEdges.insert(SelfReferentialEdge); Changed = true; - DEBUG(dbgs() << "Set self-referential edge weight to: "; + LLVM_DEBUG(dbgs() << "Set self-referential edge weight to: "; printEdgeWeight(dbgs(), SelfReferentialEdge)); } if (UpdateBlockCount && !VisitedBlocks.count(EC) && TotalWeight > 0) { @@ -1265,7 +1265,7 @@ // Generate MD_prof metadata for every branch instruction using the // edge weights computed during propagation. - DEBUG(dbgs() << "\nPropagation complete. Setting branch weights\n"); + LLVM_DEBUG(dbgs() << "\nPropagation complete. Setting branch weights\n"); LLVMContext &Ctx = F.getContext(); MDBuilder MDB(Ctx); for (auto &BI : F) { @@ -1311,7 +1311,7 @@ continue; DebugLoc BranchLoc = TI->getDebugLoc(); - DEBUG(dbgs() << "\nGetting weights for branch at line " + LLVM_DEBUG(dbgs() << "\nGetting weights for branch at line " << ((BranchLoc) ? Twine(BranchLoc.getLine()) : Twine("")) << ".\n"); @@ -1322,12 +1322,12 @@ BasicBlock *Succ = TI->getSuccessor(I); Edge E = std::make_pair(BB, Succ); uint64_t Weight = EdgeWeights[E]; - DEBUG(dbgs() << "\t"; printEdgeWeight(dbgs(), E)); + LLVM_DEBUG(dbgs() << "\t"; printEdgeWeight(dbgs(), E)); // Use uint32_t saturated arithmetic to adjust the incoming weights, // if needed. Sample counts in profiles are 64-bit unsigned values, // but internally branch weights are expressed as 32-bit values. if (Weight > std::numeric_limits::max()) { - DEBUG(dbgs() << " (saturated due to uint32_t overflow)"); + LLVM_DEBUG(dbgs() << " (saturated due to uint32_t overflow)"); Weight = std::numeric_limits::max(); } // Weight is added by one to avoid propagation errors introduced by @@ -1348,7 +1348,7 @@ // annotation is done twice. If the first annotation already set the // weights, the second pass does not need to set it. if (MaxWeight > 0 && !TI->extractProfTotalWeight(TempWeight)) { - DEBUG(dbgs() << "SUCCESS. Found non-zero weights.\n"); + LLVM_DEBUG(dbgs() << "SUCCESS. Found non-zero weights.\n"); TI->setMetadata(LLVMContext::MD_prof, MDB.createBranchWeights(Weights)); ORE->emit([&]() { @@ -1357,7 +1357,7 @@ << ore::NV("CondBranchesLoc", BranchLoc); }); } else { - DEBUG(dbgs() << "SKIPPED. All branch weights are zero.\n"); + LLVM_DEBUG(dbgs() << "SKIPPED. All branch weights are zero.\n"); } } } @@ -1452,7 +1452,7 @@ if (getFunctionLoc(F) == 0) return false; - DEBUG(dbgs() << "Line number for the first instruction in " << F.getName() + LLVM_DEBUG(dbgs() << "Line number for the first instruction in " << F.getName() << ": " << getFunctionLoc(F) << "\n"); DenseSet InlinedGUIDs; Index: lib/Transforms/InstCombine/InstCombineCalls.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombineCalls.cpp +++ lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -3902,7 +3902,7 @@ // Remove the convergent attr on calls when the callee is not convergent. if (CS.isConvergent() && !CalleeF->isConvergent() && !CalleeF->isIntrinsic()) { - DEBUG(dbgs() << "Removing convergent attr from instr " + LLVM_DEBUG(dbgs() << "Removing convergent attr from instr " << CS.getInstruction() << "\n"); CS.setNotConvergent(); return CS.getInstruction(); Index: lib/Transforms/InstCombine/InstCombineCasts.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombineCasts.cpp +++ lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -698,7 +698,7 @@ // If this cast is a truncate, evaluting in a different type always // eliminates the cast, so it is always a win. - DEBUG(dbgs() << "ICE: EvaluateInDifferentType converting expression type" + LLVM_DEBUG(dbgs() << "ICE: EvaluateInDifferentType converting expression type" " to avoid cast: " << CI << '\n'); Value *Res = EvaluateInDifferentType(Src, DestTy, false); assert(Res->getType() == DestTy); @@ -1071,7 +1071,7 @@ "Can't clear more bits than in SrcTy"); // Okay, we can transform this! Insert the new expression now. - DEBUG(dbgs() << "ICE: EvaluateInDifferentType converting expression type" + LLVM_DEBUG(dbgs() << "ICE: EvaluateInDifferentType converting expression type" " to avoid zero extend: " << CI << '\n'); Value *Res = EvaluateInDifferentType(Src, DestTy, false); assert(Res->getType() == DestTy); @@ -1345,7 +1345,7 @@ if ((DestTy->isVectorTy() || shouldChangeType(SrcTy, DestTy)) && canEvaluateSExtd(Src, DestTy)) { // Okay, we can transform this! Insert the new expression now. - DEBUG(dbgs() << "ICE: EvaluateInDifferentType converting expression type" + LLVM_DEBUG(dbgs() << "ICE: EvaluateInDifferentType converting expression type" " to avoid sign extend: " << CI << '\n'); Value *Res = EvaluateInDifferentType(Src, DestTy, true); assert(Res->getType() == DestTy); Index: lib/Transforms/InstCombine/InstCombineInternal.h =================================================================== --- lib/Transforms/InstCombine/InstCombineInternal.h +++ lib/Transforms/InstCombine/InstCombineInternal.h @@ -528,7 +528,7 @@ if (&I == V) V = UndefValue::get(I.getType()); - DEBUG(dbgs() << "IC: Replacing " << I << "\n" + LLVM_DEBUG(dbgs() << "IC: Replacing " << I << "\n" << " with " << *V << '\n'); I.replaceAllUsesWith(V); @@ -551,7 +551,7 @@ /// value, we can't rely on DCE to delete the instruction. Instead, visit /// methods should return the value returned by this function. Instruction *eraseInstFromFunction(Instruction &I) { - DEBUG(dbgs() << "IC: ERASE " << I << '\n'); + LLVM_DEBUG(dbgs() << "IC: ERASE " << I << '\n'); assert(I.use_empty() && "Cannot erase instruction that is used!"); salvageDebugInfo(I); Index: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -270,7 +270,7 @@ auto *Inst = dyn_cast(&*U); if (!Inst) return; - DEBUG(dbgs() << "Found pointer user: " << *U << '\n'); + LLVM_DEBUG(dbgs() << "Found pointer user: " << *U << '\n'); if (isa(Inst)) { for (auto P : Path) replace(P); @@ -405,8 +405,8 @@ Copy->getSource(), AI.getAlignment(), DL, &AI, &AC, &DT); if (AI.getAlignment() <= SourceAlign && isDereferenceableForAllocaSize(Copy->getSource(), &AI, DL)) { - DEBUG(dbgs() << "Found alloca equal to global: " << AI << '\n'); - DEBUG(dbgs() << " memcpy = " << *Copy << '\n'); + LLVM_DEBUG(dbgs() << "Found alloca equal to global: " << AI << '\n'); + LLVM_DEBUG(dbgs() << " memcpy = " << *Copy << '\n'); for (unsigned i = 0, e = ToDelete.size(); i != e; ++i) eraseInstFromFunction(*ToDelete[i]); Constant *TheSrc = cast(Copy->getSource()); Index: lib/Transforms/InstCombine/InstCombinePHI.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombinePHI.cpp +++ lib/Transforms/InstCombine/InstCombinePHI.cpp @@ -1008,7 +1008,7 @@ // extracted out of it. First, sort the users by their offset and size. array_pod_sort(PHIUsers.begin(), PHIUsers.end()); - DEBUG(dbgs() << "SLICING UP PHI: " << FirstPhi << '\n'; + LLVM_DEBUG(dbgs() << "SLICING UP PHI: " << FirstPhi << '\n'; for (unsigned i = 1, e = PHIsToSlice.size(); i != e; ++i) dbgs() << "AND USER PHI #" << i << ": " << *PHIsToSlice[i] << '\n'; ); @@ -1092,7 +1092,7 @@ } PredValues.clear(); - DEBUG(dbgs() << " Made element PHI for offset " << Offset << ": " + LLVM_DEBUG(dbgs() << " Made element PHI for offset " << Offset << ": " << *EltPHI << '\n'); ExtractedVals[LoweredPHIRecord(PN, Offset, Ty)] = EltPHI; } Index: lib/Transforms/InstCombine/InstCombineShifts.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombineShifts.cpp +++ lib/Transforms/InstCombine/InstCombineShifts.cpp @@ -356,7 +356,7 @@ // cast of lshr(shl(x,c1),c2) as well as other more complex cases. if (I.getOpcode() != Instruction::AShr && canEvaluateShifted(Op0, Op1C->getZExtValue(), isLeftShift, *this, &I)) { - DEBUG(dbgs() << "ICE: GetShiftedValue propagating shift through expression" + LLVM_DEBUG(dbgs() << "ICE: GetShiftedValue propagating shift through expression" " to eliminate shift:\n IN: " << *Op0 << "\n SH: " << I <<"\n"); return replaceInstUsesWith( Index: lib/Transforms/InstCombine/InstructionCombining.cpp =================================================================== --- lib/Transforms/InstCombine/InstructionCombining.cpp +++ lib/Transforms/InstCombine/InstructionCombining.cpp @@ -2945,7 +2945,7 @@ // Check to see if we can DCE the instruction. if (isInstructionTriviallyDead(I, &TLI)) { - DEBUG(dbgs() << "IC: DCE: " << *I << '\n'); + LLVM_DEBUG(dbgs() << "IC: DCE: " << *I << '\n'); eraseInstFromFunction(*I); ++NumDeadInst; MadeIRChange = true; @@ -2959,7 +2959,7 @@ if (!I->use_empty() && (I->getNumOperands() == 0 || isa(I->getOperand(0)))) { if (Constant *C = ConstantFoldInstruction(I, DL, &TLI)) { - DEBUG(dbgs() << "IC: ConstFold to: " << *C << " from: " << *I << '\n'); + LLVM_DEBUG(dbgs() << "IC: ConstFold to: " << *C << " from: " << *I << '\n'); // Add operands to the worklist. replaceInstUsesWith(*I, C); @@ -2978,7 +2978,7 @@ KnownBits Known = computeKnownBits(I, /*Depth*/0, I); if (Known.isConstant()) { Constant *C = ConstantInt::get(Ty, Known.getConstant()); - DEBUG(dbgs() << "IC: ConstFold (all bits known) to: " << *C << + LLVM_DEBUG(dbgs() << "IC: ConstFold (all bits known) to: " << *C << " from: " << *I << '\n'); // Add operands to the worklist. @@ -3018,7 +3018,7 @@ if (UserIsSuccessor && UserParent->getUniquePredecessor()) { // Okay, the CFG is simple enough, try to sink this instruction. if (TryToSinkInstruction(I, UserParent)) { - DEBUG(dbgs() << "IC: Sink: " << *I << '\n'); + LLVM_DEBUG(dbgs() << "IC: Sink: " << *I << '\n'); MadeIRChange = true; // We'll add uses of the sunk instruction below, but since sinking // can expose opportunities for it's *operands* add them to the @@ -3038,14 +3038,14 @@ #ifndef NDEBUG std::string OrigI; #endif - DEBUG(raw_string_ostream SS(OrigI); I->print(SS); OrigI = SS.str();); - DEBUG(dbgs() << "IC: Visiting: " << OrigI << '\n'); + LLVM_DEBUG(raw_string_ostream SS(OrigI); I->print(SS); OrigI = SS.str();); + LLVM_DEBUG(dbgs() << "IC: Visiting: " << OrigI << '\n'); if (Instruction *Result = visit(*I)) { ++NumCombined; // Should we replace the old instruction with a new one? if (Result != I) { - DEBUG(dbgs() << "IC: Old = " << *I << '\n' + LLVM_DEBUG(dbgs() << "IC: Old = " << *I << '\n' << " New = " << *Result << '\n'); if (I->getDebugLoc()) @@ -3073,7 +3073,7 @@ eraseInstFromFunction(*I); } else { - DEBUG(dbgs() << "IC: Mod = " << OrigI << '\n' + LLVM_DEBUG(dbgs() << "IC: Mod = " << OrigI << '\n' << " New = " << *I << '\n'); // If the instruction was modified, it's possible that it is now dead. @@ -3125,7 +3125,7 @@ // DCE instruction if trivially dead. if (isInstructionTriviallyDead(Inst, TLI)) { ++NumDeadInst; - DEBUG(dbgs() << "IC: DCE: " << *Inst << '\n'); + LLVM_DEBUG(dbgs() << "IC: DCE: " << *Inst << '\n'); salvageDebugInfo(*Inst); Inst->eraseFromParent(); MadeIRChange = true; @@ -3136,7 +3136,7 @@ if (!Inst->use_empty() && (Inst->getNumOperands() == 0 || isa(Inst->getOperand(0)))) if (Constant *C = ConstantFoldInstruction(Inst, DL, TLI)) { - DEBUG(dbgs() << "IC: ConstFold to: " << *C << " from: " + LLVM_DEBUG(dbgs() << "IC: ConstFold to: " << *C << " from: " << *Inst << '\n'); Inst->replaceAllUsesWith(C); ++NumConstProp; @@ -3159,7 +3159,7 @@ FoldRes = C; if (FoldRes != C) { - DEBUG(dbgs() << "IC: ConstFold operand of: " << *Inst + LLVM_DEBUG(dbgs() << "IC: ConstFold operand of: " << *Inst << "\n Old = " << *C << "\n New = " << *FoldRes << '\n'); U = FoldRes; @@ -3264,7 +3264,7 @@ int Iteration = 0; while (true) { ++Iteration; - DEBUG(dbgs() << "\n\nINSTCOMBINE ITERATION #" << Iteration << " on " + LLVM_DEBUG(dbgs() << "\n\nINSTCOMBINE ITERATION #" << Iteration << " on " << F.getName() << "\n"); MadeIRChange |= prepareICWorklistFromFunction(F, DL, &TLI, Worklist); Index: lib/Transforms/Instrumentation/AddressSanitizer.cpp =================================================================== --- lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -869,7 +869,7 @@ processStaticAllocas(); if (ClDebugStack) { - DEBUG(dbgs() << F); + LLVM_DEBUG(dbgs() << F); } return true; } @@ -1609,7 +1609,7 @@ bool AddressSanitizerModule::ShouldInstrumentGlobal(GlobalVariable *G) { Type *Ty = G->getValueType(); - DEBUG(dbgs() << "GLOBAL: " << *G << "\n"); + LLVM_DEBUG(dbgs() << "GLOBAL: " << *G << "\n"); if (GlobalsMD.get(G).IsBlacklisted) return false; if (!Ty->isSized()) return false; @@ -1651,7 +1651,7 @@ // See https://github.com/google/sanitizers/issues/305 // and http://msdn.microsoft.com/en-US/en-en/library/bb918180(v=vs.120).aspx if (Section.startswith(".CRT")) { - DEBUG(dbgs() << "Ignoring a global initializer callback: " << *G << "\n"); + LLVM_DEBUG(dbgs() << "Ignoring a global initializer callback: " << *G << "\n"); return false; } @@ -1668,7 +1668,7 @@ // them. if (ParsedSegment == "__OBJC" || (ParsedSegment == "__DATA" && ParsedSection.startswith("__objc_"))) { - DEBUG(dbgs() << "Ignoring ObjC runtime global: " << *G << "\n"); + LLVM_DEBUG(dbgs() << "Ignoring ObjC runtime global: " << *G << "\n"); return false; } // See https://github.com/google/sanitizers/issues/32 @@ -1680,13 +1680,13 @@ // Therefore there's no point in placing redzones into __DATA,__cfstring. // Moreover, it causes the linker to crash on OS X 10.7 if (ParsedSegment == "__DATA" && ParsedSection == "__cfstring") { - DEBUG(dbgs() << "Ignoring CFString: " << *G << "\n"); + LLVM_DEBUG(dbgs() << "Ignoring CFString: " << *G << "\n"); return false; } // The linker merges the contents of cstring_literals and removes the // trailing zeroes. if (ParsedSegment == "__TEXT" && (TAA & MachO::S_CSTRING_LITERALS)) { - DEBUG(dbgs() << "Ignoring a cstring literal: " << *G << "\n"); + LLVM_DEBUG(dbgs() << "Ignoring a cstring literal: " << *G << "\n"); return false; } } @@ -2153,7 +2153,7 @@ if (ClInitializers && MD.IsDynInit) HasDynamicallyInitializedGlobals = true; - DEBUG(dbgs() << "NEW GLOBAL: " << *NewGlobal << "\n"); + LLVM_DEBUG(dbgs() << "NEW GLOBAL: " << *NewGlobal << "\n"); Initializers[i] = Initializer; } @@ -2177,7 +2177,7 @@ if (HasDynamicallyInitializedGlobals) createInitializerPoisonCalls(M, ModuleName); - DEBUG(dbgs() << M); + LLVM_DEBUG(dbgs() << M); return true; } @@ -2418,7 +2418,7 @@ // Leave if the function doesn't need instrumentation. if (!F.hasFnAttribute(Attribute::SanitizeAddress)) return FunctionModified; - DEBUG(dbgs() << "ASAN instrumenting:\n" << F << "\n"); + LLVM_DEBUG(dbgs() << "ASAN instrumenting:\n" << F << "\n"); initializeCallbacks(*F.getParent()); DT = &getAnalysis().getDomTree(); @@ -2531,7 +2531,7 @@ if (NumInstrumented > 0 || ChangedStack || !NoReturnCalls.empty()) FunctionModified = true; - DEBUG(dbgs() << "ASAN done instrumenting: " << FunctionModified << " " + LLVM_DEBUG(dbgs() << "ASAN done instrumenting: " << FunctionModified << " " << F << "\n"); return FunctionModified; @@ -2848,7 +2848,7 @@ } auto DescriptionString = ComputeASanStackFrameDescription(SVD); - DEBUG(dbgs() << DescriptionString << " --- " << L.FrameSize << "\n"); + LLVM_DEBUG(dbgs() << DescriptionString << " --- " << L.FrameSize << "\n"); uint64_t LocalStackSize = L.FrameSize; bool DoStackMalloc = ClUseAfterReturn && !ASan.CompileKernel && LocalStackSize <= kMaxStackMallocSize; @@ -3083,7 +3083,7 @@ } else if (GetElementPtrInst *EP = dyn_cast(V)) { Res = findAllocaForValue(EP->getPointerOperand()); } else { - DEBUG(dbgs() << "Alloca search canceled on unknown instruction: " << *V << "\n"); + LLVM_DEBUG(dbgs() << "Alloca search canceled on unknown instruction: " << *V << "\n"); } if (Res) AllocaForValue[V] = Res; return Res; Index: lib/Transforms/Instrumentation/BoundsChecking.cpp =================================================================== --- lib/Transforms/Instrumentation/BoundsChecking.cpp +++ lib/Transforms/Instrumentation/BoundsChecking.cpp @@ -62,7 +62,7 @@ BuilderTy &IRB, GetTrapBBT GetTrapBB) { uint64_t NeededSize = DL.getTypeStoreSize(InstVal->getType()); - DEBUG(dbgs() << "Instrument " << *Ptr << " for " << Twine(NeededSize) + LLVM_DEBUG(dbgs() << "Instrument " << *Ptr << " for " << Twine(NeededSize) << " bytes\n"); SizeOffsetEvalType SizeOffset = ObjSizeEval.compute(Ptr); Index: lib/Transforms/Instrumentation/CFGMST.h =================================================================== --- lib/Transforms/Instrumentation/CFGMST.h +++ lib/Transforms/Instrumentation/CFGMST.h @@ -97,7 +97,7 @@ // Edges with large weight will be put into MST first so they are less likely // to be instrumented. void buildEdges() { - DEBUG(dbgs() << "Build Edge on " << F.getName() << "\n"); + LLVM_DEBUG(dbgs() << "Build Edge on " << F.getName() << "\n"); const BasicBlock *Entry = &(F.getEntryBlock()); uint64_t EntryWeight = (BFI != nullptr ? BFI->getEntryFreq() : 2); @@ -107,7 +107,7 @@ // Add a fake edge to the entry. EntryIncoming = &addEdge(nullptr, Entry, EntryWeight); - DEBUG(dbgs() << " Edge: from fake node to " << Entry->getName() + LLVM_DEBUG(dbgs() << " Edge: from fake node to " << Entry->getName() << " w = " << EntryWeight << "\n"); // Special handling for single BB functions. @@ -138,7 +138,7 @@ Weight = BPI->getEdgeProbability(&*BB, TargetBB).scale(scaleFactor); auto *E = &addEdge(&*BB, TargetBB, Weight); E->IsCritical = Critical; - DEBUG(dbgs() << " Edge: from " << BB->getName() << " to " + LLVM_DEBUG(dbgs() << " Edge: from " << BB->getName() << " to " << TargetBB->getName() << " w=" << Weight << "\n"); // Keep track of entry/exit edges: @@ -164,7 +164,7 @@ MaxExitOutWeight = BBWeight; ExitOutgoing = ExitO; } - DEBUG(dbgs() << " Edge: from " << BB->getName() << " to fake exit" + LLVM_DEBUG(dbgs() << " Edge: from " << BB->getName() << " to fake exit" << " w = " << BBWeight << "\n"); } } Index: lib/Transforms/Instrumentation/GCOVProfiling.cpp =================================================================== --- lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -315,7 +315,7 @@ ReturnBlock(1, os) { this->os = os; - DEBUG(dbgs() << "Function: " << getFunctionName(SP) << "\n"); + LLVM_DEBUG(dbgs() << "Function: " << getFunctionName(SP) << "\n"); uint32_t i = 0; for (auto &BB : *F) { @@ -383,7 +383,7 @@ for (int i = 0, e = Blocks.size() + 1; i != e; ++i) { write(0); // No flags on our blocks. } - DEBUG(dbgs() << Blocks.size() << " blocks.\n"); + LLVM_DEBUG(dbgs() << Blocks.size() << " blocks.\n"); // Emit edges between blocks. if (Blocks.empty()) return; @@ -396,7 +396,7 @@ write(Block.OutEdges.size() * 2 + 1); write(Block.Number); for (int i = 0, e = Block.OutEdges.size(); i != e; ++i) { - DEBUG(dbgs() << Block.Number << " -> " << Block.OutEdges[i]->Number + LLVM_DEBUG(dbgs() << Block.Number << " -> " << Block.OutEdges[i]->Number << "\n"); write(Block.OutEdges[i]->Number); write(0); // no flags Index: lib/Transforms/Instrumentation/HWAddressSanitizer.cpp =================================================================== --- lib/Transforms/Instrumentation/HWAddressSanitizer.cpp +++ lib/Transforms/Instrumentation/HWAddressSanitizer.cpp @@ -177,7 +177,7 @@ /// /// inserts a call to __hwasan_init to the module's constructor list. bool HWAddressSanitizer::doInitialization(Module &M) { - DEBUG(dbgs() << "Init " << M.getName() << "\n"); + LLVM_DEBUG(dbgs() << "Init " << M.getName() << "\n"); auto &DL = M.getDataLayout(); Triple TargetTriple(M.getTargetTriple()); @@ -319,7 +319,7 @@ } bool HWAddressSanitizer::instrumentMemAccess(Instruction *I) { - DEBUG(dbgs() << "Instrumenting: " << *I << "\n"); + LLVM_DEBUG(dbgs() << "Instrumenting: " << *I << "\n"); bool IsWrite = false; unsigned Alignment = 0; uint64_t TypeSize = 0; @@ -530,7 +530,7 @@ if (!F.hasFnAttribute(Attribute::SanitizeHWAddress)) return false; - DEBUG(dbgs() << "Function: " << F.getName() << "\n"); + LLVM_DEBUG(dbgs() << "Function: " << F.getName() << "\n"); initializeCallbacks(*F.getParent()); Index: lib/Transforms/Instrumentation/IndirectCallPromotion.cpp =================================================================== --- lib/Transforms/Instrumentation/IndirectCallPromotion.cpp +++ lib/Transforms/Instrumentation/IndirectCallPromotion.cpp @@ -223,12 +223,12 @@ uint64_t TotalCount, uint32_t NumCandidates) { std::vector Ret; - DEBUG(dbgs() << " \nWork on callsite #" << NumOfPGOICallsites << *Inst + LLVM_DEBUG(dbgs() << " \nWork on callsite #" << NumOfPGOICallsites << *Inst << " Num_targets: " << ValueDataRef.size() << " Num_candidates: " << NumCandidates << "\n"); NumOfPGOICallsites++; if (ICPCSSkip != 0 && NumOfPGOICallsites <= ICPCSSkip) { - DEBUG(dbgs() << " Skip: User options.\n"); + LLVM_DEBUG(dbgs() << " Skip: User options.\n"); return Ret; } @@ -236,11 +236,11 @@ uint64_t Count = ValueDataRef[I].Count; assert(Count <= TotalCount); uint64_t Target = ValueDataRef[I].Value; - DEBUG(dbgs() << " Candidate " << I << " Count=" << Count + LLVM_DEBUG(dbgs() << " Candidate " << I << " Count=" << Count << " Target_func: " << Target << "\n"); if (ICPInvokeOnly && dyn_cast(Inst)) { - DEBUG(dbgs() << " Not promote: User options.\n"); + LLVM_DEBUG(dbgs() << " Not promote: User options.\n"); ORE.emit([&]() { return OptimizationRemarkMissed(DEBUG_TYPE, "UserOptions", Inst) << " Not promote: User options"; @@ -248,7 +248,7 @@ break; } if (ICPCallOnly && dyn_cast(Inst)) { - DEBUG(dbgs() << " Not promote: User option.\n"); + LLVM_DEBUG(dbgs() << " Not promote: User option.\n"); ORE.emit([&]() { return OptimizationRemarkMissed(DEBUG_TYPE, "UserOptions", Inst) << " Not promote: User options"; @@ -256,7 +256,7 @@ break; } if (ICPCutOff != 0 && NumOfPGOICallPromotion >= ICPCutOff) { - DEBUG(dbgs() << " Not promote: Cutoff reached.\n"); + LLVM_DEBUG(dbgs() << " Not promote: Cutoff reached.\n"); ORE.emit([&]() { return OptimizationRemarkMissed(DEBUG_TYPE, "CutOffReached", Inst) << " Not promote: Cutoff reached"; @@ -266,7 +266,7 @@ Function *TargetFunction = Symtab->getFunction(Target); if (TargetFunction == nullptr) { - DEBUG(dbgs() << " Not promote: Cannot find the target\n"); + LLVM_DEBUG(dbgs() << " Not promote: Cannot find the target\n"); ORE.emit([&]() { return OptimizationRemarkMissed(DEBUG_TYPE, "UnableToFindTarget", Inst) << "Cannot promote indirect call: target not found"; @@ -387,7 +387,7 @@ InstrProfSymtab Symtab; if (Error E = Symtab.create(M, InLTO)) { std::string SymtabFailure = toString(std::move(E)); - DEBUG(dbgs() << "Failed to create symtab: " << SymtabFailure << "\n"); + LLVM_DEBUG(dbgs() << "Failed to create symtab: " << SymtabFailure << "\n"); (void)SymtabFailure; return false; } @@ -412,12 +412,12 @@ ICallPromotionFunc ICallPromotion(F, &M, &Symtab, SamplePGO, *ORE); bool FuncChanged = ICallPromotion.processFunction(PSI); if (ICPDUMPAFTER && FuncChanged) { - DEBUG(dbgs() << "\n== IR Dump After =="; F.print(dbgs())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n== IR Dump After =="; F.print(dbgs())); + LLVM_DEBUG(dbgs() << "\n"); } Changed |= FuncChanged; if (ICPCutOff != 0 && NumOfPGOICallPromotion >= ICPCutOff) { - DEBUG(dbgs() << " Stop: Cutoff reached.\n"); + LLVM_DEBUG(dbgs() << " Stop: Cutoff reached.\n"); break; } } Index: lib/Transforms/Instrumentation/InstrProfiling.cpp =================================================================== --- lib/Transforms/Instrumentation/InstrProfiling.cpp +++ lib/Transforms/Instrumentation/InstrProfiling.cpp @@ -271,7 +271,7 @@ break; } - DEBUG(dbgs() << Promoted << " counters promoted for loop (depth=" + LLVM_DEBUG(dbgs() << Promoted << " counters promoted for loop (depth=" << L.getLoopDepth() << ")\n"); return Promoted != 0; } Index: lib/Transforms/Instrumentation/MemorySanitizer.cpp =================================================================== --- lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -747,7 +747,7 @@ CheckReturnValue = SanitizeFunction && (F.getName() == "main"); TLI = &MS.getAnalysis().getTLI(); - DEBUG(if (!InsertChecks) + LLVM_DEBUG(if (!InsertChecks) dbgs() << "MemorySanitizer is not inserting checks into '" << F.getName() << "'\n"); } @@ -852,7 +852,7 @@ getShadowOriginPtr(Addr, IRB, ShadowTy, Alignment); StoreInst *NewSI = IRB.CreateAlignedStore(Shadow, ShadowPtr, Alignment); - DEBUG(dbgs() << " STORE: " << *NewSI << "\n"); + LLVM_DEBUG(dbgs() << " STORE: " << *NewSI << "\n"); if (ClCheckAccessAddress) insertShadowCheck(Addr, NewSI); @@ -869,9 +869,9 @@ void materializeOneCheck(Instruction *OrigIns, Value *Shadow, Value *Origin, bool AsCall) { IRBuilder<> IRB(OrigIns); - DEBUG(dbgs() << " SHAD0 : " << *Shadow << "\n"); + LLVM_DEBUG(dbgs() << " SHAD0 : " << *Shadow << "\n"); Value *ConvertedShadow = convertToShadowTyNoVec(Shadow, IRB); - DEBUG(dbgs() << " SHAD1 : " << *ConvertedShadow << "\n"); + LLVM_DEBUG(dbgs() << " SHAD1 : " << *ConvertedShadow << "\n"); Constant *ConstantShadow = dyn_cast_or_null(ConvertedShadow); if (ConstantShadow) { @@ -914,7 +914,7 @@ } IRB.CreateCall(MS.WarningFn, {}); IRB.CreateCall(MS.EmptyAsm, {}); - DEBUG(dbgs() << " CHECK: " << *Cmp << "\n"); + LLVM_DEBUG(dbgs() << " CHECK: " << *Cmp << "\n"); } } @@ -925,7 +925,7 @@ Value *Origin = ShadowData.Origin; materializeOneCheck(OrigIns, Shadow, Origin, InstrumentWithCalls); } - DEBUG(dbgs() << "DONE:\n" << F); + LLVM_DEBUG(dbgs() << "DONE:\n" << F); } /// \brief Add MemorySanitizer instrumentation to a function. @@ -1000,7 +1000,7 @@ for (unsigned i = 0, n = ST->getNumElements(); i < n; i++) Elements.push_back(getShadowTy(ST->getElementType(i))); StructType *Res = StructType::get(*MS.C, Elements, ST->isPacked()); - DEBUG(dbgs() << "getShadowTy: " << *ST << " ===> " << *Res << "\n"); + LLVM_DEBUG(dbgs() << "getShadowTy: " << *ST << " ===> " << *Res << "\n"); return Res; } uint32_t TypeSize = DL.getTypeSizeInBits(OrigTy); @@ -1131,7 +1131,7 @@ void setOrigin(Value *V, Value *Origin) { if (!MS.TrackOrigins) return; assert(!OriginMap.count(V) && "Values may only have one origin"); - DEBUG(dbgs() << "ORIGIN: " << *V << " ==> " << *Origin << "\n"); + LLVM_DEBUG(dbgs() << "ORIGIN: " << *V << " ==> " << *Origin << "\n"); OriginMap[V] = Origin; } @@ -1194,7 +1194,7 @@ // For instructions the shadow is already stored in the map. Value *Shadow = ShadowMap[V]; if (!Shadow) { - DEBUG(dbgs() << "No shadow: " << *V << "\n" << *(I->getParent())); + LLVM_DEBUG(dbgs() << "No shadow: " << *V << "\n" << *(I->getParent())); (void)I; assert(Shadow && "No shadow for a value"); } @@ -1202,7 +1202,7 @@ } if (UndefValue *U = dyn_cast(V)) { Value *AllOnes = PoisonUndef ? getPoisonedShadow(V) : getCleanShadow(V); - DEBUG(dbgs() << "Undef: " << *U << " ==> " << *AllOnes << "\n"); + LLVM_DEBUG(dbgs() << "Undef: " << *U << " ==> " << *AllOnes << "\n"); (void)U; return AllOnes; } @@ -1217,7 +1217,7 @@ const DataLayout &DL = F->getParent()->getDataLayout(); for (auto &FArg : F->args()) { if (!FArg.getType()->isSized()) { - DEBUG(dbgs() << "Arg is not sized\n"); + LLVM_DEBUG(dbgs() << "Arg is not sized\n"); continue; } unsigned Size = @@ -1248,7 +1248,7 @@ unsigned CopyAlign = std::min(ArgAlign, kShadowTLSAlignment); Value *Cpy = EntryIRB.CreateMemCpy(CpShadowPtr, CopyAlign, Base, CopyAlign, Size); - DEBUG(dbgs() << " ByValCpy: " << *Cpy << "\n"); + LLVM_DEBUG(dbgs() << " ByValCpy: " << *Cpy << "\n"); (void)Cpy; } *ShadowPtr = getCleanShadow(V); @@ -1261,7 +1261,7 @@ EntryIRB.CreateAlignedLoad(Base, kShadowTLSAlignment); } } - DEBUG(dbgs() << " ARG: " << FArg << " ==> " << + LLVM_DEBUG(dbgs() << " ARG: " << FArg << " ==> " << **ShadowPtr << "\n"); if (MS.TrackOrigins && !Overflow) { Value *OriginPtr = @@ -2738,13 +2738,13 @@ IRBuilder<> IRB(&I); unsigned ArgOffset = 0; - DEBUG(dbgs() << " CallSite: " << I << "\n"); + LLVM_DEBUG(dbgs() << " CallSite: " << I << "\n"); for (CallSite::arg_iterator ArgIt = CS.arg_begin(), End = CS.arg_end(); ArgIt != End; ++ArgIt) { Value *A = *ArgIt; unsigned i = ArgIt - CS.arg_begin(); if (!A->getType()->isSized()) { - DEBUG(dbgs() << "Arg " << i << " is not sized: " << I << "\n"); + LLVM_DEBUG(dbgs() << "Arg " << i << " is not sized: " << I << "\n"); continue; } unsigned Size = 0; @@ -2754,7 +2754,7 @@ // __msan_param_tls. Value *ArgShadow = getShadow(A); Value *ArgShadowBase = getShadowPtrForArgument(A, IRB, ArgOffset); - DEBUG(dbgs() << " Arg#" << i << ": " << *A << + LLVM_DEBUG(dbgs() << " Arg#" << i << ": " << *A << " Shadow: " << *ArgShadow << "\n"); bool ArgIsInitialized = false; const DataLayout &DL = F.getParent()->getDataLayout(); @@ -2783,10 +2783,10 @@ getOriginPtrForArgument(A, IRB, ArgOffset)); (void)Store; assert(Size != 0 && Store != nullptr); - DEBUG(dbgs() << " Param:" << *Store << "\n"); + LLVM_DEBUG(dbgs() << " Param:" << *Store << "\n"); ArgOffset += alignTo(Size, 8); } - DEBUG(dbgs() << " done with call args\n"); + LLVM_DEBUG(dbgs() << " done with call args\n"); FunctionType *FT = cast(CS.getCalledValue()->getType()->getContainedType(0)); @@ -2992,24 +2992,24 @@ void visitExtractValueInst(ExtractValueInst &I) { IRBuilder<> IRB(&I); Value *Agg = I.getAggregateOperand(); - DEBUG(dbgs() << "ExtractValue: " << I << "\n"); + LLVM_DEBUG(dbgs() << "ExtractValue: " << I << "\n"); Value *AggShadow = getShadow(Agg); - DEBUG(dbgs() << " AggShadow: " << *AggShadow << "\n"); + LLVM_DEBUG(dbgs() << " AggShadow: " << *AggShadow << "\n"); Value *ResShadow = IRB.CreateExtractValue(AggShadow, I.getIndices()); - DEBUG(dbgs() << " ResShadow: " << *ResShadow << "\n"); + LLVM_DEBUG(dbgs() << " ResShadow: " << *ResShadow << "\n"); setShadow(&I, ResShadow); setOriginForNaryOp(I); } void visitInsertValueInst(InsertValueInst &I) { IRBuilder<> IRB(&I); - DEBUG(dbgs() << "InsertValue: " << I << "\n"); + LLVM_DEBUG(dbgs() << "InsertValue: " << I << "\n"); Value *AggShadow = getShadow(I.getAggregateOperand()); Value *InsShadow = getShadow(I.getInsertedValueOperand()); - DEBUG(dbgs() << " AggShadow: " << *AggShadow << "\n"); - DEBUG(dbgs() << " InsShadow: " << *InsShadow << "\n"); + LLVM_DEBUG(dbgs() << " AggShadow: " << *AggShadow << "\n"); + LLVM_DEBUG(dbgs() << " InsShadow: " << *InsShadow << "\n"); Value *Res = IRB.CreateInsertValue(AggShadow, InsShadow, I.getIndices()); - DEBUG(dbgs() << " Res: " << *Res << "\n"); + LLVM_DEBUG(dbgs() << " Res: " << *Res << "\n"); setShadow(&I, Res); setOriginForNaryOp(I); } @@ -3024,17 +3024,17 @@ } void visitResumeInst(ResumeInst &I) { - DEBUG(dbgs() << "Resume: " << I << "\n"); + LLVM_DEBUG(dbgs() << "Resume: " << I << "\n"); // Nothing to do here. } void visitCleanupReturnInst(CleanupReturnInst &CRI) { - DEBUG(dbgs() << "CleanupReturn: " << CRI << "\n"); + LLVM_DEBUG(dbgs() << "CleanupReturn: " << CRI << "\n"); // Nothing to do here. } void visitCatchReturnInst(CatchReturnInst &CRI) { - DEBUG(dbgs() << "CatchReturn: " << CRI << "\n"); + LLVM_DEBUG(dbgs() << "CatchReturn: " << CRI << "\n"); // Nothing to do here. } @@ -3042,7 +3042,7 @@ // Everything else: stop propagating and check for poisoned shadow. if (ClDumpStrictInstructions) dumpInst(I); - DEBUG(dbgs() << "DEFAULT: " << I << "\n"); + LLVM_DEBUG(dbgs() << "DEFAULT: " << I << "\n"); for (size_t i = 0, n = I.getNumOperands(); i < n; i++) { Value *Operand = I.getOperand(i); if (Operand->getType()->isSized()) Index: lib/Transforms/Instrumentation/PGOInstrumentation.cpp =================================================================== --- lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -546,7 +546,7 @@ computeCFGHash(); if (!ComdatMembers.empty()) renameComdatFunction(); - DEBUG(dumpInfo("after CFGMST")); + LLVM_DEBUG(dumpInfo("after CFGMST")); NumOfPGOBB += MST.BBInfos.size(); for (auto &E : MST.AllEdges) { @@ -596,7 +596,7 @@ FunctionHash = (uint64_t)SIVisitor.getNumOfSelectInsts() << 56 | (uint64_t)ValueSites[IPVK_IndirectCallTarget].size() << 48 | (uint64_t)MST.AllEdges.size() << 32 | JC.getCRC(); - DEBUG(dbgs() << "Function Hash Computation for " << F.getName() << ":\n" + LLVM_DEBUG(dbgs() << "Function Hash Computation for " << F.getName() << ":\n" << " CRC = " << JC.getCRC() << ", Selects = " << SIVisitor.getNumOfSelectInsts() << ", Edges = " << MST.AllEdges.size() @@ -702,7 +702,7 @@ // For a critical edge, we have to split. Instrument the newly // created BB. NumOfPGOSplit++; - DEBUG(dbgs() << "Split critical edge: " << getBBInfo(SrcBB).Index << " --> " + LLVM_DEBUG(dbgs() << "Split critical edge: " << getBBInfo(SrcBB).Index << " --> " << getBBInfo(DestBB).Index << "\n"); unsigned SuccNum = GetSuccessorNumber(SrcBB, DestBB); BasicBlock *InstrBB = SplitCriticalEdge(TI, SuccNum); @@ -753,7 +753,7 @@ for (auto &I : FuncInfo.ValueSites[IPVK_IndirectCallTarget]) { CallSite CS(I); Value *Callee = CS.getCalledValue(); - DEBUG(dbgs() << "Instrument one indirect call: CallSite Index = " + LLVM_DEBUG(dbgs() << "Instrument one indirect call: CallSite Index = " << NumIndirectCallSites << "\n"); IRBuilder<> Builder(I); assert(Builder.GetInsertPoint() != I->getParent()->end() && @@ -1042,14 +1042,14 @@ std::vector &CountFromProfile = ProfileRecord.Counts; NumOfPGOFunc++; - DEBUG(dbgs() << CountFromProfile.size() << " counts\n"); + LLVM_DEBUG(dbgs() << CountFromProfile.size() << " counts\n"); uint64_t ValueSum = 0; for (unsigned I = 0, S = CountFromProfile.size(); I < S; I++) { - DEBUG(dbgs() << " " << I << ": " << CountFromProfile[I] << "\n"); + LLVM_DEBUG(dbgs() << " " << I << ": " << CountFromProfile[I] << "\n"); ValueSum += CountFromProfile[I]; } - DEBUG(dbgs() << "SUM = " << ValueSum << "\n"); + LLVM_DEBUG(dbgs() << "SUM = " << ValueSum << "\n"); getBBInfo(nullptr).UnknownCountOutEdge = 2; getBBInfo(nullptr).UnknownCountInEdge = 2; @@ -1129,7 +1129,7 @@ } } - DEBUG(dbgs() << "Populate counts in " << NumPasses << " passes.\n"); + LLVM_DEBUG(dbgs() << "Populate counts in " << NumPasses << " passes.\n"); #ifndef NDEBUG // Assert every BB has a valid counter. for (auto &BB : F) { @@ -1154,13 +1154,13 @@ FuncInfo.SIVisitor.annotateSelects(F, this, &CountPosition); assert(CountPosition == ProfileCountSize); - DEBUG(FuncInfo.dumpInfo("after reading profile.")); + LLVM_DEBUG(FuncInfo.dumpInfo("after reading profile.")); } // Assign the scaled count values to the BB with multiple out edges. void PGOUseFunc::setBranchWeights() { // Generate MD_prof metadata for every branch instruction. - DEBUG(dbgs() << "\nSetting branch weights.\n"); + LLVM_DEBUG(dbgs() << "\nSetting branch weights.\n"); for (auto &BB : F) { TerminatorInst *TI = BB.getTerminator(); if (TI->getNumSuccessors() < 2) @@ -1201,7 +1201,7 @@ } void PGOUseFunc::annotateIrrLoopHeaderWeights() { - DEBUG(dbgs() << "\nAnnotating irreducible loop header weights.\n"); + LLVM_DEBUG(dbgs() << "\nAnnotating irreducible loop header weights.\n"); // Find irr loop headers for (auto &BB : F) { // As a heuristic also annotate indrectbr targets as they have a high chance @@ -1334,7 +1334,7 @@ } for (auto &I : ValueSites) { - DEBUG(dbgs() << "Read one value site profile (kind = " << Kind + LLVM_DEBUG(dbgs() << "Read one value site profile (kind = " << Kind << "): Index = " << ValueSiteIndex << " out of " << NumValueSites << "\n"); annotateValueSite(*M, *I, ProfileRecord, @@ -1432,7 +1432,7 @@ Module &M, StringRef ProfileFileName, function_ref LookupBPI, function_ref LookupBFI) { - DEBUG(dbgs() << "Read in profile counters: "); + LLVM_DEBUG(dbgs() << "Read in profile counters: "); auto &Ctx = M.getContext(); // Read the counter array from file. auto ReaderOrErr = IndexedInstrProfReader::create(ProfileFileName); @@ -1518,12 +1518,12 @@ // inconsistent MST between prof-gen and prof-use. for (auto &F : HotFunctions) { F->addFnAttr(Attribute::InlineHint); - DEBUG(dbgs() << "Set inline attribute to function: " << F->getName() + LLVM_DEBUG(dbgs() << "Set inline attribute to function: " << F->getName() << "\n"); } for (auto &F : ColdFunctions) { F->addFnAttr(Attribute::Cold); - DEBUG(dbgs() << "Set cold attribute to function: " << F->getName() << "\n"); + LLVM_DEBUG(dbgs() << "Set cold attribute to function: " << F->getName() << "\n"); } return true; } @@ -1586,7 +1586,7 @@ for (const auto &ECI : EdgeCounts) Weights.push_back(scaleBranchCount(ECI, Scale)); - DEBUG(dbgs() << "Weight is: "; + LLVM_DEBUG(dbgs() << "Weight is: "; for (const auto &W : Weights) { dbgs() << W << " "; } dbgs() << "\n";); TI->setMetadata(LLVMContext::MD_prof, MDB.createBranchWeights(Weights)); Index: lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp =================================================================== --- lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp +++ lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp @@ -151,7 +151,7 @@ if (perform(MI)) { Changed = true; ++NumOfPGOMemOPOpt; - DEBUG(dbgs() << "MemOP call: " << MI->getCalledFunction()->getName() + LLVM_DEBUG(dbgs() << "MemOP call: " << MI->getCalledFunction()->getName() << "is Transformed.\n"); } } @@ -245,9 +245,9 @@ } ArrayRef VDs(ValueDataArray.get(), NumVals); - DEBUG(dbgs() << "Read one memory intrinsic profile with count " << ActualCount + LLVM_DEBUG(dbgs() << "Read one memory intrinsic profile with count " << ActualCount << "\n"); - DEBUG( + LLVM_DEBUG( for (auto &VD : VDs) { dbgs() << " (" << VD.Value << "," << VD.Count << ")\n"; }); @@ -260,7 +260,7 @@ TotalCount = ActualCount; if (MemOPScaleCount) - DEBUG(dbgs() << "Scale counts: numerator = " << ActualCount + LLVM_DEBUG(dbgs() << "Scale counts: numerator = " << ActualCount << " denominator = " << SavedTotalCount << "\n"); // Keeping track of the count of the default case: @@ -310,7 +310,7 @@ uint64_t SumForOpt = TotalCount - RemainCount; - DEBUG(dbgs() << "Optimize one memory intrinsic call to " << Version + LLVM_DEBUG(dbgs() << "Optimize one memory intrinsic call to " << Version << " Versions (covering " << SumForOpt << " out of " << TotalCount << ")\n"); @@ -331,8 +331,8 @@ // merge_bb: BasicBlock *BB = MI->getParent(); - DEBUG(dbgs() << "\n\n== Basic Block Before ==\n"); - DEBUG(dbgs() << *BB << "\n"); + LLVM_DEBUG(dbgs() << "\n\n== Basic Block Before ==\n"); + LLVM_DEBUG(dbgs() << *BB << "\n"); auto OrigBBFreq = BFI.getBlockFreq(BB); BasicBlock *DefaultBB = SplitBlock(BB, MI); @@ -358,7 +358,7 @@ annotateValueSite(*Func.getParent(), *MI, VDs.slice(Version), SavedRemainCount, IPVK_MemOPSize, NumVals); - DEBUG(dbgs() << "\n\n== Basic Block After==\n"); + LLVM_DEBUG(dbgs() << "\n\n== Basic Block After==\n"); for (uint64_t SizeId : SizeIds) { BasicBlock *CaseBB = BasicBlock::Create( @@ -374,13 +374,13 @@ IRBuilder<> IRBCase(CaseBB); IRBCase.CreateBr(MergeBB); SI->addCase(CaseSizeId, CaseBB); - DEBUG(dbgs() << *CaseBB << "\n"); + LLVM_DEBUG(dbgs() << *CaseBB << "\n"); } setProfMetadata(Func.getParent(), SI, CaseCounts, MaxCount); - DEBUG(dbgs() << *BB << "\n"); - DEBUG(dbgs() << *DefaultBB << "\n"); - DEBUG(dbgs() << *MergeBB << "\n"); + LLVM_DEBUG(dbgs() << *BB << "\n"); + LLVM_DEBUG(dbgs() << *DefaultBB << "\n"); + LLVM_DEBUG(dbgs() << *MergeBB << "\n"); ORE.emit([&]() { using namespace ore; Index: lib/Transforms/Instrumentation/ThreadSanitizer.cpp =================================================================== --- lib/Transforms/Instrumentation/ThreadSanitizer.cpp +++ lib/Transforms/Instrumentation/ThreadSanitizer.cpp @@ -502,7 +502,7 @@ if (Idx < 0) return false; if (IsWrite && isVtableAccess(I)) { - DEBUG(dbgs() << " VPTR : " << *I << "\n"); + LLVM_DEBUG(dbgs() << " VPTR : " << *I << "\n"); Value *StoredValue = cast(I)->getValueOperand(); // StoredValue may be a vector type if we are storing several vptrs at once. // In this case, just take the first element of the vector since this is Index: lib/Transforms/ObjCARC/ObjCARCAPElim.cpp =================================================================== --- lib/Transforms/ObjCARC/ObjCARCAPElim.cpp +++ lib/Transforms/ObjCARC/ObjCARCAPElim.cpp @@ -103,7 +103,7 @@ // zap the pair. if (Push && cast(Inst)->getArgOperand(0) == Push) { Changed = true; - DEBUG(dbgs() << "ObjCARCAPElim::OptimizeBB: Zapping push pop " + LLVM_DEBUG(dbgs() << "ObjCARCAPElim::OptimizeBB: Zapping push pop " "autorelease pair:\n" " Pop: " << *Inst << "\n" << " Push: " << *Push << "\n"); Index: lib/Transforms/ObjCARC/ObjCARCContract.cpp =================================================================== --- lib/Transforms/ObjCARC/ObjCARCContract.cpp +++ lib/Transforms/ObjCARC/ObjCARCContract.cpp @@ -129,7 +129,7 @@ Changed = true; ++NumPeeps; - DEBUG(dbgs() << "Transforming objc_retain => " + LLVM_DEBUG(dbgs() << "Transforming objc_retain => " "objc_retainAutoreleasedReturnValue since the operand is a " "return value.\nOld: "<< *Retain << "\n"); @@ -138,7 +138,7 @@ Constant *Decl = EP.get(ARCRuntimeEntryPointKind::RetainRV); cast(Retain)->setCalledFunction(Decl); - DEBUG(dbgs() << "New: " << *Retain << "\n"); + LLVM_DEBUG(dbgs() << "New: " << *Retain << "\n"); return true; } @@ -177,7 +177,7 @@ Changed = true; ++NumPeeps; - DEBUG(dbgs() << " Fusing retain/autorelease!\n" + LLVM_DEBUG(dbgs() << " Fusing retain/autorelease!\n" " Autorelease:" << *Autorelease << "\n" " Retain: " << *Retain << "\n"); @@ -186,7 +186,7 @@ : ARCRuntimeEntryPointKind::RetainAutorelease); Retain->setCalledFunction(Decl); - DEBUG(dbgs() << " New RetainAutorelease: " << *Retain << "\n"); + LLVM_DEBUG(dbgs() << " New RetainAutorelease: " << *Retain << "\n"); EraseInstruction(Autorelease); return true; @@ -365,7 +365,7 @@ Changed = true; ++NumStoreStrongs; - DEBUG( + LLVM_DEBUG( llvm::dbgs() << " Contracting retain, release into objc_storeStrong.\n" << " Old:\n" << " Store: " << *Store << "\n" @@ -392,7 +392,7 @@ // we can set the tail flag once we know it's safe. StoreStrongCalls.insert(StoreStrong); - DEBUG(llvm::dbgs() << " New Store Strong: " << *StoreStrong << "\n"); + LLVM_DEBUG(llvm::dbgs() << " New Store Strong: " << *StoreStrong << "\n"); if (&*Iter == Retain) ++Iter; if (&*Iter == Store) ++Iter; @@ -449,7 +449,7 @@ } while (IsNoopInstruction(&*BBI)); if (&*BBI == GetArgRCIdentityRoot(Inst)) { - DEBUG(dbgs() << "Adding inline asm marker for the return value " + LLVM_DEBUG(dbgs() << "Adding inline asm marker for the return value " "optimization.\n"); Changed = true; InlineAsm *IA = InlineAsm::get( @@ -471,7 +471,7 @@ Changed = true; new StoreInst(Null, CI->getArgOperand(0), CI); - DEBUG(dbgs() << "OBJCARCContract: Old = " << *CI << "\n" + LLVM_DEBUG(dbgs() << "OBJCARCContract: Old = " << *CI << "\n" << " New = " << *Null << "\n"); CI->replaceAllUsesWith(Null); @@ -518,7 +518,7 @@ PA.setAA(&getAnalysis().getAAResults()); - DEBUG(llvm::dbgs() << "**** ObjCARC Contract ****\n"); + LLVM_DEBUG(llvm::dbgs() << "**** ObjCARC Contract ****\n"); // Track whether it's ok to mark objc_storeStrong calls with the "tail" // keyword. Be conservative if the function has variadic arguments. @@ -536,7 +536,7 @@ for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E;) { Instruction *Inst = &*I++; - DEBUG(dbgs() << "Visiting: " << *Inst << "\n"); + LLVM_DEBUG(dbgs() << "Visiting: " << *Inst << "\n"); // First try to peephole Inst. If there is nothing further we can do in // terms of undoing objc-arc-expand, process the next inst. Index: lib/Transforms/ObjCARC/ObjCARCExpand.cpp =================================================================== --- lib/Transforms/ObjCARC/ObjCARCExpand.cpp +++ lib/Transforms/ObjCARC/ObjCARCExpand.cpp @@ -91,12 +91,12 @@ bool Changed = false; - DEBUG(dbgs() << "ObjCARCExpand: Visiting Function: " << F.getName() << "\n"); + LLVM_DEBUG(dbgs() << "ObjCARCExpand: Visiting Function: " << F.getName() << "\n"); for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ++I) { Instruction *Inst = &*I; - DEBUG(dbgs() << "ObjCARCExpand: Visiting: " << *Inst << "\n"); + LLVM_DEBUG(dbgs() << "ObjCARCExpand: Visiting: " << *Inst << "\n"); switch (GetBasicARCInstKind(Inst)) { case ARCInstKind::Retain: @@ -111,7 +111,7 @@ // emitted here. We'll redo them in the contract pass. Changed = true; Value *Value = cast(Inst)->getArgOperand(0); - DEBUG(dbgs() << "ObjCARCExpand: Old = " << *Inst << "\n" + LLVM_DEBUG(dbgs() << "ObjCARCExpand: Old = " << *Inst << "\n" " New = " << *Value << "\n"); Inst->replaceAllUsesWith(Value); break; @@ -121,7 +121,7 @@ } } - DEBUG(dbgs() << "ObjCARCExpand: Finished List.\n\n"); + LLVM_DEBUG(dbgs() << "ObjCARCExpand: Finished List.\n\n"); return Changed; } Index: lib/Transforms/ObjCARC/ObjCARCOpts.cpp =================================================================== --- lib/Transforms/ObjCARC/ObjCARCOpts.cpp +++ lib/Transforms/ObjCARC/ObjCARCOpts.cpp @@ -422,7 +422,7 @@ // Dump the pointers we are tracking. OS << " TopDown State:\n"; if (!BBInfo.hasTopDownPtrs()) { - DEBUG(dbgs() << " NONE!\n"); + LLVM_DEBUG(dbgs() << " NONE!\n"); } else { for (auto I = BBInfo.top_down_ptr_begin(), E = BBInfo.top_down_ptr_end(); I != E; ++I) { @@ -442,7 +442,7 @@ OS << " BottomUp State:\n"; if (!BBInfo.hasBottomUpPtrs()) { - DEBUG(dbgs() << " NONE!\n"); + LLVM_DEBUG(dbgs() << " NONE!\n"); } else { for (auto I = BBInfo.bottom_up_ptr_begin(), E = BBInfo.bottom_up_ptr_end(); I != E; ++I) { @@ -612,7 +612,7 @@ Changed = true; ++NumPeeps; - DEBUG(dbgs() << "Erasing autoreleaseRV,retainRV pair: " << *I << "\n" + LLVM_DEBUG(dbgs() << "Erasing autoreleaseRV,retainRV pair: " << *I << "\n" << "Erasing " << *RetainRV << "\n"); EraseInstruction(&*I); @@ -625,14 +625,14 @@ Changed = true; ++NumPeeps; - DEBUG(dbgs() << "Transforming objc_retainAutoreleasedReturnValue => " + LLVM_DEBUG(dbgs() << "Transforming objc_retainAutoreleasedReturnValue => " "objc_retain since the operand is not a return value.\n" "Old = " << *RetainRV << "\n"); Constant *NewDecl = EP.get(ARCRuntimeEntryPointKind::Retain); cast(RetainRV)->setCalledFunction(NewDecl); - DEBUG(dbgs() << "New = " << *RetainRV << "\n"); + LLVM_DEBUG(dbgs() << "New = " << *RetainRV << "\n"); return false; } @@ -670,7 +670,7 @@ Changed = true; ++NumPeeps; - DEBUG(dbgs() << "Transforming objc_autoreleaseReturnValue => " + LLVM_DEBUG(dbgs() << "Transforming objc_autoreleaseReturnValue => " "objc_autorelease since its operand is not used as a return " "value.\n" "Old = " << *AutoreleaseRV << "\n"); @@ -681,13 +681,13 @@ AutoreleaseRVCI->setTailCall(false); // Never tail call objc_autorelease. Class = ARCInstKind::Autorelease; - DEBUG(dbgs() << "New: " << *AutoreleaseRV << "\n"); + LLVM_DEBUG(dbgs() << "New: " << *AutoreleaseRV << "\n"); } /// Visit each call, one at a time, and make simplifications without doing any /// additional analysis. void ObjCARCOpt::OptimizeIndividualCalls(Function &F) { - DEBUG(dbgs() << "\n== ObjCARCOpt::OptimizeIndividualCalls ==\n"); + LLVM_DEBUG(dbgs() << "\n== ObjCARCOpt::OptimizeIndividualCalls ==\n"); // Reset all the flags in preparation for recomputing them. UsedInThisFunction = 0; @@ -697,7 +697,7 @@ ARCInstKind Class = GetBasicARCInstKind(Inst); - DEBUG(dbgs() << "Visiting: Class: " << Class << "; " << *Inst << "\n"); + LLVM_DEBUG(dbgs() << "Visiting: Class: " << Class << "; " << *Inst << "\n"); switch (Class) { default: break; @@ -713,7 +713,7 @@ case ARCInstKind::NoopCast: Changed = true; ++NumNoops; - DEBUG(dbgs() << "Erasing no-op cast: " << *Inst << "\n"); + LLVM_DEBUG(dbgs() << "Erasing no-op cast: " << *Inst << "\n"); EraseInstruction(Inst); continue; @@ -731,7 +731,7 @@ Constant::getNullValue(Ty), CI); Value *NewValue = UndefValue::get(CI->getType()); - DEBUG(dbgs() << "A null pointer-to-weak-pointer is undefined behavior." + LLVM_DEBUG(dbgs() << "A null pointer-to-weak-pointer is undefined behavior." "\nOld = " << *CI << "\nNew = " << *NewValue << "\n"); CI->replaceAllUsesWith(NewValue); CI->eraseFromParent(); @@ -751,7 +751,7 @@ CI); Value *NewValue = UndefValue::get(CI->getType()); - DEBUG(dbgs() << "A null pointer-to-weak-pointer is undefined behavior." + LLVM_DEBUG(dbgs() << "A null pointer-to-weak-pointer is undefined behavior." "\nOld = " << *CI << "\nNew = " << *NewValue << "\n"); CI->replaceAllUsesWith(NewValue); @@ -787,7 +787,7 @@ NewCall->setMetadata(MDKindCache.get(ARCMDKindID::ImpreciseRelease), MDNode::get(C, None)); - DEBUG(dbgs() << "Replacing autorelease{,RV}(x) with objc_release(x) " + LLVM_DEBUG(dbgs() << "Replacing autorelease{,RV}(x) with objc_release(x) " "since x is otherwise unused.\nOld: " << *Call << "\nNew: " << *NewCall << "\n"); @@ -801,7 +801,7 @@ // a tail keyword. if (IsAlwaysTail(Class)) { Changed = true; - DEBUG(dbgs() << "Adding tail keyword to function since it can never be " + LLVM_DEBUG(dbgs() << "Adding tail keyword to function since it can never be " "passed stack args: " << *Inst << "\n"); cast(Inst)->setTailCall(); } @@ -810,7 +810,7 @@ // semantics of ARC truly do not do so. if (IsNeverTail(Class)) { Changed = true; - DEBUG(dbgs() << "Removing tail keyword from function: " << *Inst << + LLVM_DEBUG(dbgs() << "Removing tail keyword from function: " << *Inst << "\n"); cast(Inst)->setTailCall(false); } @@ -818,7 +818,7 @@ // Set nounwind as needed. if (IsNoThrow(Class)) { Changed = true; - DEBUG(dbgs() << "Found no throw class. Setting nounwind on: " << *Inst + LLVM_DEBUG(dbgs() << "Found no throw class. Setting nounwind on: " << *Inst << "\n"); cast(Inst)->setDoesNotThrow(); } @@ -834,7 +834,7 @@ if (IsNullOrUndef(Arg)) { Changed = true; ++NumNoops; - DEBUG(dbgs() << "ARC calls with null are no-ops. Erasing: " << *Inst + LLVM_DEBUG(dbgs() << "ARC calls with null are no-ops. Erasing: " << *Inst << "\n"); EraseInstruction(Inst); continue; @@ -935,14 +935,14 @@ Clone->setArgOperand(0, Op); Clone->insertBefore(InsertPos); - DEBUG(dbgs() << "Cloning " + LLVM_DEBUG(dbgs() << "Cloning " << *CInst << "\n" "And inserting clone at " << *InsertPos << "\n"); Worklist.push_back(std::make_pair(Clone, Incoming)); } } // Erase the original call. - DEBUG(dbgs() << "Erasing: " << *CInst << "\n"); + LLVM_DEBUG(dbgs() << "Erasing: " << *CInst << "\n"); EraseInstruction(CInst); continue; } @@ -1119,7 +1119,7 @@ ARCInstKind Class = GetARCInstKind(Inst); const Value *Arg = nullptr; - DEBUG(dbgs() << " Class: " << Class << "\n"); + LLVM_DEBUG(dbgs() << " Class: " << Class << "\n"); switch (Class) { case ARCInstKind::Release: { @@ -1142,7 +1142,7 @@ // Don't do retain+release tracking for ARCInstKind::RetainRV, because // it's better to let it remain as the first instruction after a call. if (Class != ARCInstKind::RetainRV) { - DEBUG(dbgs() << " Matching with: " << *Inst << "\n"); + LLVM_DEBUG(dbgs() << " Matching with: " << *Inst << "\n"); Retains[Inst] = S.GetRRInfo(); } S.ClearSequenceProgress(); @@ -1184,7 +1184,7 @@ bool ObjCARCOpt::VisitBottomUp(BasicBlock *BB, DenseMap &BBStates, BlotMapVector &Retains) { - DEBUG(dbgs() << "\n== ObjCARCOpt::VisitBottomUp ==\n"); + LLVM_DEBUG(dbgs() << "\n== ObjCARCOpt::VisitBottomUp ==\n"); bool NestingDetected = false; BBState &MyStates = BBStates[BB]; @@ -1207,7 +1207,7 @@ } } - DEBUG(dbgs() << "Before:\n" << BBStates[BB] << "\n" + LLVM_DEBUG(dbgs() << "Before:\n" << BBStates[BB] << "\n" << "Performing Dataflow:\n"); // Visit all the instructions, bottom-up. @@ -1218,7 +1218,7 @@ if (isa(Inst)) continue; - DEBUG(dbgs() << " Visiting " << *Inst << "\n"); + LLVM_DEBUG(dbgs() << " Visiting " << *Inst << "\n"); NestingDetected |= VisitInstructionBottomUp(Inst, BB, Retains, MyStates); } @@ -1233,7 +1233,7 @@ NestingDetected |= VisitInstructionBottomUp(II, BB, Retains, MyStates); } - DEBUG(dbgs() << "\nFinal State:\n" << BBStates[BB] << "\n"); + LLVM_DEBUG(dbgs() << "\nFinal State:\n" << BBStates[BB] << "\n"); return NestingDetected; } @@ -1246,7 +1246,7 @@ ARCInstKind Class = GetARCInstKind(Inst); const Value *Arg = nullptr; - DEBUG(dbgs() << " Class: " << Class << "\n"); + LLVM_DEBUG(dbgs() << " Class: " << Class << "\n"); switch (Class) { case ARCInstKind::RetainBlock: @@ -1272,7 +1272,7 @@ if (S.MatchWithRelease(MDKindCache, Inst)) { // If we succeed, copy S's RRInfo into the Release -> {Retain Set // Map}. Then we clear S. - DEBUG(dbgs() << " Matching with: " << *Inst << "\n"); + LLVM_DEBUG(dbgs() << " Matching with: " << *Inst << "\n"); Releases[Inst] = S.GetRRInfo(); S.ClearSequenceProgress(); } @@ -1312,7 +1312,7 @@ ObjCARCOpt::VisitTopDown(BasicBlock *BB, DenseMap &BBStates, DenseMap &Releases) { - DEBUG(dbgs() << "\n== ObjCARCOpt::VisitTopDown ==\n"); + LLVM_DEBUG(dbgs() << "\n== ObjCARCOpt::VisitTopDown ==\n"); bool NestingDetected = false; BBState &MyStates = BBStates[BB]; @@ -1334,20 +1334,20 @@ } } - DEBUG(dbgs() << "Before:\n" << BBStates[BB] << "\n" + LLVM_DEBUG(dbgs() << "Before:\n" << BBStates[BB] << "\n" << "Performing Dataflow:\n"); // Visit all the instructions, top-down. for (Instruction &Inst : *BB) { - DEBUG(dbgs() << " Visiting " << Inst << "\n"); + LLVM_DEBUG(dbgs() << " Visiting " << Inst << "\n"); NestingDetected |= VisitInstructionTopDown(&Inst, Releases, MyStates); } - DEBUG(dbgs() << "\nState Before Checking for CFG Hazards:\n" + LLVM_DEBUG(dbgs() << "\nState Before Checking for CFG Hazards:\n" << BBStates[BB] << "\n\n"); CheckForCFGHazards(BB, BBStates, MyStates); - DEBUG(dbgs() << "Final State:\n" << BBStates[BB] << "\n"); + LLVM_DEBUG(dbgs() << "Final State:\n" << BBStates[BB] << "\n"); return NestingDetected; } @@ -1470,7 +1470,7 @@ Type *ArgTy = Arg->getType(); Type *ParamTy = PointerType::getUnqual(Type::getInt8Ty(ArgTy->getContext())); - DEBUG(dbgs() << "== ObjCARCOpt::MoveCalls ==\n"); + LLVM_DEBUG(dbgs() << "== ObjCARCOpt::MoveCalls ==\n"); // Insert the new retain and release calls. for (Instruction *InsertPt : ReleasesToMove.ReverseInsertPts) { @@ -1481,7 +1481,7 @@ Call->setDoesNotThrow(); Call->setTailCall(); - DEBUG(dbgs() << "Inserting new Retain: " << *Call << "\n" + LLVM_DEBUG(dbgs() << "Inserting new Retain: " << *Call << "\n" "At insertion point: " << *InsertPt << "\n"); } for (Instruction *InsertPt : RetainsToMove.ReverseInsertPts) { @@ -1496,7 +1496,7 @@ if (ReleasesToMove.IsTailCallRelease) Call->setTailCall(); - DEBUG(dbgs() << "Inserting new Release: " << *Call << "\n" + LLVM_DEBUG(dbgs() << "Inserting new Release: " << *Call << "\n" "At insertion point: " << *InsertPt << "\n"); } @@ -1504,12 +1504,12 @@ for (Instruction *OrigRetain : RetainsToMove.Calls) { Retains.blot(OrigRetain); DeadInsts.push_back(OrigRetain); - DEBUG(dbgs() << "Deleting retain: " << *OrigRetain << "\n"); + LLVM_DEBUG(dbgs() << "Deleting retain: " << *OrigRetain << "\n"); } for (Instruction *OrigRelease : ReleasesToMove.Calls) { Releases.erase(OrigRelease); DeadInsts.push_back(OrigRelease); - DEBUG(dbgs() << "Deleting release: " << *OrigRelease << "\n"); + LLVM_DEBUG(dbgs() << "Deleting release: " << *OrigRelease << "\n"); } } @@ -1715,7 +1715,7 @@ DenseMap &BBStates, BlotMapVector &Retains, DenseMap &Releases, Module *M) { - DEBUG(dbgs() << "\n== ObjCARCOpt::PerformCodePlacement ==\n"); + LLVM_DEBUG(dbgs() << "\n== ObjCARCOpt::PerformCodePlacement ==\n"); bool AnyPairsCompletelyEliminated = false; SmallVector DeadInsts; @@ -1729,7 +1729,7 @@ Instruction *Retain = cast(V); - DEBUG(dbgs() << "Visiting: " << *Retain << "\n"); + LLVM_DEBUG(dbgs() << "Visiting: " << *Retain << "\n"); Value *Arg = GetArgRCIdentityRoot(Retain); @@ -1774,7 +1774,7 @@ /// Weak pointer optimizations. void ObjCARCOpt::OptimizeWeakCalls(Function &F) { - DEBUG(dbgs() << "\n== ObjCARCOpt::OptimizeWeakCalls ==\n"); + LLVM_DEBUG(dbgs() << "\n== ObjCARCOpt::OptimizeWeakCalls ==\n"); // First, do memdep-style RLE and S2L optimizations. We can't use memdep // itself because it uses AliasAnalysis and we need to do provenance @@ -1782,7 +1782,7 @@ for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ) { Instruction *Inst = &*I++; - DEBUG(dbgs() << "Visiting: " << *Inst << "\n"); + LLVM_DEBUG(dbgs() << "Visiting: " << *Inst << "\n"); ARCInstKind Class = GetBasicARCInstKind(Inst); if (Class != ARCInstKind::LoadWeak && @@ -2041,7 +2041,7 @@ if (!F.getReturnType()->isPointerTy()) return; - DEBUG(dbgs() << "\n== ObjCARCOpt::OptimizeReturns ==\n"); + LLVM_DEBUG(dbgs() << "\n== ObjCARCOpt::OptimizeReturns ==\n"); SmallPtrSet DependingInstructions; SmallPtrSet Visited; @@ -2050,7 +2050,7 @@ if (!Ret) continue; - DEBUG(dbgs() << "Visiting: " << *Ret << "\n"); + LLVM_DEBUG(dbgs() << "Visiting: " << *Ret << "\n"); const Value *Arg = GetRCIdentityRoot(Ret->getOperand(0)); @@ -2088,7 +2088,7 @@ // If so, we can zap the retain and autorelease. Changed = true; ++NumRets; - DEBUG(dbgs() << "Erasing: " << *Retain << "\nErasing: " + LLVM_DEBUG(dbgs() << "Erasing: " << *Retain << "\nErasing: " << *Autorelease << "\n"); EraseInstruction(Retain); EraseInstruction(Autorelease); @@ -2149,7 +2149,7 @@ Changed = false; - DEBUG(dbgs() << "<<< ObjCARCOpt: Visiting Function: " << F.getName() << " >>>" + LLVM_DEBUG(dbgs() << "<<< ObjCARCOpt: Visiting Function: " << F.getName() << " >>>" "\n"); PA.setAA(&getAnalysis().getAAResults()); @@ -2198,7 +2198,7 @@ } #endif - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n"); return Changed; } Index: lib/Transforms/ObjCARC/PtrState.cpp =================================================================== --- lib/Transforms/ObjCARC/PtrState.cpp +++ lib/Transforms/ObjCARC/PtrState.cpp @@ -126,22 +126,22 @@ //===----------------------------------------------------------------------===// void PtrState::SetKnownPositiveRefCount() { - DEBUG(dbgs() << " Setting Known Positive.\n"); + LLVM_DEBUG(dbgs() << " Setting Known Positive.\n"); KnownPositiveRefCount = true; } void PtrState::ClearKnownPositiveRefCount() { - DEBUG(dbgs() << " Clearing Known Positive.\n"); + LLVM_DEBUG(dbgs() << " Clearing Known Positive.\n"); KnownPositiveRefCount = false; } void PtrState::SetSeq(Sequence NewSeq) { - DEBUG(dbgs() << " Old: " << GetSeq() << "; New: " << NewSeq << "\n"); + LLVM_DEBUG(dbgs() << " Old: " << GetSeq() << "; New: " << NewSeq << "\n"); Seq = NewSeq; } void PtrState::ResetSequenceProgress(Sequence NewSeq) { - DEBUG(dbgs() << " Resetting sequence progress.\n"); + LLVM_DEBUG(dbgs() << " Resetting sequence progress.\n"); SetSeq(NewSeq); Partial = false; RRI.clear(); @@ -184,7 +184,7 @@ // simple and avoids adding overhead for the non-nested case. bool NestingDetected = false; if (GetSeq() == S_Release || GetSeq() == S_MovableRelease) { - DEBUG(dbgs() << " Found nested releases (i.e. a release pair)\n"); + LLVM_DEBUG(dbgs() << " Found nested releases (i.e. a release pair)\n"); NestingDetected = true; } @@ -234,7 +234,7 @@ if (!CanAlterRefCount(Inst, Ptr, PA, Class)) return false; - DEBUG(dbgs() << " CanAlterRefCount: Seq: " << S << "; " << *Ptr + LLVM_DEBUG(dbgs() << " CanAlterRefCount: Seq: " << S << "; " << *Ptr << "\n"); switch (S) { case S_Use: @@ -277,17 +277,17 @@ case S_Release: case S_MovableRelease: if (CanUse(Inst, Ptr, PA, Class)) { - DEBUG(dbgs() << " CanUse: Seq: " << GetSeq() << "; " << *Ptr + LLVM_DEBUG(dbgs() << " CanUse: Seq: " << GetSeq() << "; " << *Ptr << "\n"); SetSeqAndInsertReverseInsertPt(S_Use); } else if (Seq == S_Release && IsUser(Class)) { - DEBUG(dbgs() << " PreciseReleaseUse: Seq: " << GetSeq() << "; " + LLVM_DEBUG(dbgs() << " PreciseReleaseUse: Seq: " << GetSeq() << "; " << *Ptr << "\n"); // Non-movable releases depend on any possible objc pointer use. SetSeqAndInsertReverseInsertPt(S_Stop); } else if (const auto *Call = getreturnRVOperand(*Inst, Class)) { if (CanUse(Call, Ptr, PA, GetBasicARCInstKind(Call))) { - DEBUG(dbgs() << " ReleaseUse: Seq: " << GetSeq() << "; " + LLVM_DEBUG(dbgs() << " ReleaseUse: Seq: " << GetSeq() << "; " << *Ptr << "\n"); SetSeqAndInsertReverseInsertPt(S_Stop); } @@ -295,7 +295,7 @@ break; case S_Stop: if (CanUse(Inst, Ptr, PA, Class)) { - DEBUG(dbgs() << " PreciseStopUse: Seq: " << GetSeq() << "; " + LLVM_DEBUG(dbgs() << " PreciseStopUse: Seq: " << GetSeq() << "; " << *Ptr << "\n"); SetSeq(S_Use); } @@ -377,7 +377,7 @@ Class != ARCInstKind::IntrinsicUser) return false; - DEBUG(dbgs() << " CanAlterRefCount: Seq: " << GetSeq() << "; " << *Ptr + LLVM_DEBUG(dbgs() << " CanAlterRefCount: Seq: " << GetSeq() << "; " << *Ptr << "\n"); ClearKnownPositiveRefCount(); switch (GetSeq()) { @@ -410,7 +410,7 @@ case S_CanRelease: if (!CanUse(Inst, Ptr, PA, Class)) return; - DEBUG(dbgs() << " CanUse: Seq: " << GetSeq() << "; " << *Ptr + LLVM_DEBUG(dbgs() << " CanUse: Seq: " << GetSeq() << "; " << *Ptr << "\n"); SetSeq(S_Use); return; Index: lib/Transforms/Scalar/ADCE.cpp =================================================================== --- lib/Transforms/Scalar/ADCE.cpp +++ lib/Transforms/Scalar/ADCE.cpp @@ -298,7 +298,7 @@ auto &Info = BlockInfo[BB]; // Real function return if (isa(Info.Terminator)) { - DEBUG(dbgs() << "post-dom root child is a return: " << BB->getName() + LLVM_DEBUG(dbgs() << "post-dom root child is a return: " << BB->getName() << '\n';); continue; } @@ -356,7 +356,7 @@ // where we need to mark the inputs as live. while (!Worklist.empty()) { Instruction *LiveInst = Worklist.pop_back_val(); - DEBUG(dbgs() << "work live: "; LiveInst->dump();); + LLVM_DEBUG(dbgs() << "work live: "; LiveInst->dump();); for (Use &OI : LiveInst->operands()) if (Instruction *Inst = dyn_cast(OI)) @@ -378,7 +378,7 @@ if (Info.Live) return; - DEBUG(dbgs() << "mark live: "; I->dump()); + LLVM_DEBUG(dbgs() << "mark live: "; I->dump()); Info.Live = true; Worklist.push_back(I); @@ -402,7 +402,7 @@ void AggressiveDeadCodeElimination::markLive(BlockInfoType &BBInfo) { if (BBInfo.Live) return; - DEBUG(dbgs() << "mark block live: " << BBInfo.BB->getName() << '\n'); + LLVM_DEBUG(dbgs() << "mark block live: " << BBInfo.BB->getName() << '\n'); BBInfo.Live = true; if (!BBInfo.CFLive) { BBInfo.CFLive = true; @@ -463,7 +463,7 @@ if (BlocksWithDeadTerminators.empty()) return; - DEBUG({ + LLVM_DEBUG({ dbgs() << "new live blocks:\n"; for (auto *BB : NewLiveBlocks) dbgs() << "\t" << BB->getName() << '\n'; @@ -487,7 +487,7 @@ // Dead terminators which control live blocks are now marked live. for (auto *BB : IDFBlocks) { - DEBUG(dbgs() << "live control in: " << BB->getName() << '\n'); + LLVM_DEBUG(dbgs() << "live control in: " << BB->getName() << '\n'); markLive(BB->getTerminator()); } } @@ -501,7 +501,7 @@ // Updates control and dataflow around dead blocks updateDeadRegions(); - DEBUG({ + LLVM_DEBUG({ for (Instruction &I : instructions(F)) { // Check if the instruction is alive. if (isLive(&I)) @@ -555,7 +555,7 @@ // A dead region is the set of dead blocks with a common live post-dominator. void AggressiveDeadCodeElimination::updateDeadRegions() { - DEBUG({ + LLVM_DEBUG({ dbgs() << "final dead terminator blocks: " << '\n'; for (auto *BB : BlocksWithDeadTerminators) dbgs() << '\t' << BB->getName() @@ -607,7 +607,7 @@ // It might have happened that the same successor appeared multiple times // and the CFG edge wasn't really removed. if (Succ != PreferredSucc->BB) { - DEBUG(dbgs() << "ADCE: (Post)DomTree edge enqueued for deletion" + LLVM_DEBUG(dbgs() << "ADCE: (Post)DomTree edge enqueued for deletion" << BB->getName() << " -> " << Succ->getName() << "\n"); DeletedEdges.push_back({DominatorTree::Delete, BB, Succ}); } @@ -652,7 +652,7 @@ InstInfo[PredTerm].Live = true; return; } - DEBUG(dbgs() << "making unconditional " << BB->getName() << '\n'); + LLVM_DEBUG(dbgs() << "making unconditional " << BB->getName() << '\n'); NumBranchesRemoved += 1; IRBuilder<> Builder(PredTerm); auto *NewTerm = Builder.CreateBr(Target); Index: lib/Transforms/Scalar/AlignmentFromAssumptions.cpp =================================================================== --- lib/Transforms/Scalar/AlignmentFromAssumptions.cpp +++ lib/Transforms/Scalar/AlignmentFromAssumptions.cpp @@ -98,7 +98,7 @@ const SCEV *DiffAlign = SE->getMulExpr(DiffAlignDiv, AlignSCEV); const SCEV *DiffUnitsSCEV = SE->getMinusSCEV(DiffAlign, DiffSCEV); - DEBUG(dbgs() << "\talignment relative to " << *AlignSCEV << " is " << + LLVM_DEBUG(dbgs() << "\talignment relative to " << *AlignSCEV << " is " << *DiffUnitsSCEV << " (diff: " << *DiffSCEV << ")\n"); if (const SCEVConstant *ConstDUSCEV = @@ -139,12 +139,12 @@ // address. This address is displaced by the provided offset. DiffSCEV = SE->getMinusSCEV(DiffSCEV, OffSCEV); - DEBUG(dbgs() << "AFI: alignment of " << *Ptr << " relative to " << + LLVM_DEBUG(dbgs() << "AFI: alignment of " << *Ptr << " relative to " << *AlignSCEV << " and offset " << *OffSCEV << " using diff " << *DiffSCEV << "\n"); unsigned NewAlignment = getNewAlignmentDiff(DiffSCEV, AlignSCEV, SE); - DEBUG(dbgs() << "\tnew alignment: " << NewAlignment << "\n"); + LLVM_DEBUG(dbgs() << "\tnew alignment: " << NewAlignment << "\n"); if (NewAlignment) { return NewAlignment; @@ -160,7 +160,7 @@ const SCEV *DiffStartSCEV = DiffARSCEV->getStart(); const SCEV *DiffIncSCEV = DiffARSCEV->getStepRecurrence(*SE); - DEBUG(dbgs() << "\ttrying start/inc alignment using start " << + LLVM_DEBUG(dbgs() << "\ttrying start/inc alignment using start " << *DiffStartSCEV << " and inc " << *DiffIncSCEV << "\n"); // Now compute the new alignment using the displacement to the value in the @@ -170,25 +170,25 @@ NewAlignment = getNewAlignmentDiff(DiffStartSCEV, AlignSCEV, SE); unsigned NewIncAlignment = getNewAlignmentDiff(DiffIncSCEV, AlignSCEV, SE); - DEBUG(dbgs() << "\tnew start alignment: " << NewAlignment << "\n"); - DEBUG(dbgs() << "\tnew inc alignment: " << NewIncAlignment << "\n"); + LLVM_DEBUG(dbgs() << "\tnew start alignment: " << NewAlignment << "\n"); + LLVM_DEBUG(dbgs() << "\tnew inc alignment: " << NewIncAlignment << "\n"); if (!NewAlignment || !NewIncAlignment) { return 0; } else if (NewAlignment > NewIncAlignment) { if (NewAlignment % NewIncAlignment == 0) { - DEBUG(dbgs() << "\tnew start/inc alignment: " << + LLVM_DEBUG(dbgs() << "\tnew start/inc alignment: " << NewIncAlignment << "\n"); return NewIncAlignment; } } else if (NewIncAlignment > NewAlignment) { if (NewIncAlignment % NewAlignment == 0) { - DEBUG(dbgs() << "\tnew start/inc alignment: " << + LLVM_DEBUG(dbgs() << "\tnew start/inc alignment: " << NewAlignment << "\n"); return NewAlignment; } } else if (NewIncAlignment == NewAlignment) { - DEBUG(dbgs() << "\tnew start/inc alignment: " << + LLVM_DEBUG(dbgs() << "\tnew start/inc alignment: " << NewAlignment << "\n"); return NewAlignment; } @@ -358,7 +358,7 @@ unsigned AltSrcAlignment = (SI == NewSrcAlignments.end()) ? 0 : SI->second; - DEBUG(dbgs() << "\tmem trans: " << NewDestAlignment << " " << + LLVM_DEBUG(dbgs() << "\tmem trans: " << NewDestAlignment << " " << AltDestAlignment << " " << NewSrcAlignment << " " << AltSrcAlignment << "\n"); Index: lib/Transforms/Scalar/BDCE.cpp =================================================================== --- lib/Transforms/Scalar/BDCE.cpp +++ lib/Transforms/Scalar/BDCE.cpp @@ -100,7 +100,7 @@ // For live instructions that have all dead bits, first make them dead by // replacing all uses with something else. Then, if they don't need to // remain live (because they have side effects, etc.) we can remove them. - DEBUG(dbgs() << "BDCE: Trivializing: " << I << " (all bits dead)\n"); + LLVM_DEBUG(dbgs() << "BDCE: Trivializing: " << I << " (all bits dead)\n"); clearAssumptionsOfUsers(&I, DB); Index: lib/Transforms/Scalar/CallSiteSplitting.cpp =================================================================== --- lib/Transforms/Scalar/CallSiteSplitting.cpp +++ lib/Transforms/Scalar/CallSiteSplitting.cpp @@ -262,7 +262,7 @@ if (Instr->getNumUses()) CallPN = PHINode::Create(Instr->getType(), Preds.size(), "phi.call"); - DEBUG(dbgs() << "split call-site : " << *Instr << " into \n"); + LLVM_DEBUG(dbgs() << "split call-site : " << *Instr << " into \n"); assert(Preds.size() == 2 && "The ValueToValueMaps array has size 2."); // ValueToValueMapTy is neither copy nor moveable, so we use a simple array @@ -289,7 +289,7 @@ ++ArgNo; } } - DEBUG(dbgs() << " " << *NewCI << " in " << SplitBlock->getName() + LLVM_DEBUG(dbgs() << " " << *NewCI << " in " << SplitBlock->getName() << "\n"); if (CallPN) CallPN->addIncoming(NewCI, SplitBlock); Index: lib/Transforms/Scalar/ConstantHoisting.cpp =================================================================== --- lib/Transforms/Scalar/ConstantHoisting.cpp +++ lib/Transforms/Scalar/ConstantHoisting.cpp @@ -132,8 +132,8 @@ if (skipFunction(Fn)) return false; - DEBUG(dbgs() << "********** Begin Constant Hoisting **********\n"); - DEBUG(dbgs() << "********** Function: " << Fn.getName() << '\n'); + LLVM_DEBUG(dbgs() << "********** Begin Constant Hoisting **********\n"); + LLVM_DEBUG(dbgs() << "********** Function: " << Fn.getName() << '\n'); bool MadeChange = Impl.runImpl(Fn, getAnalysis().getTTI(Fn), @@ -144,11 +144,11 @@ Fn.getEntryBlock()); if (MadeChange) { - DEBUG(dbgs() << "********** Function after Constant Hoisting: " + LLVM_DEBUG(dbgs() << "********** Function after Constant Hoisting: " << Fn.getName() << '\n'); - DEBUG(dbgs() << Fn); + LLVM_DEBUG(dbgs() << Fn); } - DEBUG(dbgs() << "********** End Constant Hoisting **********\n"); + LLVM_DEBUG(dbgs() << "********** End Constant Hoisting **********\n"); return MadeChange; } @@ -364,7 +364,7 @@ Itr->second = ConstCandVec.size() - 1; } ConstCandVec[Itr->second].addUser(Inst, Idx, Cost); - DEBUG(if (isa(Inst->getOperand(Idx))) + LLVM_DEBUG(if (isa(Inst->getOperand(Idx))) dbgs() << "Collect constant " << *ConstInt << " from " << *Inst << " with cost " << Cost << '\n'; else @@ -501,20 +501,20 @@ return NumUses; } - DEBUG(dbgs() << "== Maximize constants in range ==\n"); + LLVM_DEBUG(dbgs() << "== Maximize constants in range ==\n"); int MaxCost = -1; for (auto ConstCand = S; ConstCand != E; ++ConstCand) { auto Value = ConstCand->ConstInt->getValue(); Type *Ty = ConstCand->ConstInt->getType(); int Cost = 0; NumUses += ConstCand->Uses.size(); - DEBUG(dbgs() << "= Constant: " << ConstCand->ConstInt->getValue() << "\n"); + LLVM_DEBUG(dbgs() << "= Constant: " << ConstCand->ConstInt->getValue() << "\n"); for (auto User : ConstCand->Uses) { unsigned Opcode = User.Inst->getOpcode(); unsigned OpndIdx = User.OpndIdx; Cost += TTI->getIntImmCost(Opcode, OpndIdx, Value, Ty); - DEBUG(dbgs() << "Cost: " << Cost << "\n"); + LLVM_DEBUG(dbgs() << "Cost: " << Cost << "\n"); for (auto C2 = S; C2 != E; ++C2) { Optional Diff = calculateOffsetDiff( @@ -524,17 +524,17 @@ const int ImmCosts = TTI->getIntImmCodeSizeCost(Opcode, OpndIdx, Diff.getValue(), Ty); Cost -= ImmCosts; - DEBUG(dbgs() << "Offset " << Diff.getValue() << " " + LLVM_DEBUG(dbgs() << "Offset " << Diff.getValue() << " " << "has penalty: " << ImmCosts << "\n" << "Adjusted cost: " << Cost << "\n"); } } } - DEBUG(dbgs() << "Cumulative cost: " << Cost << "\n"); + LLVM_DEBUG(dbgs() << "Cumulative cost: " << Cost << "\n"); if (Cost > MaxCost) { MaxCost = Cost; MaxCostItr = ConstCand; - DEBUG(dbgs() << "New candidate: " << MaxCostItr->ConstInt->getValue() + LLVM_DEBUG(dbgs() << "New candidate: " << MaxCostItr->ConstInt->getValue() << "\n"); } } @@ -641,7 +641,7 @@ Mat = BinaryOperator::Create(Instruction::Add, Base, Offset, "const_mat", InsertionPt); - DEBUG(dbgs() << "Materialize constant (" << *Base->getOperand(0) + LLVM_DEBUG(dbgs() << "Materialize constant (" << *Base->getOperand(0) << " + " << *Offset << ") in BB " << Mat->getParent()->getName() << '\n' << *Mat << '\n'); Mat->setDebugLoc(ConstUser.Inst->getDebugLoc()); @@ -650,10 +650,10 @@ // Visit constant integer. if (isa(Opnd)) { - DEBUG(dbgs() << "Update: " << *ConstUser.Inst << '\n'); + LLVM_DEBUG(dbgs() << "Update: " << *ConstUser.Inst << '\n'); if (!updateOperand(ConstUser.Inst, ConstUser.OpndIdx, Mat) && Offset) Mat->eraseFromParent(); - DEBUG(dbgs() << "To : " << *ConstUser.Inst << '\n'); + LLVM_DEBUG(dbgs() << "To : " << *ConstUser.Inst << '\n'); return; } @@ -669,13 +669,13 @@ ClonedCastInst->insertAfter(CastInst); // Use the same debug location as the original cast instruction. ClonedCastInst->setDebugLoc(CastInst->getDebugLoc()); - DEBUG(dbgs() << "Clone instruction: " << *CastInst << '\n' + LLVM_DEBUG(dbgs() << "Clone instruction: " << *CastInst << '\n' << "To : " << *ClonedCastInst << '\n'); } - DEBUG(dbgs() << "Update: " << *ConstUser.Inst << '\n'); + LLVM_DEBUG(dbgs() << "Update: " << *ConstUser.Inst << '\n'); updateOperand(ConstUser.Inst, ConstUser.OpndIdx, ClonedCastInst); - DEBUG(dbgs() << "To : " << *ConstUser.Inst << '\n'); + LLVM_DEBUG(dbgs() << "To : " << *ConstUser.Inst << '\n'); return; } @@ -689,15 +689,15 @@ // Use the same debug location as the instruction we are about to update. ConstExprInst->setDebugLoc(ConstUser.Inst->getDebugLoc()); - DEBUG(dbgs() << "Create instruction: " << *ConstExprInst << '\n' + LLVM_DEBUG(dbgs() << "Create instruction: " << *ConstExprInst << '\n' << "From : " << *ConstExpr << '\n'); - DEBUG(dbgs() << "Update: " << *ConstUser.Inst << '\n'); + LLVM_DEBUG(dbgs() << "Update: " << *ConstUser.Inst << '\n'); if (!updateOperand(ConstUser.Inst, ConstUser.OpndIdx, ConstExprInst)) { ConstExprInst->eraseFromParent(); if (Offset) Mat->eraseFromParent(); } - DEBUG(dbgs() << "To : " << *ConstUser.Inst << '\n'); + LLVM_DEBUG(dbgs() << "To : " << *ConstUser.Inst << '\n'); return; } } @@ -720,7 +720,7 @@ Base->setDebugLoc(IP->getDebugLoc()); - DEBUG(dbgs() << "Hoist constant (" << *ConstInfo.BaseConstant + LLVM_DEBUG(dbgs() << "Hoist constant (" << *ConstInfo.BaseConstant << ") to BB " << IP->getParent()->getName() << '\n' << *Base << '\n'); Index: lib/Transforms/Scalar/CorrelatedValuePropagation.cpp =================================================================== --- lib/Transforms/Scalar/CorrelatedValuePropagation.cpp +++ lib/Transforms/Scalar/CorrelatedValuePropagation.cpp @@ -170,7 +170,7 @@ V = SI->getTrueValue(); } - DEBUG(dbgs() << "CVP: Threading PHI over " << *SI << '\n'); + LLVM_DEBUG(dbgs() << "CVP: Threading PHI over " << *SI << '\n'); } P->setIncomingValue(i, V); Index: lib/Transforms/Scalar/DeadStoreElimination.cpp =================================================================== --- lib/Transforms/Scalar/DeadStoreElimination.cpp +++ lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -411,7 +411,7 @@ // Insert our part of the overlap into the map. auto &IM = IOL[DepWrite]; - DEBUG(dbgs() << "DSE: Partial overwrite: Earlier [" << EarlierOff << ", " << + LLVM_DEBUG(dbgs() << "DSE: Partial overwrite: Earlier [" << EarlierOff << ", " << int64_t(EarlierOff + Earlier.Size) << ") Later [" << LaterOff << ", " << int64_t(LaterOff + Later.Size) << ")\n"); @@ -450,7 +450,7 @@ ILI = IM.begin(); if (ILI->second <= EarlierOff && ILI->first >= int64_t(EarlierOff + Earlier.Size)) { - DEBUG(dbgs() << "DSE: Full overwrite from partials: Earlier [" << + LLVM_DEBUG(dbgs() << "DSE: Full overwrite from partials: Earlier [" << EarlierOff << ", " << int64_t(EarlierOff + Earlier.Size) << ") Composite Later [" << @@ -465,7 +465,7 @@ if (EnablePartialStoreMerging && LaterOff >= EarlierOff && int64_t(EarlierOff + Earlier.Size) > LaterOff && uint64_t(LaterOff - EarlierOff) + Later.Size <= Earlier.Size) { - DEBUG(dbgs() << "DSE: Partial overwrite an earlier load [" << EarlierOff + LLVM_DEBUG(dbgs() << "DSE: Partial overwrite an earlier load [" << EarlierOff << ", " << int64_t(EarlierOff + Earlier.Size) << ") by a later store [" << LaterOff << ", " << int64_t(LaterOff + Later.Size) << ")\n"); @@ -668,7 +668,7 @@ if (!AA->isMustAlias(F->getArgOperand(0), DepPointer)) break; - DEBUG(dbgs() << "DSE: Dead Store to soon to be freed memory:\n DEAD: " + LLVM_DEBUG(dbgs() << "DSE: Dead Store to soon to be freed memory:\n DEAD: " << *Dependency << '\n'); // DCE instructions only used to calculate that store. @@ -778,7 +778,7 @@ if (AllDead) { Instruction *Dead = &*BBI; - DEBUG(dbgs() << "DSE: Dead Store at End of Block:\n DEAD: " + LLVM_DEBUG(dbgs() << "DSE: Dead Store at End of Block:\n DEAD: " << *Dead << "\n Objects: "; for (SmallVectorImpl::iterator I = Pointers.begin(), E = Pointers.end(); I != E; ++I) { @@ -798,7 +798,7 @@ // Remove any dead non-memory-mutating instructions. if (isInstructionTriviallyDead(&*BBI, TLI)) { - DEBUG(dbgs() << "DSE: Removing trivially dead instruction:\n DEAD: " + LLVM_DEBUG(dbgs() << "DSE: Removing trivially dead instruction:\n DEAD: " << *&*BBI << '\n'); deleteDeadInstruction(&*BBI, &BBI, *MD, *TLI, IOL, InstrOrdering, &DeadStackObjects); ++NumFastOther; @@ -898,7 +898,7 @@ !((EarlierWriteAlign != 0) && LaterOffset % EarlierWriteAlign == 0)) return false; - DEBUG(dbgs() << "DSE: Remove Dead Store:\n OW " + LLVM_DEBUG(dbgs() << "DSE: Remove Dead Store:\n OW " << (IsOverwriteEnd ? "END" : "BEGIN") << ": " << *EarlierWrite << "\n KILLER (offset " << LaterOffset << ", " << EarlierSize << ")\n"); @@ -1010,7 +1010,7 @@ if (SI->getPointerOperand() == DepLoad->getPointerOperand() && isRemovable(SI) && memoryIsNotModifiedBetween(DepLoad, SI, AA)) { - DEBUG(dbgs() << "DSE: Remove Store Of Load from same pointer:\n LOAD: " + LLVM_DEBUG(dbgs() << "DSE: Remove Store Of Load from same pointer:\n LOAD: " << *DepLoad << "\n STORE: " << *SI << '\n'); deleteDeadInstruction(SI, &BBI, *MD, *TLI, IOL, InstrOrdering); @@ -1027,7 +1027,7 @@ if (UnderlyingPointer && isCallocLikeFn(UnderlyingPointer, TLI) && memoryIsNotModifiedBetween(UnderlyingPointer, SI, AA)) { - DEBUG( + LLVM_DEBUG( dbgs() << "DSE: Remove null store to the calloc'ed object:\n DEAD: " << *Inst << "\n OBJECT: " << *UnderlyingPointer << '\n'); @@ -1159,7 +1159,7 @@ isOverwrite(Loc, DepLoc, DL, *TLI, DepWriteOffset, InstWriteOffset, DepWrite, IOL); if (OR == OW_Complete) { - DEBUG(dbgs() << "DSE: Remove Dead Store:\n DEAD: " + LLVM_DEBUG(dbgs() << "DSE: Remove Dead Store:\n DEAD: " << *DepWrite << "\n KILLER: " << *Inst << '\n'); // Delete the store and now-dead instructions that feed it. @@ -1218,7 +1218,7 @@ // store, shifted appropriately. APInt Merged = (EarlierValue & ~Mask) | (LaterValue << LShiftAmount); - DEBUG(dbgs() << "DSE: Merge Stores:\n Earlier: " << *DepWrite + LLVM_DEBUG(dbgs() << "DSE: Merge Stores:\n Earlier: " << *DepWrite << "\n Later: " << *Inst << "\n Merged Value: " << Merged << '\n'); Index: lib/Transforms/Scalar/EarlyCSE.cpp =================================================================== --- lib/Transforms/Scalar/EarlyCSE.cpp +++ lib/Transforms/Scalar/EarlyCSE.cpp @@ -690,7 +690,7 @@ ? ConstantInt::getTrue(BB->getContext()) : ConstantInt::getFalse(BB->getContext()); AvailableValues.insert(CondInst, TorF); - DEBUG(dbgs() << "EarlyCSE CVP: Add conditional value for '" + LLVM_DEBUG(dbgs() << "EarlyCSE CVP: Add conditional value for '" << CondInst->getName() << "' as " << *TorF << " in " << BB->getName() << "\n"); // Replace all dominated uses with the known value. @@ -716,7 +716,7 @@ // Dead instructions should just be removed. if (isInstructionTriviallyDead(Inst, &TLI)) { - DEBUG(dbgs() << "EarlyCSE DCE: " << *Inst << '\n'); + LLVM_DEBUG(dbgs() << "EarlyCSE DCE: " << *Inst << '\n'); salvageDebugInfo(*Inst); removeMSSA(Inst); Inst->eraseFromParent(); @@ -733,16 +733,16 @@ auto *CondI = dyn_cast(cast(Inst)->getArgOperand(0)); if (CondI && SimpleValue::canHandle(CondI)) { - DEBUG(dbgs() << "EarlyCSE considering assumption: " << *Inst << '\n'); + LLVM_DEBUG(dbgs() << "EarlyCSE considering assumption: " << *Inst << '\n'); AvailableValues.insert(CondI, ConstantInt::getTrue(BB->getContext())); } else - DEBUG(dbgs() << "EarlyCSE skipping assumption: " << *Inst << '\n'); + LLVM_DEBUG(dbgs() << "EarlyCSE skipping assumption: " << *Inst << '\n'); continue; } // Skip sideeffect intrinsics, for the same reason as assume intrinsics. if (match(Inst, m_Intrinsic())) { - DEBUG(dbgs() << "EarlyCSE skipping sideeffect: " << *Inst << '\n'); + LLVM_DEBUG(dbgs() << "EarlyCSE skipping sideeffect: " << *Inst << '\n'); continue; } @@ -768,7 +768,7 @@ // Is the condition known to be true? if (isa(KnownCond) && cast(KnownCond)->isOne()) { - DEBUG(dbgs() << "EarlyCSE removing guard: " << *Inst << '\n'); + LLVM_DEBUG(dbgs() << "EarlyCSE removing guard: " << *Inst << '\n'); removeMSSA(Inst); Inst->eraseFromParent(); Changed = true; @@ -793,7 +793,7 @@ // If the instruction can be simplified (e.g. X+0 = X) then replace it with // its simpler value. if (Value *V = SimplifyInstruction(Inst, SQ)) { - DEBUG(dbgs() << "EarlyCSE Simplify: " << *Inst << " to: " << *V << '\n'); + LLVM_DEBUG(dbgs() << "EarlyCSE Simplify: " << *Inst << " to: " << *V << '\n'); bool Killed = false; if (!Inst->use_empty()) { Inst->replaceAllUsesWith(V); @@ -815,7 +815,7 @@ if (SimpleValue::canHandle(Inst)) { // See if the instruction has an available value. If so, use it. if (Value *V = AvailableValues.lookup(Inst)) { - DEBUG(dbgs() << "EarlyCSE CSE: " << *Inst << " to: " << *V << '\n'); + LLVM_DEBUG(dbgs() << "EarlyCSE CSE: " << *Inst << " to: " << *V << '\n'); if (auto *I = dyn_cast(V)) I->andIRFlags(Inst); Inst->replaceAllUsesWith(V); @@ -860,7 +860,7 @@ InVal.DefInst, Inst))) { Value *Op = getOrCreateResult(InVal.DefInst, Inst->getType()); if (Op != nullptr) { - DEBUG(dbgs() << "EarlyCSE CSE LOAD: " << *Inst + LLVM_DEBUG(dbgs() << "EarlyCSE CSE LOAD: " << *Inst << " to: " << *InVal.DefInst << '\n'); if (!Inst->use_empty()) Inst->replaceAllUsesWith(Op); @@ -899,7 +899,7 @@ if (InVal.first != nullptr && isSameMemGeneration(InVal.second, CurrentGeneration, InVal.first, Inst)) { - DEBUG(dbgs() << "EarlyCSE CSE CALL: " << *Inst + LLVM_DEBUG(dbgs() << "EarlyCSE CSE CALL: " << *Inst << " to: " << *InVal.first << '\n'); if (!Inst->use_empty()) Inst->replaceAllUsesWith(InVal.first); @@ -950,7 +950,7 @@ MemInst.getPointerOperand() || MSSA) && "can't have an intervening store if not using MemorySSA!"); - DEBUG(dbgs() << "EarlyCSE DSE (writeback): " << *Inst << '\n'); + LLVM_DEBUG(dbgs() << "EarlyCSE DSE (writeback): " << *Inst << '\n'); removeMSSA(Inst); Inst->eraseFromParent(); Changed = true; @@ -981,7 +981,7 @@ !LastStoreMemInst.isVolatile() && "Violated invariant"); if (LastStoreMemInst.isMatchingMemLoc(MemInst)) { - DEBUG(dbgs() << "EarlyCSE DEAD STORE: " << *LastStore + LLVM_DEBUG(dbgs() << "EarlyCSE DEAD STORE: " << *LastStore << " due to: " << *Inst << '\n'); removeMSSA(LastStore); LastStore->eraseFromParent(); Index: lib/Transforms/Scalar/Float2Int.cpp =================================================================== --- lib/Transforms/Scalar/Float2Int.cpp +++ lib/Transforms/Scalar/Float2Int.cpp @@ -138,7 +138,7 @@ // Helper - mark I as having been traversed, having range R. void Float2IntPass::seen(Instruction *I, ConstantRange R) { - DEBUG(dbgs() << "F2I: " << *I << ":" << R << "\n"); + LLVM_DEBUG(dbgs() << "F2I: " << *I << ":" << R << "\n"); auto IT = SeenInsts.find(I); if (IT != SeenInsts.end()) IT->second = std::move(R); @@ -359,7 +359,7 @@ for (User *U : I->users()) { Instruction *UI = dyn_cast(U); if (!UI || SeenInsts.find(UI) == SeenInsts.end()) { - DEBUG(dbgs() << "F2I: Failing because of " << *U << "\n"); + LLVM_DEBUG(dbgs() << "F2I: Failing because of " << *U << "\n"); Fail = true; break; } @@ -380,7 +380,7 @@ // lower limits, plus one so it can be signed. unsigned MinBW = std::max(R.getLower().getMinSignedBits(), R.getUpper().getMinSignedBits()) + 1; - DEBUG(dbgs() << "F2I: MinBitwidth=" << MinBW << ", R: " << R << "\n"); + LLVM_DEBUG(dbgs() << "F2I: MinBitwidth=" << MinBW << ", R: " << R << "\n"); // If we've run off the realms of the exactly representable integers, // the floating point result will differ from an integer approximation. @@ -391,11 +391,11 @@ unsigned MaxRepresentableBits = APFloat::semanticsPrecision(ConvertedToTy->getFltSemantics()) - 1; if (MinBW > MaxRepresentableBits) { - DEBUG(dbgs() << "F2I: Value not guaranteed to be representable!\n"); + LLVM_DEBUG(dbgs() << "F2I: Value not guaranteed to be representable!\n"); continue; } if (MinBW > 64) { - DEBUG(dbgs() << "F2I: Value requires more than 64 bits to represent!\n"); + LLVM_DEBUG(dbgs() << "F2I: Value requires more than 64 bits to represent!\n"); continue; } @@ -490,7 +490,7 @@ } bool Float2IntPass::runImpl(Function &F) { - DEBUG(dbgs() << "F2I: Looking at function " << F.getName() << "\n"); + LLVM_DEBUG(dbgs() << "F2I: Looking at function " << F.getName() << "\n"); // Clear out all state. ECs = EquivalenceClasses(); SeenInsts.clear(); Index: lib/Transforms/Scalar/GVN.cpp =================================================================== --- lib/Transforms/Scalar/GVN.cpp +++ lib/Transforms/Scalar/GVN.cpp @@ -783,7 +783,7 @@ if (Res->getType() != LoadTy) { Res = getStoreValueForLoad(Res, Offset, LoadTy, InsertPt, DL); - DEBUG(dbgs() << "GVN COERCED NONLOCAL VAL:\nOffset: " << Offset << " " + LLVM_DEBUG(dbgs() << "GVN COERCED NONLOCAL VAL:\nOffset: " << Offset << " " << *getSimpleValue() << '\n' << *Res << '\n' << "\n\n\n"); } @@ -799,7 +799,7 @@ // but then there all of the operations based on it would need to be // rehashed. Just leave the dead load around. gvn.getMemDep().removeInstruction(Load); - DEBUG(dbgs() << "GVN COERCED NONLOCAL LOAD:\nOffset: " << Offset << " " + LLVM_DEBUG(dbgs() << "GVN COERCED NONLOCAL LOAD:\nOffset: " << Offset << " " << *getCoercedLoadValue() << '\n' << *Res << '\n' << "\n\n\n"); @@ -807,12 +807,12 @@ } else if (isMemIntrinValue()) { Res = getMemInstValueForLoad(getMemIntrinValue(), Offset, LoadTy, InsertPt, DL); - DEBUG(dbgs() << "GVN COERCED NONLOCAL MEM INTRIN:\nOffset: " << Offset + LLVM_DEBUG(dbgs() << "GVN COERCED NONLOCAL MEM INTRIN:\nOffset: " << Offset << " " << *getMemIntrinValue() << '\n' << *Res << '\n' << "\n\n\n"); } else { assert(isUndefValue() && "Should be UndefVal"); - DEBUG(dbgs() << "GVN COERCED NONLOCAL Undef:\n";); + LLVM_DEBUG(dbgs() << "GVN COERCED NONLOCAL Undef:\n";); return UndefValue::get(LoadTy); } assert(Res && "failed to materialize?"); @@ -914,7 +914,7 @@ } } // Nothing known about this clobber, have to be conservative - DEBUG( + LLVM_DEBUG( // fast print dep, using operator<< on instruction is too slow. dbgs() << "GVN: load "; LI->printAsOperand(dbgs()); @@ -978,7 +978,7 @@ } // Unknown def - must be conservative - DEBUG( + LLVM_DEBUG( // fast print dep, using operator<< on instruction is too slow. dbgs() << "GVN: load "; LI->printAsOperand(dbgs()); @@ -1113,7 +1113,7 @@ // If any predecessor block is an EH pad that does not allow non-PHI // instructions before the terminator, we can't PRE the load. if (Pred->getTerminator()->isEHPad()) { - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "COULD NOT PRE LOAD BECAUSE OF AN EH PAD PREDECESSOR '" << Pred->getName() << "': " << *LI << '\n'); return false; @@ -1125,13 +1125,13 @@ if (Pred->getTerminator()->getNumSuccessors() != 1) { if (isa(Pred->getTerminator())) { - DEBUG(dbgs() << "COULD NOT PRE LOAD BECAUSE OF INDBR CRITICAL EDGE '" + LLVM_DEBUG(dbgs() << "COULD NOT PRE LOAD BECAUSE OF INDBR CRITICAL EDGE '" << Pred->getName() << "': " << *LI << '\n'); return false; } if (LoadBB->isEHPad()) { - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "COULD NOT PRE LOAD BECAUSE OF AN EH PAD CRITICAL EDGE '" << Pred->getName() << "': " << *LI << '\n'); return false; @@ -1161,7 +1161,7 @@ BasicBlock *NewPred = splitCriticalEdges(OrigPred, LoadBB); assert(!PredLoads.count(OrigPred) && "Split edges shouldn't be in map!"); PredLoads[NewPred] = nullptr; - DEBUG(dbgs() << "Split critical edge " << OrigPred->getName() << "->" + LLVM_DEBUG(dbgs() << "Split critical edge " << OrigPred->getName() << "->" << LoadBB->getName() << '\n'); } @@ -1186,7 +1186,7 @@ // If we couldn't find or insert a computation of this phi translated value, // we fail PRE. if (!LoadPtr) { - DEBUG(dbgs() << "COULDN'T INSERT PHI TRANSLATED VALUE OF: " + LLVM_DEBUG(dbgs() << "COULDN'T INSERT PHI TRANSLATED VALUE OF: " << *LI->getPointerOperand() << "\n"); CanDoPRE = false; break; @@ -1208,8 +1208,8 @@ // Okay, we can eliminate this load by inserting a reload in the predecessor // and using PHI construction to get the value in the other predecessors, do // it. - DEBUG(dbgs() << "GVN REMOVING PRE LOAD: " << *LI << '\n'); - DEBUG(if (!NewInsts.empty()) + LLVM_DEBUG(dbgs() << "GVN REMOVING PRE LOAD: " << *LI << '\n'); + LLVM_DEBUG(if (!NewInsts.empty()) dbgs() << "INSERTED " << NewInsts.size() << " INSTS: " << *NewInsts.back() << '\n'); @@ -1262,7 +1262,7 @@ ValuesPerBlock.push_back(AvailableValueInBlock::get(UnavailablePred, NewLoad)); MD->invalidateCachedPointerInfo(LoadPtr); - DEBUG(dbgs() << "GVN INSERTED " << *NewLoad << '\n'); + LLVM_DEBUG(dbgs() << "GVN INSERTED " << *NewLoad << '\n'); } // Perform PHI construction. @@ -1320,7 +1320,7 @@ // clobber in the current block. Reject this early. if (NumDeps == 1 && !Deps[0].getResult().isDef() && !Deps[0].getResult().isClobber()) { - DEBUG( + LLVM_DEBUG( dbgs() << "GVN: non-local load "; LI->printAsOperand(dbgs()); dbgs() << " has unknown dependencies\n"; @@ -1353,7 +1353,7 @@ // load, then it is fully redundant and we can use PHI insertion to compute // its value. Insert PHIs and remove the fully redundant value now. if (UnavailableBlocks.empty()) { - DEBUG(dbgs() << "GVN REMOVING NONLOCAL LOAD: " << *LI << '\n'); + LLVM_DEBUG(dbgs() << "GVN REMOVING NONLOCAL LOAD: " << *LI << '\n'); // Perform PHI construction. Value *V = ConstructSSAForLoadSet(LI, ValuesPerBlock, *this); @@ -1506,7 +1506,7 @@ // Only handle the local case below if (!Dep.isDef() && !Dep.isClobber()) { // This might be a NonFuncLocal or an Unknown - DEBUG( + LLVM_DEBUG( // fast print dep, using operator<< on instruction is too slow. dbgs() << "GVN: load "; L->printAsOperand(dbgs()); @@ -1695,7 +1695,7 @@ if (it != ReplaceWithConstMap.end()) { assert(!isa(Operand) && "Replacing constants with constants is invalid"); - DEBUG(dbgs() << "GVN replacing: " << *Operand << " with " << *it->second + LLVM_DEBUG(dbgs() << "GVN replacing: " << *Operand << " with " << *it->second << " in instruction " << *Instr << '\n'); Instr->setOperand(OpNum, it->second); Changed = true; @@ -2038,7 +2038,7 @@ unsigned Iteration = 0; while (ShouldContinue) { - DEBUG(dbgs() << "GVN iteration: " << Iteration << "\n"); + LLVM_DEBUG(dbgs() << "GVN iteration: " << Iteration << "\n"); ShouldContinue = iterateOnFunction(F); Changed |= ShouldContinue; ++Iteration; @@ -2104,10 +2104,10 @@ const Instruction *MaybeFirstICF = FirstImplicitControlFlowInsts.lookup(BB); for (auto *I : InstrsToErase) { assert(I->getParent() == BB && "Removing instruction from wrong block?"); - DEBUG(dbgs() << "GVN removed: " << *I << '\n'); + LLVM_DEBUG(dbgs() << "GVN removed: " << *I << '\n'); salvageDebugInfo(*I); if (MD) MD->removeInstruction(I); - DEBUG(verifyRemoved(I)); + LLVM_DEBUG(verifyRemoved(I)); if (MaybeFirstICF == I) { // We have erased the first ICF in block. The map needs to be updated. InvalidateImplicitCF = true; @@ -2289,7 +2289,7 @@ PREInstr = CurInst->clone(); if (!performScalarPREInsertion(PREInstr, PREPred, CurrentBlock, ValNo)) { // If we failed insertion, make sure we remove the instruction. - DEBUG(verifyRemoved(PREInstr)); + LLVM_DEBUG(verifyRemoved(PREInstr)); PREInstr->deleteValue(); return false; } @@ -2327,10 +2327,10 @@ VN.erase(CurInst); removeFromLeaderTable(ValNo, CurInst, CurrentBlock); - DEBUG(dbgs() << "GVN PRE removed: " << *CurInst << '\n'); + LLVM_DEBUG(dbgs() << "GVN PRE removed: " << *CurInst << '\n'); if (MD) MD->removeInstruction(CurInst); - DEBUG(verifyRemoved(CurInst)); + LLVM_DEBUG(verifyRemoved(CurInst)); bool InvalidateImplicitCF = FirstImplicitControlFlowInsts.lookup(CurInst->getParent()) == CurInst; // FIXME: Intended to be markInstructionForDeletion(CurInst), but it causes Index: lib/Transforms/Scalar/GVNHoist.cpp =================================================================== --- lib/Transforms/Scalar/GVNHoist.cpp +++ lib/Transforms/Scalar/GVNHoist.cpp @@ -622,7 +622,7 @@ // Iterate in reverse order to keep lower ranked values on the top. for (std::pair &VI : reverse(it1->second)) { // Get the value of instruction I - DEBUG(dbgs() << "\nPushing on stack: " << *VI.second); + LLVM_DEBUG(dbgs() << "\nPushing on stack: " << *VI.second); RenameStack[VI.first].push_back(VI.second); } } @@ -636,7 +636,7 @@ if (P == CHIBBs.end()) { continue; } - DEBUG(dbgs() << "\nLooking at CHIs in: " << Pred->getName();); + LLVM_DEBUG(dbgs() << "\nLooking at CHIs in: " << Pred->getName();); // A CHI is found (BB -> Pred is an edge in the CFG) // Pop the stack until Top(V) = Ve. auto &VCHI = P->second; @@ -651,7 +651,7 @@ DT->properlyDominates(Pred, si->second.back()->getParent())) { C.Dest = BB; // Assign the edge C.I = si->second.pop_back_val(); // Assign the argument - DEBUG(dbgs() << "\nCHI Inserted in BB: " << C.Dest->getName() + LLVM_DEBUG(dbgs() << "\nCHI Inserted in BB: " << C.Dest->getName() << *C.I << ", VN: " << C.VN.first << ", " << C.VN.second); } @@ -798,7 +798,7 @@ // Ignore spurious PDFs. if (DT->properlyDominates(IDFB, V[i]->getParent())) { OutValue[IDFB].push_back(C); - DEBUG(dbgs() << "\nInsertion a CHI for BB: " << IDFB->getName() + LLVM_DEBUG(dbgs() << "\nInsertion a CHI for BB: " << IDFB->getName() << ", for Insn: " << *V[i]); } } Index: lib/Transforms/Scalar/GVNSink.cpp =================================================================== --- lib/Transforms/Scalar/GVNSink.cpp +++ lib/Transforms/Scalar/GVNSink.cpp @@ -561,7 +561,7 @@ GVNSink() = default; bool run(Function &F) { - DEBUG(dbgs() << "GVNSink: running on function @" << F.getName() << "\n"); + LLVM_DEBUG(dbgs() << "GVNSink: running on function @" << F.getName() << "\n"); unsigned NumSunk = 0; ReversePostOrderTraversal RPOT(&F); @@ -629,7 +629,7 @@ LockstepReverseIterator &LRI, unsigned &InstNum, unsigned &MemoryInstNum, ModelledPHISet &NeededPHIs, SmallPtrSetImpl &PHIContents) { auto Insts = *LRI; - DEBUG(dbgs() << " -- Analyzing instruction set: [\n"; for (auto *I + LLVM_DEBUG(dbgs() << " -- Analyzing instruction set: [\n"; for (auto *I : Insts) { I->dump(); } dbgs() << " ]\n";); @@ -637,7 +637,7 @@ DenseMap VNums; for (auto *I : Insts) { uint32_t N = VN.lookupOrAdd(I); - DEBUG(dbgs() << " VN=" << Twine::utohexstr(N) << " for" << *I << "\n"); + LLVM_DEBUG(dbgs() << " VN=" << Twine::utohexstr(N) << " for" << *I << "\n"); if (N == ~0U) return None; VNums[N]++; @@ -749,7 +749,7 @@ } unsigned GVNSink::sinkBB(BasicBlock *BBEnd) { - DEBUG(dbgs() << "GVNSink: running on basic block "; + LLVM_DEBUG(dbgs() << "GVNSink: running on basic block "; BBEnd->printAsOperand(dbgs()); dbgs() << "\n"); SmallVector Preds; for (auto *B : predecessors(BBEnd)) { @@ -794,7 +794,7 @@ Candidates.begin(), Candidates.end(), [](const SinkingInstructionCandidate &A, const SinkingInstructionCandidate &B) { return A > B; }); - DEBUG(dbgs() << " -- Sinking candidates:\n"; for (auto &C + LLVM_DEBUG(dbgs() << " -- Sinking candidates:\n"; for (auto &C : Candidates) dbgs() << " " << C << "\n";); @@ -803,14 +803,14 @@ return 0; auto C = Candidates.front(); - DEBUG(dbgs() << " -- Sinking: " << C << "\n"); + LLVM_DEBUG(dbgs() << " -- Sinking: " << C << "\n"); BasicBlock *InsertBB = BBEnd; if (C.Blocks.size() < NumOrigPreds) { - DEBUG(dbgs() << " -- Splitting edge to "; BBEnd->printAsOperand(dbgs()); + LLVM_DEBUG(dbgs() << " -- Splitting edge to "; BBEnd->printAsOperand(dbgs()); dbgs() << "\n"); InsertBB = SplitBlockPredecessors(BBEnd, C.Blocks, ".gvnsink.split"); if (!InsertBB) { - DEBUG(dbgs() << " -- FAILED to split edge!\n"); + LLVM_DEBUG(dbgs() << " -- FAILED to split edge!\n"); // Edge couldn't be split. return 0; } Index: lib/Transforms/Scalar/GuardWidening.cpp =================================================================== --- lib/Transforms/Scalar/GuardWidening.cpp +++ lib/Transforms/Scalar/GuardWidening.cpp @@ -312,7 +312,7 @@ for (auto *Candidate : make_range(I, E)) { auto Score = computeWideningScore(GuardInst, GuardInstLoop, Candidate, CurLoop); - DEBUG(dbgs() << "Score between " << *GuardInst->getArgOperand(0) + LLVM_DEBUG(dbgs() << "Score between " << *GuardInst->getArgOperand(0) << " and " << *Candidate->getArgOperand(0) << " is " << scoreTypeToString(Score) << "\n"); if (Score > BestScoreSoFar) { @@ -323,14 +323,14 @@ } if (BestScoreSoFar == WS_IllegalOrNegative) { - DEBUG(dbgs() << "Did not eliminate guard " << *GuardInst << "\n"); + LLVM_DEBUG(dbgs() << "Did not eliminate guard " << *GuardInst << "\n"); return false; } assert(BestSoFar != GuardInst && "Should have never visited same guard!"); assert(DT.dominates(BestSoFar, GuardInst) && "Should be!"); - DEBUG(dbgs() << "Widening " << *GuardInst << " into " << *BestSoFar + LLVM_DEBUG(dbgs() << "Widening " << *GuardInst << " into " << *BestSoFar << " with score " << scoreTypeToString(BestScoreSoFar) << "\n"); widenGuard(BestSoFar, GuardInst->getArgOperand(0)); GuardInst->setArgOperand(0, ConstantInt::getTrue(GuardInst->getContext())); Index: lib/Transforms/Scalar/IndVarSimplify.cpp =================================================================== --- lib/Transforms/Scalar/IndVarSimplify.cpp +++ lib/Transforms/Scalar/IndVarSimplify.cpp @@ -210,7 +210,7 @@ if (FromBase == ToBase) return true; - DEBUG(dbgs() << "INDVARS: GEP rewrite bail out " + LLVM_DEBUG(dbgs() << "INDVARS: GEP rewrite bail out " << *FromBase << " != " << *ToBase << "\n"); return false; @@ -653,7 +653,7 @@ Value *ExitVal = expandSCEVIfNeeded(Rewriter, ExitValue, L, Inst, PN->getType()); - DEBUG(dbgs() << "INDVARS: RLEV: AfterLoopVal = " << *ExitVal << '\n' + LLVM_DEBUG(dbgs() << "INDVARS: RLEV: AfterLoopVal = " << *ExitVal << '\n' << " LoopVal = " << *Inst << "\n"); if (!isValidRewrite(Inst, ExitVal)) { @@ -1084,7 +1084,7 @@ Instruction *NarrowDef = DU.NarrowDef; Instruction *WideDef = DU.WideDef; - DEBUG(dbgs() << "Cloning bitwise IVUser: " << *NarrowUse << "\n"); + LLVM_DEBUG(dbgs() << "Cloning bitwise IVUser: " << *NarrowUse << "\n"); // Replace NarrowDef operands with WideDef. Otherwise, we don't know anything // about the narrow operand yet so must insert a [sz]ext. It is probably loop @@ -1115,7 +1115,7 @@ Instruction *NarrowDef = DU.NarrowDef; Instruction *WideDef = DU.WideDef; - DEBUG(dbgs() << "Cloning arithmetic IVUser: " << *NarrowUse << "\n"); + LLVM_DEBUG(dbgs() << "Cloning arithmetic IVUser: " << *NarrowUse << "\n"); unsigned IVOpIdx = (NarrowUse->getOperand(0) == NarrowDef) ? 0 : 1; @@ -1315,7 +1315,7 @@ /// This IV user cannot be widen. Replace this use of the original narrow IV /// with a truncation of the new wide IV to isolate and eliminate the narrow IV. static void truncateIVUse(NarrowIVDefUse DU, DominatorTree *DT, LoopInfo *LI) { - DEBUG(dbgs() << "INDVARS: Truncate IV " << *DU.WideDef + LLVM_DEBUG(dbgs() << "INDVARS: Truncate IV " << *DU.WideDef << " for user " << *DU.NarrowUse << "\n"); IRBuilder<> Builder( getInsertPointForUses(DU.NarrowUse, DU.NarrowDef, DT, LI)); @@ -1396,7 +1396,7 @@ Value *Trunc = Builder.CreateTrunc(WidePhi, DU.NarrowDef->getType()); UsePhi->replaceAllUsesWith(Trunc); DeadInsts.emplace_back(UsePhi); - DEBUG(dbgs() << "INDVARS: Widen lcssa phi " << *UsePhi + LLVM_DEBUG(dbgs() << "INDVARS: Widen lcssa phi " << *UsePhi << " to " << *WidePhi << "\n"); } return nullptr; @@ -1428,14 +1428,14 @@ // A wider extend was hidden behind a narrower one. This may induce // another round of IV widening in which the intermediate IV becomes // dead. It should be very rare. - DEBUG(dbgs() << "INDVARS: New IV " << *WidePhi + LLVM_DEBUG(dbgs() << "INDVARS: New IV " << *WidePhi << " not wide enough to subsume " << *DU.NarrowUse << "\n"); DU.NarrowUse->replaceUsesOfWith(DU.NarrowDef, DU.WideDef); NewDef = DU.NarrowUse; } } if (NewDef != DU.NarrowUse) { - DEBUG(dbgs() << "INDVARS: eliminating " << *DU.NarrowUse + LLVM_DEBUG(dbgs() << "INDVARS: eliminating " << *DU.NarrowUse << " replaced by " << *DU.WideDef << "\n"); ++NumElimExt; DU.NarrowUse->replaceAllUsesWith(NewDef); @@ -1491,7 +1491,7 @@ // absolutely guarantee it. Hence the following failsafe check. In rare cases // where it fails, we simply throw away the newly created wide use. if (WideAddRec.first != SE->getSCEV(WideUse)) { - DEBUG(dbgs() << "Wide use expression mismatch: " << *WideUse + LLVM_DEBUG(dbgs() << "Wide use expression mismatch: " << *WideUse << ": " << *SE->getSCEV(WideUse) << " != " << *WideAddRec.first << "\n"); DeadInsts.emplace_back(WideUse); return nullptr; @@ -1597,7 +1597,7 @@ WideInc->setDebugLoc(OrigInc->getDebugLoc()); } - DEBUG(dbgs() << "Wide IV: " << *WidePhi << "\n"); + LLVM_DEBUG(dbgs() << "Wide IV: " << *WidePhi << "\n"); ++NumWidened; // Traverse the def-use chain using a worklist starting at the original IV. @@ -2231,7 +2231,7 @@ else P = ICmpInst::ICMP_EQ; - DEBUG(dbgs() << "INDVARS: Rewriting loop exit condition to:\n" + LLVM_DEBUG(dbgs() << "INDVARS: Rewriting loop exit condition to:\n" << " LHS:" << *CmpIndVar << '\n' << " op:\t" << (P == ICmpInst::ICMP_NE ? "!=" : "==") << "\n" @@ -2272,7 +2272,7 @@ NewLimit = Start + Count; ExitCnt = ConstantInt::get(CmpIndVar->getType(), NewLimit); - DEBUG(dbgs() << " Widen RHS:\t" << *ExitCnt << "\n"); + LLVM_DEBUG(dbgs() << " Widen RHS:\t" << *ExitCnt << "\n"); } else { // We try to extend trip count first. If that doesn't work we truncate IV. // Zext(trunc(IV)) == IV implies equivalence of the following two: Index: lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp =================================================================== --- lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp +++ lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp @@ -1429,7 +1429,7 @@ bool IsSignedPredicate = MainLoopStructure.IsSignedPredicate; Optional MaybeSR = calculateSubRanges(IsSignedPredicate); if (!MaybeSR.hasValue()) { - DEBUG(dbgs() << "irce: could not compute subranges\n"); + LLVM_DEBUG(dbgs() << "irce: could not compute subranges\n"); return false; } @@ -1462,7 +1462,7 @@ ExitPreLoopAtSCEV = *SR.LowLimit; else { if (CanBeMin(SE, *SR.HighLimit, IsSignedPredicate)) { - DEBUG(dbgs() << "irce: could not prove no-overflow when computing " + LLVM_DEBUG(dbgs() << "irce: could not prove no-overflow when computing " << "preloop exit limit. HighLimit = " << *(*SR.HighLimit) << "\n"); return false; @@ -1471,7 +1471,7 @@ } if (!isSafeToExpandAt(ExitPreLoopAtSCEV, InsertPt, SE)) { - DEBUG(dbgs() << "irce: could not prove that it is safe to expand the" + LLVM_DEBUG(dbgs() << "irce: could not prove that it is safe to expand the" << " preloop exit limit " << *ExitPreLoopAtSCEV << " at block " << InsertPt->getParent()->getName() << "\n"); return false; @@ -1488,7 +1488,7 @@ ExitMainLoopAtSCEV = *SR.HighLimit; else { if (CanBeMin(SE, *SR.LowLimit, IsSignedPredicate)) { - DEBUG(dbgs() << "irce: could not prove no-overflow when computing " + LLVM_DEBUG(dbgs() << "irce: could not prove no-overflow when computing " << "mainloop exit limit. LowLimit = " << *(*SR.LowLimit) << "\n"); return false; @@ -1497,7 +1497,7 @@ } if (!isSafeToExpandAt(ExitMainLoopAtSCEV, InsertPt, SE)) { - DEBUG(dbgs() << "irce: could not prove that it is safe to expand the" + LLVM_DEBUG(dbgs() << "irce: could not prove that it is safe to expand the" << " main loop exit limit " << *ExitMainLoopAtSCEV << " at block " << InsertPt->getParent()->getName() << "\n"); return false; @@ -1743,13 +1743,13 @@ return false; if (L->getBlocks().size() >= LoopSizeCutoff) { - DEBUG(dbgs() << "irce: giving up constraining loop, too large\n";); + LLVM_DEBUG(dbgs() << "irce: giving up constraining loop, too large\n";); return false; } BasicBlock *Preheader = L->getLoopPreheader(); if (!Preheader) { - DEBUG(dbgs() << "irce: loop has no preheader, leaving\n"); + LLVM_DEBUG(dbgs() << "irce: loop has no preheader, leaving\n"); return false; } @@ -1775,7 +1775,7 @@ IRC.print(OS); }; - DEBUG(PrintRecognizedRangeChecks(dbgs())); + LLVM_DEBUG(PrintRecognizedRangeChecks(dbgs())); if (PrintRangeChecks) PrintRecognizedRangeChecks(errs()); @@ -1784,7 +1784,7 @@ Optional MaybeLoopStructure = LoopStructure::parseLoopStructure(SE, BPI, *L, FailureReason); if (!MaybeLoopStructure.hasValue()) { - DEBUG(dbgs() << "irce: could not parse loop structure: " << FailureReason + LLVM_DEBUG(dbgs() << "irce: could not parse loop structure: " << FailureReason << "\n";); return false; } @@ -1836,7 +1836,7 @@ L->print(dbgs()); }; - DEBUG(PrintConstrainedLoopInfo()); + LLVM_DEBUG(PrintConstrainedLoopInfo()); if (PrintChangedLoops) PrintConstrainedLoopInfo(); Index: lib/Transforms/Scalar/InferAddressSpaces.cpp =================================================================== --- lib/Transforms/Scalar/InferAddressSpaces.cpp +++ lib/Transforms/Scalar/InferAddressSpaces.cpp @@ -653,13 +653,13 @@ // Tries to update the address space of the stack top according to the // address spaces of its operands. - DEBUG(dbgs() << "Updating the address space of\n " << *V << '\n'); + LLVM_DEBUG(dbgs() << "Updating the address space of\n " << *V << '\n'); Optional NewAS = updateAddressSpace(*V, *InferredAddrSpace); if (!NewAS.hasValue()) continue; // If any updates are made, grabs its users to the worklist because // their address spaces can also be possibly updated. - DEBUG(dbgs() << " to " << NewAS.getValue() << '\n'); + LLVM_DEBUG(dbgs() << " to " << NewAS.getValue() << '\n'); (*InferredAddrSpace)[V] = NewAS.getValue(); for (Value *User : V->users()) { @@ -901,14 +901,14 @@ if (NewV == nullptr) continue; - DEBUG(dbgs() << "Replacing the uses of " << *V + LLVM_DEBUG(dbgs() << "Replacing the uses of " << *V << "\n with\n " << *NewV << '\n'); if (Constant *C = dyn_cast(V)) { Constant *Replace = ConstantExpr::getAddrSpaceCast(cast(NewV), C->getType()); if (C != Replace) { - DEBUG(dbgs() << "Inserting replacement const cast: " + LLVM_DEBUG(dbgs() << "Inserting replacement const cast: " << Replace << ": " << *Replace << '\n'); C->replaceAllUsesWith(Replace); V = Replace; Index: lib/Transforms/Scalar/JumpThreading.cpp =================================================================== --- lib/Transforms/Scalar/JumpThreading.cpp +++ lib/Transforms/Scalar/JumpThreading.cpp @@ -339,7 +339,7 @@ DeferredDominance *DDT_, bool HasProfileData_, std::unique_ptr BFI_, std::unique_ptr BPI_) { - DEBUG(dbgs() << "Jump threading on function '" << F.getName() << "'\n"); + LLVM_DEBUG(dbgs() << "Jump threading on function '" << F.getName() << "'\n"); TLI = TLI_; LVI = LVI_; AA = AA_; @@ -388,7 +388,7 @@ // edges which simplifies the CFG. if (pred_empty(BB) && BB != &BB->getParent()->getEntryBlock()) { - DEBUG(dbgs() << " JT: Deleting dead block '" << BB->getName() + LLVM_DEBUG(dbgs() << " JT: Deleting dead block '" << BB->getName() << "' with terminator: " << *BB->getTerminator() << '\n'); LoopHeaders.erase(BB); LVI->eraseBlock(BB); @@ -1085,7 +1085,7 @@ Updates.push_back({DominatorTree::Delete, BB, Succ}); } - DEBUG(dbgs() << " In block '" << BB->getName() + LLVM_DEBUG(dbgs() << " In block '" << BB->getName() << "' folding undef terminator: " << *BBTerm << '\n'); BranchInst::Create(BBTerm->getSuccessor(BestSucc), BBTerm); BBTerm->eraseFromParent(); @@ -1097,7 +1097,7 @@ // terminator to an unconditional branch. This can occur due to threading in // other blocks. if (getKnownConstant(Condition, Preference)) { - DEBUG(dbgs() << " In block '" << BB->getName() + LLVM_DEBUG(dbgs() << " In block '" << BB->getName() << "' folding terminator: " << *BB->getTerminator() << '\n'); ++NumFolds; ConstantFoldTerminator(BB, true, nullptr, DDT); @@ -1572,7 +1572,7 @@ assert(!PredValues.empty() && "ComputeValueKnownInPredecessors returned true with no values"); - DEBUG(dbgs() << "IN BB: " << *BB; + LLVM_DEBUG(dbgs() << "IN BB: " << *BB; for (const auto &PredValue : PredValues) { dbgs() << " BB '" << BB->getName() << "': FOUND condition = " << *PredValue.first @@ -1888,7 +1888,7 @@ BasicBlock *SuccBB) { // If threading to the same block as we come from, we would infinite loop. if (SuccBB == BB) { - DEBUG(dbgs() << " Not threading across BB '" << BB->getName() + LLVM_DEBUG(dbgs() << " Not threading across BB '" << BB->getName() << "' - would thread to self!\n"); return false; } @@ -1896,7 +1896,7 @@ // If threading this would thread across a loop header, don't thread the edge. // See the comments above FindLoopHeaders for justifications and caveats. if (LoopHeaders.count(BB) || LoopHeaders.count(SuccBB)) { - DEBUG({ + LLVM_DEBUG({ bool BBIsHeader = LoopHeaders.count(BB); bool SuccIsHeader = LoopHeaders.count(SuccBB); dbgs() << " Not threading across " @@ -1910,7 +1910,7 @@ unsigned JumpThreadCost = getJumpThreadDuplicationCost(BB, BB->getTerminator(), BBDupThreshold); if (JumpThreadCost > BBDupThreshold) { - DEBUG(dbgs() << " Not threading BB '" << BB->getName() + LLVM_DEBUG(dbgs() << " Not threading BB '" << BB->getName() << "' - Cost is too high: " << JumpThreadCost << "\n"); return false; } @@ -1920,13 +1920,13 @@ if (PredBBs.size() == 1) PredBB = PredBBs[0]; else { - DEBUG(dbgs() << " Factoring out " << PredBBs.size() + LLVM_DEBUG(dbgs() << " Factoring out " << PredBBs.size() << " common predecessors.\n"); PredBB = SplitBlockPreds(BB, PredBBs, ".thr_comm"); } // And finally, do it! - DEBUG(dbgs() << " Threading edge from '" << PredBB->getName() << "' to '" + LLVM_DEBUG(dbgs() << " Threading edge from '" << PredBB->getName() << "' to '" << SuccBB->getName() << "' with cost: " << JumpThreadCost << ", across block:\n " << *BB << "\n"); @@ -2008,7 +2008,7 @@ if (UsesToRename.empty()) continue; - DEBUG(dbgs() << "JT: Renaming non-local uses of: " << I << "\n"); + LLVM_DEBUG(dbgs() << "JT: Renaming non-local uses of: " << I << "\n"); // We found a use of I outside of BB. Rename all uses of I that are outside // its block to be uses of the appropriate PHI node etc. See ValuesInBlocks @@ -2019,7 +2019,7 @@ while (!UsesToRename.empty()) SSAUpdate.RewriteUse(*UsesToRename.pop_back_val()); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n"); } // Ok, NewBB is good to go. Update the terminator of PredBB to jump to @@ -2219,7 +2219,7 @@ // cause us to transform this into an irreducible loop, don't do this. // See the comments above FindLoopHeaders for justifications and caveats. if (LoopHeaders.count(BB)) { - DEBUG(dbgs() << " Not duplicating loop header '" << BB->getName() + LLVM_DEBUG(dbgs() << " Not duplicating loop header '" << BB->getName() << "' into predecessor block '" << PredBBs[0]->getName() << "' - it might create an irreducible loop!\n"); return false; @@ -2228,7 +2228,7 @@ unsigned DuplicationCost = getJumpThreadDuplicationCost(BB, BB->getTerminator(), BBDupThreshold); if (DuplicationCost > BBDupThreshold) { - DEBUG(dbgs() << " Not duplicating BB '" << BB->getName() + LLVM_DEBUG(dbgs() << " Not duplicating BB '" << BB->getName() << "' - Cost is too high: " << DuplicationCost << "\n"); return false; } @@ -2239,7 +2239,7 @@ if (PredBBs.size() == 1) PredBB = PredBBs[0]; else { - DEBUG(dbgs() << " Factoring out " << PredBBs.size() + LLVM_DEBUG(dbgs() << " Factoring out " << PredBBs.size() << " common predecessors.\n"); PredBB = SplitBlockPreds(BB, PredBBs, ".thr_comm"); } @@ -2247,7 +2247,7 @@ // Okay, we decided to do this! Clone all the instructions in BB onto the end // of PredBB. - DEBUG(dbgs() << " Duplicating block '" << BB->getName() << "' into end of '" + LLVM_DEBUG(dbgs() << " Duplicating block '" << BB->getName() << "' into end of '" << PredBB->getName() << "' to eliminate branch on phi. Cost: " << DuplicationCost << " block is:" << *BB << "\n"); @@ -2341,7 +2341,7 @@ if (UsesToRename.empty()) continue; - DEBUG(dbgs() << "JT: Renaming non-local uses of: " << I << "\n"); + LLVM_DEBUG(dbgs() << "JT: Renaming non-local uses of: " << I << "\n"); // We found a use of I outside of BB. Rename all uses of I that are outside // its block to be uses of the appropriate PHI node etc. See ValuesInBlocks @@ -2352,7 +2352,7 @@ while (!UsesToRename.empty()) SSAUpdate.RewriteUse(*UsesToRename.pop_back_val()); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n"); } // PredBB no longer jumps to BB, remove entries in the PHI node for the edge @@ -2642,7 +2642,7 @@ BasicBlock *UnguardedBlock = DuplicateInstructionsInSplitBetween( BB, PredUnguardedBlock, Guard, UnguardedMapping); assert(UnguardedBlock && "Could not create the unguarded block?"); - DEBUG(dbgs() << "Moved guard " << *Guard << " to block " + LLVM_DEBUG(dbgs() << "Moved guard " << *Guard << " to block " << GuardedBlock->getName() << "\n"); // DuplicateInstructionsInSplitBetween inserts a new block "BB.split" between // PredBB and BB. We need to perform two inserts and one delete for each of Index: lib/Transforms/Scalar/LICM.cpp =================================================================== --- lib/Transforms/Scalar/LICM.cpp +++ lib/Transforms/Scalar/LICM.cpp @@ -392,7 +392,7 @@ // If the instruction is dead, we would try to sink it because it isn't // used in the loop, instead, just delete it. if (isInstructionTriviallyDead(&I, TLI)) { - DEBUG(dbgs() << "LICM deleting dead inst: " << I << '\n'); + LLVM_DEBUG(dbgs() << "LICM deleting dead inst: " << I << '\n'); ++II; CurAST->deleteValue(&I); I.eraseFromParent(); @@ -453,7 +453,7 @@ // just fold it. if (Constant *C = ConstantFoldInstruction( &I, I.getModule()->getDataLayout(), TLI)) { - DEBUG(dbgs() << "LICM folding inst: " << I << " --> " << *C << '\n'); + LLVM_DEBUG(dbgs() << "LICM folding inst: " << I << " --> " << *C << '\n'); CurAST->copyValue(&I, C); I.replaceAllUsesWith(C); if (isInstructionTriviallyDead(&I, TLI)) { @@ -907,7 +907,7 @@ static bool sink(Instruction &I, LoopInfo *LI, DominatorTree *DT, const Loop *CurLoop, LoopSafetyInfo *SafetyInfo, OptimizationRemarkEmitter *ORE, bool FreeInLoop) { - DEBUG(dbgs() << "LICM sinking instruction: " << I << "\n"); + LLVM_DEBUG(dbgs() << "LICM sinking instruction: " << I << "\n"); ORE->emit([&]() { return OptimizationRemark(DEBUG_TYPE, "InstSunk", &I) << "sinking " << ore::NV("Inst", &I); @@ -1009,7 +1009,7 @@ const LoopSafetyInfo *SafetyInfo, OptimizationRemarkEmitter *ORE) { auto *Preheader = CurLoop->getLoopPreheader(); - DEBUG(dbgs() << "LICM hoisting to " << Preheader->getName() << ": " << I + LLVM_DEBUG(dbgs() << "LICM hoisting to " << Preheader->getName() << ": " << I << "\n"); ORE->emit([&]() { return OptimizationRemark(DEBUG_TYPE, "Hoisted", &I) << "hoisting " @@ -1390,7 +1390,7 @@ return false; // Otherwise, this is safe to promote, lets do it! - DEBUG(dbgs() << "LICM: Promoting value stored to in loop: " << *SomePtr + LLVM_DEBUG(dbgs() << "LICM: Promoting value stored to in loop: " << *SomePtr << '\n'); ORE->emit([&]() { return OptimizationRemark(DEBUG_TYPE, "PromoteLoopAccessesToScalar", Index: lib/Transforms/Scalar/LoopDataPrefetch.cpp =================================================================== --- lib/Transforms/Scalar/LoopDataPrefetch.cpp +++ lib/Transforms/Scalar/LoopDataPrefetch.cpp @@ -244,7 +244,7 @@ if (ItersAhead > getMaxPrefetchIterationsAhead()) return MadeChange; - DEBUG(dbgs() << "Prefetching " << ItersAhead + LLVM_DEBUG(dbgs() << "Prefetching " << ItersAhead << " iterations ahead (loop size: " << LoopSize << ") in " << L->getHeader()->getParent()->getName() << ": " << *L); @@ -320,7 +320,7 @@ ConstantInt::get(I32, MemI->mayReadFromMemory() ? 0 : 1), ConstantInt::get(I32, 3), ConstantInt::get(I32, 1)}); ++NumPrefetches; - DEBUG(dbgs() << " Access: " << *PtrValue << ", SCEV: " << *LSCEV + LLVM_DEBUG(dbgs() << " Access: " << *PtrValue << ", SCEV: " << *LSCEV << "\n"); ORE->emit([&]() { return OptimizationRemark(DEBUG_TYPE, "Prefetched", MemI) Index: lib/Transforms/Scalar/LoopDeletion.cpp =================================================================== --- lib/Transforms/Scalar/LoopDeletion.cpp +++ lib/Transforms/Scalar/LoopDeletion.cpp @@ -142,14 +142,14 @@ // of trouble. BasicBlock *Preheader = L->getLoopPreheader(); if (!Preheader || !L->hasDedicatedExits()) { - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "Deletion requires Loop with preheader and dedicated exits.\n"); return LoopDeletionResult::Unmodified; } // We can't remove loops that contain subloops. If the subloops were dead, // they would already have been removed in earlier executions of this pass. if (L->begin() != L->end()) { - DEBUG(dbgs() << "Loop contains subloops.\n"); + LLVM_DEBUG(dbgs() << "Loop contains subloops.\n"); return LoopDeletionResult::Unmodified; } @@ -157,7 +157,7 @@ BasicBlock *ExitBlock = L->getUniqueExitBlock(); if (ExitBlock && isLoopNeverExecuted(L)) { - DEBUG(dbgs() << "Loop is proven to never execute, delete it!"); + LLVM_DEBUG(dbgs() << "Loop is proven to never execute, delete it!"); // Set incoming value to undef for phi nodes in the exit block. for (PHINode &P : ExitBlock->phis()) { std::fill(P.incoming_values().begin(), P.incoming_values().end(), @@ -178,13 +178,13 @@ // block will be branched to, or trying to preserve the branching logic in // a loop invariant manner. if (!ExitBlock) { - DEBUG(dbgs() << "Deletion requires single exit block\n"); + LLVM_DEBUG(dbgs() << "Deletion requires single exit block\n"); return LoopDeletionResult::Unmodified; } // Finally, we have to check that the loop really is dead. bool Changed = false; if (!isLoopDead(L, SE, ExitingBlocks, ExitBlock, Changed, Preheader)) { - DEBUG(dbgs() << "Loop is not invariant, cannot delete.\n"); + LLVM_DEBUG(dbgs() << "Loop is not invariant, cannot delete.\n"); return Changed ? LoopDeletionResult::Modified : LoopDeletionResult::Unmodified; } @@ -193,12 +193,12 @@ // They could be infinite, in which case we'd be changing program behavior. const SCEV *S = SE.getMaxBackedgeTakenCount(L); if (isa(S)) { - DEBUG(dbgs() << "Could not compute SCEV MaxBackedgeTakenCount.\n"); + LLVM_DEBUG(dbgs() << "Could not compute SCEV MaxBackedgeTakenCount.\n"); return Changed ? LoopDeletionResult::Modified : LoopDeletionResult::Unmodified; } - DEBUG(dbgs() << "Loop is invariant, delete it!"); + LLVM_DEBUG(dbgs() << "Loop is invariant, delete it!"); deleteDeadLoop(L, &DT, &SE, &LI); ++NumDeleted; @@ -209,8 +209,8 @@ LoopStandardAnalysisResults &AR, LPMUpdater &Updater) { - DEBUG(dbgs() << "Analyzing Loop for deletion: "); - DEBUG(L.dump()); + LLVM_DEBUG(dbgs() << "Analyzing Loop for deletion: "); + LLVM_DEBUG(L.dump()); std::string LoopName = L.getName(); auto Result = deleteLoopIfDead(&L, AR.DT, AR.SE, AR.LI); if (Result == LoopDeletionResult::Unmodified) @@ -255,8 +255,8 @@ ScalarEvolution &SE = getAnalysis().getSE(); LoopInfo &LI = getAnalysis().getLoopInfo(); - DEBUG(dbgs() << "Analyzing Loop for deletion: "); - DEBUG(L->dump()); + LLVM_DEBUG(dbgs() << "Analyzing Loop for deletion: "); + LLVM_DEBUG(L->dump()); LoopDeletionResult Result = deleteLoopIfDead(L, DT, SE, LI); Index: lib/Transforms/Scalar/LoopDistribute.cpp =================================================================== --- lib/Transforms/Scalar/LoopDistribute.cpp +++ lib/Transforms/Scalar/LoopDistribute.cpp @@ -362,7 +362,7 @@ std::tie(LoadToPart, NewElt) = LoadToPartition.insert(std::make_pair(Inst, PartI)); if (!NewElt) { - DEBUG(dbgs() << "Merging partitions due to this load in multiple " + LLVM_DEBUG(dbgs() << "Merging partitions due to this load in multiple " << "partitions: " << PartI << ", " << LoadToPart->second << "\n" << *Inst << "\n"); @@ -602,7 +602,7 @@ const SmallVectorImpl &Dependences) { Accesses.append(Instructions.begin(), Instructions.end()); - DEBUG(dbgs() << "Backward dependences:\n"); + LLVM_DEBUG(dbgs() << "Backward dependences:\n"); for (auto &Dep : Dependences) if (Dep.isPossiblyBackward()) { // Note that the designations source and destination follow the program @@ -611,7 +611,7 @@ ++Accesses[Dep.Source].NumUnsafeDependencesStartOrEnd; --Accesses[Dep.Destination].NumUnsafeDependencesStartOrEnd; - DEBUG(Dep.print(dbgs(), 2, Instructions)); + LLVM_DEBUG(Dep.print(dbgs(), 2, Instructions)); } } @@ -632,7 +632,7 @@ bool processLoop(std::function &GetLAA) { assert(L->empty() && "Only process inner loops."); - DEBUG(dbgs() << "\nLDist: In \"" << L->getHeader()->getParent()->getName() + LLVM_DEBUG(dbgs() << "\nLDist: In \"" << L->getHeader()->getParent()->getName() << "\" checking " << *L << "\n"); if (!L->getExitBlock()) @@ -705,7 +705,7 @@ for (auto *Inst : DefsUsedOutside) Partitions.addToNewNonCyclicPartition(Inst); - DEBUG(dbgs() << "Seeded partitions:\n" << Partitions); + LLVM_DEBUG(dbgs() << "Seeded partitions:\n" << Partitions); if (Partitions.getSize() < 2) return fail("CantIsolateUnsafeDeps", "cannot isolate unsafe dependencies"); @@ -713,19 +713,19 @@ // Run the merge heuristics: Merge non-cyclic adjacent partitions since we // should be able to vectorize these together. Partitions.mergeBeforePopulating(); - DEBUG(dbgs() << "\nMerged partitions:\n" << Partitions); + LLVM_DEBUG(dbgs() << "\nMerged partitions:\n" << Partitions); if (Partitions.getSize() < 2) return fail("CantIsolateUnsafeDeps", "cannot isolate unsafe dependencies"); // Now, populate the partitions with non-memory operations. Partitions.populateUsedSet(); - DEBUG(dbgs() << "\nPopulated partitions:\n" << Partitions); + LLVM_DEBUG(dbgs() << "\nPopulated partitions:\n" << Partitions); // In order to preserve original lexical order for loads, keep them in the // partition that we set up in the MemoryInstructionDependences loop. if (Partitions.mergeToAvoidDuplicatedLoads()) { - DEBUG(dbgs() << "\nPartitions merged to ensure unique loads:\n" + LLVM_DEBUG(dbgs() << "\nPartitions merged to ensure unique loads:\n" << Partitions); if (Partitions.getSize() < 2) return fail("CantIsolateUnsafeDeps", @@ -740,7 +740,7 @@ return fail("TooManySCEVRuntimeChecks", "too many SCEV run-time checks needed.\n"); - DEBUG(dbgs() << "\nDistributing loop: " << *L << "\n"); + LLVM_DEBUG(dbgs() << "\nDistributing loop: " << *L << "\n"); // We're done forming the partitions set up the reverse mapping from // instructions to partitions. Partitions.setupPartitionIdOnInstructions(); @@ -759,8 +759,8 @@ RtPtrChecking); if (!Pred.isAlwaysTrue() || !Checks.empty()) { - DEBUG(dbgs() << "\nPointers:\n"); - DEBUG(LAI->getRuntimePointerChecking()->printChecks(dbgs(), Checks)); + LLVM_DEBUG(dbgs() << "\nPointers:\n"); + LLVM_DEBUG(LAI->getRuntimePointerChecking()->printChecks(dbgs(), Checks)); LoopVersioning LVer(*LAI, L, LI, DT, SE, false); LVer.setAliasChecks(std::move(Checks)); LVer.setSCEVChecks(LAI->getPSE().getUnionPredicate()); @@ -775,8 +775,8 @@ // Now, we remove the instruction from each loop that don't belong to that // partition. Partitions.removeUnusedInsts(); - DEBUG(dbgs() << "\nAfter removing unused Instrs:\n"); - DEBUG(Partitions.printBlocks()); + LLVM_DEBUG(dbgs() << "\nAfter removing unused Instrs:\n"); + LLVM_DEBUG(Partitions.printBlocks()); if (LDistVerify) { LI->verify(*DT); @@ -798,7 +798,7 @@ LLVMContext &Ctx = F->getContext(); bool Forced = isForced().getValueOr(false); - DEBUG(dbgs() << "Skipping; " << Message << "\n"); + LLVM_DEBUG(dbgs() << "Skipping; " << Message << "\n"); // With Rpass-missed report that distribution failed. ORE->emit([&]() { Index: lib/Transforms/Scalar/LoopIdiomRecognize.cpp =================================================================== --- lib/Transforms/Scalar/LoopIdiomRecognize.cpp +++ lib/Transforms/Scalar/LoopIdiomRecognize.cpp @@ -310,7 +310,7 @@ SmallVector ExitBlocks; CurLoop->getUniqueExitBlocks(ExitBlocks); - DEBUG(dbgs() << "loop-idiom Scanning: F[" + LLVM_DEBUG(dbgs() << "loop-idiom Scanning: F[" << CurLoop->getHeader()->getParent()->getName() << "] Loop %" << CurLoop->getHeader()->getName() << "\n"); @@ -936,7 +936,7 @@ NewCall = Builder.CreateCall(MSP, {BasePtr, PatternPtr, NumBytes}); } - DEBUG(dbgs() << " Formed memset: " << *NewCall << "\n" + LLVM_DEBUG(dbgs() << " Formed memset: " << *NewCall << "\n" << " from store to: " << *Ev << " at: " << *TheStore << "\n"); NewCall->setDebugLoc(TheStore->getDebugLoc()); @@ -1067,7 +1067,7 @@ } NewCall->setDebugLoc(SI->getDebugLoc()); - DEBUG(dbgs() << " Formed memcpy: " << *NewCall << "\n" + LLVM_DEBUG(dbgs() << " Formed memcpy: " << *NewCall << "\n" << " from load ptr=" << *LoadEv << " at: " << *LI << "\n" << " from store ptr=" << *StoreEv << " at: " << *SI << "\n"); @@ -1085,7 +1085,7 @@ bool IsLoopMemset) { if (ApplyCodeSizeHeuristics && CurLoop->getNumBlocks() > 1) { if (!CurLoop->getParentLoop() && (!IsMemset || !IsLoopMemset)) { - DEBUG(dbgs() << " " << CurLoop->getHeader()->getParent()->getName() + LLVM_DEBUG(dbgs() << " " << CurLoop->getHeader()->getParent()->getName() << " : LIR " << (IsMemset ? "Memset" : "Memcpy") << " avoided: multi-block top-level loop\n"); return true; Index: lib/Transforms/Scalar/LoopInterchange.cpp =================================================================== --- lib/Transforms/Scalar/LoopInterchange.cpp +++ lib/Transforms/Scalar/LoopInterchange.cpp @@ -73,8 +73,8 @@ static void printDepMatrix(CharMatrix &DepMatrix) { for (auto &Row : DepMatrix) { for (auto D : Row) - DEBUG(dbgs() << D << " "); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << D << " "); + LLVM_DEBUG(dbgs() << "\n"); } } #endif @@ -103,7 +103,7 @@ } } - DEBUG(dbgs() << "Found " << MemInstr.size() + LLVM_DEBUG(dbgs() << "Found " << MemInstr.size() << " Loads and Stores to analyze\n"); ValueVector::iterator I, IE, J, JE; @@ -121,7 +121,7 @@ // Track Output, Flow, and Anti dependencies. if (auto D = DI->depends(Src, Dst, true)) { assert(D->isOrdered() && "Expected an output, flow or anti dep."); - DEBUG(StringRef DepType = + LLVM_DEBUG(StringRef DepType = D->isFlow() ? "flow" : D->isAnti() ? "anti" : "output"; dbgs() << "Found " << DepType << " dependency between Src and Dst\n" @@ -165,7 +165,7 @@ DepMatrix.push_back(Dep); if (DepMatrix.size() > MaxMemInstrCount) { - DEBUG(dbgs() << "Cannot handle more than " << MaxMemInstrCount + LLVM_DEBUG(dbgs() << "Cannot handle more than " << MaxMemInstrCount << " dependencies inside loop\n"); return false; } @@ -271,7 +271,7 @@ } static void populateWorklist(Loop &L, SmallVector &V) { - DEBUG(dbgs() << "Calling populateWorklist on Func: " + LLVM_DEBUG(dbgs() << "Calling populateWorklist on Func: " << L.getHeader()->getParent()->getName() << " Loop: %" << L.getHeader()->getName() << '\n'); LoopVector LoopList; @@ -474,7 +474,7 @@ for (Loop *L : *LI) populateWorklist(*L, Worklist); - DEBUG(dbgs() << "Worklist size = " << Worklist.size() << "\n"); + LLVM_DEBUG(dbgs() << "Worklist size = " << Worklist.size() << "\n"); bool Changed = true; while (!Worklist.empty()) { LoopVector LoopList = Worklist.pop_back_val(); @@ -487,15 +487,15 @@ for (Loop *L : LoopList) { const SCEV *ExitCountOuter = SE->getBackedgeTakenCount(L); if (ExitCountOuter == SE->getCouldNotCompute()) { - DEBUG(dbgs() << "Couldn't compute backedge count\n"); + LLVM_DEBUG(dbgs() << "Couldn't compute backedge count\n"); return false; } if (L->getNumBackEdges() != 1) { - DEBUG(dbgs() << "NumBackEdges is not equal to 1\n"); + LLVM_DEBUG(dbgs() << "NumBackEdges is not equal to 1\n"); return false; } if (!L->getExitingBlock()) { - DEBUG(dbgs() << "Loop doesn't have unique exit block\n"); + LLVM_DEBUG(dbgs() << "Loop doesn't have unique exit block\n"); return false; } } @@ -512,30 +512,30 @@ bool Changed = false; unsigned LoopNestDepth = LoopList.size(); if (LoopNestDepth < 2) { - DEBUG(dbgs() << "Loop doesn't contain minimum nesting level.\n"); + LLVM_DEBUG(dbgs() << "Loop doesn't contain minimum nesting level.\n"); return false; } if (LoopNestDepth > MaxLoopNestDepth) { - DEBUG(dbgs() << "Cannot handle loops of depth greater than " + LLVM_DEBUG(dbgs() << "Cannot handle loops of depth greater than " << MaxLoopNestDepth << "\n"); return false; } if (!isComputableLoopNest(LoopList)) { - DEBUG(dbgs() << "Not valid loop candidate for interchange\n"); + LLVM_DEBUG(dbgs() << "Not valid loop candidate for interchange\n"); return false; } - DEBUG(dbgs() << "Processing LoopList of size = " << LoopNestDepth << "\n"); + LLVM_DEBUG(dbgs() << "Processing LoopList of size = " << LoopNestDepth << "\n"); CharMatrix DependencyMatrix; Loop *OuterMostLoop = *(LoopList.begin()); if (!populateDependencyMatrix(DependencyMatrix, LoopNestDepth, OuterMostLoop, DI)) { - DEBUG(dbgs() << "Populating dependency matrix failed\n"); + LLVM_DEBUG(dbgs() << "Populating dependency matrix failed\n"); return false; } #ifdef DUMP_DEP_MATRICIES - DEBUG(dbgs() << "Dependence before interchange\n"); + LLVM_DEBUG(dbgs() << "Dependence before interchange\n"); printDepMatrix(DependencyMatrix); #endif @@ -557,7 +557,7 @@ LoopNestExit = OuterMostLoopLatchBI->getSuccessor(0); if (isa(LoopNestExit->begin())) { - DEBUG(dbgs() << "PHI Nodes in loop nest exit is not handled for now " + LLVM_DEBUG(dbgs() << "PHI Nodes in loop nest exit is not handled for now " "since on failure all loops branch to loop nest exit.\n"); return false; } @@ -575,7 +575,7 @@ // Update the DependencyMatrix interChangeDependencies(DependencyMatrix, i, i - 1); #ifdef DUMP_DEP_MATRICIES - DEBUG(dbgs() << "Dependence after interchange\n"); + LLVM_DEBUG(dbgs() << "Dependence after interchange\n"); printDepMatrix(DependencyMatrix); #endif Changed |= Interchanged; @@ -586,7 +586,7 @@ bool processLoop(LoopVector LoopList, unsigned InnerLoopId, unsigned OuterLoopId, BasicBlock *LoopNestExit, std::vector> &DependencyMatrix) { - DEBUG(dbgs() << "Processing Inner Loop Id = " << InnerLoopId + LLVM_DEBUG(dbgs() << "Processing Inner Loop Id = " << InnerLoopId << " and OuterLoopId = " << OuterLoopId << "\n"); Loop *InnerLoop = LoopList[InnerLoopId]; Loop *OuterLoop = LoopList[OuterLoopId]; @@ -594,13 +594,13 @@ LoopInterchangeLegality LIL(OuterLoop, InnerLoop, SE, LI, DT, PreserveLCSSA, ORE); if (!LIL.canInterchangeLoops(InnerLoopId, OuterLoopId, DependencyMatrix)) { - DEBUG(dbgs() << "Not interchanging Loops. Cannot prove legality\n"); + LLVM_DEBUG(dbgs() << "Not interchanging Loops. Cannot prove legality\n"); return false; } - DEBUG(dbgs() << "Loops are legal to interchange\n"); + LLVM_DEBUG(dbgs() << "Loops are legal to interchange\n"); LoopInterchangeProfitability LIP(OuterLoop, InnerLoop, SE, ORE); if (!LIP.isProfitable(InnerLoopId, OuterLoopId, DependencyMatrix)) { - DEBUG(dbgs() << "Interchanging loops not profitable\n"); + LLVM_DEBUG(dbgs() << "Interchanging loops not profitable\n"); return false; } @@ -614,7 +614,7 @@ LoopInterchangeTransform LIT(OuterLoop, InnerLoop, SE, LI, DT, LoopNestExit, LIL.hasInnerLoopReduction()); LIT.transform(); - DEBUG(dbgs() << "Loops interchanged\n"); + LLVM_DEBUG(dbgs() << "Loops interchanged\n"); return true; } }; @@ -662,7 +662,7 @@ BasicBlock *InnerLoopPreHeader = InnerLoop->getLoopPreheader(); BasicBlock *OuterLoopLatch = OuterLoop->getLoopLatch(); - DEBUG(dbgs() << "Checking if loops are tightly nested\n"); + LLVM_DEBUG(dbgs() << "Checking if loops are tightly nested\n"); // A perfectly nested loop will not have any branch in between the outer and // inner block i.e. outer header will branch to either inner preheader and @@ -676,14 +676,14 @@ if (Succ != InnerLoopPreHeader && Succ != OuterLoopLatch) return false; - DEBUG(dbgs() << "Checking instructions in Loop header and Loop latch\n"); + LLVM_DEBUG(dbgs() << "Checking instructions in Loop header and Loop latch\n"); // We do not have any basic block in between now make sure the outer header // and outer loop latch doesn't contain any unsafe instructions. if (containsUnsafeInstructionsInHeader(OuterLoopHeader) || containsUnsafeInstructionsInLatch(OuterLoopLatch)) return false; - DEBUG(dbgs() << "Loops are perfectly nested\n"); + LLVM_DEBUG(dbgs() << "Loops are perfectly nested\n"); // We have a perfect loop nest. return true; } @@ -726,7 +726,7 @@ else if (RecurrenceDescriptor::isReductionPHI(PHI, L, RD)) Reductions.push_back(PHI); else { - DEBUG( + LLVM_DEBUG( dbgs() << "Failed to recognize PHI as an induction or reduction.\n"); return false; } @@ -778,7 +778,7 @@ SmallVector Inductions; SmallVector Reductions; if (!findInductionAndReductions(InnerLoop, Inductions, Reductions)) { - DEBUG(dbgs() << "Only inner loops with induction or reduction PHI nodes " + LLVM_DEBUG(dbgs() << "Only inner loops with induction or reduction PHI nodes " << "are supported currently.\n"); ORE->emit([&]() { return OptimizationRemarkMissed(DEBUG_TYPE, "UnsupportedPHIInner", @@ -792,7 +792,7 @@ // TODO: Currently we handle only loops with 1 induction variable. if (Inductions.size() != 1) { - DEBUG(dbgs() << "We currently only support loops with 1 induction variable." + LLVM_DEBUG(dbgs() << "We currently only support loops with 1 induction variable." << "Failed to interchange due to current limitation\n"); ORE->emit([&]() { return OptimizationRemarkMissed(DEBUG_TYPE, "MultiInductionInner", @@ -809,7 +809,7 @@ InnerInductionVar = Inductions.pop_back_val(); Reductions.clear(); if (!findInductionAndReductions(OuterLoop, Inductions, Reductions)) { - DEBUG(dbgs() << "Only outer loops with induction or reduction PHI nodes " + LLVM_DEBUG(dbgs() << "Only outer loops with induction or reduction PHI nodes " << "are supported currently.\n"); ORE->emit([&]() { return OptimizationRemarkMissed(DEBUG_TYPE, "UnsupportedPHIOuter", @@ -824,7 +824,7 @@ // Outer loop cannot have reduction because then loops will not be tightly // nested. if (!Reductions.empty()) { - DEBUG(dbgs() << "Outer loops with reductions are not supported " + LLVM_DEBUG(dbgs() << "Outer loops with reductions are not supported " << "currently.\n"); ORE->emit([&]() { return OptimizationRemarkMissed(DEBUG_TYPE, "ReductionsOuter", @@ -837,7 +837,7 @@ } // TODO: Currently we handle only loops with 1 induction variable. if (Inductions.size() != 1) { - DEBUG(dbgs() << "Loops with more than 1 induction variables are not " + LLVM_DEBUG(dbgs() << "Loops with more than 1 induction variables are not " << "supported currently.\n"); ORE->emit([&]() { return OptimizationRemarkMissed(DEBUG_TYPE, "MultiIndutionOuter", @@ -851,7 +851,7 @@ // TODO: Triangular loops are not handled for now. if (!isLoopStructureUnderstood(InnerInductionVar)) { - DEBUG(dbgs() << "Loop structure not understood by pass\n"); + LLVM_DEBUG(dbgs() << "Loop structure not understood by pass\n"); ORE->emit([&]() { return OptimizationRemarkMissed(DEBUG_TYPE, "UnsupportedStructureInner", InnerLoop->getStartLoc(), @@ -865,7 +865,7 @@ BasicBlock *LoopExitBlock = getLoopLatchExitBlock(OuterLoopLatch, OuterLoopHeader); if (!LoopExitBlock || !containsSafePHI(LoopExitBlock, true)) { - DEBUG(dbgs() << "Can only handle LCSSA PHIs in outer loops currently.\n"); + LLVM_DEBUG(dbgs() << "Can only handle LCSSA PHIs in outer loops currently.\n"); ORE->emit([&]() { return OptimizationRemarkMissed(DEBUG_TYPE, "NoLCSSAPHIOuter", OuterLoop->getStartLoc(), @@ -878,7 +878,7 @@ LoopExitBlock = getLoopLatchExitBlock(InnerLoopLatch, InnerLoopHeader); if (!LoopExitBlock || !containsSafePHI(LoopExitBlock, false)) { - DEBUG(dbgs() << "Can only handle LCSSA PHIs in inner loops currently.\n"); + LLVM_DEBUG(dbgs() << "Can only handle LCSSA PHIs in inner loops currently.\n"); ORE->emit([&]() { return OptimizationRemarkMissed(DEBUG_TYPE, "NoLCSSAPHIOuterInner", InnerLoop->getStartLoc(), @@ -908,7 +908,7 @@ dyn_cast(InnerInductionVar->getIncomingValue(0)); if (!InnerIndexVarInc) { - DEBUG(dbgs() << "Did not find an instruction to increment the induction " + LLVM_DEBUG(dbgs() << "Did not find an instruction to increment the induction " << "variable.\n"); ORE->emit([&]() { return OptimizationRemarkMissed(DEBUG_TYPE, "NoIncrementInInner", @@ -932,7 +932,7 @@ // We found an instruction. If this is not induction variable then it is not // safe to split this loop latch. if (!I.isIdenticalTo(InnerIndexVarInc)) { - DEBUG(dbgs() << "Found unsupported instructions between induction " + LLVM_DEBUG(dbgs() << "Found unsupported instructions between induction " << "variable increment and branch.\n"); ORE->emit([&]() { return OptimizationRemarkMissed( @@ -950,7 +950,7 @@ // The loop latch ended and we didn't find the induction variable return as // current limitation. if (!FoundInduction) { - DEBUG(dbgs() << "Did not find the induction variable.\n"); + LLVM_DEBUG(dbgs() << "Did not find the induction variable.\n"); ORE->emit([&]() { return OptimizationRemarkMissed(DEBUG_TYPE, "NoIndutionVariable", InnerLoop->getStartLoc(), @@ -966,7 +966,7 @@ unsigned OuterLoopId, CharMatrix &DepMatrix) { if (!isLegalToInterChangeLoops(DepMatrix, InnerLoopId, OuterLoopId)) { - DEBUG(dbgs() << "Failed interchange InnerLoopId = " << InnerLoopId + LLVM_DEBUG(dbgs() << "Failed interchange InnerLoopId = " << InnerLoopId << " and OuterLoopId = " << OuterLoopId << " due to dependence\n"); ORE->emit([&]() { @@ -985,7 +985,7 @@ // readnone functions do not prevent interchanging. if (CI->doesNotReadMemory()) continue; - DEBUG(dbgs() << "Loops with call instructions cannot be interchanged " + LLVM_DEBUG(dbgs() << "Loops with call instructions cannot be interchanged " << "safely."); return false; } @@ -1015,13 +1015,13 @@ // TODO: The loops could not be interchanged due to current limitations in the // transform module. if (currentLimitations()) { - DEBUG(dbgs() << "Not legal because of current transform limitation\n"); + LLVM_DEBUG(dbgs() << "Not legal because of current transform limitation\n"); return false; } // Check if the loops are tightly nested. if (!tightlyNested(OuterLoop, InnerLoop)) { - DEBUG(dbgs() << "Loops not tightly nested\n"); + LLVM_DEBUG(dbgs() << "Loops not tightly nested\n"); ORE->emit([&]() { return OptimizationRemarkMissed(DEBUG_TYPE, "NotTightlyNested", InnerLoop->getStartLoc(), @@ -1115,7 +1115,7 @@ // of induction variables in the instruction and allows reordering if number // of bad orders is more than good. int Cost = getInstrOrderCost(); - DEBUG(dbgs() << "Cost = " << Cost << "\n"); + LLVM_DEBUG(dbgs() << "Cost = " << Cost << "\n"); if (Cost < -LoopInterchangeCostThreshold) return true; @@ -1173,10 +1173,10 @@ if (InnerLoop->getSubLoops().empty()) { BasicBlock *InnerLoopPreHeader = InnerLoop->getLoopPreheader(); - DEBUG(dbgs() << "Calling Split Inner Loop\n"); + LLVM_DEBUG(dbgs() << "Calling Split Inner Loop\n"); PHINode *InductionPHI = getInductionVariable(InnerLoop, SE); if (!InductionPHI) { - DEBUG(dbgs() << "Failed to find the point to split loop latch \n"); + LLVM_DEBUG(dbgs() << "Failed to find the point to split loop latch \n"); return false; } @@ -1194,16 +1194,16 @@ // incremented/decremented. // TODO: This splitting logic may not work always. Fix this. splitInnerLoopLatch(InnerIndexVar); - DEBUG(dbgs() << "splitInnerLoopLatch done\n"); + LLVM_DEBUG(dbgs() << "splitInnerLoopLatch done\n"); // Splits the inner loops phi nodes out into a separate basic block. splitInnerLoopHeader(); - DEBUG(dbgs() << "splitInnerLoopHeader done\n"); + LLVM_DEBUG(dbgs() << "splitInnerLoopHeader done\n"); } Transformed |= adjustLoopLinks(); if (!Transformed) { - DEBUG(dbgs() << "adjustLoopLinks failed\n"); + LLVM_DEBUG(dbgs() << "adjustLoopLinks failed\n"); return false; } @@ -1238,7 +1238,7 @@ } } - DEBUG(dbgs() << "Output of splitInnerLoopHeader InnerLoopHeaderSucc & " + LLVM_DEBUG(dbgs() << "Output of splitInnerLoopHeader InnerLoopHeaderSucc & " "InnerLoopHeader\n"); } @@ -1287,7 +1287,7 @@ } bool LoopInterchangeTransform::adjustLoopBranches() { - DEBUG(dbgs() << "adjustLoopBranches called\n"); + LLVM_DEBUG(dbgs() << "adjustLoopBranches called\n"); std::vector DTUpdates; // Adjust the loop preheader Index: lib/Transforms/Scalar/LoopLoadElimination.cpp =================================================================== --- lib/Transforms/Scalar/LoopLoadElimination.cpp +++ lib/Transforms/Scalar/LoopLoadElimination.cpp @@ -284,7 +284,7 @@ Candidates.remove_if([&](const StoreToLoadForwardingCandidate &Cand) { if (LoadToSingleCand[Cand.Load] != &Cand) { - DEBUG(dbgs() << "Removing from candidates: \n" << Cand + LLVM_DEBUG(dbgs() << "Removing from candidates: \n" << Cand << " The load may have multiple stores forwarding to " << "it\n"); return true; @@ -394,8 +394,8 @@ return false; }); - DEBUG(dbgs() << "\nPointer Checks (count: " << Checks.size() << "):\n"); - DEBUG(LAI.getRuntimePointerChecking()->printChecks(dbgs(), Checks)); + LLVM_DEBUG(dbgs() << "\nPointer Checks (count: " << Checks.size() << "):\n"); + LLVM_DEBUG(LAI.getRuntimePointerChecking()->printChecks(dbgs(), Checks)); return Checks; } @@ -439,7 +439,7 @@ /// \brief Top-level driver for each loop: find store->load forwarding /// candidates, add run-time checks and perform transformation. bool processLoop() { - DEBUG(dbgs() << "\nIn \"" << L->getHeader()->getParent()->getName() + LLVM_DEBUG(dbgs() << "\nIn \"" << L->getHeader()->getParent()->getName() << "\" checking " << *L << "\n"); // Look for store-to-load forwarding cases across the @@ -479,7 +479,7 @@ SmallVector Candidates; unsigned NumForwarding = 0; for (const StoreToLoadForwardingCandidate Cand : StoreToLoadDependences) { - DEBUG(dbgs() << "Candidate " << Cand); + LLVM_DEBUG(dbgs() << "Candidate " << Cand); // Make sure that the stored values is available everywhere in the loop in // the next iteration. @@ -498,7 +498,7 @@ continue; ++NumForwarding; - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << NumForwarding << ". Valid store-to-load forwarding across the loop backedge\n"); Candidates.push_back(Cand); @@ -513,25 +513,25 @@ // Too many checks are likely to outweigh the benefits of forwarding. if (Checks.size() > Candidates.size() * CheckPerElim) { - DEBUG(dbgs() << "Too many run-time checks needed.\n"); + LLVM_DEBUG(dbgs() << "Too many run-time checks needed.\n"); return false; } if (LAI.getPSE().getUnionPredicate().getComplexity() > LoadElimSCEVCheckThreshold) { - DEBUG(dbgs() << "Too many SCEV run-time checks needed.\n"); + LLVM_DEBUG(dbgs() << "Too many SCEV run-time checks needed.\n"); return false; } if (!Checks.empty() || !LAI.getPSE().getUnionPredicate().isAlwaysTrue()) { if (L->getHeader()->getParent()->optForSize()) { - DEBUG(dbgs() << "Versioning is needed but not allowed when optimizing " + LLVM_DEBUG(dbgs() << "Versioning is needed but not allowed when optimizing " "for size.\n"); return false; } if (!L->isLoopSimplifyForm()) { - DEBUG(dbgs() << "Loop is not is loop-simplify form"); + LLVM_DEBUG(dbgs() << "Loop is not is loop-simplify form"); return false; } Index: lib/Transforms/Scalar/LoopPredication.cpp =================================================================== --- lib/Transforms/Scalar/LoopPredication.cpp +++ lib/Transforms/Scalar/LoopPredication.cpp @@ -380,11 +380,11 @@ if (!NewLatchCheck.IV) return None; NewLatchCheck.Limit = SE->getTruncateExpr(LatchCheck.Limit, RangeCheckType); - DEBUG(dbgs() << "IV of type: " << *LatchType + LLVM_DEBUG(dbgs() << "IV of type: " << *LatchType << "can be represented as range check type:" << *RangeCheckType << "\n"); - DEBUG(dbgs() << "LatchCheck.IV: " << *NewLatchCheck.IV << "\n"); - DEBUG(dbgs() << "LatchCheck.Limit: " << *NewLatchCheck.Limit << "\n"); + LLVM_DEBUG(dbgs() << "LatchCheck.IV: " << *NewLatchCheck.IV << "\n"); + LLVM_DEBUG(dbgs() << "LatchCheck.Limit: " << *NewLatchCheck.Limit << "\n"); return NewLatchCheck; } @@ -417,15 +417,15 @@ SE->getMinusSCEV(LatchStart, SE->getOne(Ty))); if (!CanExpand(GuardStart) || !CanExpand(GuardLimit) || !CanExpand(LatchLimit) || !CanExpand(RHS)) { - DEBUG(dbgs() << "Can't expand limit check!\n"); + LLVM_DEBUG(dbgs() << "Can't expand limit check!\n"); return None; } auto LimitCheckPred = ICmpInst::getFlippedStrictnessPredicate(LatchCheck.Pred); - DEBUG(dbgs() << "LHS: " << *LatchLimit << "\n"); - DEBUG(dbgs() << "RHS: " << *RHS << "\n"); - DEBUG(dbgs() << "Pred: " << LimitCheckPred << "\n"); + LLVM_DEBUG(dbgs() << "LHS: " << *LatchLimit << "\n"); + LLVM_DEBUG(dbgs() << "RHS: " << *RHS << "\n"); + LLVM_DEBUG(dbgs() << "Pred: " << LimitCheckPred << "\n"); Instruction *InsertAt = Preheader->getTerminator(); auto *LimitCheck = @@ -444,14 +444,14 @@ const SCEV *LatchLimit = LatchCheck.Limit; if (!CanExpand(GuardStart) || !CanExpand(GuardLimit) || !CanExpand(LatchLimit)) { - DEBUG(dbgs() << "Can't expand limit check!\n"); + LLVM_DEBUG(dbgs() << "Can't expand limit check!\n"); return None; } // The decrement of the latch check IV should be the same as the // rangeCheckIV. auto *PostDecLatchCheckIV = LatchCheck.IV->getPostIncExpr(*SE); if (RangeCheck.IV != PostDecLatchCheckIV) { - DEBUG(dbgs() << "Not the same. PostDecLatchCheckIV: " + LLVM_DEBUG(dbgs() << "Not the same. PostDecLatchCheckIV: " << *PostDecLatchCheckIV << " and RangeCheckIV: " << *RangeCheck.IV << "\n"); return None; @@ -477,8 +477,8 @@ Optional LoopPredication::widenICmpRangeCheck(ICmpInst *ICI, SCEVExpander &Expander, IRBuilder<> &Builder) { - DEBUG(dbgs() << "Analyzing ICmpInst condition:\n"); - DEBUG(ICI->dump()); + LLVM_DEBUG(dbgs() << "Analyzing ICmpInst condition:\n"); + LLVM_DEBUG(ICI->dump()); // parseLoopStructure guarantees that the latch condition is: // ++i latchLimit, where is u<, u<=, s<, or s<=. @@ -486,32 +486,32 @@ // i u< guardLimit auto RangeCheck = parseLoopICmp(ICI); if (!RangeCheck) { - DEBUG(dbgs() << "Failed to parse the loop latch condition!\n"); + LLVM_DEBUG(dbgs() << "Failed to parse the loop latch condition!\n"); return None; } - DEBUG(dbgs() << "Guard check:\n"); - DEBUG(RangeCheck->dump()); + LLVM_DEBUG(dbgs() << "Guard check:\n"); + LLVM_DEBUG(RangeCheck->dump()); if (RangeCheck->Pred != ICmpInst::ICMP_ULT) { - DEBUG(dbgs() << "Unsupported range check predicate(" << RangeCheck->Pred + LLVM_DEBUG(dbgs() << "Unsupported range check predicate(" << RangeCheck->Pred << ")!\n"); return None; } auto *RangeCheckIV = RangeCheck->IV; if (!RangeCheckIV->isAffine()) { - DEBUG(dbgs() << "Range check IV is not affine!\n"); + LLVM_DEBUG(dbgs() << "Range check IV is not affine!\n"); return None; } auto *Step = RangeCheckIV->getStepRecurrence(*SE); // We cannot just compare with latch IV step because the latch and range IVs // may have different types. if (!isSupportedStep(Step)) { - DEBUG(dbgs() << "Range check and latch have IVs different steps!\n"); + LLVM_DEBUG(dbgs() << "Range check and latch have IVs different steps!\n"); return None; } auto *Ty = RangeCheckIV->getType(); auto CurrLatchCheckOpt = generateLoopLatchCheck(Ty); if (!CurrLatchCheckOpt) { - DEBUG(dbgs() << "Failed to generate a loop latch check " + LLVM_DEBUG(dbgs() << "Failed to generate a loop latch check " "corresponding to range type: " << *Ty << "\n"); return None; @@ -524,7 +524,7 @@ CurrLatchCheck.IV->getStepRecurrence(*SE)->getType() && "Range and latch steps should be of same type!"); if (Step != CurrLatchCheck.IV->getStepRecurrence(*SE)) { - DEBUG(dbgs() << "Range and latch have different step values!\n"); + LLVM_DEBUG(dbgs() << "Range and latch have different step values!\n"); return None; } @@ -540,8 +540,8 @@ bool LoopPredication::widenGuardConditions(IntrinsicInst *Guard, SCEVExpander &Expander) { - DEBUG(dbgs() << "Processing guard:\n"); - DEBUG(Guard->dump()); + LLVM_DEBUG(dbgs() << "Processing guard:\n"); + LLVM_DEBUG(Guard->dump()); IRBuilder<> Builder(cast(Preheader->getTerminator())); @@ -594,7 +594,7 @@ LastCheck = Builder.CreateAnd(LastCheck, Check); Guard->setOperand(0, LastCheck); - DEBUG(dbgs() << "Widened checks = " << NumWidened << "\n"); + LLVM_DEBUG(dbgs() << "Widened checks = " << NumWidened << "\n"); return true; } @@ -603,7 +603,7 @@ BasicBlock *LoopLatch = L->getLoopLatch(); if (!LoopLatch) { - DEBUG(dbgs() << "The loop doesn't have a single latch!\n"); + LLVM_DEBUG(dbgs() << "The loop doesn't have a single latch!\n"); return None; } @@ -614,7 +614,7 @@ if (!match(LoopLatch->getTerminator(), m_Br(m_ICmp(Pred, m_Value(LHS), m_Value(RHS)), TrueDest, FalseDest))) { - DEBUG(dbgs() << "Failed to match the latch terminator!\n"); + LLVM_DEBUG(dbgs() << "Failed to match the latch terminator!\n"); return None; } assert((TrueDest == L->getHeader() || FalseDest == L->getHeader()) && @@ -624,20 +624,20 @@ auto Result = parseLoopICmp(Pred, LHS, RHS); if (!Result) { - DEBUG(dbgs() << "Failed to parse the loop latch condition!\n"); + LLVM_DEBUG(dbgs() << "Failed to parse the loop latch condition!\n"); return None; } // Check affine first, so if it's not we don't try to compute the step // recurrence. if (!Result->IV->isAffine()) { - DEBUG(dbgs() << "The induction variable is not affine!\n"); + LLVM_DEBUG(dbgs() << "The induction variable is not affine!\n"); return None; } auto *Step = Result->IV->getStepRecurrence(*SE); if (!isSupportedStep(Step)) { - DEBUG(dbgs() << "Unsupported loop stride(" << *Step << ")!\n"); + LLVM_DEBUG(dbgs() << "Unsupported loop stride(" << *Step << ")!\n"); return None; } @@ -653,7 +653,7 @@ }; if (IsUnsupportedPredicate(Step, Result->Pred)) { - DEBUG(dbgs() << "Unsupported loop latch predicate(" << Result->Pred + LLVM_DEBUG(dbgs() << "Unsupported loop latch predicate(" << Result->Pred << ")!\n"); return None; } @@ -693,8 +693,8 @@ bool LoopPredication::runOnLoop(Loop *Loop) { L = Loop; - DEBUG(dbgs() << "Analyzing "); - DEBUG(L->dump()); + LLVM_DEBUG(dbgs() << "Analyzing "); + LLVM_DEBUG(L->dump()); Module *M = L->getHeader()->getModule(); @@ -715,8 +715,8 @@ return false; LatchCheck = *LatchCheckOpt; - DEBUG(dbgs() << "Latch check:\n"); - DEBUG(LatchCheck.dump()); + LLVM_DEBUG(dbgs() << "Latch check:\n"); + LLVM_DEBUG(LatchCheck.dump()); // Collect all the guards into a vector and process later, so as not // to invalidate the instruction iterator. Index: lib/Transforms/Scalar/LoopRerollPass.cpp =================================================================== --- lib/Transforms/Scalar/LoopRerollPass.cpp +++ lib/Transforms/Scalar/LoopRerollPass.cpp @@ -643,13 +643,13 @@ if (IncSCEV->getValue()->isZero() || AInt.uge(MaxInc)) continue; IVToIncMap[&*I] = IncSCEV->getValue()->getSExtValue(); - DEBUG(dbgs() << "LRR: Possible IV: " << *I << " = " << *PHISCEV + LLVM_DEBUG(dbgs() << "LRR: Possible IV: " << *I << " = " << *PHISCEV << "\n"); if (isLoopControlIV(L, &*I)) { assert(!LoopControlIV && "Found two loop control only IV"); LoopControlIV = &(*I); - DEBUG(dbgs() << "LRR: Possible loop control only IV: " << *I << " = " + LLVM_DEBUG(dbgs() << "LRR: Possible loop control only IV: " << *I << " = " << *PHISCEV << "\n"); } else PossibleIVs.push_back(&*I); @@ -717,7 +717,7 @@ if (!SLR.valid()) continue; - DEBUG(dbgs() << "LRR: Possible reduction: " << *I << " (with " << + LLVM_DEBUG(dbgs() << "LRR: Possible reduction: " << *I << " (with " << SLR.size() << " chained instructions)\n"); Reductions.addSLR(SLR); } @@ -856,7 +856,7 @@ BaseUsers.push_back(II); continue; } else { - DEBUG(dbgs() << "LRR: Aborting due to non-instruction: " << *I << "\n"); + LLVM_DEBUG(dbgs() << "LRR: Aborting due to non-instruction: " << *I << "\n"); return false; } } @@ -878,7 +878,7 @@ // away. if (BaseUsers.size()) { if (Roots.find(0) != Roots.end()) { - DEBUG(dbgs() << "LRR: Multiple roots found for base - aborting!\n"); + LLVM_DEBUG(dbgs() << "LRR: Multiple roots found for base - aborting!\n"); return false; } Roots[0] = Base; @@ -894,7 +894,7 @@ if (KV.first == 0) continue; if (!KV.second->hasNUses(NumBaseUses)) { - DEBUG(dbgs() << "LRR: Aborting - Root and Base #users not the same: " + LLVM_DEBUG(dbgs() << "LRR: Aborting - Root and Base #users not the same: " << "#Base=" << NumBaseUses << ", #Root=" << KV.second->getNumUses() << "\n"); return false; @@ -1024,12 +1024,12 @@ // Ensure all sets have the same size. if (RootSets.empty()) { - DEBUG(dbgs() << "LRR: Aborting because no root sets found!\n"); + LLVM_DEBUG(dbgs() << "LRR: Aborting because no root sets found!\n"); return false; } for (auto &V : RootSets) { if (V.Roots.empty() || V.Roots.size() != RootSets[0].Roots.size()) { - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "LRR: Aborting because not all root sets have the same size\n"); return false; } @@ -1038,13 +1038,13 @@ Scale = RootSets[0].Roots.size() + 1; if (Scale > IL_MaxRerollIterations) { - DEBUG(dbgs() << "LRR: Aborting - too many iterations found. " + LLVM_DEBUG(dbgs() << "LRR: Aborting - too many iterations found. " << "#Found=" << Scale << ", #Max=" << IL_MaxRerollIterations << "\n"); return false; } - DEBUG(dbgs() << "LRR: Successfully found roots: Scale=" << Scale << "\n"); + LLVM_DEBUG(dbgs() << "LRR: Successfully found roots: Scale=" << Scale << "\n"); return true; } @@ -1078,7 +1078,7 @@ // While we're here, check the use sets are the same size. if (V.size() != VBase.size()) { - DEBUG(dbgs() << "LRR: Aborting - use sets are different sizes\n"); + LLVM_DEBUG(dbgs() << "LRR: Aborting - use sets are different sizes\n"); return false; } @@ -1235,13 +1235,13 @@ // set. for (auto &KV : Uses) { if (KV.second.count() != 1 && !isIgnorableInst(KV.first)) { - DEBUG(dbgs() << "LRR: Aborting - instruction is not used in 1 iteration: " + LLVM_DEBUG(dbgs() << "LRR: Aborting - instruction is not used in 1 iteration: " << *KV.first << " (#uses=" << KV.second.count() << ")\n"); return false; } } - DEBUG( + LLVM_DEBUG( for (auto &KV : Uses) { dbgs() << "LRR: " << KV.second.find_first() << "\t" << *KV.first << "\n"; } @@ -1304,7 +1304,7 @@ if (TryIt == Uses.end() || TryIt == RootIt || instrDependsOn(TryIt->first, RootIt, TryIt)) { - DEBUG(dbgs() << "LRR: iteration root match failed at " << *BaseInst << + LLVM_DEBUG(dbgs() << "LRR: iteration root match failed at " << *BaseInst << " vs. " << *RootInst << "\n"); return false; } @@ -1341,7 +1341,7 @@ // root instruction, does not also belong to the base set or the set of // some other root instruction. if (RootIt->second.count() > 1) { - DEBUG(dbgs() << "LRR: iteration root match failed at " << *BaseInst << + LLVM_DEBUG(dbgs() << "LRR: iteration root match failed at " << *BaseInst << " vs. " << *RootInst << " (prev. case overlap)\n"); return false; } @@ -1352,7 +1352,7 @@ if (RootInst->mayReadFromMemory()) for (auto &K : AST) { if (K.aliasesUnknownInst(RootInst, *AA)) { - DEBUG(dbgs() << "LRR: iteration root match failed at " << *BaseInst << + LLVM_DEBUG(dbgs() << "LRR: iteration root match failed at " << *BaseInst << " vs. " << *RootInst << " (depends on future store)\n"); return false; } @@ -1366,7 +1366,7 @@ !isSafeToSpeculativelyExecute(BaseInst)) || (!isUnorderedLoadStore(RootInst) && !isSafeToSpeculativelyExecute(RootInst)))) { - DEBUG(dbgs() << "LRR: iteration root match failed at " << *BaseInst << + LLVM_DEBUG(dbgs() << "LRR: iteration root match failed at " << *BaseInst << " vs. " << *RootInst << " (side effects prevent reordering)\n"); return false; @@ -1419,7 +1419,7 @@ BaseInst->getOperand(!j) == Op2) { Swapped = true; } else { - DEBUG(dbgs() << "LRR: iteration root match failed at " << *BaseInst + LLVM_DEBUG(dbgs() << "LRR: iteration root match failed at " << *BaseInst << " vs. " << *RootInst << " (operand " << j << ")\n"); return false; } @@ -1433,7 +1433,7 @@ hasUsesOutsideLoop(BaseInst, L)) || (!PossibleRedLastSet.count(RootInst) && hasUsesOutsideLoop(RootInst, L))) { - DEBUG(dbgs() << "LRR: iteration root match failed at " << *BaseInst << + LLVM_DEBUG(dbgs() << "LRR: iteration root match failed at " << *BaseInst << " vs. " << *RootInst << " (uses outside loop)\n"); return false; } @@ -1451,7 +1451,7 @@ "Mismatched set sizes!"); } - DEBUG(dbgs() << "LRR: Matched all iteration increments for " << + LLVM_DEBUG(dbgs() << "LRR: Matched all iteration increments for " << *IV << "\n"); return true; @@ -1464,7 +1464,7 @@ J != JE;) { unsigned I = Uses[&*J].find_first(); if (I > 0 && I < IL_All) { - DEBUG(dbgs() << "LRR: removing: " << *J << "\n"); + LLVM_DEBUG(dbgs() << "LRR: removing: " << *J << "\n"); J++->eraseFromParent(); continue; } @@ -1617,14 +1617,14 @@ int Iter = PossibleRedIter[J]; if (Iter != PrevIter && Iter != PrevIter + 1 && !PossibleReds[i].getReducedValue()->isAssociative()) { - DEBUG(dbgs() << "LRR: Out-of-order non-associative reduction: " << + LLVM_DEBUG(dbgs() << "LRR: Out-of-order non-associative reduction: " << J << "\n"); return false; } if (Iter != PrevIter) { if (Count != BaseCount) { - DEBUG(dbgs() << "LRR: Iteration " << PrevIter << + LLVM_DEBUG(dbgs() << "LRR: Iteration " << PrevIter << " reduction use count " << Count << " is not equal to the base use count " << BaseCount << "\n"); @@ -1723,7 +1723,7 @@ if (!DAGRoots.findRoots()) return false; - DEBUG(dbgs() << "LRR: Found all root induction increments for: " << + LLVM_DEBUG(dbgs() << "LRR: Found all root induction increments for: " << *IV << "\n"); if (!DAGRoots.validate(Reductions)) @@ -1752,7 +1752,7 @@ PreserveLCSSA = mustPreserveAnalysisID(LCSSAID); BasicBlock *Header = L->getHeader(); - DEBUG(dbgs() << "LRR: F[" << Header->getParent()->getName() << + LLVM_DEBUG(dbgs() << "LRR: F[" << Header->getParent()->getName() << "] Loop %" << Header->getName() << " (" << L->getNumBlocks() << " block(s))\n"); @@ -1765,8 +1765,8 @@ const SCEV *LIBETC = SE->getBackedgeTakenCount(L); const SCEV *IterCount = SE->getAddExpr(LIBETC, SE->getOne(LIBETC->getType())); - DEBUG(dbgs() << "\n Before Reroll:\n" << *(L->getHeader()) << "\n"); - DEBUG(dbgs() << "LRR: iteration count = " << *IterCount << "\n"); + LLVM_DEBUG(dbgs() << "\n Before Reroll:\n" << *(L->getHeader()) << "\n"); + LLVM_DEBUG(dbgs() << "LRR: iteration count = " << *IterCount << "\n"); // First, we need to find the induction variable with respect to which we can // reroll (there may be several possible options). @@ -1776,7 +1776,7 @@ collectPossibleIVs(L, PossibleIVs); if (PossibleIVs.empty()) { - DEBUG(dbgs() << "LRR: No possible IVs found\n"); + LLVM_DEBUG(dbgs() << "LRR: No possible IVs found\n"); return false; } @@ -1791,7 +1791,7 @@ Changed = true; break; } - DEBUG(dbgs() << "\n After Reroll:\n" << *(L->getHeader()) << "\n"); + LLVM_DEBUG(dbgs() << "\n After Reroll:\n" << *(L->getHeader()) << "\n"); // Trip count of L has changed so SE must be re-evaluated. if (Changed) Index: lib/Transforms/Scalar/LoopRotation.cpp =================================================================== --- lib/Transforms/Scalar/LoopRotation.cpp +++ lib/Transforms/Scalar/LoopRotation.cpp @@ -216,13 +216,13 @@ CodeMetrics Metrics; Metrics.analyzeBasicBlock(OrigHeader, *TTI, EphValues); if (Metrics.notDuplicatable) { - DEBUG(dbgs() << "LoopRotation: NOT rotating - contains non-duplicatable" + LLVM_DEBUG(dbgs() << "LoopRotation: NOT rotating - contains non-duplicatable" << " instructions: "; L->dump()); return false; } if (Metrics.convergent) { - DEBUG(dbgs() << "LoopRotation: NOT rotating - contains convergent " + LLVM_DEBUG(dbgs() << "LoopRotation: NOT rotating - contains convergent " "instructions: "; L->dump()); return false; @@ -244,7 +244,7 @@ if (SE) SE->forgetLoop(L); - DEBUG(dbgs() << "LoopRotation: rotating "; L->dump()); + LLVM_DEBUG(dbgs() << "LoopRotation: rotating "; L->dump()); // Find new Loop header. NewHeader is a Header's one and only successor // that is inside loop. Header's other successor is outside the @@ -455,7 +455,7 @@ // emitted code isn't too gross in this common case. MergeBlockIntoPredecessor(OrigHeader, DT, LI); - DEBUG(dbgs() << "LoopRotation: into "; L->dump()); + LLVM_DEBUG(dbgs() << "LoopRotation: into "; L->dump()); ++NumRotated; return true; @@ -558,7 +558,7 @@ if (!shouldSpeculateInstrs(Latch->begin(), Jmp->getIterator(), L)) return false; - DEBUG(dbgs() << "Folding loop latch " << Latch->getName() << " into " + LLVM_DEBUG(dbgs() << "Folding loop latch " << Latch->getName() << " into " << LastExit->getName() << "\n"); // Hoist the instructions from Latch into LastExit. Index: lib/Transforms/Scalar/LoopSink.cpp =================================================================== --- lib/Transforms/Scalar/LoopSink.cpp +++ lib/Transforms/Scalar/LoopSink.cpp @@ -224,11 +224,11 @@ } // Replaces uses of I with IC in blocks dominated by N replaceDominatedUsesWith(&I, IC, DT, N); - DEBUG(dbgs() << "Sinking a clone of " << I << " To: " << N->getName() + LLVM_DEBUG(dbgs() << "Sinking a clone of " << I << " To: " << N->getName() << '\n'); NumLoopSunkCloned++; } - DEBUG(dbgs() << "Sinking " << I << " To: " << MoveBB->getName() << '\n'); + LLVM_DEBUG(dbgs() << "Sinking " << I << " To: " << MoveBB->getName() << '\n'); NumLoopSunk++; I.moveBefore(&*MoveBB->getFirstInsertionPt()); Index: lib/Transforms/Scalar/LoopStrengthReduce.cpp =================================================================== --- lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -2401,7 +2401,7 @@ } } - DEBUG(dbgs() << " Change loop exiting icmp to use postinc iv: " + LLVM_DEBUG(dbgs() << " Change loop exiting icmp to use postinc iv: " << *Cond << '\n'); // It's possible for the setcc instruction to be anywhere in the loop, and @@ -2643,7 +2643,7 @@ if (Types.size() == 1) Types.clear(); - DEBUG(print_factors_and_types(dbgs())); + LLVM_DEBUG(print_factors_and_types(dbgs())); } /// Helper for CollectChains that finds an IV operand (computed by an AddRec in @@ -2774,7 +2774,7 @@ return false; if (!Users.empty()) { - DEBUG(dbgs() << "Chain: " << *Chain.Incs[0].UserInst << " users:\n"; + LLVM_DEBUG(dbgs() << "Chain: " << *Chain.Incs[0].UserInst << " users:\n"; for (Instruction *Inst : Users) { dbgs() << " " << *Inst << "\n"; }); @@ -2830,7 +2830,7 @@ // the stride. cost -= NumReusedIncrements; - DEBUG(dbgs() << "Chain: " << *Chain.Incs[0].UserInst << " Cost: " << cost + LLVM_DEBUG(dbgs() << "Chain: " << *Chain.Incs[0].UserInst << " Cost: " << cost << "\n"); return cost < 0; @@ -2884,7 +2884,7 @@ if (isa(UserInst)) return; if (NChains >= MaxChains && !StressIVChain) { - DEBUG(dbgs() << "IV Chain Limit\n"); + LLVM_DEBUG(dbgs() << "IV Chain Limit\n"); return; } LastIncExpr = OperExpr; @@ -2897,10 +2897,10 @@ IVChainVec.push_back(IVChain(IVInc(UserInst, IVOper, LastIncExpr), OperExprBase)); ChainUsersVec.resize(NChains); - DEBUG(dbgs() << "IV Chain#" << ChainIdx << " Head: (" << *UserInst + LLVM_DEBUG(dbgs() << "IV Chain#" << ChainIdx << " Head: (" << *UserInst << ") IV=" << *LastIncExpr << "\n"); } else { - DEBUG(dbgs() << "IV Chain#" << ChainIdx << " Inc: (" << *UserInst + LLVM_DEBUG(dbgs() << "IV Chain#" << ChainIdx << " Inc: (" << *UserInst << ") IV+" << *LastIncExpr << "\n"); // Add this IV user to the end of the chain. IVChainVec[ChainIdx].add(IVInc(UserInst, IVOper, LastIncExpr)); @@ -2971,7 +2971,7 @@ /// loop latch. This will discover chains on side paths, but requires /// maintaining multiple copies of the Chains state. void LSRInstance::CollectChains() { - DEBUG(dbgs() << "Collecting IV Chains.\n"); + LLVM_DEBUG(dbgs() << "Collecting IV Chains.\n"); SmallVector ChainUsersVec; SmallVector LatchPath; @@ -3040,10 +3040,10 @@ void LSRInstance::FinalizeChain(IVChain &Chain) { assert(!Chain.Incs.empty() && "empty IV chains are not allowed"); - DEBUG(dbgs() << "Final Chain: " << *Chain.Incs[0].UserInst << "\n"); + LLVM_DEBUG(dbgs() << "Final Chain: " << *Chain.Incs[0].UserInst << "\n"); for (const IVInc &Inc : Chain) { - DEBUG(dbgs() << " Inc: " << *Inc.UserInst << "\n"); + LLVM_DEBUG(dbgs() << " Inc: " << *Inc.UserInst << "\n"); auto UseI = find(Inc.UserInst->operands(), Inc.IVOperand); assert(UseI != Inc.UserInst->op_end() && "cannot find IV operand"); IVIncSet.insert(UseI); @@ -3100,11 +3100,11 @@ } if (IVOpIter == IVOpEnd) { // Gracefully give up on this chain. - DEBUG(dbgs() << "Concealed chain head: " << *Head.UserInst << "\n"); + LLVM_DEBUG(dbgs() << "Concealed chain head: " << *Head.UserInst << "\n"); return; } - DEBUG(dbgs() << "Generate chain at: " << *IVSrc << "\n"); + LLVM_DEBUG(dbgs() << "Generate chain at: " << *IVSrc << "\n"); Type *IVTy = IVSrc->getType(); Type *IntTy = SE.getEffectiveSCEVType(IVTy); const SCEV *LeftOverExpr = nullptr; @@ -3180,7 +3180,7 @@ find(UserInst->operands(), U.getOperandValToReplace()); assert(UseI != UserInst->op_end() && "cannot find IV operand"); if (IVIncSet.count(UseI)) { - DEBUG(dbgs() << "Use is in profitable chain: " << **UseI << '\n'); + LLVM_DEBUG(dbgs() << "Use is in profitable chain: " << **UseI << '\n'); continue; } @@ -3256,7 +3256,7 @@ } } - DEBUG(print_fixups(dbgs())); + LLVM_DEBUG(print_fixups(dbgs())); } /// Insert a formula for the given expression into the given use, separating out @@ -3939,7 +3939,7 @@ if (Imms.size() == 1) continue; - DEBUG(dbgs() << "Generating cross-use offsets for " << *Reg << ':'; + LLVM_DEBUG(dbgs() << "Generating cross-use offsets for " << *Reg << ':'; for (const auto &Entry : Imms) dbgs() << ' ' << Entry.first; dbgs() << '\n'); @@ -3954,7 +3954,7 @@ if (!isa(OrigReg) && UsedByIndicesMap[Reg].count() == 1) { - DEBUG(dbgs() << "Skipping cross-use reuse for " << *OrigReg << '\n'); + LLVM_DEBUG(dbgs() << "Skipping cross-use reuse for " << *OrigReg << '\n'); continue; } @@ -4100,7 +4100,7 @@ GenerateCrossUseConstantOffsets(); - DEBUG(dbgs() << "\n" + LLVM_DEBUG(dbgs() << "\n" "After generating reuse formulae:\n"; print_uses(dbgs())); } @@ -4124,7 +4124,7 @@ for (size_t LUIdx = 0, NumUses = Uses.size(); LUIdx != NumUses; ++LUIdx) { LSRUse &LU = Uses[LUIdx]; - DEBUG(dbgs() << "Filtering for use "; LU.print(dbgs()); dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "Filtering for use "; LU.print(dbgs()); dbgs() << '\n'); bool Any = false; for (size_t FIdx = 0, NumForms = LU.Formulae.size(); @@ -4148,7 +4148,7 @@ // as the basis of rediscovering the desired formula that uses an AddRec // corresponding to the existing phi. Once all formulae have been // generated, these initial losers may be pruned. - DEBUG(dbgs() << " Filtering loser "; F.print(dbgs()); + LLVM_DEBUG(dbgs() << " Filtering loser "; F.print(dbgs()); dbgs() << "\n"); } else { @@ -4176,7 +4176,7 @@ CostBest.RateFormula(TTI, Best, Regs, VisitedRegs, L, SE, DT, LU); if (CostF.isLess(CostBest, TTI)) std::swap(F, Best); - DEBUG(dbgs() << " Filtering out formula "; F.print(dbgs()); + LLVM_DEBUG(dbgs() << " Filtering out formula "; F.print(dbgs()); dbgs() << "\n" " in favor of formula "; Best.print(dbgs()); dbgs() << '\n'); @@ -4198,7 +4198,7 @@ BestFormulae.clear(); } - DEBUG(if (ChangedFormulae) { + LLVM_DEBUG(if (ChangedFormulae) { dbgs() << "\n" "After filtering out undesirable candidates:\n"; print_uses(dbgs()); @@ -4231,9 +4231,9 @@ /// register pressure); remove it to simplify the system. void LSRInstance::NarrowSearchSpaceByDetectingSupersets() { if (EstimateSearchSpaceComplexity() >= ComplexityLimit) { - DEBUG(dbgs() << "The search space is too complex.\n"); + LLVM_DEBUG(dbgs() << "The search space is too complex.\n"); - DEBUG(dbgs() << "Narrowing the search space by eliminating formulae " + LLVM_DEBUG(dbgs() << "Narrowing the search space by eliminating formulae " "which use a superset of registers used by other " "formulae.\n"); @@ -4253,7 +4253,7 @@ NewF.BaseRegs.erase(NewF.BaseRegs.begin() + (I - F.BaseRegs.begin())); if (LU.HasFormulaWithSameRegs(NewF)) { - DEBUG(dbgs() << " Deleting "; F.print(dbgs()); dbgs() << '\n'); + LLVM_DEBUG(dbgs() << " Deleting "; F.print(dbgs()); dbgs() << '\n'); LU.DeleteFormula(F); --i; --e; @@ -4268,7 +4268,7 @@ NewF.BaseRegs.erase(NewF.BaseRegs.begin() + (I - F.BaseRegs.begin())); if (LU.HasFormulaWithSameRegs(NewF)) { - DEBUG(dbgs() << " Deleting "; F.print(dbgs()); + LLVM_DEBUG(dbgs() << " Deleting "; F.print(dbgs()); dbgs() << '\n'); LU.DeleteFormula(F); --i; @@ -4284,7 +4284,7 @@ LU.RecomputeRegs(LUIdx, RegUses); } - DEBUG(dbgs() << "After pre-selection:\n"; + LLVM_DEBUG(dbgs() << "After pre-selection:\n"; print_uses(dbgs())); } } @@ -4295,7 +4295,7 @@ if (EstimateSearchSpaceComplexity() < ComplexityLimit) return; - DEBUG(dbgs() << "The search space is too complex.\n" + LLVM_DEBUG(dbgs() << "The search space is too complex.\n" "Narrowing the search space by assuming that uses separated " "by a constant offset will use the same registers.\n"); @@ -4315,7 +4315,7 @@ LU.Kind, LU.AccessTy)) continue; - DEBUG(dbgs() << " Deleting use "; LU.print(dbgs()); dbgs() << '\n'); + LLVM_DEBUG(dbgs() << " Deleting use "; LU.print(dbgs()); dbgs() << '\n'); LUThatHas->AllFixupsOutsideLoop &= LU.AllFixupsOutsideLoop; @@ -4323,7 +4323,7 @@ for (LSRFixup &Fixup : LU.Fixups) { Fixup.Offset += F.BaseOffset; LUThatHas->pushFixup(Fixup); - DEBUG(dbgs() << "New fixup has offset " << Fixup.Offset << '\n'); + LLVM_DEBUG(dbgs() << "New fixup has offset " << Fixup.Offset << '\n'); } // Delete formulae from the new use which are no longer legal. @@ -4332,7 +4332,7 @@ Formula &F = LUThatHas->Formulae[i]; if (!isLegalUse(TTI, LUThatHas->MinOffset, LUThatHas->MaxOffset, LUThatHas->Kind, LUThatHas->AccessTy, F)) { - DEBUG(dbgs() << " Deleting "; F.print(dbgs()); + LLVM_DEBUG(dbgs() << " Deleting "; F.print(dbgs()); dbgs() << '\n'); LUThatHas->DeleteFormula(F); --i; @@ -4352,7 +4352,7 @@ } } - DEBUG(dbgs() << "After pre-selection:\n"; print_uses(dbgs())); + LLVM_DEBUG(dbgs() << "After pre-selection:\n"; print_uses(dbgs())); } /// Call FilterOutUndesirableDedicatedRegisters again, if necessary, now that @@ -4360,14 +4360,14 @@ /// eliminate. void LSRInstance::NarrowSearchSpaceByRefilteringUndesirableDedicatedRegisters(){ if (EstimateSearchSpaceComplexity() >= ComplexityLimit) { - DEBUG(dbgs() << "The search space is too complex.\n"); + LLVM_DEBUG(dbgs() << "The search space is too complex.\n"); - DEBUG(dbgs() << "Narrowing the search space by re-filtering out " + LLVM_DEBUG(dbgs() << "Narrowing the search space by re-filtering out " "undesirable dedicated registers.\n"); FilterOutUndesirableDedicatedRegisters(); - DEBUG(dbgs() << "After pre-selection:\n"; + LLVM_DEBUG(dbgs() << "After pre-selection:\n"; print_uses(dbgs())); } } @@ -4385,7 +4385,7 @@ if (EstimateSearchSpaceComplexity() < ComplexityLimit) return; - DEBUG(dbgs() << "The search space is too complex.\n" + LLVM_DEBUG(dbgs() << "The search space is too complex.\n" "Narrowing the search space by choosing the best Formula " "from the Formulae with the same Scale and ScaledReg.\n"); @@ -4401,7 +4401,7 @@ for (size_t LUIdx = 0, NumUses = Uses.size(); LUIdx != NumUses; ++LUIdx) { LSRUse &LU = Uses[LUIdx]; - DEBUG(dbgs() << "Filtering for use "; LU.print(dbgs()); dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "Filtering for use "; LU.print(dbgs()); dbgs() << '\n'); // Return true if Formula FA is better than Formula FB. auto IsBetterThan = [&](Formula &FA, Formula &FB) { @@ -4445,7 +4445,7 @@ Formula &Best = LU.Formulae[P.first->second]; if (IsBetterThan(F, Best)) std::swap(F, Best); - DEBUG(dbgs() << " Filtering out formula "; F.print(dbgs()); + LLVM_DEBUG(dbgs() << " Filtering out formula "; F.print(dbgs()); dbgs() << "\n" " in favor of formula "; Best.print(dbgs()); dbgs() << '\n'); @@ -4464,7 +4464,7 @@ BestFormulae.clear(); } - DEBUG(if (ChangedFormulae) { + LLVM_DEBUG(if (ChangedFormulae) { dbgs() << "\n" "After filtering out undesirable candidates:\n"; print_uses(dbgs()); @@ -4523,7 +4523,7 @@ // Used in each formula of a solution (in example above this is reg(c)). // We can skip them in calculations. SmallPtrSet UniqRegs; - DEBUG(dbgs() << "The search space is too complex.\n"); + LLVM_DEBUG(dbgs() << "The search space is too complex.\n"); // Map each register to probability of not selecting DenseMap RegNumMap; @@ -4543,7 +4543,7 @@ RegNumMap.insert(std::make_pair(Reg, PNotSel)); } - DEBUG(dbgs() << "Narrowing the search space by deleting costly formulas\n"); + LLVM_DEBUG(dbgs() << "Narrowing the search space by deleting costly formulas\n"); // Delete formulas where registers number expectation is high. for (size_t LUIdx = 0, NumUses = Uses.size(); LUIdx != NumUses; ++LUIdx) { @@ -4585,25 +4585,25 @@ MinIdx = i; } } - DEBUG(dbgs() << " The formula "; LU.Formulae[MinIdx].print(dbgs()); + LLVM_DEBUG(dbgs() << " The formula "; LU.Formulae[MinIdx].print(dbgs()); dbgs() << " with min reg num " << FMinRegNum << '\n'); if (MinIdx != 0) std::swap(LU.Formulae[MinIdx], LU.Formulae[0]); while (LU.Formulae.size() != 1) { - DEBUG(dbgs() << " Deleting "; LU.Formulae.back().print(dbgs()); + LLVM_DEBUG(dbgs() << " Deleting "; LU.Formulae.back().print(dbgs()); dbgs() << '\n'); LU.Formulae.pop_back(); } LU.RecomputeRegs(LUIdx, RegUses); assert(LU.Formulae.size() == 1 && "Should be exactly 1 min regs formula"); Formula &F = LU.Formulae[0]; - DEBUG(dbgs() << " Leaving only "; F.print(dbgs()); dbgs() << '\n'); + LLVM_DEBUG(dbgs() << " Leaving only "; F.print(dbgs()); dbgs() << '\n'); // When we choose the formula, the regs become unique. UniqRegs.insert(F.BaseRegs.begin(), F.BaseRegs.end()); if (F.ScaledReg) UniqRegs.insert(F.ScaledReg); } - DEBUG(dbgs() << "After pre-selection:\n"; + LLVM_DEBUG(dbgs() << "After pre-selection:\n"; print_uses(dbgs())); } @@ -4617,7 +4617,7 @@ while (EstimateSearchSpaceComplexity() >= ComplexityLimit) { // Ok, we have too many of formulae on our hands to conveniently handle. // Use a rough heuristic to thin out the list. - DEBUG(dbgs() << "The search space is too complex.\n"); + LLVM_DEBUG(dbgs() << "The search space is too complex.\n"); // Pick the register which is used by the most LSRUses, which is likely // to be a good reuse register candidate. @@ -4638,7 +4638,7 @@ } } - DEBUG(dbgs() << "Narrowing the search space by assuming " << *Best + LLVM_DEBUG(dbgs() << "Narrowing the search space by assuming " << *Best << " will yield profitable reuse.\n"); Taken.insert(Best); @@ -4652,7 +4652,7 @@ for (size_t i = 0, e = LU.Formulae.size(); i != e; ++i) { Formula &F = LU.Formulae[i]; if (!F.referencesReg(Best)) { - DEBUG(dbgs() << " Deleting "; F.print(dbgs()); dbgs() << '\n'); + LLVM_DEBUG(dbgs() << " Deleting "; F.print(dbgs()); dbgs() << '\n'); LU.DeleteFormula(F); --e; --i; @@ -4666,7 +4666,7 @@ LU.RecomputeRegs(LUIdx, RegUses); } - DEBUG(dbgs() << "After pre-selection:\n"; + LLVM_DEBUG(dbgs() << "After pre-selection:\n"; print_uses(dbgs())); } } @@ -4749,7 +4749,7 @@ if (F.getNumRegs() == 1 && Workspace.size() == 1) VisitedRegs.insert(F.ScaledReg ? F.ScaledReg : F.BaseRegs[0]); } else { - DEBUG(dbgs() << "New best at "; NewCost.print(dbgs()); + LLVM_DEBUG(dbgs() << "New best at "; NewCost.print(dbgs()); dbgs() << ".\n Regs:"; for (const SCEV *S : NewRegs) dbgs() << ' ' << *S; @@ -4778,12 +4778,12 @@ SolveRecurse(Solution, SolutionCost, Workspace, CurCost, CurRegs, VisitedRegs); if (Solution.empty()) { - DEBUG(dbgs() << "\nNo Satisfactory Solution\n"); + LLVM_DEBUG(dbgs() << "\nNo Satisfactory Solution\n"); return; } // Ok, we've now made all our decisions. - DEBUG(dbgs() << "\n" + LLVM_DEBUG(dbgs() << "\n" "The chosen solution requires "; SolutionCost.print(dbgs()); dbgs() << ":\n"; for (size_t i = 0, e = Uses.size(); i != e; ++i) { @@ -5267,7 +5267,7 @@ for (const IVStrideUse &U : IU) { if (++NumUsers > MaxIVUsers) { (void)U; - DEBUG(dbgs() << "LSR skipping loop, too many IV Users in " << U << "\n"); + LLVM_DEBUG(dbgs() << "LSR skipping loop, too many IV Users in " << U << "\n"); return; } // Bail out if we have a PHI on an EHPad that gets a value from a @@ -5300,7 +5300,7 @@ } #endif // DEBUG - DEBUG(dbgs() << "\nLSR on loop "; + LLVM_DEBUG(dbgs() << "\nLSR on loop "; L->getHeader()->printAsOperand(dbgs(), /*PrintType=*/false); dbgs() << ":\n"); @@ -5313,7 +5313,7 @@ // Skip nested loops until we can model them better with formulae. if (!L->empty()) { - DEBUG(dbgs() << "LSR skipping outer loop " << *L << "\n"); + LLVM_DEBUG(dbgs() << "LSR skipping outer loop " << *L << "\n"); return; } @@ -5324,7 +5324,7 @@ CollectLoopInvariantFixupsAndFormulae(); assert(!Uses.empty() && "IVUsers reported at least one use"); - DEBUG(dbgs() << "LSR found " << Uses.size() << " uses:\n"; + LLVM_DEBUG(dbgs() << "LSR found " << Uses.size() << " uses:\n"; print_uses(dbgs())); // Now use the reuse data to generate a bunch of interesting ways Index: lib/Transforms/Scalar/LoopUnrollPass.cpp =================================================================== --- lib/Transforms/Scalar/LoopUnrollPass.cpp +++ lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -405,9 +405,9 @@ // First accumulate the cost of this instruction. if (!Cost.IsFree) { UnrolledCost += TTI.getUserCost(I); - DEBUG(dbgs() << "Adding cost of instruction (iteration " << Iteration + LLVM_DEBUG(dbgs() << "Adding cost of instruction (iteration " << Iteration << "): "); - DEBUG(I->dump()); + LLVM_DEBUG(I->dump()); } // We must count the cost of every operand which is not free, @@ -442,14 +442,14 @@ assert(L->isLCSSAForm(DT) && "Must have loops in LCSSA form to track live-out values."); - DEBUG(dbgs() << "Starting LoopUnroll profitability analysis...\n"); + LLVM_DEBUG(dbgs() << "Starting LoopUnroll profitability analysis...\n"); // Simulate execution of each iteration of the loop counting instructions, // which would be simplified. // Since the same load will take different values on different iterations, // we literally have to go through all loop's iterations. for (unsigned Iteration = 0; Iteration < TripCount; ++Iteration) { - DEBUG(dbgs() << " Analyzing iteration " << Iteration << "\n"); + LLVM_DEBUG(dbgs() << " Analyzing iteration " << Iteration << "\n"); // Prepare for the iteration by collecting any simplified entry or backedge // inputs. @@ -522,7 +522,7 @@ // If unrolled body turns out to be too big, bail out. if (UnrolledCost > MaxUnrolledLoopSize) { - DEBUG(dbgs() << " Exceeded threshold.. exiting.\n" + LLVM_DEBUG(dbgs() << " Exceeded threshold.. exiting.\n" << " UnrolledCost: " << UnrolledCost << ", MaxUnrolledLoopSize: " << MaxUnrolledLoopSize << "\n"); @@ -578,7 +578,7 @@ // If we found no optimization opportunities on the first iteration, we // won't find them on later ones too. if (UnrolledCost == RolledDynamicCost) { - DEBUG(dbgs() << " No opportunities found.. exiting.\n" + LLVM_DEBUG(dbgs() << " No opportunities found.. exiting.\n" << " UnrolledCost: " << UnrolledCost << "\n"); return None; } @@ -600,7 +600,7 @@ } } - DEBUG(dbgs() << "Analysis finished:\n" + LLVM_DEBUG(dbgs() << "Analysis finished:\n" << "UnrolledCost: " << UnrolledCost << ", " << "RolledDynamicCost: " << RolledDynamicCost << "\n"); return {{UnrolledCost, RolledDynamicCost}}; @@ -806,7 +806,7 @@ if (TripCount) { UP.Partial |= ExplicitUnroll; if (!UP.Partial) { - DEBUG(dbgs() << " will not try to unroll partially because " + LLVM_DEBUG(dbgs() << " will not try to unroll partially because " << "-unroll-allow-partial not given\n"); UP.Count = 0; return false; @@ -894,7 +894,7 @@ // Reduce count based on the type of unrolling and the threshold values. UP.Runtime |= PragmaEnableUnroll || PragmaCount > 0 || UserUnrollCount; if (!UP.Runtime) { - DEBUG(dbgs() << " will not try to unroll loop with runtime trip count " + LLVM_DEBUG(dbgs() << " will not try to unroll loop with runtime trip count " << "-unroll-runtime not given\n"); UP.Count = 0; return false; @@ -915,7 +915,7 @@ if (!UP.AllowRemainder && UP.Count != 0 && (TripMultiple % UP.Count) != 0) { while (UP.Count != 0 && TripMultiple % UP.Count != 0) UP.Count >>= 1; - DEBUG(dbgs() << "Remainder loop is restricted (that could architecture " + LLVM_DEBUG(dbgs() << "Remainder loop is restricted (that could architecture " "specific or because the loop contains a convergent " "instruction), so unroll count must divide the trip " "multiple, " @@ -942,7 +942,7 @@ if (UP.Count > UP.MaxCount) UP.Count = UP.MaxCount; - DEBUG(dbgs() << " partially unrolling with count: " << UP.Count << "\n"); + LLVM_DEBUG(dbgs() << " partially unrolling with count: " << UP.Count << "\n"); if (UP.Count < 2) UP.Count = 0; return ExplicitUnroll; @@ -955,12 +955,12 @@ Optional ProvidedCount, Optional ProvidedThreshold, Optional ProvidedAllowPartial, Optional ProvidedRuntime, Optional ProvidedUpperBound, Optional ProvidedAllowPeeling) { - DEBUG(dbgs() << "Loop Unroll: F[" << L->getHeader()->getParent()->getName() + LLVM_DEBUG(dbgs() << "Loop Unroll: F[" << L->getHeader()->getParent()->getName() << "] Loop %" << L->getHeader()->getName() << "\n"); if (HasUnrollDisablePragma(L)) return LoopUnrollResult::Unmodified; if (!L->isLoopSimplifyForm()) { - DEBUG( + LLVM_DEBUG( dbgs() << " Not unrolling loop which is not in loop-simplify form.\n"); return LoopUnrollResult::Unmodified; } @@ -977,14 +977,14 @@ return LoopUnrollResult::Unmodified; unsigned LoopSize = ApproximateLoopSize( L, NumInlineCandidates, NotDuplicatable, Convergent, TTI, &AC, UP.BEInsns); - DEBUG(dbgs() << " Loop Size = " << LoopSize << "\n"); + LLVM_DEBUG(dbgs() << " Loop Size = " << LoopSize << "\n"); if (NotDuplicatable) { - DEBUG(dbgs() << " Not unrolling loop which contains non-duplicatable" + LLVM_DEBUG(dbgs() << " Not unrolling loop which contains non-duplicatable" << " instructions.\n"); return LoopUnrollResult::Unmodified; } if (NumInlineCandidates != 0) { - DEBUG(dbgs() << " Not unrolling loop with inlinable calls.\n"); + LLVM_DEBUG(dbgs() << " Not unrolling loop with inlinable calls.\n"); return LoopUnrollResult::Unmodified; } Index: lib/Transforms/Scalar/LoopUnswitch.cpp =================================================================== --- lib/Transforms/Scalar/LoopUnswitch.cpp +++ lib/Transforms/Scalar/LoopUnswitch.cpp @@ -298,7 +298,7 @@ MaxSize -= Props.SizeEstimation * Props.CanBeUnswitchedCount; if (Metrics.notDuplicatable) { - DEBUG(dbgs() << "NOT unswitching loop %" + LLVM_DEBUG(dbgs() << "NOT unswitching loop %" << L->getHeader()->getName() << ", contents cannot be " << "duplicated!\n"); return false; @@ -856,7 +856,7 @@ TerminatorInst *TI) { // Check to see if it would be profitable to unswitch current loop. if (!BranchesInfo.CostAllowsUnswitching()) { - DEBUG(dbgs() << "NOT unswitching loop %" + LLVM_DEBUG(dbgs() << "NOT unswitching loop %" << currentLoop->getHeader()->getName() << " at non-trivial condition '" << *Val << "' == " << *LoopCond << "\n" @@ -865,7 +865,7 @@ } if (hasBranchDivergence && getAnalysis().isDivergent(LoopCond)) { - DEBUG(dbgs() << "NOT unswitching loop %" + LLVM_DEBUG(dbgs() << "NOT unswitching loop %" << currentLoop->getHeader()->getName() << " at non-trivial condition '" << *Val << "' == " << *LoopCond << "\n" @@ -970,7 +970,7 @@ void LoopUnswitch::UnswitchTrivialCondition(Loop *L, Value *Cond, Constant *Val, BasicBlock *ExitBlock, TerminatorInst *TI) { - DEBUG(dbgs() << "loop-unswitch: Trivial-Unswitch loop %" + LLVM_DEBUG(dbgs() << "loop-unswitch: Trivial-Unswitch loop %" << loopHeader->getName() << " [" << L->getBlocks().size() << " blocks] in Function " << L->getHeader()->getParent()->getName() << " on cond: " << *Val @@ -1196,7 +1196,7 @@ void LoopUnswitch::UnswitchNontrivialCondition(Value *LIC, Constant *Val, Loop *L, TerminatorInst *TI) { Function *F = loopHeader->getParent(); - DEBUG(dbgs() << "loop-unswitch: Unswitching loop %" + LLVM_DEBUG(dbgs() << "loop-unswitch: Unswitching loop %" << loopHeader->getName() << " [" << L->getBlocks().size() << " blocks] in Function " << F->getName() << " when '" << *Val << "' == " << *LIC << "\n"); @@ -1355,7 +1355,7 @@ static void ReplaceUsesOfWith(Instruction *I, Value *V, std::vector &Worklist, Loop *L, LPPassManager *LPM) { - DEBUG(dbgs() << "Replace with '" << *V << "': " << *I << "\n"); + LLVM_DEBUG(dbgs() << "Replace with '" << *V << "': " << *I << "\n"); // Add uses to the worklist, which may be dead now. for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) @@ -1524,7 +1524,7 @@ // Simple DCE. if (isInstructionTriviallyDead(I)) { - DEBUG(dbgs() << "Remove dead instruction '" << *I << "\n"); + LLVM_DEBUG(dbgs() << "Remove dead instruction '" << *I << "\n"); // Add uses to the worklist, which may be dead now. for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) @@ -1557,7 +1557,7 @@ if (!SinglePred) continue; // Nothing to do. assert(SinglePred == Pred && "CFG broken"); - DEBUG(dbgs() << "Merging blocks: " << Pred->getName() << " <- " + LLVM_DEBUG(dbgs() << "Merging blocks: " << Pred->getName() << " <- " << Succ->getName() << "\n"); // Resolve any single entry PHI nodes in Succ. Index: lib/Transforms/Scalar/LoopVersioningLICM.cpp =================================================================== --- lib/Transforms/Scalar/LoopVersioningLICM.cpp +++ lib/Transforms/Scalar/LoopVersioningLICM.cpp @@ -245,48 +245,48 @@ bool LoopVersioningLICM::legalLoopStructure() { // Loop must be in loop simplify form. if (!CurLoop->isLoopSimplifyForm()) { - DEBUG( + LLVM_DEBUG( dbgs() << " loop is not in loop-simplify form.\n"); return false; } // Loop should be innermost loop, if not return false. if (!CurLoop->getSubLoops().empty()) { - DEBUG(dbgs() << " loop is not innermost\n"); + LLVM_DEBUG(dbgs() << " loop is not innermost\n"); return false; } // Loop should have a single backedge, if not return false. if (CurLoop->getNumBackEdges() != 1) { - DEBUG(dbgs() << " loop has multiple backedges\n"); + LLVM_DEBUG(dbgs() << " loop has multiple backedges\n"); return false; } // Loop must have a single exiting block, if not return false. if (!CurLoop->getExitingBlock()) { - DEBUG(dbgs() << " loop has multiple exiting block\n"); + LLVM_DEBUG(dbgs() << " loop has multiple exiting block\n"); return false; } // We only handle bottom-tested loop, i.e. loop in which the condition is // 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 (CurLoop->getExitingBlock() != CurLoop->getLoopLatch()) { - DEBUG(dbgs() << " loop is not bottom tested\n"); + LLVM_DEBUG(dbgs() << " loop is not bottom tested\n"); return false; } // Parallel loops must not have aliasing loop-invariant memory accesses. // Hence we don't need to version anything in this case. if (CurLoop->isAnnotatedParallel()) { - DEBUG(dbgs() << " Parallel loop is not worth versioning\n"); + LLVM_DEBUG(dbgs() << " Parallel loop is not worth versioning\n"); return false; } // Loop depth more then LoopDepthThreshold are not allowed if (CurLoop->getLoopDepth() > LoopDepthThreshold) { - DEBUG(dbgs() << " loop depth is more then threshold\n"); + LLVM_DEBUG(dbgs() << " loop depth is more then threshold\n"); return false; } // We need to be able to compute the loop trip count in order // to generate the bound checks. const SCEV *ExitCount = SE->getBackedgeTakenCount(CurLoop); if (ExitCount == SE->getCouldNotCompute()) { - DEBUG(dbgs() << " loop does not has trip count\n"); + LLVM_DEBUG(dbgs() << " loop does not has trip count\n"); return false; } return true; @@ -334,18 +334,18 @@ } // Ensure types should be of same type. if (!TypeSafety) { - DEBUG(dbgs() << " Alias tracker type safety failed!\n"); + LLVM_DEBUG(dbgs() << " Alias tracker type safety failed!\n"); return false; } // Ensure loop body shouldn't be read only. if (!HasMod) { - DEBUG(dbgs() << " No memory modified in loop body\n"); + LLVM_DEBUG(dbgs() << " No memory modified in loop body\n"); return false; } // Make sure alias set has may alias case. // If there no alias memory ambiguity, return false. if (!HasMayAlias) { - DEBUG(dbgs() << " No ambiguity in memory access.\n"); + LLVM_DEBUG(dbgs() << " No ambiguity in memory access.\n"); return false; } return true; @@ -361,12 +361,12 @@ assert(I != nullptr && "Null instruction found!"); // Check function call safety if (isa(I) && !AA->doesNotAccessMemory(CallSite(I))) { - DEBUG(dbgs() << " Unsafe call site found.\n"); + LLVM_DEBUG(dbgs() << " Unsafe call site found.\n"); return false; } // Avoid loops with possiblity of throw if (I->mayThrow()) { - DEBUG(dbgs() << " May throw instruction found in loop body\n"); + LLVM_DEBUG(dbgs() << " May throw instruction found in loop body\n"); return false; } // If current instruction is load instructions @@ -374,7 +374,7 @@ if (I->mayReadFromMemory()) { LoadInst *Ld = dyn_cast(I); if (!Ld || !Ld->isSimple()) { - DEBUG(dbgs() << " Found a non-simple load.\n"); + LLVM_DEBUG(dbgs() << " Found a non-simple load.\n"); return false; } LoadAndStoreCounter++; @@ -388,7 +388,7 @@ else if (I->mayWriteToMemory()) { StoreInst *St = dyn_cast(I); if (!St || !St->isSimple()) { - DEBUG(dbgs() << " Found a non-simple store.\n"); + LLVM_DEBUG(dbgs() << " Found a non-simple store.\n"); return false; } LoadAndStoreCounter++; @@ -427,13 +427,13 @@ LAI = &LAA->getInfo(CurLoop); // Check LoopAccessInfo for need of runtime check. if (LAI->getRuntimePointerChecking()->getChecks().empty()) { - DEBUG(dbgs() << " LAA: Runtime check not found !!\n"); + LLVM_DEBUG(dbgs() << " LAA: Runtime check not found !!\n"); return false; } // Number of runtime-checks should be less then RuntimeMemoryCheckThreshold if (LAI->getNumRuntimePointerChecks() > VectorizerParams::RuntimeMemoryCheckThreshold) { - DEBUG(dbgs() << " LAA: Runtime checks are more than threshold !!\n"); + LLVM_DEBUG(dbgs() << " LAA: Runtime checks are more than threshold !!\n"); ORE->emit([&]() { return OptimizationRemarkMissed(DEBUG_TYPE, "RuntimeCheck", CurLoop->getStartLoc(), @@ -447,22 +447,22 @@ } // Loop should have at least one invariant load or store instruction. if (!InvariantCounter) { - DEBUG(dbgs() << " Invariant not found !!\n"); + LLVM_DEBUG(dbgs() << " Invariant not found !!\n"); return false; } // Read only loop not allowed. if (IsReadOnlyLoop) { - DEBUG(dbgs() << " Found a read-only loop!\n"); + LLVM_DEBUG(dbgs() << " Found a read-only loop!\n"); return false; } // Profitablity check: // Check invariant threshold, should be in limit. if (InvariantCounter * 100 < InvariantThreshold * LoadAndStoreCounter) { - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << " Invariant load & store are less then defined threshold\n"); - DEBUG(dbgs() << " Invariant loads & stores: " + LLVM_DEBUG(dbgs() << " Invariant loads & stores: " << ((InvariantCounter * 100) / LoadAndStoreCounter) << "%\n"); - DEBUG(dbgs() << " Invariant loads & store threshold: " + LLVM_DEBUG(dbgs() << " Invariant loads & store threshold: " << InvariantThreshold << "%\n"); ORE->emit([&]() { return OptimizationRemarkMissed(DEBUG_TYPE, "InvariantThreshold", @@ -496,16 +496,16 @@ /// Return true if legal else returns false. bool LoopVersioningLICM::isLegalForVersioning() { using namespace ore; - DEBUG(dbgs() << "Loop: " << *CurLoop); + LLVM_DEBUG(dbgs() << "Loop: " << *CurLoop); // Make sure not re-visiting same loop again. if (isLoopAlreadyVisited()) { - DEBUG( + LLVM_DEBUG( dbgs() << " Revisiting loop in LoopVersioningLICM not allowed.\n\n"); return false; } // Check loop structure leagality. if (!legalLoopStructure()) { - DEBUG( + LLVM_DEBUG( dbgs() << " Loop structure not suitable for LoopVersioningLICM\n\n"); ORE->emit([&]() { return OptimizationRemarkMissed(DEBUG_TYPE, "IllegalLoopStruct", @@ -517,13 +517,13 @@ } // Check loop instruction leagality. if (!legalLoopInstructions()) { - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << " Loop instructions not suitable for LoopVersioningLICM\n\n"); return false; } // Check loop memory access leagality. if (!legalLoopMemoryAccesses()) { - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << " Loop memory access not suitable for LoopVersioningLICM\n\n"); ORE->emit([&]() { return OptimizationRemarkMissed(DEBUG_TYPE, "IllegalLoopMemoryAccess", @@ -534,7 +534,7 @@ return false; } // Loop versioning is feasible, return true. - DEBUG(dbgs() << " Loop Versioning found to be beneficial\n\n"); + LLVM_DEBUG(dbgs() << " Loop Versioning found to be beneficial\n\n"); ORE->emit([&]() { return OptimizationRemark(DEBUG_TYPE, "IsLegalForVersioning", CurLoop->getStartLoc(), CurLoop->getHeader()) Index: lib/Transforms/Scalar/MemCpyOptimizer.cpp =================================================================== --- lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -479,7 +479,7 @@ AMemSet = Builder.CreateMemSet(StartPtr, ByteVal, Range.End-Range.Start, Alignment); - DEBUG(dbgs() << "Replace stores:\n"; + LLVM_DEBUG(dbgs() << "Replace stores:\n"; for (Instruction *SI : Range.TheStores) dbgs() << *SI << '\n'; dbgs() << "With: " << *AMemSet << '\n'); @@ -594,7 +594,7 @@ // We made it, we need to lift for (auto *I : llvm::reverse(ToLift)) { - DEBUG(dbgs() << "Lifting " << *I << " before " << *P << "\n"); + LLVM_DEBUG(dbgs() << "Lifting " << *I << " before " << *P << "\n"); I->moveBefore(P); } @@ -670,7 +670,7 @@ LI->getPointerOperand(), Size, Align, SI->isVolatile()); - DEBUG(dbgs() << "Promoting " << *LI << " to " << *SI + LLVM_DEBUG(dbgs() << "Promoting " << *LI << " to " << *SI << " => " << *M << "\n"); MD->removeInstruction(SI); @@ -760,7 +760,7 @@ auto *M = Builder.CreateMemSet(SI->getPointerOperand(), ByteVal, Size, Align, SI->isVolatile()); - DEBUG(dbgs() << "Promoting " << *SI << " to " << *M << "\n"); + LLVM_DEBUG(dbgs() << "Promoting " << *SI << " to " << *M << "\n"); MD->removeInstruction(SI); SI->eraseFromParent(); @@ -1284,7 +1284,7 @@ MemoryLocation::getForSource(M))) return false; - DEBUG(dbgs() << "MemCpyOptPass: Optimizing memmove -> memcpy: " << *M + LLVM_DEBUG(dbgs() << "MemCpyOptPass: Optimizing memmove -> memcpy: " << *M << "\n"); // If not, then we know we can transform this. @@ -1367,7 +1367,7 @@ TmpCast = new BitCastInst(MDep->getSource(), ByValArg->getType(), "tmpcast", CS.getInstruction()); - DEBUG(dbgs() << "MemCpyOptPass: Forwarding memcpy to byval:\n" + LLVM_DEBUG(dbgs() << "MemCpyOptPass: Forwarding memcpy to byval:\n" << " " << *MDep << "\n" << " " << *CS.getInstruction() << "\n"); Index: lib/Transforms/Scalar/MergeICmps.cpp =================================================================== --- lib/Transforms/Scalar/MergeICmps.cpp +++ lib/Transforms/Scalar/MergeICmps.cpp @@ -76,25 +76,25 @@ BCEAtom visitICmpLoadOperand(Value *const Val) { BCEAtom Result; if (auto *const LoadI = dyn_cast(Val)) { - DEBUG(dbgs() << "load\n"); + LLVM_DEBUG(dbgs() << "load\n"); if (LoadI->isUsedOutsideOfBlock(LoadI->getParent())) { - DEBUG(dbgs() << "used outside of block\n"); + LLVM_DEBUG(dbgs() << "used outside of block\n"); return {}; } if (LoadI->isVolatile()) { - DEBUG(dbgs() << "volatile\n"); + LLVM_DEBUG(dbgs() << "volatile\n"); return {}; } Value *const Addr = LoadI->getOperand(0); if (auto *const GEP = dyn_cast(Addr)) { - DEBUG(dbgs() << "GEP\n"); + LLVM_DEBUG(dbgs() << "GEP\n"); if (LoadI->isUsedOutsideOfBlock(LoadI->getParent())) { - DEBUG(dbgs() << "used outside of block\n"); + LLVM_DEBUG(dbgs() << "used outside of block\n"); return {}; } const auto &DL = GEP->getModule()->getDataLayout(); if (!isDereferenceablePointer(GEP, DL)) { - DEBUG(dbgs() << "not dereferenceable\n"); + LLVM_DEBUG(dbgs() << "not dereferenceable\n"); // We need to make sure that we can do comparison in any order, so we // require memory to be unconditionnally dereferencable. return {}; @@ -184,7 +184,7 @@ BCECmpBlock visitICmp(const ICmpInst *const CmpI, const ICmpInst::Predicate ExpectedPredicate) { if (CmpI->getPredicate() == ExpectedPredicate) { - DEBUG(dbgs() << "cmp " + LLVM_DEBUG(dbgs() << "cmp " << (ExpectedPredicate == ICmpInst::ICMP_EQ ? "eq" : "ne") << "\n"); auto Lhs = visitICmpLoadOperand(CmpI->getOperand(0)); @@ -204,7 +204,7 @@ if (Block->empty()) return {}; auto *const BranchI = dyn_cast(Block->getTerminator()); if (!BranchI) return {}; - DEBUG(dbgs() << "branch\n"); + LLVM_DEBUG(dbgs() << "branch\n"); if (BranchI->isUnconditional()) { // In this case, we expect an incoming value which is the result of the // comparison. This is the last link in the chain of comparisons (note @@ -212,7 +212,7 @@ // can be reordered). auto *const CmpI = dyn_cast(Val); if (!CmpI) return {}; - DEBUG(dbgs() << "icmp\n"); + LLVM_DEBUG(dbgs() << "icmp\n"); auto Result = visitICmp(CmpI, ICmpInst::ICMP_EQ); Result.CmpI = CmpI; Result.BranchI = BranchI; @@ -221,12 +221,12 @@ // In this case, we expect a constant incoming value (the comparison is // chained). const auto *const Const = dyn_cast(Val); - DEBUG(dbgs() << "const\n"); + LLVM_DEBUG(dbgs() << "const\n"); if (!Const->isZero()) return {}; - DEBUG(dbgs() << "false\n"); + LLVM_DEBUG(dbgs() << "false\n"); auto *const CmpI = dyn_cast(BranchI->getCondition()); if (!CmpI) return {}; - DEBUG(dbgs() << "icmp\n"); + LLVM_DEBUG(dbgs() << "icmp\n"); assert(BranchI->getNumSuccessors() == 2 && "expecting a cond branch"); BasicBlock *const FalseBlock = BranchI->getSuccessor(1); auto Result = visitICmp( @@ -285,16 +285,16 @@ Block, Phi.getParent()); Comparison.BB = Block; if (!Comparison.IsValid()) { - DEBUG(dbgs() << "skip: not a valid BCECmpBlock\n"); + LLVM_DEBUG(dbgs() << "skip: not a valid BCECmpBlock\n"); return; } if (Comparison.doesOtherWork()) { - DEBUG(dbgs() << "block does extra work besides compare\n"); + LLVM_DEBUG(dbgs() << "block does extra work besides compare\n"); if (BlockIdx == 0) { // First block. // TODO(courbet): The first block can do other things, and we should // split them apart in a separate block before the comparison chain. // Right now we just discard it and make the chain shorter. - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "ignoring first block that does extra work besides compare\n"); continue; } @@ -323,12 +323,12 @@ // We could still merge bb1 and bb2 though. return; } - DEBUG(dbgs() << "*Found cmp of " << Comparison.SizeBits() + LLVM_DEBUG(dbgs() << "*Found cmp of " << Comparison.SizeBits() << " bits between " << Comparison.Lhs().Base() << " + " << Comparison.Lhs().Offset << " and " << Comparison.Rhs().Base() << " + " << Comparison.Rhs().Offset << "\n"); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n"); Comparisons.push_back(Comparison); } assert(!Comparisons.empty() && "chain with no BCE basic blocks"); @@ -428,7 +428,7 @@ LLVMContext &Context = BB->getContext(); if (Comparisons.size() >= 2) { - DEBUG(dbgs() << "Merging " << Comparisons.size() << " comparisons\n"); + LLVM_DEBUG(dbgs() << "Merging " << Comparisons.size() << " comparisons\n"); const auto TotalSize = std::accumulate(Comparisons.begin(), Comparisons.end(), 0, [](int Size, const BCECmpBlock &C) { @@ -472,17 +472,17 @@ } else { assert(Comparisons.size() == 1); // There are no blocks to merge, but we still need to update the branches. - DEBUG(dbgs() << "Only one comparison, updating branches\n"); + LLVM_DEBUG(dbgs() << "Only one comparison, updating branches\n"); if (NextBBInChain) { if (FirstComparison.BranchI->isConditional()) { - DEBUG(dbgs() << "conditional -> conditional\n"); + LLVM_DEBUG(dbgs() << "conditional -> conditional\n"); // Just update the "true" target, the "false" target should already be // the phi block. assert(FirstComparison.BranchI->getSuccessor(1) == Phi.getParent()); FirstComparison.BranchI->setSuccessor(0, NextBBInChain); Phi.addIncoming(ConstantInt::getFalse(Context), BB); } else { - DEBUG(dbgs() << "unconditional -> conditional\n"); + LLVM_DEBUG(dbgs() << "unconditional -> conditional\n"); // Replace the unconditional branch by a conditional one. FirstComparison.BranchI->eraseFromParent(); IRBuilder<> Builder(BB); @@ -492,14 +492,14 @@ } } else { if (FirstComparison.BranchI->isConditional()) { - DEBUG(dbgs() << "conditional -> unconditional\n"); + LLVM_DEBUG(dbgs() << "conditional -> unconditional\n"); // Replace the conditional branch by an unconditional one. FirstComparison.BranchI->eraseFromParent(); IRBuilder<> Builder(BB); Builder.CreateBr(Phi.getParent()); Phi.addIncoming(FirstComparison.CmpI, BB); } else { - DEBUG(dbgs() << "unconditional -> unconditional\n"); + LLVM_DEBUG(dbgs() << "unconditional -> unconditional\n"); Phi.addIncoming(FirstComparison.CmpI, BB); } } @@ -517,7 +517,7 @@ if (CurBlock->hasAddressTaken()) { // Somebody is jumping to the block through an address, all bets are // off. - DEBUG(dbgs() << "skip: block " << BlockIndex + LLVM_DEBUG(dbgs() << "skip: block " << BlockIndex << " has its address taken\n"); return {}; } @@ -525,13 +525,13 @@ auto *SinglePredecessor = CurBlock->getSinglePredecessor(); if (!SinglePredecessor) { // The block has two or more predecessors. - DEBUG(dbgs() << "skip: block " << BlockIndex + LLVM_DEBUG(dbgs() << "skip: block " << BlockIndex << " has two or more predecessors\n"); return {}; } if (Phi.getBasicBlockIndex(SinglePredecessor) < 0) { // The block does not link back to the phi. - DEBUG(dbgs() << "skip: block " << BlockIndex + LLVM_DEBUG(dbgs() << "skip: block " << BlockIndex << " does not link back to the phi\n"); return {}; } @@ -542,9 +542,9 @@ } bool processPhi(PHINode &Phi, const TargetLibraryInfo *const TLI) { - DEBUG(dbgs() << "processPhi()\n"); + LLVM_DEBUG(dbgs() << "processPhi()\n"); if (Phi.getNumIncomingValues() <= 1) { - DEBUG(dbgs() << "skip: only one incoming value in phi\n"); + LLVM_DEBUG(dbgs() << "skip: only one incoming value in phi\n"); return false; } // We are looking for something that has the following structure: @@ -568,18 +568,18 @@ if (isa(Phi.getIncomingValue(I))) continue; if (LastBlock) { // There are several non-constant values. - DEBUG(dbgs() << "skip: several non-constant values\n"); + LLVM_DEBUG(dbgs() << "skip: several non-constant values\n"); return false; } LastBlock = Phi.getIncomingBlock(I); } if (!LastBlock) { // There is no non-constant block. - DEBUG(dbgs() << "skip: no non-constant block\n"); + LLVM_DEBUG(dbgs() << "skip: no non-constant block\n"); return false; } if (LastBlock->getSingleSuccessor() != Phi.getParent()) { - DEBUG(dbgs() << "skip: last block non-phi successor\n"); + LLVM_DEBUG(dbgs() << "skip: last block non-phi successor\n"); return false; } @@ -589,7 +589,7 @@ BCECmpChain CmpChain(Blocks, Phi); if (CmpChain.size() < 2) { - DEBUG(dbgs() << "skip: only one compare block\n"); + LLVM_DEBUG(dbgs() << "skip: only one compare block\n"); return false; } @@ -624,7 +624,7 @@ PreservedAnalyses MergeICmps::runImpl(Function &F, const TargetLibraryInfo *TLI, const TargetTransformInfo *TTI) { - DEBUG(dbgs() << "MergeICmpsPass: " << F.getName() << "\n"); + LLVM_DEBUG(dbgs() << "MergeICmpsPass: " << F.getName() << "\n"); // We only try merging comparisons if the target wants to expand memcmp later. // The rationale is to avoid turning small chains into memcmp calls. Index: lib/Transforms/Scalar/MergedLoadStoreMotion.cpp =================================================================== --- lib/Transforms/Scalar/MergedLoadStoreMotion.cpp +++ lib/Transforms/Scalar/MergedLoadStoreMotion.cpp @@ -203,7 +203,7 @@ /// StoreInst *MergedLoadStoreMotion::canSinkFromBlock(BasicBlock *BB1, StoreInst *Store0) { - DEBUG(dbgs() << "can Sink? : "; Store0->dump(); dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "can Sink? : "; Store0->dump(); dbgs() << "\n"); BasicBlock *BB0 = Store0->getParent(); for (Instruction &Inst : reverse(*BB1)) { auto *Store1 = dyn_cast(&Inst); @@ -254,7 +254,7 @@ if (A0 && A1 && A0->isIdenticalTo(A1) && A0->hasOneUse() && (A0->getParent() == S0->getParent()) && A1->hasOneUse() && (A1->getParent() == S1->getParent()) && isa(A0)) { - DEBUG(dbgs() << "Sink Instruction into BB \n"; BB->dump(); + LLVM_DEBUG(dbgs() << "Sink Instruction into BB \n"; BB->dump(); dbgs() << "Instruction Left\n"; S0->dump(); dbgs() << "\n"; dbgs() << "Instruction Right\n"; S1->dump(); dbgs() << "\n"); // Hoist the instruction. @@ -338,7 +338,7 @@ break; RBI = Pred0->rbegin(); RBE = Pred0->rend(); - DEBUG(dbgs() << "Search again\n"; Instruction *I = &*RBI; I->dump()); + LLVM_DEBUG(dbgs() << "Search again\n"; Instruction *I = &*RBI; I->dump()); } } return MergedStores; @@ -350,7 +350,7 @@ this->AA = &AA; bool Changed = false; - DEBUG(dbgs() << "Instruction Merger\n"); + LLVM_DEBUG(dbgs() << "Instruction Merger\n"); // Merge unconditional branches, allowing PRE to catch more // optimization opportunities. Index: lib/Transforms/Scalar/NewGVN.cpp =================================================================== --- lib/Transforms/Scalar/NewGVN.cpp +++ lib/Transforms/Scalar/NewGVN.cpp @@ -221,13 +221,13 @@ Components.resize(Components.size() + 1); auto &Component = Components.back(); Component.insert(I); - DEBUG(dbgs() << "Component root is " << *I << "\n"); + LLVM_DEBUG(dbgs() << "Component root is " << *I << "\n"); InComponent.insert(I); ValueToComponent[I] = ComponentID; // Pop a component off the stack and label it. while (!Stack.empty() && Root.lookup(Stack.back()) >= OurDFS) { auto *Member = Stack.back(); - DEBUG(dbgs() << "Component member is " << *Member << "\n"); + LLVM_DEBUG(dbgs() << "Component member is " << *Member << "\n"); Component.insert(Member); InComponent.insert(Member); ValueToComponent[Member] = ComponentID; @@ -1067,7 +1067,7 @@ return nullptr; if (auto *C = dyn_cast(V)) { if (I) - DEBUG(dbgs() << "Simplified " << *I << " to " + LLVM_DEBUG(dbgs() << "Simplified " << *I << " to " << " constant " << *C << "\n"); NumGVNOpsSimplified++; assert(isa(E) && @@ -1076,7 +1076,7 @@ return createConstantExpression(C); } else if (isa(V) || isa(V)) { if (I) - DEBUG(dbgs() << "Simplified " << *I << " to " + LLVM_DEBUG(dbgs() << "Simplified " << *I << " to " << " variable " << *V << "\n"); deleteExpression(E); return createVariableExpression(V); @@ -1100,7 +1100,7 @@ } if (I) - DEBUG(dbgs() << "Simplified " << *I << " to " + LLVM_DEBUG(dbgs() << "Simplified " << *I << " to " << " expression " << *CC->getDefiningExpr() << "\n"); NumGVNOpsSimplified++; deleteExpression(E); @@ -1421,7 +1421,7 @@ if (Offset >= 0) { if (auto *C = dyn_cast( lookupOperandLeader(DepSI->getValueOperand()))) { - DEBUG(dbgs() << "Coercing load from store " << *DepSI << " to constant " + LLVM_DEBUG(dbgs() << "Coercing load from store " << *DepSI << " to constant " << *C << "\n"); return createConstantExpression( getConstantStoreValueForLoad(C, Offset, LoadType, DL)); @@ -1437,7 +1437,7 @@ if (auto *C = dyn_cast(lookupOperandLeader(DepLI))) if (auto *PossibleConstant = getConstantLoadValueForLoad(C, Offset, LoadType, DL)) { - DEBUG(dbgs() << "Coercing load from load " << *LI << " to constant " + LLVM_DEBUG(dbgs() << "Coercing load from load " << *LI << " to constant " << *PossibleConstant << "\n"); return createConstantExpression(PossibleConstant); } @@ -1447,7 +1447,7 @@ if (Offset >= 0) { if (auto *PossibleConstant = getConstantMemInstValueForLoad(DepMI, Offset, LoadType, DL)) { - DEBUG(dbgs() << "Coercing load from meminst " << *DepMI + LLVM_DEBUG(dbgs() << "Coercing load from meminst " << *DepMI << " to constant " << *PossibleConstant << "\n"); return createConstantExpression(PossibleConstant); } @@ -1529,7 +1529,7 @@ if (!PI) return nullptr; - DEBUG(dbgs() << "Found predicate info from instruction !\n"); + LLVM_DEBUG(dbgs() << "Found predicate info from instruction !\n"); auto *PWC = dyn_cast(PI); if (!PWC) @@ -1569,7 +1569,7 @@ return nullptr; if (CopyOf != Cmp->getOperand(0) && CopyOf != Cmp->getOperand(1)) { - DEBUG(dbgs() << "Copy is not of any condition operands!\n"); + LLVM_DEBUG(dbgs() << "Copy is not of any condition operands!\n"); return nullptr; } Value *FirstOp = lookupOperandLeader(Cmp->getOperand(0)); @@ -1652,10 +1652,10 @@ CongruenceClass *NewClass) { assert(NewClass && "Every MemoryAccess should be getting mapped to a non-null class"); - DEBUG(dbgs() << "Setting " << *From); - DEBUG(dbgs() << " equivalent to congruence class "); - DEBUG(dbgs() << NewClass->getID() << " with current MemoryAccess leader "); - DEBUG(dbgs() << *NewClass->getMemoryLeader() << "\n"); + LLVM_DEBUG(dbgs() << "Setting " << *From); + LLVM_DEBUG(dbgs() << " equivalent to congruence class "); + LLVM_DEBUG(dbgs() << NewClass->getID() << " with current MemoryAccess leader "); + LLVM_DEBUG(dbgs() << *NewClass->getMemoryLeader() << "\n"); auto LookupResult = MemoryAccessToClass.find(From); bool Changed = false; @@ -1673,7 +1673,7 @@ OldClass->setMemoryLeader(nullptr); } else { OldClass->setMemoryLeader(getNextMemoryLeader(OldClass)); - DEBUG(dbgs() << "Memory class leader change for class " + LLVM_DEBUG(dbgs() << "Memory class leader change for class " << OldClass->getID() << " to " << *OldClass->getMemoryLeader() << " due to removal of a memory member " << *From @@ -1753,12 +1753,12 @@ // If it has undef at this point, it means there are no-non-undef arguments, // and thus, the value of the phi node must be undef. if (HasUndef) { - DEBUG(dbgs() << "PHI Node " << *I + LLVM_DEBUG(dbgs() << "PHI Node " << *I << " has no non-undef arguments, valuing it as undef\n"); return createConstantExpression(UndefValue::get(I->getType())); } - DEBUG(dbgs() << "No arguments of PHI node " << *I << " are live\n"); + LLVM_DEBUG(dbgs() << "No arguments of PHI node " << *I << " are live\n"); deleteExpression(E); return createDeadExpression(); } @@ -1797,7 +1797,7 @@ InstrToDFSNum(AllSameValue) > InstrToDFSNum(I)) return E; NumGVNPhisAllSame++; - DEBUG(dbgs() << "Simplified PHI node " << *I << " to " << *AllSameValue + LLVM_DEBUG(dbgs() << "Simplified PHI node " << *I << " to " << *AllSameValue << "\n"); deleteExpression(E); return createVariableOrConstant(AllSameValue); @@ -2091,7 +2091,7 @@ } void NewGVN::addMemoryUsers(const MemoryAccess *To, MemoryAccess *U) const { - DEBUG(dbgs() << "Adding memory user " << *U << " to " << *To << "\n"); + LLVM_DEBUG(dbgs() << "Adding memory user " << *U << " to " << *To << "\n"); MemoryToUsers[To].insert(U); } @@ -2227,7 +2227,7 @@ (isa(I) && NewClass->getStoreCount() == 1)); NewClass->setMemoryLeader(InstMA); // Mark it touched if we didn't just create a singleton - DEBUG(dbgs() << "Memory class leader change for class " << NewClass->getID() + LLVM_DEBUG(dbgs() << "Memory class leader change for class " << NewClass->getID() << " due to new memory instruction becoming leader\n"); markMemoryLeaderChangeTouched(NewClass); } @@ -2236,7 +2236,7 @@ if (OldClass->getMemoryLeader() == InstMA) { if (!OldClass->definesNoMemory()) { OldClass->setMemoryLeader(getNextMemoryLeader(OldClass)); - DEBUG(dbgs() << "Memory class leader change for class " + LLVM_DEBUG(dbgs() << "Memory class leader change for class " << OldClass->getID() << " to " << *OldClass->getMemoryLeader() << " due to removal of old leader " << *InstMA << "\n"); @@ -2276,7 +2276,7 @@ NewClass->setStoredValue(SE->getStoredValue()); markValueLeaderChangeTouched(NewClass); // Shift the new class leader to be the store - DEBUG(dbgs() << "Changing leader of congruence class " + LLVM_DEBUG(dbgs() << "Changing leader of congruence class " << NewClass->getID() << " from " << *NewClass->getLeader() << " to " << *SI << " because store joined class\n"); // If we changed the leader, we have to mark it changed because we don't @@ -2298,7 +2298,7 @@ // See if we destroyed the class or need to swap leaders. if (OldClass->empty() && OldClass != TOPClass) { if (OldClass->getDefiningExpr()) { - DEBUG(dbgs() << "Erasing expression " << *OldClass->getDefiningExpr() + LLVM_DEBUG(dbgs() << "Erasing expression " << *OldClass->getDefiningExpr() << " from table\n"); // We erase it as an exact expression to make sure we don't just erase an // equivalent one. @@ -2316,7 +2316,7 @@ // When the leader changes, the value numbering of // everything may change due to symbolization changes, so we need to // reprocess. - DEBUG(dbgs() << "Value class leader change for class " << OldClass->getID() + LLVM_DEBUG(dbgs() << "Value class leader change for class " << OldClass->getID() << "\n"); ++NumGVNLeaderChanges; // Destroy the stored value if there are no more stores to represent it. @@ -2380,12 +2380,12 @@ "VariableExpression should have been handled already"); EClass = NewClass; - DEBUG(dbgs() << "Created new congruence class for " << *I + LLVM_DEBUG(dbgs() << "Created new congruence class for " << *I << " using expression " << *E << " at " << NewClass->getID() << " and leader " << *(NewClass->getLeader())); if (NewClass->getStoredValue()) - DEBUG(dbgs() << " and stored value " << *(NewClass->getStoredValue())); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " and stored value " << *(NewClass->getStoredValue())); + LLVM_DEBUG(dbgs() << "\n"); } else { EClass = lookupResult.first->second; if (isa(E)) @@ -2403,7 +2403,7 @@ bool ClassChanged = IClass != EClass; bool LeaderChanged = LeaderChanges.erase(I); if (ClassChanged || LeaderChanged) { - DEBUG(dbgs() << "New class " << EClass->getID() << " for expression " << *E + LLVM_DEBUG(dbgs() << "New class " << EClass->getID() << " for expression " << *E << "\n"); if (ClassChanged) { moveValueToNewCongruenceClass(I, E, IClass, EClass); @@ -2442,11 +2442,11 @@ if (ReachableEdges.insert({From, To}).second) { // If this block wasn't reachable before, all instructions are touched. if (ReachableBlocks.insert(To).second) { - DEBUG(dbgs() << "Block " << getBlockName(To) << " marked reachable\n"); + LLVM_DEBUG(dbgs() << "Block " << getBlockName(To) << " marked reachable\n"); const auto &InstRange = BlockInstRange.lookup(To); TouchedInstructions.set(InstRange.first, InstRange.second); } else { - DEBUG(dbgs() << "Block " << getBlockName(To) + LLVM_DEBUG(dbgs() << "Block " << getBlockName(To) << " was reachable, but new edge {" << getBlockName(From) << "," << getBlockName(To) << "} to it found\n"); @@ -2495,11 +2495,11 @@ BasicBlock *FalseSucc = BR->getSuccessor(1); if (CondEvaluated && (CI = dyn_cast(CondEvaluated))) { if (CI->isOne()) { - DEBUG(dbgs() << "Condition for Terminator " << *TI + LLVM_DEBUG(dbgs() << "Condition for Terminator " << *TI << " evaluated to true\n"); updateReachableEdge(B, TrueSucc); } else if (CI->isZero()) { - DEBUG(dbgs() << "Condition for Terminator " << *TI + LLVM_DEBUG(dbgs() << "Condition for Terminator " << *TI << " evaluated to false\n"); updateReachableEdge(B, FalseSucc); } @@ -2685,7 +2685,7 @@ auto *FoundVal = findPHIOfOpsLeader(E, OrigInst, PredBB); if (!FoundVal) { ExpressionToPhiOfOps[E].insert(OrigInst); - DEBUG(dbgs() << "Cannot find phi of ops operand for " << *TransInst + LLVM_DEBUG(dbgs() << "Cannot find phi of ops operand for " << *TransInst << " in block " << getBlockName(PredBB) << "\n"); return nullptr; } @@ -2730,7 +2730,7 @@ auto *ValuePHI = RealToTemp.lookup(Op); if (!ValuePHI) continue; - DEBUG(dbgs() << "Found possible dependent phi of ops\n"); + LLVM_DEBUG(dbgs() << "Found possible dependent phi of ops\n"); Op = ValuePHI; } auto *OpPHI = cast(Op); @@ -2785,7 +2785,7 @@ if (!FoundVal) return nullptr; } else { - DEBUG(dbgs() << "Skipping phi of ops operand for incoming block " + LLVM_DEBUG(dbgs() << "Skipping phi of ops operand for incoming block " << getBlockName(PredBB) << " because the block is unreachable\n"); FoundVal = UndefValue::get(I->getType()); @@ -2793,7 +2793,7 @@ } Ops.push_back({FoundVal, PredBB}); - DEBUG(dbgs() << "Found phi of ops operand " << *FoundVal << " in " + LLVM_DEBUG(dbgs() << "Found phi of ops operand " << *FoundVal << " in " << getBlockName(PredBB) << "\n"); } for (auto Dep : Deps) @@ -2801,7 +2801,7 @@ sortPHIOps(Ops); auto *E = performSymbolicPHIEvaluation(Ops, I, PHIBlock); if (isa(E) || isa(E)) { - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "Not creating real PHI of ops because it simplified to existing " "value or constant\n"); return E; @@ -2827,7 +2827,7 @@ } } RevisitOnReachabilityChange[PHIBlock].set(InstrToDFSNum(I)); - DEBUG(dbgs() << "Created phi of ops " << *ValuePHI << " for " << *I + LLVM_DEBUG(dbgs() << "Created phi of ops " << *ValuePHI << " for " << *I << "\n"); return E; @@ -2902,7 +2902,7 @@ void NewGVN::cleanupTables() { for (unsigned i = 0, e = CongruenceClasses.size(); i != e; ++i) { - DEBUG(dbgs() << "Congruence class " << CongruenceClasses[i]->getID() + LLVM_DEBUG(dbgs() << "Congruence class " << CongruenceClasses[i]->getID() << " has " << CongruenceClasses[i]->size() << " members\n"); // Make sure we delete the congruence class (probably worth switching to // a unique_ptr at some point. @@ -2973,7 +2973,7 @@ // we change its DFS number so that it doesn't get value numbered. if (isInstructionTriviallyDead(&I, TLI)) { InstrDFS[&I] = 0; - DEBUG(dbgs() << "Skipping trivially dead instruction " << I << "\n"); + LLVM_DEBUG(dbgs() << "Skipping trivially dead instruction " << I << "\n"); markInstructionForDeletion(&I); continue; } @@ -3039,9 +3039,9 @@ [&AllSameValue](const MemoryAccess *V) { return V == AllSameValue; }); if (AllEqual) - DEBUG(dbgs() << "Memory Phi value numbered to " << *AllSameValue << "\n"); + LLVM_DEBUG(dbgs() << "Memory Phi value numbered to " << *AllSameValue << "\n"); else - DEBUG(dbgs() << "Memory Phi value numbered to itself\n"); + LLVM_DEBUG(dbgs() << "Memory Phi value numbered to itself\n"); // If it's equal to something, it's in that class. Otherwise, it has to be in // a class where it is the leader (other things may be equivalent to it, but // it needs to start off in its own class, which means it must have been the @@ -3060,7 +3060,7 @@ // Value number a single instruction, symbolically evaluating, performing // congruence finding, and updating mappings. void NewGVN::valueNumberInstruction(Instruction *I) { - DEBUG(dbgs() << "Processing instruction " << *I << "\n"); + LLVM_DEBUG(dbgs() << "Processing instruction " << *I << "\n"); if (!I->isTerminator()) { const Expression *Symbolized = nullptr; SmallPtrSet Visited; @@ -3246,7 +3246,7 @@ // and redoing the iteration to see if anything changed. void NewGVN::verifyIterationSettled(Function &F) { #ifndef NDEBUG - DEBUG(dbgs() << "Beginning iteration verification\n"); + LLVM_DEBUG(dbgs() << "Beginning iteration verification\n"); if (DebugCounter::isCounterSet(VNCounter)) DebugCounter::setCounterValue(VNCounter, StartingVNCounter); @@ -3364,7 +3364,7 @@ // If it's not reachable, erase any touched instructions and move on. if (!BlockReachable) { TouchedInstructions.reset(CurrInstRange.first, CurrInstRange.second); - DEBUG(dbgs() << "Skipping instructions in block " + LLVM_DEBUG(dbgs() << "Skipping instructions in block " << getBlockName(CurrBlock) << " because it is unreachable\n"); continue; @@ -3376,7 +3376,7 @@ TouchedInstructions.reset(InstrNum); if (auto *MP = dyn_cast(V)) { - DEBUG(dbgs() << "Processing MemoryPhi " << *MP << "\n"); + LLVM_DEBUG(dbgs() << "Processing MemoryPhi " << *MP << "\n"); valueNumberMemoryPhi(MP); } else if (auto *I = dyn_cast(V)) { valueNumberInstruction(I); @@ -3446,7 +3446,7 @@ // Initialize the touched instructions to include the entry block. const auto &InstRange = BlockInstRange.lookup(&F.getEntryBlock()); TouchedInstructions.set(InstRange.first, InstRange.second); - DEBUG(dbgs() << "Block " << getBlockName(&F.getEntryBlock()) + LLVM_DEBUG(dbgs() << "Block " << getBlockName(&F.getEntryBlock()) << " marked reachable\n"); ReachableBlocks.insert(&F.getEntryBlock()); @@ -3472,7 +3472,7 @@ }; for (auto &BB : make_filter_range(F, UnreachableBlockPred)) { - DEBUG(dbgs() << "We believe block " << getBlockName(&BB) + LLVM_DEBUG(dbgs() << "We believe block " << getBlockName(&BB) << " is unreachable\n"); deleteInstructionsInBlock(&BB); Changed = true; @@ -3695,7 +3695,7 @@ } void NewGVN::deleteInstructionsInBlock(BasicBlock *BB) { - DEBUG(dbgs() << " BasicBlock Dead:" << *BB); + LLVM_DEBUG(dbgs() << " BasicBlock Dead:" << *BB); ++NumGVNBlocksDeleted; // Delete the instructions backwards, as it has a reduced likelihood of having @@ -3722,12 +3722,12 @@ } void NewGVN::markInstructionForDeletion(Instruction *I) { - DEBUG(dbgs() << "Marking " << *I << " for deletion\n"); + LLVM_DEBUG(dbgs() << "Marking " << *I << " for deletion\n"); InstructionsToErase.insert(I); } void NewGVN::replaceInstruction(Instruction *I, Value *V) { - DEBUG(dbgs() << "Replacing " << *I << " with " << *V << "\n"); + LLVM_DEBUG(dbgs() << "Replacing " << *I << " with " << *V << "\n"); patchAndReplaceAllUsesWith(I, V); // We save the actual erasing to avoid invalidating memory // dependencies until we are done with everything. @@ -3853,7 +3853,7 @@ auto ReplaceUnreachablePHIArgs = [&](PHINode *PHI, BasicBlock *BB) { for (auto &Operand : PHI->incoming_values()) if (!ReachableEdges.count({PHI->getIncomingBlock(Operand), BB})) { - DEBUG(dbgs() << "Replacing incoming value of " << PHI << " for block " + LLVM_DEBUG(dbgs() << "Replacing incoming value of " << PHI << " for block " << getBlockName(PHI->getIncomingBlock(Operand)) << " with undef due to it being unreachable\n"); Operand.set(UndefValue::get(PHI->getType())); @@ -3887,7 +3887,7 @@ // Map to store the use counts DenseMap UseCounts; for (auto *CC : reverse(CongruenceClasses)) { - DEBUG(dbgs() << "Eliminating in congruence class " << CC->getID() << "\n"); + LLVM_DEBUG(dbgs() << "Eliminating in congruence class " << CC->getID() << "\n"); // Track the equivalent store info so we can decide whether to try // dead store elimination. SmallVector PossibleDeadStores; @@ -3925,7 +3925,7 @@ MembersLeft.insert(Member); continue; } - DEBUG(dbgs() << "Found replacement " << *(Leader) << " for " << *Member + LLVM_DEBUG(dbgs() << "Found replacement " << *(Leader) << " for " << *Member << "\n"); auto *I = cast(Member); assert(Leader != I && "About to accidentally remove our leader"); @@ -3966,7 +3966,7 @@ // remove from temp instruction list. AllTempInstructions.erase(PN); auto *DefBlock = getBlockForValue(Def); - DEBUG(dbgs() << "Inserting fully real phi of ops" << *Def + LLVM_DEBUG(dbgs() << "Inserting fully real phi of ops" << *Def << " into block " << getBlockName(getBlockForValue(Def)) << "\n"); PN->insertBefore(&DefBlock->front()); @@ -3975,14 +3975,14 @@ } if (EliminationStack.empty()) { - DEBUG(dbgs() << "Elimination Stack is empty\n"); + LLVM_DEBUG(dbgs() << "Elimination Stack is empty\n"); } else { - DEBUG(dbgs() << "Elimination Stack Top DFS numbers are (" + LLVM_DEBUG(dbgs() << "Elimination Stack Top DFS numbers are (" << EliminationStack.dfs_back().first << "," << EliminationStack.dfs_back().second << ")\n"); } - DEBUG(dbgs() << "Current DFS numbers are (" << MemberDFSIn << "," + LLVM_DEBUG(dbgs() << "Current DFS numbers are (" << MemberDFSIn << "," << MemberDFSOut << ")\n"); // First, we see if we are out of scope or empty. If so, // and there equivalences, we try to replace the top of @@ -4065,7 +4065,7 @@ // Don't replace our existing users with ourselves. if (U->get() == DominatingLeader) continue; - DEBUG(dbgs() << "Found replacement " << *DominatingLeader << " for " + LLVM_DEBUG(dbgs() << "Found replacement " << *DominatingLeader << " for " << *U->get() << " in " << *(U->getUser()) << "\n"); // If we replaced something in an instruction, handle the patching of @@ -4132,7 +4132,7 @@ (void)Leader; assert(DT->dominates(Leader->getParent(), Member->getParent())); // Member is dominater by Leader, and thus dead - DEBUG(dbgs() << "Marking dead store " << *Member + LLVM_DEBUG(dbgs() << "Marking dead store " << *Member << " that is dominated by " << *Leader << "\n"); markInstructionForDeletion(Member); CC->erase(Member); Index: lib/Transforms/Scalar/PlaceSafepoints.cpp =================================================================== --- lib/Transforms/Scalar/PlaceSafepoints.cpp +++ lib/Transforms/Scalar/PlaceSafepoints.cpp @@ -323,7 +323,7 @@ // avoiding the runtime cost of the actual safepoint. if (!AllBackedges) { if (mustBeFiniteCountedLoop(L, SE, Pred)) { - DEBUG(dbgs() << "skipping safepoint placement in finite loop\n"); + LLVM_DEBUG(dbgs() << "skipping safepoint placement in finite loop\n"); FiniteExecution++; continue; } @@ -332,7 +332,7 @@ // Note: This is only semantically legal since we won't do any further // IPO or inlining before the actual call insertion.. If we hadn't, we // might latter loose this call safepoint. - DEBUG(dbgs() << "skipping safepoint placement due to unconditional call\n"); + LLVM_DEBUG(dbgs() << "skipping safepoint placement due to unconditional call\n"); CallInLoop++; continue; } @@ -348,7 +348,7 @@ // variables) and branches to the true header TerminatorInst *Term = Pred->getTerminator(); - DEBUG(dbgs() << "[LSP] terminator instruction: " << *Term); + LLVM_DEBUG(dbgs() << "[LSP] terminator instruction: " << *Term); PollLocations.push_back(Term); } Index: lib/Transforms/Scalar/Reassociate.cpp =================================================================== --- lib/Transforms/Scalar/Reassociate.cpp +++ lib/Transforms/Scalar/Reassociate.cpp @@ -168,7 +168,7 @@ // Assign distinct ranks to function arguments. for (auto &Arg : F.args()) { ValueRankMap[&Arg] = ++Rank; - DEBUG(dbgs() << "Calculated Rank[" << Arg.getName() << "] = " << Rank + LLVM_DEBUG(dbgs() << "Calculated Rank[" << Arg.getName() << "] = " << Rank << "\n"); } @@ -210,7 +210,7 @@ !BinaryOperator::isFNeg(I)) ++Rank; - DEBUG(dbgs() << "Calculated Rank[" << V->getName() << "] = " << Rank << "\n"); + LLVM_DEBUG(dbgs() << "Calculated Rank[" << V->getName() << "] = " << Rank << "\n"); return ValueRankMap[I] = Rank; } @@ -445,7 +445,7 @@ /// type and thus make the expression bigger. static bool LinearizeExprTree(BinaryOperator *I, SmallVectorImpl &Ops) { - DEBUG(dbgs() << "LINEARIZE: " << *I << '\n'); + LLVM_DEBUG(dbgs() << "LINEARIZE: " << *I << '\n'); unsigned Bitwidth = I->getType()->getScalarType()->getPrimitiveSizeInBits(); unsigned Opcode = I->getOpcode(); assert(I->isAssociative() && I->isCommutative() && @@ -494,14 +494,14 @@ for (unsigned OpIdx = 0; OpIdx < 2; ++OpIdx) { // Visit operands. Value *Op = I->getOperand(OpIdx); APInt Weight = P.second; // Number of paths to this operand. - DEBUG(dbgs() << "OPERAND: " << *Op << " (" << Weight << ")\n"); + LLVM_DEBUG(dbgs() << "OPERAND: " << *Op << " (" << Weight << ")\n"); assert(!Op->use_empty() && "No uses, so how did we get to it?!"); // If this is a binary operation of the right kind with only one use then // add its operands to the expression. if (BinaryOperator *BO = isReassociableOp(Op, Opcode)) { assert(Visited.insert(Op).second && "Not first visit!"); - DEBUG(dbgs() << "DIRECT ADD: " << *Op << " (" << Weight << ")\n"); + LLVM_DEBUG(dbgs() << "DIRECT ADD: " << *Op << " (" << Weight << ")\n"); Worklist.push_back(std::make_pair(BO, Weight)); continue; } @@ -514,7 +514,7 @@ if (!Op->hasOneUse()) { // This value has uses not accounted for by the expression, so it is // not safe to modify. Mark it as being a leaf. - DEBUG(dbgs() << "ADD USES LEAF: " << *Op << " (" << Weight << ")\n"); + LLVM_DEBUG(dbgs() << "ADD USES LEAF: " << *Op << " (" << Weight << ")\n"); LeafOrder.push_back(Op); Leaves[Op] = Weight; continue; @@ -540,7 +540,7 @@ // to the expression, then no longer consider it to be a leaf and add // its operands to the expression. if (BinaryOperator *BO = isReassociableOp(Op, Opcode)) { - DEBUG(dbgs() << "UNLEAF: " << *Op << " (" << It->second << ")\n"); + LLVM_DEBUG(dbgs() << "UNLEAF: " << *Op << " (" << It->second << ")\n"); Worklist.push_back(std::make_pair(BO, It->second)); Leaves.erase(It); continue; @@ -573,9 +573,9 @@ if (BinaryOperator *BO = dyn_cast(Op)) if ((Opcode == Instruction::Mul && BinaryOperator::isNeg(BO)) || (Opcode == Instruction::FMul && BinaryOperator::isFNeg(BO))) { - DEBUG(dbgs() << "MORPH LEAF: " << *Op << " (" << Weight << ") TO "); + LLVM_DEBUG(dbgs() << "MORPH LEAF: " << *Op << " (" << Weight << ") TO "); BO = LowerNegateToMultiply(BO); - DEBUG(dbgs() << *BO << '\n'); + LLVM_DEBUG(dbgs() << *BO << '\n'); Worklist.push_back(std::make_pair(BO, Weight)); Changed = true; continue; @@ -583,7 +583,7 @@ // Failed to morph into an expression of the right type. This really is // a leaf. - DEBUG(dbgs() << "ADD LEAF: " << *Op << " (" << Weight << ")\n"); + LLVM_DEBUG(dbgs() << "ADD LEAF: " << *Op << " (" << Weight << ")\n"); assert(!isReassociableOp(Op, Opcode) && "Value was morphed?"); LeafOrder.push_back(Op); Leaves[Op] = Weight; @@ -675,9 +675,9 @@ if (NewLHS == OldRHS && NewRHS == OldLHS) { // The order of the operands was reversed. Swap them. - DEBUG(dbgs() << "RA: " << *Op << '\n'); + LLVM_DEBUG(dbgs() << "RA: " << *Op << '\n'); Op->swapOperands(); - DEBUG(dbgs() << "TO: " << *Op << '\n'); + LLVM_DEBUG(dbgs() << "TO: " << *Op << '\n'); MadeChange = true; ++NumChanged; break; @@ -685,7 +685,7 @@ // The new operation differs non-trivially from the original. Overwrite // the old operands with the new ones. - DEBUG(dbgs() << "RA: " << *Op << '\n'); + LLVM_DEBUG(dbgs() << "RA: " << *Op << '\n'); if (NewLHS != OldLHS) { BinaryOperator *BO = isReassociableOp(OldLHS, Opcode); if (BO && !NotRewritable.count(BO)) @@ -698,7 +698,7 @@ NodesToRewrite.push_back(BO); Op->setOperand(1, NewRHS); } - DEBUG(dbgs() << "TO: " << *Op << '\n'); + LLVM_DEBUG(dbgs() << "TO: " << *Op << '\n'); ExpressionChanged = Op; MadeChange = true; @@ -711,7 +711,7 @@ // while the right-hand side will be the current element of Ops. Value *NewRHS = Ops[i].Op; if (NewRHS != Op->getOperand(1)) { - DEBUG(dbgs() << "RA: " << *Op << '\n'); + LLVM_DEBUG(dbgs() << "RA: " << *Op << '\n'); if (NewRHS == Op->getOperand(0)) { // The new right-hand side was already present as the left operand. If // we are lucky then swapping the operands will sort out both of them. @@ -724,7 +724,7 @@ Op->setOperand(1, NewRHS); ExpressionChanged = Op; } - DEBUG(dbgs() << "TO: " << *Op << '\n'); + LLVM_DEBUG(dbgs() << "TO: " << *Op << '\n'); MadeChange = true; ++NumChanged; } @@ -756,9 +756,9 @@ NewOp = NodesToRewrite.pop_back_val(); } - DEBUG(dbgs() << "RA: " << *Op << '\n'); + LLVM_DEBUG(dbgs() << "RA: " << *Op << '\n'); Op->setOperand(0, NewOp); - DEBUG(dbgs() << "TO: " << *Op << '\n'); + LLVM_DEBUG(dbgs() << "TO: " << *Op << '\n'); ExpressionChanged = Op; MadeChange = true; ++NumChanged; @@ -929,7 +929,7 @@ Sub->replaceAllUsesWith(New); New->setDebugLoc(Sub->getDebugLoc()); - DEBUG(dbgs() << "Negated: " << *New << '\n'); + LLVM_DEBUG(dbgs() << "Negated: " << *New << '\n'); return New; } @@ -1415,7 +1415,7 @@ ++NumFound; } while (i != Ops.size() && Ops[i].Op == TheOp); - DEBUG(dbgs() << "\nFACTORING [" << NumFound << "]: " << *TheOp << '\n'); + LLVM_DEBUG(dbgs() << "\nFACTORING [" << NumFound << "]: " << *TheOp << '\n'); ++NumFactor; // Insert a new multiply. @@ -1553,7 +1553,7 @@ // If any factor occurred more than one time, we can pull it out. if (MaxOcc > 1) { - DEBUG(dbgs() << "\nFACTORING [" << MaxOcc << "]: " << *MaxOccVal << '\n'); + LLVM_DEBUG(dbgs() << "\nFACTORING [" << MaxOcc << "]: " << *MaxOccVal << '\n'); ++NumFactor; // Create a new instruction that uses the MaxOccVal twice. If we don't do @@ -1876,7 +1876,7 @@ /// Zap the given instruction, adding interesting operands to the work list. void ReassociatePass::EraseInst(Instruction *I) { assert(isInstructionTriviallyDead(I) && "Trivially dead instructions only!"); - DEBUG(dbgs() << "Erasing dead inst: "; I->dump()); + LLVM_DEBUG(dbgs() << "Erasing dead inst: "; I->dump()); SmallVector Ops(I->op_begin(), I->op_end()); // Erase the dead instruction. @@ -2120,7 +2120,7 @@ ValueEntry(getRank(E.first), E.first)); } - DEBUG(dbgs() << "RAIn:\t"; PrintOps(I, Ops); dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "RAIn:\t"; PrintOps(I, Ops); dbgs() << '\n'); // Now that we have linearized the tree to a list and have gathered all of // the operands and their ranks, sort the operands by their rank. Use a @@ -2138,7 +2138,7 @@ return; // This expression tree simplified to something that isn't a tree, // eliminate it. - DEBUG(dbgs() << "Reassoc to scalar: " << *V << '\n'); + LLVM_DEBUG(dbgs() << "Reassoc to scalar: " << *V << '\n'); I->replaceAllUsesWith(V); if (Instruction *VI = dyn_cast(V)) if (I->getDebugLoc()) @@ -2169,7 +2169,7 @@ } } - DEBUG(dbgs() << "RAOut:\t"; PrintOps(I, Ops); dbgs() << '\n'); + LLVM_DEBUG(dbgs() << "RAOut:\t"; PrintOps(I, Ops); dbgs() << '\n'); if (Ops.size() == 1) { if (Ops[0].Op == I) Index: lib/Transforms/Scalar/RewriteStatepointsForGC.cpp =================================================================== --- lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -616,7 +616,7 @@ Value *&Cached = Cache[I]; if (!Cached) { Cached = findBaseDefiningValue(I).BDV; - DEBUG(dbgs() << "fBDV-cached: " << I->getName() << " -> " + LLVM_DEBUG(dbgs() << "fBDV-cached: " << I->getName() << " -> " << Cached->getName() << "\n"); } assert(Cache[I] != nullptr); @@ -848,9 +848,9 @@ } #ifndef NDEBUG - DEBUG(dbgs() << "States after initialization:\n"); + LLVM_DEBUG(dbgs() << "States after initialization:\n"); for (auto Pair : States) { - DEBUG(dbgs() << " " << Pair.second << " for " << *Pair.first << "\n"); + LLVM_DEBUG(dbgs() << " " << Pair.second << " for " << *Pair.first << "\n"); } #endif @@ -923,9 +923,9 @@ } #ifndef NDEBUG - DEBUG(dbgs() << "States after meet iteration:\n"); + LLVM_DEBUG(dbgs() << "States after meet iteration:\n"); for (auto Pair : States) { - DEBUG(dbgs() << " " << Pair.second << " for " << *Pair.first << "\n"); + LLVM_DEBUG(dbgs() << " " << Pair.second << " for " << *Pair.first << "\n"); } #endif @@ -1124,7 +1124,7 @@ assert(BDV && Base); assert(!isKnownBaseResult(BDV) && "why did it get added?"); - DEBUG(dbgs() << "Updating base value cache" + LLVM_DEBUG(dbgs() << "Updating base value cache" << " for: " << BDV->getName() << " from: " << (Cache.count(BDV) ? Cache[BDV]->getName().str() : "none") << " to: " << Base->getName() << "\n"); Index: lib/Transforms/Scalar/SCCP.cpp =================================================================== --- lib/Transforms/Scalar/SCCP.cpp +++ lib/Transforms/Scalar/SCCP.cpp @@ -257,7 +257,7 @@ bool MarkBlockExecutable(BasicBlock *BB) { if (!BBExecutable.insert(BB).second) return false; - DEBUG(dbgs() << "Marking Block Executable: " << BB->getName() << '\n'); + LLVM_DEBUG(dbgs() << "Marking Block Executable: " << BB->getName() << '\n'); BBWorkList.push_back(BB); // Add the block to the work list! return true; } @@ -395,7 +395,7 @@ // the users of the instruction are updated later. void markConstant(LatticeVal &IV, Value *V, Constant *C) { if (!IV.markConstant(C)) return; - DEBUG(dbgs() << "markConstant: " << *C << ": " << *V << '\n'); + LLVM_DEBUG(dbgs() << "markConstant: " << *C << ": " << *V << '\n'); pushToWorkList(IV, V); } @@ -408,7 +408,7 @@ assert(!V->getType()->isStructTy() && "structs should use mergeInValue"); LatticeVal &IV = ValueState[V]; IV.markForcedConstant(C); - DEBUG(dbgs() << "markForcedConstant: " << *C << ": " << *V << '\n'); + LLVM_DEBUG(dbgs() << "markForcedConstant: " << *C << ": " << *V << '\n'); pushToWorkList(IV, V); } @@ -418,7 +418,7 @@ void markOverdefined(LatticeVal &IV, Value *V) { if (!IV.markOverdefined()) return; - DEBUG(dbgs() << "markOverdefined: "; + LLVM_DEBUG(dbgs() << "markOverdefined: "; if (auto *F = dyn_cast(V)) dbgs() << "Function '" << F->getName() << "'\n"; else @@ -520,7 +520,7 @@ // If the destination is already executable, we just made an *edge* // feasible that wasn't before. Revisit the PHI nodes in the block // because they have potentially new operands. - DEBUG(dbgs() << "Marking Edge Executable: " << Source->getName() + LLVM_DEBUG(dbgs() << "Marking Edge Executable: " << Source->getName() << " -> " << Dest->getName() << '\n'); for (PHINode &PN : Dest->phis()) @@ -592,7 +592,7 @@ void visitInstruction(Instruction &I) { // All the instructions we don't do any special handling for just // go to overdefined. - DEBUG(dbgs() << "SCCP: Don't know how to handle: " << I << '\n'); + LLVM_DEBUG(dbgs() << "SCCP: Don't know how to handle: " << I << '\n'); markOverdefined(&I); } }; @@ -679,7 +679,7 @@ return; } - DEBUG(dbgs() << "Unknown terminator instruction: " << TI << '\n'); + LLVM_DEBUG(dbgs() << "Unknown terminator instruction: " << TI << '\n'); llvm_unreachable("SCCP: Don't know how to handle this terminator!"); } @@ -739,7 +739,7 @@ return Addr->getBasicBlock() == To; } - DEBUG(dbgs() << "Unknown terminator instruction: " << *TI << '\n'); + LLVM_DEBUG(dbgs() << "Unknown terminator instruction: " << *TI << '\n'); llvm_unreachable("SCCP: Don't know how to handle this terminator!"); } @@ -1240,7 +1240,7 @@ while (!OverdefinedInstWorkList.empty()) { Value *I = OverdefinedInstWorkList.pop_back_val(); - DEBUG(dbgs() << "\nPopped off OI-WL: " << *I << '\n'); + LLVM_DEBUG(dbgs() << "\nPopped off OI-WL: " << *I << '\n'); // "I" got into the work list because it either made the transition from // bottom to constant, or to overdefined. @@ -1258,7 +1258,7 @@ while (!InstWorkList.empty()) { Value *I = InstWorkList.pop_back_val(); - DEBUG(dbgs() << "\nPopped off I-WL: " << *I << '\n'); + LLVM_DEBUG(dbgs() << "\nPopped off I-WL: " << *I << '\n'); // "I" got into the work list because it made the transition from undef to // constant. @@ -1278,7 +1278,7 @@ BasicBlock *BB = BBWorkList.back(); BBWorkList.pop_back(); - DEBUG(dbgs() << "\nPopped off BBWL: " << *BB << '\n'); + LLVM_DEBUG(dbgs() << "\nPopped off BBWL: " << *BB << '\n'); // Notify all instructions in this basic block that they are newly // executable. @@ -1630,7 +1630,7 @@ if (C) { Icmp->replaceAllUsesWith(C); - DEBUG(dbgs() << "Replacing " << *Icmp << " with " << *C + LLVM_DEBUG(dbgs() << "Replacing " << *Icmp << " with " << *C << ", because of range information " << A << " " << B << "\n"); Icmp->eraseFromParent(); @@ -1672,7 +1672,7 @@ IV.isConstant() ? IV.getConstant() : UndefValue::get(V->getType()); } assert(Const && "Constant is nullptr here!"); - DEBUG(dbgs() << " Constant: " << *Const << " = " << *V << '\n'); + LLVM_DEBUG(dbgs() << " Constant: " << *Const << " = " << *V << '\n'); // Replaces all of the uses of a variable with uses of the constant. V->replaceAllUsesWith(Const); @@ -1683,7 +1683,7 @@ // and return true if the function was modified. static bool runSCCP(Function &F, const DataLayout &DL, const TargetLibraryInfo *TLI) { - DEBUG(dbgs() << "SCCP on function '" << F.getName() << "'\n"); + LLVM_DEBUG(dbgs() << "SCCP on function '" << F.getName() << "'\n"); SCCPSolver Solver(DL, TLI); // Mark the first block of the function as being executable. @@ -1697,7 +1697,7 @@ bool ResolvedUndefs = true; while (ResolvedUndefs) { Solver.Solve(); - DEBUG(dbgs() << "RESOLVING UNDEFs\n"); + LLVM_DEBUG(dbgs() << "RESOLVING UNDEFs\n"); ResolvedUndefs = Solver.ResolvedUndefsIn(F); } @@ -1709,7 +1709,7 @@ for (BasicBlock &BB : F) { if (!Solver.isBlockExecutable(&BB)) { - DEBUG(dbgs() << " BasicBlock Dead:" << BB); + LLVM_DEBUG(dbgs() << " BasicBlock Dead:" << BB); ++NumDeadBlocks; NumInstRemoved += removeAllNonTerminatorAndEHPadInstructions(&BB); @@ -1852,7 +1852,7 @@ while (ResolvedUndefs) { Solver.Solve(); - DEBUG(dbgs() << "RESOLVING UNDEFS\n"); + LLVM_DEBUG(dbgs() << "RESOLVING UNDEFS\n"); ResolvedUndefs = false; for (Function &F : M) ResolvedUndefs |= Solver.ResolvedUndefsIn(F); @@ -1882,7 +1882,7 @@ for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { if (!Solver.isBlockExecutable(&*BB)) { - DEBUG(dbgs() << " BasicBlock Dead:" << *BB); + LLVM_DEBUG(dbgs() << " BasicBlock Dead:" << *BB); ++NumDeadBlocks; NumInstRemoved += @@ -1980,7 +1980,7 @@ GlobalVariable *GV = I->first; assert(!I->second.isOverdefined() && "Overdefined values should have been taken out of the map!"); - DEBUG(dbgs() << "Found that GV '" << GV->getName() << "' is constant!\n"); + LLVM_DEBUG(dbgs() << "Found that GV '" << GV->getName() << "' is constant!\n"); while (!GV->use_empty()) { StoreInst *SI = cast(GV->user_back()); SI->eraseFromParent(); Index: lib/Transforms/Scalar/SROA.cpp =================================================================== --- lib/Transforms/Scalar/SROA.cpp +++ lib/Transforms/Scalar/SROA.cpp @@ -682,7 +682,7 @@ // Completely skip uses which have a zero size or start either before or // past the end of the allocation. if (Size == 0 || Offset.uge(AllocSize)) { - DEBUG(dbgs() << "WARNING: Ignoring " << Size << " byte use @" << Offset + LLVM_DEBUG(dbgs() << "WARNING: Ignoring " << Size << " byte use @" << Offset << " which has zero size or starts outside of the " << AllocSize << " byte alloca:\n" << " alloca: " << AS.AI << "\n" @@ -701,7 +701,7 @@ // them, and so have to record at least the information here. assert(AllocSize >= BeginOffset); // Established above. if (Size > AllocSize - BeginOffset) { - DEBUG(dbgs() << "WARNING: Clamping a " << Size << " byte use @" << Offset + LLVM_DEBUG(dbgs() << "WARNING: Clamping a " << Size << " byte use @" << Offset << " to remain within the " << AllocSize << " byte alloca:\n" << " alloca: " << AS.AI << "\n" << " use: " << I << "\n"); @@ -804,7 +804,7 @@ // FIXME: We should instead consider the pointer to have escaped if this // function is being instrumented for addressing bugs or race conditions. if (Size > AllocSize || Offset.ugt(AllocSize - Size)) { - DEBUG(dbgs() << "WARNING: Ignoring " << Size << " byte store @" << Offset + LLVM_DEBUG(dbgs() << "WARNING: Ignoring " << Size << " byte store @" << Offset << " which extends past the end of the " << AllocSize << " byte alloca:\n" << " alloca: " << AS.AI << "\n" @@ -1235,7 +1235,7 @@ } static void speculatePHINodeLoads(PHINode &PN) { - DEBUG(dbgs() << " original: " << PN << "\n"); + LLVM_DEBUG(dbgs() << " original: " << PN << "\n"); Type *LoadTy = cast(PN.getType())->getElementType(); IRBuilderTy PHIBuilder(&PN); @@ -1273,7 +1273,7 @@ NewPN->addIncoming(Load, Pred); } - DEBUG(dbgs() << " speculated to: " << *NewPN << "\n"); + LLVM_DEBUG(dbgs() << " speculated to: " << *NewPN << "\n"); PN.eraseFromParent(); } @@ -1313,7 +1313,7 @@ } static void speculateSelectInstLoads(SelectInst &SI) { - DEBUG(dbgs() << " original: " << SI << "\n"); + LLVM_DEBUG(dbgs() << " original: " << SI << "\n"); IRBuilderTy IRB(&SI); Value *TV = SI.getTrueValue(); @@ -1344,7 +1344,7 @@ Value *V = IRB.CreateSelect(SI.getCondition(), TL, FL, LI->getName() + ".sroa.speculated"); - DEBUG(dbgs() << " speculated to: " << *V << "\n"); + LLVM_DEBUG(dbgs() << " speculated to: " << *V << "\n"); LI->replaceAllUsesWith(V); LI->eraseFromParent(); } @@ -2067,7 +2067,7 @@ static Value *extractInteger(const DataLayout &DL, IRBuilderTy &IRB, Value *V, IntegerType *Ty, uint64_t Offset, const Twine &Name) { - DEBUG(dbgs() << " start: " << *V << "\n"); + LLVM_DEBUG(dbgs() << " start: " << *V << "\n"); IntegerType *IntTy = cast(V->getType()); assert(DL.getTypeStoreSize(Ty) + Offset <= DL.getTypeStoreSize(IntTy) && "Element extends past full value"); @@ -2076,13 +2076,13 @@ ShAmt = 8 * (DL.getTypeStoreSize(IntTy) - DL.getTypeStoreSize(Ty) - Offset); if (ShAmt) { V = IRB.CreateLShr(V, ShAmt, Name + ".shift"); - DEBUG(dbgs() << " shifted: " << *V << "\n"); + LLVM_DEBUG(dbgs() << " shifted: " << *V << "\n"); } assert(Ty->getBitWidth() <= IntTy->getBitWidth() && "Cannot extract to a larger integer!"); if (Ty != IntTy) { V = IRB.CreateTrunc(V, Ty, Name + ".trunc"); - DEBUG(dbgs() << " trunced: " << *V << "\n"); + LLVM_DEBUG(dbgs() << " trunced: " << *V << "\n"); } return V; } @@ -2093,10 +2093,10 @@ IntegerType *Ty = cast(V->getType()); assert(Ty->getBitWidth() <= IntTy->getBitWidth() && "Cannot insert a larger integer!"); - DEBUG(dbgs() << " start: " << *V << "\n"); + LLVM_DEBUG(dbgs() << " start: " << *V << "\n"); if (Ty != IntTy) { V = IRB.CreateZExt(V, IntTy, Name + ".ext"); - DEBUG(dbgs() << " extended: " << *V << "\n"); + LLVM_DEBUG(dbgs() << " extended: " << *V << "\n"); } assert(DL.getTypeStoreSize(Ty) + Offset <= DL.getTypeStoreSize(IntTy) && "Element store outside of alloca store"); @@ -2105,15 +2105,15 @@ ShAmt = 8 * (DL.getTypeStoreSize(IntTy) - DL.getTypeStoreSize(Ty) - Offset); if (ShAmt) { V = IRB.CreateShl(V, ShAmt, Name + ".shift"); - DEBUG(dbgs() << " shifted: " << *V << "\n"); + LLVM_DEBUG(dbgs() << " shifted: " << *V << "\n"); } if (ShAmt || Ty->getBitWidth() < IntTy->getBitWidth()) { APInt Mask = ~Ty->getMask().zext(IntTy->getBitWidth()).shl(ShAmt); Old = IRB.CreateAnd(Old, Mask, Name + ".mask"); - DEBUG(dbgs() << " masked: " << *Old << "\n"); + LLVM_DEBUG(dbgs() << " masked: " << *Old << "\n"); V = IRB.CreateOr(Old, V, Name + ".insert"); - DEBUG(dbgs() << " inserted: " << *V << "\n"); + LLVM_DEBUG(dbgs() << " inserted: " << *V << "\n"); } return V; } @@ -2130,7 +2130,7 @@ if (NumElements == 1) { V = IRB.CreateExtractElement(V, IRB.getInt32(BeginIndex), Name + ".extract"); - DEBUG(dbgs() << " extract: " << *V << "\n"); + LLVM_DEBUG(dbgs() << " extract: " << *V << "\n"); return V; } @@ -2140,7 +2140,7 @@ Mask.push_back(IRB.getInt32(i)); V = IRB.CreateShuffleVector(V, UndefValue::get(V->getType()), ConstantVector::get(Mask), Name + ".extract"); - DEBUG(dbgs() << " shuffle: " << *V << "\n"); + LLVM_DEBUG(dbgs() << " shuffle: " << *V << "\n"); return V; } @@ -2154,7 +2154,7 @@ // Single element to insert. V = IRB.CreateInsertElement(Old, V, IRB.getInt32(BeginIndex), Name + ".insert"); - DEBUG(dbgs() << " insert: " << *V << "\n"); + LLVM_DEBUG(dbgs() << " insert: " << *V << "\n"); return V; } @@ -2179,7 +2179,7 @@ Mask.push_back(UndefValue::get(IRB.getInt32Ty())); V = IRB.CreateShuffleVector(V, UndefValue::get(V->getType()), ConstantVector::get(Mask), Name + ".expand"); - DEBUG(dbgs() << " shuffle: " << *V << "\n"); + LLVM_DEBUG(dbgs() << " shuffle: " << *V << "\n"); Mask.clear(); for (unsigned i = 0; i != VecTy->getNumElements(); ++i) @@ -2187,7 +2187,7 @@ V = IRB.CreateSelect(ConstantVector::get(Mask), V, Old, Name + "blend"); - DEBUG(dbgs() << " blend: " << *V << "\n"); + LLVM_DEBUG(dbgs() << " blend: " << *V << "\n"); return V; } @@ -2290,9 +2290,9 @@ IsSplittable = I->isSplittable(); IsSplit = BeginOffset < NewAllocaBeginOffset || EndOffset > NewAllocaEndOffset; - DEBUG(dbgs() << " rewriting " << (IsSplit ? "split " : "")); - DEBUG(AS.printSlice(dbgs(), I, "")); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << " rewriting " << (IsSplit ? "split " : "")); + LLVM_DEBUG(AS.printSlice(dbgs(), I, "")); + LLVM_DEBUG(dbgs() << "\n"); // Compute the intersecting offset range. assert(BeginOffset < NewAllocaEndOffset); @@ -2322,7 +2322,7 @@ // Every instruction which can end up as a user must have a rewrite rule. bool visitInstruction(Instruction &I) { - DEBUG(dbgs() << " !!!! Cannot rewrite: " << I << "\n"); + LLVM_DEBUG(dbgs() << " !!!! Cannot rewrite: " << I << "\n"); llvm_unreachable("No rewrite rule for this instruction!"); } @@ -2426,7 +2426,7 @@ } bool visitLoadInst(LoadInst &LI) { - DEBUG(dbgs() << " original: " << LI << "\n"); + LLVM_DEBUG(dbgs() << " original: " << LI << "\n"); Value *OldOp = LI.getOperand(0); assert(OldOp == OldPtr); @@ -2526,7 +2526,7 @@ Pass.DeadInsts.insert(&LI); deleteIfTriviallyDead(OldOp); - DEBUG(dbgs() << " to: " << *V << "\n"); + LLVM_DEBUG(dbgs() << " to: " << *V << "\n"); return !LI.isVolatile() && !IsPtrAdjusted; } @@ -2553,7 +2553,7 @@ Store->setAAMetadata(AATags); Pass.DeadInsts.insert(&SI); - DEBUG(dbgs() << " to: " << *Store << "\n"); + LLVM_DEBUG(dbgs() << " to: " << *Store << "\n"); return true; } @@ -2574,12 +2574,12 @@ if (AATags) Store->setAAMetadata(AATags); Pass.DeadInsts.insert(&SI); - DEBUG(dbgs() << " to: " << *Store << "\n"); + LLVM_DEBUG(dbgs() << " to: " << *Store << "\n"); return true; } bool visitStoreInst(StoreInst &SI) { - DEBUG(dbgs() << " original: " << SI << "\n"); + LLVM_DEBUG(dbgs() << " original: " << SI << "\n"); Value *OldOp = SI.getOperand(1); assert(OldOp == OldPtr); @@ -2647,7 +2647,7 @@ Pass.DeadInsts.insert(&SI); deleteIfTriviallyDead(OldOp); - DEBUG(dbgs() << " to: " << *NewSI << "\n"); + LLVM_DEBUG(dbgs() << " to: " << *NewSI << "\n"); return NewSI->getPointerOperand() == &NewAI && !SI.isVolatile(); } @@ -2681,12 +2681,12 @@ /// \brief Compute a vector splat for a given element value. Value *getVectorSplat(Value *V, unsigned NumElements) { V = IRB.CreateVectorSplat(NumElements, V, "vsplat"); - DEBUG(dbgs() << " splat: " << *V << "\n"); + LLVM_DEBUG(dbgs() << " splat: " << *V << "\n"); return V; } bool visitMemSetInst(MemSetInst &II) { - DEBUG(dbgs() << " original: " << II << "\n"); + LLVM_DEBUG(dbgs() << " original: " << II << "\n"); assert(II.getRawDest() == OldPtr); AAMDNodes AATags; @@ -2725,7 +2725,7 @@ getSliceAlign(), II.isVolatile()); if (AATags) New->setAAMetadata(AATags); - DEBUG(dbgs() << " to: " << *New << "\n"); + LLVM_DEBUG(dbgs() << " to: " << *New << "\n"); return false; } @@ -2791,7 +2791,7 @@ II.isVolatile()); if (AATags) New->setAAMetadata(AATags); - DEBUG(dbgs() << " to: " << *New << "\n"); + LLVM_DEBUG(dbgs() << " to: " << *New << "\n"); return !II.isVolatile(); } @@ -2799,7 +2799,7 @@ // Rewriting of memory transfer instructions can be a bit tricky. We break // them into two categories: split intrinsics and unsplit intrinsics. - DEBUG(dbgs() << " original: " << II << "\n"); + LLVM_DEBUG(dbgs() << " original: " << II << "\n"); AAMDNodes AATags; II.getAAMetadata(AATags); @@ -2828,7 +2828,7 @@ II.setAlignment(MinAlign(II.getAlignment(), SliceAlign)); } - DEBUG(dbgs() << " to: " << II << "\n"); + LLVM_DEBUG(dbgs() << " to: " << II << "\n"); deleteIfTriviallyDead(OldPtr); return false; } @@ -2896,7 +2896,7 @@ MinAlign(SliceAlign, OtherAlign), II.isVolatile()); if (AATags) New->setAAMetadata(AATags); - DEBUG(dbgs() << " to: " << *New << "\n"); + LLVM_DEBUG(dbgs() << " to: " << *New << "\n"); return false; } @@ -2968,14 +2968,14 @@ IRB.CreateAlignedStore(Src, DstPtr, DstAlign, II.isVolatile())); if (AATags) Store->setAAMetadata(AATags); - DEBUG(dbgs() << " to: " << *Store << "\n"); + LLVM_DEBUG(dbgs() << " to: " << *Store << "\n"); return !II.isVolatile(); } bool visitIntrinsicInst(IntrinsicInst &II) { assert(II.getIntrinsicID() == Intrinsic::lifetime_start || II.getIntrinsicID() == Intrinsic::lifetime_end); - DEBUG(dbgs() << " original: " << II << "\n"); + LLVM_DEBUG(dbgs() << " original: " << II << "\n"); assert(II.getArgOperand(1) == OldPtr); // Record this instruction for deletion. @@ -3003,13 +3003,13 @@ New = IRB.CreateLifetimeEnd(Ptr, Size); (void)New; - DEBUG(dbgs() << " to: " << *New << "\n"); + LLVM_DEBUG(dbgs() << " to: " << *New << "\n"); return true; } bool visitPHINode(PHINode &PN) { - DEBUG(dbgs() << " original: " << PN << "\n"); + LLVM_DEBUG(dbgs() << " original: " << PN << "\n"); assert(BeginOffset >= NewAllocaBeginOffset && "PHIs are unsplittable"); assert(EndOffset <= NewAllocaEndOffset && "PHIs are unsplittable"); @@ -3028,7 +3028,7 @@ // Replace the operands which were using the old pointer. std::replace(PN.op_begin(), PN.op_end(), cast(OldPtr), NewPtr); - DEBUG(dbgs() << " to: " << PN << "\n"); + LLVM_DEBUG(dbgs() << " to: " << PN << "\n"); deleteIfTriviallyDead(OldPtr); // PHIs can't be promoted on their own, but often can be speculated. We @@ -3039,7 +3039,7 @@ } bool visitSelectInst(SelectInst &SI) { - DEBUG(dbgs() << " original: " << SI << "\n"); + LLVM_DEBUG(dbgs() << " original: " << SI << "\n"); assert((SI.getTrueValue() == OldPtr || SI.getFalseValue() == OldPtr) && "Pointer isn't an operand!"); assert(BeginOffset >= NewAllocaBeginOffset && "Selects are unsplittable"); @@ -3052,7 +3052,7 @@ if (SI.getOperand(2) == OldPtr) SI.setOperand(2, NewPtr); - DEBUG(dbgs() << " to: " << SI << "\n"); + LLVM_DEBUG(dbgs() << " to: " << SI << "\n"); deleteIfTriviallyDead(OldPtr); // Selects can't be promoted on their own, but often can be speculated. We @@ -3088,7 +3088,7 @@ /// Rewrite loads and stores through a pointer and all pointers derived from /// it. bool rewrite(Instruction &I) { - DEBUG(dbgs() << " Rewriting FCA loads and stores...\n"); + LLVM_DEBUG(dbgs() << " Rewriting FCA loads and stores...\n"); enqueueUsers(I); bool Changed = false; while (!Queue.empty()) { @@ -3202,7 +3202,7 @@ if (AATags) Load->setAAMetadata(AATags); Agg = IRB.CreateInsertValue(Agg, Load, Indices, Name + ".insert"); - DEBUG(dbgs() << " to: " << *Load << "\n"); + LLVM_DEBUG(dbgs() << " to: " << *Load << "\n"); } }; @@ -3212,7 +3212,7 @@ return false; // We have an aggregate being loaded, split it apart. - DEBUG(dbgs() << " original: " << LI << "\n"); + LLVM_DEBUG(dbgs() << " original: " << LI << "\n"); AAMDNodes AATags; LI.getAAMetadata(AATags); LoadOpSplitter Splitter(&LI, *U, AATags); @@ -3243,7 +3243,7 @@ StoreInst *Store = IRB.CreateStore(ExtractValue, InBoundsGEP); if (AATags) Store->setAAMetadata(AATags); - DEBUG(dbgs() << " to: " << *Store << "\n"); + LLVM_DEBUG(dbgs() << " to: " << *Store << "\n"); } }; @@ -3255,7 +3255,7 @@ return false; // We have an aggregate being stored, split it apart. - DEBUG(dbgs() << " original: " << SI << "\n"); + LLVM_DEBUG(dbgs() << " original: " << SI << "\n"); AAMDNodes AATags; SI.getAAMetadata(AATags); StoreOpSplitter Splitter(&SI, *U, AATags); @@ -3454,7 +3454,7 @@ /// /// \returns true if any changes are made. bool SROA::presplitLoadsAndStores(AllocaInst &AI, AllocaSlices &AS) { - DEBUG(dbgs() << "Pre-splitting loads and stores\n"); + LLVM_DEBUG(dbgs() << "Pre-splitting loads and stores\n"); // Track the loads and stores which are candidates for pre-splitting here, in // the order they first appear during the partition scan. These give stable @@ -3486,7 +3486,7 @@ // maybe it would make it more principled? SmallPtrSet UnsplittableLoads; - DEBUG(dbgs() << " Searching for candidate loads and stores\n"); + LLVM_DEBUG(dbgs() << " Searching for candidate loads and stores\n"); for (auto &P : AS.partitions()) { for (Slice &S : P) { Instruction *I = cast(S.getUse()->getUser()); @@ -3541,7 +3541,7 @@ } // Record the initial split. - DEBUG(dbgs() << " Candidate: " << *I << "\n"); + LLVM_DEBUG(dbgs() << " Candidate: " << *I << "\n"); auto &Offsets = SplitOffsetsMap[I]; assert(Offsets.Splits.empty() && "Should not have splits the first time we see an instruction!"); @@ -3601,7 +3601,7 @@ if (LoadOffsets.Splits == StoreOffsets.Splits) return false; - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << " Mismatched splits for load and store:\n" << " " << *LI << "\n" << " " << *SI << "\n"); @@ -3677,7 +3677,7 @@ Instruction *BasePtr = cast(LI->getPointerOperand()); IRB.SetInsertPoint(LI); - DEBUG(dbgs() << " Splitting load: " << *LI << "\n"); + LLVM_DEBUG(dbgs() << " Splitting load: " << *LI << "\n"); uint64_t PartOffset = 0, PartSize = Offsets.Splits.front(); int Idx = 0, Size = Offsets.Splits.size(); @@ -3702,7 +3702,7 @@ Slice(BaseOffset + PartOffset, BaseOffset + PartOffset + PartSize, &PLoad->getOperandUse(PLoad->getPointerOperandIndex()), /*IsSplittable*/ false)); - DEBUG(dbgs() << " new slice [" << NewSlices.back().beginOffset() + LLVM_DEBUG(dbgs() << " new slice [" << NewSlices.back().beginOffset() << ", " << NewSlices.back().endOffset() << "): " << *PLoad << "\n"); @@ -3724,14 +3724,14 @@ StoreInst *SI = cast(LU); if (!Stores.empty() && SplitOffsetsMap.count(SI)) { DeferredStores = true; - DEBUG(dbgs() << " Deferred splitting of store: " << *SI << "\n"); + LLVM_DEBUG(dbgs() << " Deferred splitting of store: " << *SI << "\n"); continue; } Value *StoreBasePtr = SI->getPointerOperand(); IRB.SetInsertPoint(SI); - DEBUG(dbgs() << " Splitting store of load: " << *SI << "\n"); + LLVM_DEBUG(dbgs() << " Splitting store of load: " << *SI << "\n"); for (int Idx = 0, Size = SplitLoads.size(); Idx < Size; ++Idx) { LoadInst *PLoad = SplitLoads[Idx]; @@ -3747,7 +3747,7 @@ PartPtrTy, StoreBasePtr->getName() + "."), getAdjustedAlignment(SI, PartOffset, DL), /*IsVolatile*/ false); PStore->copyMetadata(*LI, LLVMContext::MD_mem_parallel_loop_access); - DEBUG(dbgs() << " +" << PartOffset << ":" << *PStore << "\n"); + LLVM_DEBUG(dbgs() << " +" << PartOffset << ":" << *PStore << "\n"); } // We want to immediately iterate on any allocas impacted by splitting @@ -3796,7 +3796,7 @@ Value *LoadBasePtr = LI->getPointerOperand(); Instruction *StoreBasePtr = cast(SI->getPointerOperand()); - DEBUG(dbgs() << " Splitting store: " << *SI << "\n"); + LLVM_DEBUG(dbgs() << " Splitting store: " << *SI << "\n"); // Check whether we have an already split load. auto SplitLoadsMapI = SplitLoadsMap.find(LI); @@ -3806,7 +3806,7 @@ assert(SplitLoads->size() == Offsets.Splits.size() + 1 && "Too few split loads for the number of splits in the store!"); } else { - DEBUG(dbgs() << " of load: " << *LI << "\n"); + LLVM_DEBUG(dbgs() << " of load: " << *LI << "\n"); } uint64_t PartOffset = 0, PartSize = Offsets.Splits.front(); @@ -3846,11 +3846,11 @@ Slice(BaseOffset + PartOffset, BaseOffset + PartOffset + PartSize, &PStore->getOperandUse(PStore->getPointerOperandIndex()), /*IsSplittable*/ false)); - DEBUG(dbgs() << " new slice [" << NewSlices.back().beginOffset() + LLVM_DEBUG(dbgs() << " new slice [" << NewSlices.back().beginOffset() << ", " << NewSlices.back().endOffset() << "): " << *PStore << "\n"); if (!SplitLoads) { - DEBUG(dbgs() << " of split load: " << *PLoad << "\n"); + LLVM_DEBUG(dbgs() << " of split load: " << *PLoad << "\n"); } // See if we've finished all the splits. @@ -3905,10 +3905,10 @@ // sequence. AS.insert(NewSlices); - DEBUG(dbgs() << " Pre-split slices:\n"); + LLVM_DEBUG(dbgs() << " Pre-split slices:\n"); #ifndef NDEBUG for (auto I = AS.begin(), E = AS.end(); I != E; ++I) - DEBUG(AS.print(dbgs(), I, " ")); + LLVM_DEBUG(AS.print(dbgs(), I, " ")); #endif // Finally, don't try to promote any allocas that new require re-splitting. @@ -3992,7 +3992,7 @@ ++NumNewAllocas; } - DEBUG(dbgs() << "Rewriting alloca partition " + LLVM_DEBUG(dbgs() << "Rewriting alloca partition " << "[" << P.beginOffset() << "," << P.endOffset() << ") to: " << *NewAI << "\n"); @@ -4253,7 +4253,7 @@ /// the slices of the alloca, and then hands it off to be split and /// rewritten as needed. bool SROA::runOnAlloca(AllocaInst &AI) { - DEBUG(dbgs() << "SROA alloca: " << AI << "\n"); + LLVM_DEBUG(dbgs() << "SROA alloca: " << AI << "\n"); ++NumAllocasAnalyzed; // Special case dead allocas, as they're trivial. @@ -4277,7 +4277,7 @@ // Build the slices using a recursive instruction-visiting builder. AllocaSlices AS(DL, AI); - DEBUG(AS.print(dbgs())); + LLVM_DEBUG(AS.print(dbgs())); if (AS.isEscaped()) return Changed; @@ -4305,11 +4305,11 @@ Changed |= splitAlloca(AI, AS); - DEBUG(dbgs() << " Speculating PHIs\n"); + LLVM_DEBUG(dbgs() << " Speculating PHIs\n"); while (!SpeculatablePHIs.empty()) speculatePHINodeLoads(*SpeculatablePHIs.pop_back_val()); - DEBUG(dbgs() << " Speculating Selects\n"); + LLVM_DEBUG(dbgs() << " Speculating Selects\n"); while (!SpeculatableSelects.empty()) speculateSelectInstLoads(*SpeculatableSelects.pop_back_val()); @@ -4330,7 +4330,7 @@ bool Changed = false; while (!DeadInsts.empty()) { Instruction *I = DeadInsts.pop_back_val(); - DEBUG(dbgs() << "Deleting dead instruction: " << *I << "\n"); + LLVM_DEBUG(dbgs() << "Deleting dead instruction: " << *I << "\n"); // If the instruction is an alloca, find the possible dbg.declare connected // to it, and remove it too. We must do this before calling RAUW or we will @@ -4369,7 +4369,7 @@ NumPromoted += PromotableAllocas.size(); - DEBUG(dbgs() << "Promoting allocas with mem2reg...\n"); + LLVM_DEBUG(dbgs() << "Promoting allocas with mem2reg...\n"); PromoteMemToReg(PromotableAllocas, *DT, AC); PromotableAllocas.clear(); return true; @@ -4377,7 +4377,7 @@ PreservedAnalyses SROA::runImpl(Function &F, DominatorTree &RunDT, AssumptionCache &RunAC) { - DEBUG(dbgs() << "SROA function: " << F.getName() << "\n"); + LLVM_DEBUG(dbgs() << "SROA function: " << F.getName() << "\n"); C = &F.getContext(); DT = &RunDT; AC = &RunAC; Index: lib/Transforms/Scalar/SimpleLoopUnswitch.cpp =================================================================== --- lib/Transforms/Scalar/SimpleLoopUnswitch.cpp +++ lib/Transforms/Scalar/SimpleLoopUnswitch.cpp @@ -342,7 +342,7 @@ static bool unswitchTrivialBranch(Loop &L, BranchInst &BI, DominatorTree &DT, LoopInfo &LI) { assert(BI.isConditional() && "Can only unswitch a conditional branch!"); - DEBUG(dbgs() << " Trying to unswitch branch: " << BI << "\n"); + LLVM_DEBUG(dbgs() << " Trying to unswitch branch: " << BI << "\n"); Value *LoopCond = BI.getCondition(); @@ -379,7 +379,7 @@ if (!areLoopExitPHIsLoopInvariant(L, *ParentBB, *LoopExitBB)) return false; - DEBUG(dbgs() << " unswitching trivial branch when: " << CondVal + LLVM_DEBUG(dbgs() << " unswitching trivial branch when: " << CondVal << " == " << LoopCond << "\n"); // Split the preheader, so that we know that there is a safe place to insert @@ -463,7 +463,7 @@ /// branch. Still more cleanup can be done with some simplify-cfg like pass. static bool unswitchTrivialSwitch(Loop &L, SwitchInst &SI, DominatorTree &DT, LoopInfo &LI) { - DEBUG(dbgs() << " Trying to unswitch switch: " << SI << "\n"); + LLVM_DEBUG(dbgs() << " Trying to unswitch switch: " << SI << "\n"); Value *LoopCond = SI.getCondition(); // If this isn't switching on an invariant condition, we can't unswitch it. @@ -493,7 +493,7 @@ else if (ExitCaseIndices.empty()) return false; - DEBUG(dbgs() << " unswitching trivial cases...\n"); + LLVM_DEBUG(dbgs() << " unswitching trivial cases...\n"); SmallVector, 4> ExitCases; ExitCases.reserve(ExitCaseIndices.size()); @@ -1937,7 +1937,7 @@ if (UnswitchCandidates.empty()) return Changed; - DEBUG(dbgs() << "Considering " << UnswitchCandidates.size() + LLVM_DEBUG(dbgs() << "Considering " << UnswitchCandidates.size() << " non-trivial loop invariant conditions for unswitching.\n"); // Given that unswitching these terminators will require duplicating parts of @@ -1974,7 +1974,7 @@ assert(LoopCost >= 0 && "Must not have negative loop costs!"); BBCostMap[BB] = Cost; } - DEBUG(dbgs() << " Total loop cost: " << LoopCost << "\n"); + LLVM_DEBUG(dbgs() << " Total loop cost: " << LoopCost << "\n"); // Now we find the best candidate by searching for the one with the following // properties in order: @@ -2028,7 +2028,7 @@ int BestUnswitchCost; for (TerminatorInst *CandidateTI : UnswitchCandidates) { int CandidateCost = ComputeUnswitchedCost(CandidateTI); - DEBUG(dbgs() << " Computed cost of " << CandidateCost + LLVM_DEBUG(dbgs() << " Computed cost of " << CandidateCost << " for unswitch candidate: " << *CandidateTI << "\n"); if (!BestUnswitchTI || CandidateCost < BestUnswitchCost) { BestUnswitchTI = CandidateTI; @@ -2037,13 +2037,13 @@ } if (BestUnswitchCost < UnswitchThreshold) { - DEBUG(dbgs() << " Trying to unswitch non-trivial (cost = " + LLVM_DEBUG(dbgs() << " Trying to unswitch non-trivial (cost = " << BestUnswitchCost << ") branch: " << *BestUnswitchTI << "\n"); Changed |= unswitchInvariantBranch(L, cast(*BestUnswitchTI), DT, LI, AC, NonTrivialUnswitchCB); } else { - DEBUG(dbgs() << "Cannot unswitch, lowest cost found: " << BestUnswitchCost + LLVM_DEBUG(dbgs() << "Cannot unswitch, lowest cost found: " << BestUnswitchCost << "\n"); } @@ -2056,7 +2056,7 @@ Function &F = *L.getHeader()->getParent(); (void)F; - DEBUG(dbgs() << "Unswitching loop in " << F.getName() << ": " << L << "\n"); + LLVM_DEBUG(dbgs() << "Unswitching loop in " << F.getName() << ": " << L << "\n"); // Save the current loop name in a variable so that we can report it even // after it has been deleted. @@ -2118,7 +2118,7 @@ Function &F = *L->getHeader()->getParent(); - DEBUG(dbgs() << "Unswitching loop in " << F.getName() << ": " << *L << "\n"); + LLVM_DEBUG(dbgs() << "Unswitching loop in " << F.getName() << ": " << *L << "\n"); auto &DT = getAnalysis().getDomTree(); auto &LI = getAnalysis().getLoopInfo(); Index: lib/Transforms/Scalar/Sink.cpp =================================================================== --- lib/Transforms/Scalar/Sink.cpp +++ lib/Transforms/Scalar/Sink.cpp @@ -187,7 +187,7 @@ if (!SuccToSinkTo) return false; - DEBUG(dbgs() << "Sink" << *Inst << " ("; + LLVM_DEBUG(dbgs() << "Sink" << *Inst << " ("; Inst->getParent()->printAsOperand(dbgs(), false); dbgs() << " -> "; SuccToSinkTo->printAsOperand(dbgs(), false); @@ -244,7 +244,7 @@ do { MadeChange = false; - DEBUG(dbgs() << "Sinking iteration " << NumSinkIter << "\n"); + LLVM_DEBUG(dbgs() << "Sinking iteration " << NumSinkIter << "\n"); // Process all basic blocks. for (BasicBlock &I : F) MadeChange |= ProcessBlock(I, DT, LI, AA); Index: lib/Transforms/Scalar/SpeculateAroundPHIs.cpp =================================================================== --- lib/Transforms/Scalar/SpeculateAroundPHIs.cpp +++ lib/Transforms/Scalar/SpeculateAroundPHIs.cpp @@ -64,7 +64,7 @@ // block. We should consider using actual post-dominance here in the // future. if (UI->getParent() != PhiBB) { - DEBUG(dbgs() << " Unsafe: use in a different BB: " << *UI << "\n"); + LLVM_DEBUG(dbgs() << " Unsafe: use in a different BB: " << *UI << "\n"); return false; } @@ -75,7 +75,7 @@ // probably change this to do at least a limited scan of the intervening // instructions and allow handling stores in easily proven safe cases. if (mayBeMemoryDependent(*UI)) { - DEBUG(dbgs() << " Unsafe: can't speculate use: " << *UI << "\n"); + LLVM_DEBUG(dbgs() << " Unsafe: can't speculate use: " << *UI << "\n"); return false; } @@ -126,7 +126,7 @@ // If when we directly test whether this is safe it fails, bail. if (UnsafeSet.count(OpI) || ParentBB != PhiBB || mayBeMemoryDependent(*OpI)) { - DEBUG(dbgs() << " Unsafe: can't speculate transitive use: " << *OpI + LLVM_DEBUG(dbgs() << " Unsafe: can't speculate transitive use: " << *OpI << "\n"); // Record the stack of instructions which reach this node as unsafe // so we prune subsequent searches. @@ -229,7 +229,7 @@ NonFreeMat |= MatCost != TTI.TCC_Free; } if (!NonFreeMat) { - DEBUG(dbgs() << " Free: " << PN << "\n"); + LLVM_DEBUG(dbgs() << " Free: " << PN << "\n"); // No profit in free materialization. return false; } @@ -237,7 +237,7 @@ // Now check that the uses of this PHI can actually be speculated, // otherwise we'll still have to materialize the PHI value. if (!isSafeToSpeculatePHIUsers(PN, DT, PotentialSpecSet, UnsafeSet)) { - DEBUG(dbgs() << " Unsafe PHI: " << PN << "\n"); + LLVM_DEBUG(dbgs() << " Unsafe PHI: " << PN << "\n"); return false; } @@ -288,7 +288,7 @@ // just bail. We're only interested in cases where folding the incoming // constants is at least break-even on all paths. if (FoldedCost > MatCost) { - DEBUG(dbgs() << " Not profitable to fold imm: " << *IncomingC << "\n" + LLVM_DEBUG(dbgs() << " Not profitable to fold imm: " << *IncomingC << "\n" " Materializing cost: " << MatCost << "\n" " Accumulated folded cost: " << FoldedCost << "\n"); return false; @@ -310,7 +310,7 @@ "less that its materialized cost, " "the sum must be as well."); - DEBUG(dbgs() << " Cost savings " << (TotalMatCost - TotalFoldedCost) + LLVM_DEBUG(dbgs() << " Cost savings " << (TotalMatCost - TotalFoldedCost) << ": " << PN << "\n"); CostSavingsMap[&PN] = TotalMatCost - TotalFoldedCost; return true; @@ -489,7 +489,7 @@ // and zero out the cost of everything it depends on. int CostSavings = CostSavingsMap.find(PN)->second; if (SpecCost > CostSavings) { - DEBUG(dbgs() << " Not profitable, speculation cost: " << *PN << "\n" + LLVM_DEBUG(dbgs() << " Not profitable, speculation cost: " << *PN << "\n" " Cost savings: " << CostSavings << "\n" " Speculation cost: " << SpecCost << "\n"); continue; @@ -545,7 +545,7 @@ SmallPtrSetImpl &PotentialSpecSet, SmallSetVector &PredSet, DominatorTree &DT) { - DEBUG(dbgs() << " Speculating around " << SpecPNs.size() << " PHIs!\n"); + LLVM_DEBUG(dbgs() << " Speculating around " << SpecPNs.size() << " PHIs!\n"); NumPHIsSpeculated += SpecPNs.size(); // Split any critical edges so that we have a block to hoist into. @@ -558,7 +558,7 @@ CriticalEdgeSplittingOptions(&DT).setMergeIdenticalEdges()); if (NewPredBB) { ++NumEdgesSplit; - DEBUG(dbgs() << " Split critical edge from: " << PredBB->getName() + LLVM_DEBUG(dbgs() << " Split critical edge from: " << PredBB->getName() << "\n"); SpecPreds.push_back(NewPredBB); } else { @@ -593,7 +593,7 @@ int NumSpecInsts = SpecList.size() * SpecPreds.size(); int NumRedundantInsts = NumSpecInsts - SpecList.size(); - DEBUG(dbgs() << " Inserting " << NumSpecInsts << " speculated instructions, " + LLVM_DEBUG(dbgs() << " Inserting " << NumSpecInsts << " speculated instructions, " << NumRedundantInsts << " redundancies\n"); NumSpeculatedInstructions += NumSpecInsts; NumNewRedundantInstructions += NumRedundantInsts; @@ -716,7 +716,7 @@ /// true when at least some speculation occurs. static bool tryToSpeculatePHIs(SmallVectorImpl &PNs, DominatorTree &DT, TargetTransformInfo &TTI) { - DEBUG(dbgs() << "Evaluating phi nodes for speculation:\n"); + LLVM_DEBUG(dbgs() << "Evaluating phi nodes for speculation:\n"); // Savings in cost from speculating around a PHI node. SmallDenseMap CostSavingsMap; @@ -745,7 +745,7 @@ PNs.end()); // If no PHIs were profitable, skip. if (PNs.empty()) { - DEBUG(dbgs() << " No safe and profitable PHIs found!\n"); + LLVM_DEBUG(dbgs() << " No safe and profitable PHIs found!\n"); return false; } @@ -763,13 +763,13 @@ // differently. if (isa(PredBB->getTerminator()) || isa(PredBB->getTerminator())) { - DEBUG(dbgs() << " Invalid: predecessor terminator: " << PredBB->getName() + LLVM_DEBUG(dbgs() << " Invalid: predecessor terminator: " << PredBB->getName() << "\n"); return false; } } if (PredSet.size() < 2) { - DEBUG(dbgs() << " Unimportant: phi with only one predecessor\n"); + LLVM_DEBUG(dbgs() << " Unimportant: phi with only one predecessor\n"); return false; } Index: lib/Transforms/Scalar/SpeculativeExecution.cpp =================================================================== --- lib/Transforms/Scalar/SpeculativeExecution.cpp +++ lib/Transforms/Scalar/SpeculativeExecution.cpp @@ -151,7 +151,7 @@ bool SpeculativeExecutionPass::runImpl(Function &F, TargetTransformInfo *TTI) { if (OnlyIfDivergentTarget && !TTI->hasBranchDivergence()) { - DEBUG(dbgs() << "Not running SpeculativeExecution because " + LLVM_DEBUG(dbgs() << "Not running SpeculativeExecution because " "TTI->hasBranchDivergence() is false.\n"); return false; } Index: lib/Transforms/Scalar/StructurizeCFG.cpp =================================================================== --- lib/Transforms/Scalar/StructurizeCFG.cpp +++ lib/Transforms/Scalar/StructurizeCFG.cpp @@ -478,7 +478,7 @@ Visited.clear(); for (RegionNode *RN : reverse(Order)) { - DEBUG(dbgs() << "Visiting: " + LLVM_DEBUG(dbgs() << "Visiting: " << (RN->isSubRegion() ? "SubRegion with entry: " : "") << RN->getEntry()->getName() << " Loop Depth: " << LI->getLoopDepth(RN->getEntry()) << "\n"); @@ -887,7 +887,7 @@ if (!DA.isUniform(Br->getCondition())) return false; - DEBUG(dbgs() << "BB: " << BB->getName() << " has uniform terminator\n"); + LLVM_DEBUG(dbgs() << "BB: " << BB->getName() << " has uniform terminator\n"); } return true; } @@ -901,7 +901,7 @@ // TODO: We could probably be smarter here with how we handle sub-regions. auto &DA = getAnalysis(); if (hasOnlyUniformBranches(R, DA)) { - DEBUG(dbgs() << "Skipping region with uniform control flow: " << *R << '\n'); + LLVM_DEBUG(dbgs() << "Skipping region with uniform control flow: " << *R << '\n'); // Mark all direct child block terminators as having been treated as // uniform. To account for a possible future in which non-uniform Index: lib/Transforms/Scalar/TailRecursionElimination.cpp =================================================================== --- lib/Transforms/Scalar/TailRecursionElimination.cpp +++ lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -302,7 +302,7 @@ if (Visited[CI->getParent()] != ESCAPED) { // If the escape point was part way through the block, calls after the // escape point wouldn't have been put into DeferredTails. - DEBUG(dbgs() << "Marked as tail call candidate: " << *CI << "\n"); + LLVM_DEBUG(dbgs() << "Marked as tail call candidate: " << *CI << "\n"); CI->setTailCall(); Modified = true; } else { @@ -699,7 +699,7 @@ BranchInst *BI = UncondBranchPreds.pop_back_val(); BasicBlock *Pred = BI->getParent(); if (CallInst *CI = findTRECandidate(BI, CannotTailCallElimCallsMarkedTail, TTI)){ - DEBUG(dbgs() << "FOLDING: " << *BB + LLVM_DEBUG(dbgs() << "FOLDING: " << *BB << "INTO UNCOND BRANCH PRED: " << *Pred); ReturnInst *RI = FoldReturnIntoUncondBranch(Ret, BB, Pred); Index: lib/Transforms/Utils/AddDiscriminators.cpp =================================================================== --- lib/Transforms/Utils/AddDiscriminators.cpp +++ lib/Transforms/Utils/AddDiscriminators.cpp @@ -210,7 +210,7 @@ // it in 1 byte ULEB128 representation. unsigned Discriminator = R.second ? ++LDM[L] : LDM[L]; I.setDebugLoc(DIL->setBaseDiscriminator(Discriminator)); - DEBUG(dbgs() << DIL->getFilename() << ":" << DIL->getLine() << ":" + LLVM_DEBUG(dbgs() << DIL->getFilename() << ":" << DIL->getLine() << ":" << DIL->getColumn() << ":" << Discriminator << " " << I << "\n"); Changed = true; Index: lib/Transforms/Utils/CodeExtractor.cpp =================================================================== --- lib/Transforms/Utils/CodeExtractor.cpp +++ lib/Transforms/Utils/CodeExtractor.cpp @@ -563,8 +563,8 @@ BasicBlock *newHeader, Function *oldFunction, Module *M) { - DEBUG(dbgs() << "inputs: " << inputs.size() << "\n"); - DEBUG(dbgs() << "outputs: " << outputs.size() << "\n"); + LLVM_DEBUG(dbgs() << "inputs: " << inputs.size() << "\n"); + LLVM_DEBUG(dbgs() << "outputs: " << outputs.size() << "\n"); // This function returns unsigned, outputs will go back by reference. switch (NumExitBlocks) { @@ -578,20 +578,20 @@ // Add the types of the input values to the function's argument list for (Value *value : inputs) { - DEBUG(dbgs() << "value used in func: " << *value << "\n"); + LLVM_DEBUG(dbgs() << "value used in func: " << *value << "\n"); paramTy.push_back(value->getType()); } // Add the types of the output values to the function's argument list. for (Value *output : outputs) { - DEBUG(dbgs() << "instr used in func: " << *output << "\n"); + LLVM_DEBUG(dbgs() << "instr used in func: " << *output << "\n"); if (AggregateArgs) paramTy.push_back(output->getType()); else paramTy.push_back(PointerType::getUnqual(output->getType())); } - DEBUG({ + LLVM_DEBUG({ dbgs() << "Function type: " << *RetTy << " f("; for (Type *i : paramTy) dbgs() << *i << ", "; @@ -1210,7 +1210,7 @@ } } - DEBUG(if (verifyFunction(*newFunction)) + LLVM_DEBUG(if (verifyFunction(*newFunction)) report_fatal_error("verifyFunction failed!")); return newFunction; } Index: lib/Transforms/Utils/CtorUtils.cpp =================================================================== --- lib/Transforms/Utils/CtorUtils.cpp +++ lib/Transforms/Utils/CtorUtils.cpp @@ -138,7 +138,7 @@ if (!F) continue; - DEBUG(dbgs() << "Optimizing Global Constructor: " << *F << "\n"); + LLVM_DEBUG(dbgs() << "Optimizing Global Constructor: " << *F << "\n"); // We cannot simplify external ctor functions. if (F->empty()) Index: lib/Transforms/Utils/Evaluator.cpp =================================================================== --- lib/Transforms/Utils/Evaluator.cpp +++ lib/Transforms/Utils/Evaluator.cpp @@ -210,22 +210,22 @@ while (true) { Constant *InstResult = nullptr; - DEBUG(dbgs() << "Evaluating Instruction: " << *CurInst << "\n"); + LLVM_DEBUG(dbgs() << "Evaluating Instruction: " << *CurInst << "\n"); if (StoreInst *SI = dyn_cast(CurInst)) { if (!SI->isSimple()) { - DEBUG(dbgs() << "Store is not simple! Can not evaluate.\n"); + LLVM_DEBUG(dbgs() << "Store is not simple! Can not evaluate.\n"); return false; // no volatile/atomic accesses. } Constant *Ptr = getVal(SI->getOperand(1)); if (auto *FoldedPtr = ConstantFoldConstant(Ptr, DL, TLI)) { - DEBUG(dbgs() << "Folding constant ptr expression: " << *Ptr); + LLVM_DEBUG(dbgs() << "Folding constant ptr expression: " << *Ptr); Ptr = FoldedPtr; - DEBUG(dbgs() << "; To: " << *Ptr << "\n"); + LLVM_DEBUG(dbgs() << "; To: " << *Ptr << "\n"); } if (!isSimpleEnoughPointerToCommit(Ptr)) { // If this is too complex for us to commit, reject it. - DEBUG(dbgs() << "Pointer is too complex for us to evaluate store."); + LLVM_DEBUG(dbgs() << "Pointer is too complex for us to evaluate store."); return false; } @@ -234,14 +234,14 @@ // If this might be too difficult for the backend to handle (e.g. the addr // of one global variable divided by another) then we can't commit it. if (!isSimpleEnoughValueToCommit(Val, SimpleConstants, DL)) { - DEBUG(dbgs() << "Store value is too complex to evaluate store. " << *Val + LLVM_DEBUG(dbgs() << "Store value is too complex to evaluate store. " << *Val << "\n"); return false; } if (ConstantExpr *CE = dyn_cast(Ptr)) { if (CE->getOpcode() == Instruction::BitCast) { - DEBUG(dbgs() << "Attempting to resolve bitcast on constant ptr.\n"); + LLVM_DEBUG(dbgs() << "Attempting to resolve bitcast on constant ptr.\n"); // If we're evaluating a store through a bitcast, then we need // to pull the bitcast off the pointer type and push it onto the // stored value. @@ -270,7 +270,7 @@ // If we can't improve the situation by introspecting NewTy, // we have to give up. } else { - DEBUG(dbgs() << "Failed to bitcast constant ptr, can not " + LLVM_DEBUG(dbgs() << "Failed to bitcast constant ptr, can not " "evaluate.\n"); return false; } @@ -280,7 +280,7 @@ // onto the stored value. Val = ConstantExpr::getBitCast(Val, NewTy); - DEBUG(dbgs() << "Evaluated bitcast: " << *Val << "\n"); + LLVM_DEBUG(dbgs() << "Evaluated bitcast: " << *Val << "\n"); } } @@ -289,36 +289,36 @@ InstResult = ConstantExpr::get(BO->getOpcode(), getVal(BO->getOperand(0)), getVal(BO->getOperand(1))); - DEBUG(dbgs() << "Found a BinaryOperator! Simplifying: " << *InstResult + LLVM_DEBUG(dbgs() << "Found a BinaryOperator! Simplifying: " << *InstResult << "\n"); } else if (CmpInst *CI = dyn_cast(CurInst)) { InstResult = ConstantExpr::getCompare(CI->getPredicate(), getVal(CI->getOperand(0)), getVal(CI->getOperand(1))); - DEBUG(dbgs() << "Found a CmpInst! Simplifying: " << *InstResult + LLVM_DEBUG(dbgs() << "Found a CmpInst! Simplifying: " << *InstResult << "\n"); } else if (CastInst *CI = dyn_cast(CurInst)) { InstResult = ConstantExpr::getCast(CI->getOpcode(), getVal(CI->getOperand(0)), CI->getType()); - DEBUG(dbgs() << "Found a Cast! Simplifying: " << *InstResult + LLVM_DEBUG(dbgs() << "Found a Cast! Simplifying: " << *InstResult << "\n"); } else if (SelectInst *SI = dyn_cast(CurInst)) { InstResult = ConstantExpr::getSelect(getVal(SI->getOperand(0)), getVal(SI->getOperand(1)), getVal(SI->getOperand(2))); - DEBUG(dbgs() << "Found a Select! Simplifying: " << *InstResult + LLVM_DEBUG(dbgs() << "Found a Select! Simplifying: " << *InstResult << "\n"); } else if (auto *EVI = dyn_cast(CurInst)) { InstResult = ConstantExpr::getExtractValue( getVal(EVI->getAggregateOperand()), EVI->getIndices()); - DEBUG(dbgs() << "Found an ExtractValueInst! Simplifying: " << *InstResult + LLVM_DEBUG(dbgs() << "Found an ExtractValueInst! Simplifying: " << *InstResult << "\n"); } else if (auto *IVI = dyn_cast(CurInst)) { InstResult = ConstantExpr::getInsertValue( getVal(IVI->getAggregateOperand()), getVal(IVI->getInsertedValueOperand()), IVI->getIndices()); - DEBUG(dbgs() << "Found an InsertValueInst! Simplifying: " << *InstResult + LLVM_DEBUG(dbgs() << "Found an InsertValueInst! Simplifying: " << *InstResult << "\n"); } else if (GetElementPtrInst *GEP = dyn_cast(CurInst)) { Constant *P = getVal(GEP->getOperand(0)); @@ -329,31 +329,31 @@ InstResult = ConstantExpr::getGetElementPtr(GEP->getSourceElementType(), P, GEPOps, cast(GEP)->isInBounds()); - DEBUG(dbgs() << "Found a GEP! Simplifying: " << *InstResult + LLVM_DEBUG(dbgs() << "Found a GEP! Simplifying: " << *InstResult << "\n"); } else if (LoadInst *LI = dyn_cast(CurInst)) { if (!LI->isSimple()) { - DEBUG(dbgs() << "Found a Load! Not a simple load, can not evaluate.\n"); + LLVM_DEBUG(dbgs() << "Found a Load! Not a simple load, can not evaluate.\n"); return false; // no volatile/atomic accesses. } Constant *Ptr = getVal(LI->getOperand(0)); if (auto *FoldedPtr = ConstantFoldConstant(Ptr, DL, TLI)) { Ptr = FoldedPtr; - DEBUG(dbgs() << "Found a constant pointer expression, constant " + LLVM_DEBUG(dbgs() << "Found a constant pointer expression, constant " "folding: " << *Ptr << "\n"); } InstResult = ComputeLoadResult(Ptr); if (!InstResult) { - DEBUG(dbgs() << "Failed to compute load result. Can not evaluate load." + LLVM_DEBUG(dbgs() << "Failed to compute load result. Can not evaluate load." "\n"); return false; // Could not evaluate load. } - DEBUG(dbgs() << "Evaluated load: " << *InstResult << "\n"); + LLVM_DEBUG(dbgs() << "Evaluated load: " << *InstResult << "\n"); } else if (AllocaInst *AI = dyn_cast(CurInst)) { if (AI->isArrayAllocation()) { - DEBUG(dbgs() << "Found an array alloca. Can not evaluate.\n"); + LLVM_DEBUG(dbgs() << "Found an array alloca. Can not evaluate.\n"); return false; // Cannot handle array allocs. } Type *Ty = AI->getAllocatedType(); @@ -361,27 +361,27 @@ Ty, false, GlobalValue::InternalLinkage, UndefValue::get(Ty), AI->getName())); InstResult = AllocaTmps.back().get(); - DEBUG(dbgs() << "Found an alloca. Result: " << *InstResult << "\n"); + LLVM_DEBUG(dbgs() << "Found an alloca. Result: " << *InstResult << "\n"); } else if (isa(CurInst) || isa(CurInst)) { CallSite CS(&*CurInst); // Debug info can safely be ignored here. if (isa(CS.getInstruction())) { - DEBUG(dbgs() << "Ignoring debug info.\n"); + LLVM_DEBUG(dbgs() << "Ignoring debug info.\n"); ++CurInst; continue; } // Cannot handle inline asm. if (isa(CS.getCalledValue())) { - DEBUG(dbgs() << "Found inline asm, can not evaluate.\n"); + LLVM_DEBUG(dbgs() << "Found inline asm, can not evaluate.\n"); return false; } if (IntrinsicInst *II = dyn_cast(CS.getInstruction())) { if (MemSetInst *MSI = dyn_cast(II)) { if (MSI->isVolatile()) { - DEBUG(dbgs() << "Can not optimize a volatile memset " << + LLVM_DEBUG(dbgs() << "Can not optimize a volatile memset " << "intrinsic.\n"); return false; } @@ -390,7 +390,7 @@ Constant *DestVal = ComputeLoadResult(getVal(Ptr)); if (Val->isNullValue() && DestVal && DestVal->isNullValue()) { // This memset is a no-op. - DEBUG(dbgs() << "Ignoring no-op memset.\n"); + LLVM_DEBUG(dbgs() << "Ignoring no-op memset.\n"); ++CurInst; continue; } @@ -398,7 +398,7 @@ if (II->getIntrinsicID() == Intrinsic::lifetime_start || II->getIntrinsicID() == Intrinsic::lifetime_end) { - DEBUG(dbgs() << "Ignoring lifetime intrinsic.\n"); + LLVM_DEBUG(dbgs() << "Ignoring lifetime intrinsic.\n"); ++CurInst; continue; } @@ -407,7 +407,7 @@ // We don't insert an entry into Values, as it doesn't have a // meaningful return value. if (!II->use_empty()) { - DEBUG(dbgs() << "Found unused invariant_start. Can't evaluate.\n"); + LLVM_DEBUG(dbgs() << "Found unused invariant_start. Can't evaluate.\n"); return false; } ConstantInt *Size = cast(II->getArgOperand(0)); @@ -419,10 +419,10 @@ Size->getValue().getLimitedValue() >= DL.getTypeStoreSize(ElemTy)) { Invariants.insert(GV); - DEBUG(dbgs() << "Found a global var that is an invariant: " << *GV + LLVM_DEBUG(dbgs() << "Found a global var that is an invariant: " << *GV << "\n"); } else { - DEBUG(dbgs() << "Found a global var, but can not treat it as an " + LLVM_DEBUG(dbgs() << "Found a global var, but can not treat it as an " "invariant.\n"); } } @@ -430,23 +430,23 @@ ++CurInst; continue; } else if (II->getIntrinsicID() == Intrinsic::assume) { - DEBUG(dbgs() << "Skipping assume intrinsic.\n"); + LLVM_DEBUG(dbgs() << "Skipping assume intrinsic.\n"); ++CurInst; continue; } else if (II->getIntrinsicID() == Intrinsic::sideeffect) { - DEBUG(dbgs() << "Skipping sideeffect intrinsic.\n"); + LLVM_DEBUG(dbgs() << "Skipping sideeffect intrinsic.\n"); ++CurInst; continue; } - DEBUG(dbgs() << "Unknown intrinsic. Can not evaluate.\n"); + LLVM_DEBUG(dbgs() << "Unknown intrinsic. Can not evaluate.\n"); return false; } // Resolve function pointers. Function *Callee = dyn_cast(getVal(CS.getCalledValue())); if (!Callee || Callee->isInterposable()) { - DEBUG(dbgs() << "Can not resolve function pointer.\n"); + LLVM_DEBUG(dbgs() << "Can not resolve function pointer.\n"); return false; // Cannot resolve. } @@ -458,15 +458,15 @@ // If this is a function we can constant fold, do it. if (Constant *C = ConstantFoldCall(CS, Callee, Formals, TLI)) { InstResult = C; - DEBUG(dbgs() << "Constant folded function call. Result: " << + LLVM_DEBUG(dbgs() << "Constant folded function call. Result: " << *InstResult << "\n"); } else { - DEBUG(dbgs() << "Can not constant fold function call.\n"); + LLVM_DEBUG(dbgs() << "Can not constant fold function call.\n"); return false; } } else { if (Callee->getFunctionType()->isVarArg()) { - DEBUG(dbgs() << "Can not constant fold vararg function call.\n"); + LLVM_DEBUG(dbgs() << "Can not constant fold vararg function call.\n"); return false; } @@ -474,21 +474,21 @@ // Execute the call, if successful, use the return value. ValueStack.emplace_back(); if (!EvaluateFunction(Callee, RetVal, Formals)) { - DEBUG(dbgs() << "Failed to evaluate function.\n"); + LLVM_DEBUG(dbgs() << "Failed to evaluate function.\n"); return false; } ValueStack.pop_back(); InstResult = RetVal; if (InstResult) { - DEBUG(dbgs() << "Successfully evaluated function. Result: " + LLVM_DEBUG(dbgs() << "Successfully evaluated function. Result: " << *InstResult << "\n\n"); } else { - DEBUG(dbgs() << "Successfully evaluated function. Result: 0\n\n"); + LLVM_DEBUG(dbgs() << "Successfully evaluated function. Result: 0\n\n"); } } } else if (isa(CurInst)) { - DEBUG(dbgs() << "Found a terminator instruction.\n"); + LLVM_DEBUG(dbgs() << "Found a terminator instruction.\n"); if (BranchInst *BI = dyn_cast(CurInst)) { if (BI->isUnconditional()) { @@ -515,16 +515,16 @@ NextBB = nullptr; } else { // invoke, unwind, resume, unreachable. - DEBUG(dbgs() << "Can not handle terminator."); + LLVM_DEBUG(dbgs() << "Can not handle terminator."); return false; // Cannot handle this terminator. } // We succeeded at evaluating this block! - DEBUG(dbgs() << "Successfully evaluated block.\n"); + LLVM_DEBUG(dbgs() << "Successfully evaluated block.\n"); return true; } else { // Did not know how to evaluate this! - DEBUG(dbgs() << "Failed to evaluate block due to unhandled instruction." + LLVM_DEBUG(dbgs() << "Failed to evaluate block due to unhandled instruction." "\n"); return false; } @@ -539,7 +539,7 @@ // If we just processed an invoke, we finished evaluating the block. if (InvokeInst *II = dyn_cast(CurInst)) { NextBB = II->getNormalDest(); - DEBUG(dbgs() << "Found an invoke instruction. Finished Block.\n\n"); + LLVM_DEBUG(dbgs() << "Found an invoke instruction. Finished Block.\n\n"); return true; } @@ -578,7 +578,7 @@ while (true) { BasicBlock *NextBB = nullptr; // Initialized to avoid compiler warnings. - DEBUG(dbgs() << "Trying to evaluate BB: " << *CurBB << "\n"); + LLVM_DEBUG(dbgs() << "Trying to evaluate BB: " << *CurBB << "\n"); if (!EvaluateBlock(CurInst, NextBB)) return false; Index: lib/Transforms/Utils/FlattenCFG.cpp =================================================================== --- lib/Transforms/Utils/FlattenCFG.cpp +++ lib/Transforms/Utils/FlattenCFG.cpp @@ -312,7 +312,7 @@ new UnreachableInst(CB->getContext(), CB); } while (Iteration); - DEBUG(dbgs() << "Use parallel and/or in:\n" << *FirstCondBlock); + LLVM_DEBUG(dbgs() << "Use parallel and/or in:\n" << *FirstCondBlock); return true; } @@ -469,7 +469,7 @@ // Remove \param SecondEntryBlock SecondEntryBlock->dropAllReferences(); SecondEntryBlock->eraseFromParent(); - DEBUG(dbgs() << "If conditions merged into:\n" << *FirstEntryBlock); + LLVM_DEBUG(dbgs() << "If conditions merged into:\n" << *FirstEntryBlock); return true; } Index: lib/Transforms/Utils/FunctionComparator.cpp =================================================================== --- lib/Transforms/Utils/FunctionComparator.cpp +++ lib/Transforms/Utils/FunctionComparator.cpp @@ -377,7 +377,7 @@ } } default: // Unknown constant, abort. - DEBUG(dbgs() << "Looking at valueID " << L->getValueID() << "\n"); + LLVM_DEBUG(dbgs() << "Looking at valueID " << L->getValueID() << "\n"); llvm_unreachable("Constant ValueID not recognized."); return -1; } Index: lib/Transforms/Utils/LibCallsShrinkWrap.cpp =================================================================== --- lib/Transforms/Utils/LibCallsShrinkWrap.cpp +++ lib/Transforms/Utils/LibCallsShrinkWrap.cpp @@ -79,11 +79,11 @@ bool perform() { bool Changed = false; for (auto &CI : WorkList) { - DEBUG(dbgs() << "CDCE calls: " << CI->getCalledFunction()->getName() + LLVM_DEBUG(dbgs() << "CDCE calls: " << CI->getCalledFunction()->getName() << "\n"); if (perform(CI)) { Changed = true; - DEBUG(dbgs() << "Transformed\n"); + LLVM_DEBUG(dbgs() << "Transformed\n"); } } return Changed; @@ -421,7 +421,7 @@ const LibFunc &Func) { // FIXME: LibFunc_powf and powl TBD. if (Func != LibFunc_pow) { - DEBUG(dbgs() << "Not handled powf() and powl()\n"); + LLVM_DEBUG(dbgs() << "Not handled powf() and powl()\n"); return nullptr; } @@ -433,7 +433,7 @@ if (ConstantFP *CF = dyn_cast(Base)) { double D = CF->getValueAPF().convertToDouble(); if (D < 1.0f || D > APInt::getMaxValue(8).getZExtValue()) { - DEBUG(dbgs() << "Not handled pow(): constant base out of range\n"); + LLVM_DEBUG(dbgs() << "Not handled pow(): constant base out of range\n"); return nullptr; } @@ -447,7 +447,7 @@ // If the Base value coming from an integer type. Instruction *I = dyn_cast(Base); if (!I) { - DEBUG(dbgs() << "Not handled pow(): FP type base\n"); + LLVM_DEBUG(dbgs() << "Not handled pow(): FP type base\n"); return nullptr; } unsigned Opcode = I->getOpcode(); @@ -461,7 +461,7 @@ else if (BW == 32) UpperV = 32.0f; else { - DEBUG(dbgs() << "Not handled pow(): type too wide\n"); + LLVM_DEBUG(dbgs() << "Not handled pow(): type too wide\n"); return nullptr; } @@ -477,7 +477,7 @@ Value *Cond0 = BBBuilder.CreateFCmp(CmpInst::FCMP_OLE, Base, V0); return BBBuilder.CreateOr(Cond0, Cond); } - DEBUG(dbgs() << "Not handled pow(): base not from integer convert\n"); + LLVM_DEBUG(dbgs() << "Not handled pow(): base not from integer convert\n"); return nullptr; } @@ -496,8 +496,8 @@ SuccBB->setName("cdce.end"); CI->removeFromParent(); CallBB->getInstList().insert(CallBB->getFirstInsertionPt(), CI); - DEBUG(dbgs() << "== Basic Block After =="); - DEBUG(dbgs() << *CallBB->getSinglePredecessor() << *CallBB + LLVM_DEBUG(dbgs() << "== Basic Block After =="); + LLVM_DEBUG(dbgs() << *CallBB->getSinglePredecessor() << *CallBB << *CallBB->getSingleSuccessor() << "\n"); } Index: lib/Transforms/Utils/Local.cpp =================================================================== --- lib/Transforms/Utils/Local.cpp +++ lib/Transforms/Utils/Local.cpp @@ -733,7 +733,7 @@ static bool CanPropagatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) { assert(*succ_begin(BB) == Succ && "Succ is not successor of BB!"); - DEBUG(dbgs() << "Looking to fold " << BB->getName() << " into " + LLVM_DEBUG(dbgs() << "Looking to fold " << BB->getName() << " into " << Succ->getName() << "\n"); // Shortcut, if there is only a single predecessor it must be BB and merging // is always safe @@ -757,7 +757,7 @@ if (BBPreds.count(IBB) && !CanMergeValues(BBPN->getIncomingValueForBlock(IBB), PN->getIncomingValue(PI))) { - DEBUG(dbgs() << "Can't fold, phi node " << PN->getName() << " in " + LLVM_DEBUG(dbgs() << "Can't fold, phi node " << PN->getName() << " in " << Succ->getName() << " is conflicting with " << BBPN->getName() << " with regard to common predecessor " << IBB->getName() << "\n"); @@ -773,7 +773,7 @@ BasicBlock *IBB = PN->getIncomingBlock(PI); if (BBPreds.count(IBB) && !CanMergeValues(Val, PN->getIncomingValue(PI))) { - DEBUG(dbgs() << "Can't fold, phi node " << PN->getName() << " in " + LLVM_DEBUG(dbgs() << "Can't fold, phi node " << PN->getName() << " in " << Succ->getName() << " is conflicting with regard to common " << "predecessor " << IBB->getName() << "\n"); return false; @@ -963,7 +963,7 @@ } } - DEBUG(dbgs() << "Killing Trivial BB: \n" << *BB); + LLVM_DEBUG(dbgs() << "Killing Trivial BB: \n" << *BB); std::vector Updates; if (DDT) { @@ -1504,7 +1504,7 @@ DIExpression::WithStackValue); DII->setOperand(0, wrapMD(I.getOperand(0))); DII->setOperand(2, MetadataAsValue::get(I.getContext(), DIExpr)); - DEBUG(dbgs() << "SALVAGE: " << *DII << '\n'); + LLVM_DEBUG(dbgs() << "SALVAGE: " << *DII << '\n'); }; auto applyOffset = [&](DbgInfoIntrinsic *DII, uint64_t Offset) { @@ -1527,7 +1527,7 @@ MetadataAsValue *CastSrc = wrapMD(I.getOperand(0)); for (auto *DII : DbgUsers) { DII->setOperand(0, CastSrc); - DEBUG(dbgs() << "SALVAGE: " << *DII << '\n'); + LLVM_DEBUG(dbgs() << "SALVAGE: " << *DII << '\n'); } } else if (auto *GEP = dyn_cast(&I)) { unsigned BitWidth = @@ -1594,7 +1594,7 @@ DIExpr = DIExpression::prepend(DIExpr, DIExpression::WithDeref); DII->setOperand(0, AddrMD); DII->setOperand(2, MetadataAsValue::get(I.getContext(), DIExpr)); - DEBUG(dbgs() << "SALVAGE: " << *DII << '\n'); + LLVM_DEBUG(dbgs() << "SALVAGE: " << *DII << '\n'); } } } @@ -2057,7 +2057,7 @@ if (!Dominates(Root, U)) continue; U.set(To); - DEBUG(dbgs() << "Replace dominated use of '" << From->getName() << "' as " + LLVM_DEBUG(dbgs() << "Replace dominated use of '" << From->getName() << "' as " << *To << " in " << *U << "\n"); ++Count; } Index: lib/Transforms/Utils/LoopSimplify.cpp =================================================================== --- lib/Transforms/Utils/LoopSimplify.cpp +++ lib/Transforms/Utils/LoopSimplify.cpp @@ -141,7 +141,7 @@ if (!PreheaderBB) return nullptr; - DEBUG(dbgs() << "LoopSimplify: Creating pre-header " + LLVM_DEBUG(dbgs() << "LoopSimplify: Creating pre-header " << PreheaderBB->getName() << "\n"); // Make sure that NewBB is put someplace intelligent, which doesn't mess up @@ -242,7 +242,7 @@ OuterLoopPreds.push_back(PN->getIncomingBlock(i)); } } - DEBUG(dbgs() << "LoopSimplify: Splitting out a new outer loop\n"); + LLVM_DEBUG(dbgs() << "LoopSimplify: Splitting out a new outer loop\n"); // If ScalarEvolution is around and knows anything about values in // this loop, tell it to forget them, because we're about to @@ -371,7 +371,7 @@ BranchInst *BETerminator = BranchInst::Create(Header, BEBlock); BETerminator->setDebugLoc(Header->getFirstNonPHI()->getDebugLoc()); - DEBUG(dbgs() << "LoopSimplify: Inserting unique backedge block " + LLVM_DEBUG(dbgs() << "LoopSimplify: Inserting unique backedge block " << BEBlock->getName() << "\n"); // Move the new backedge block to right after the last backedge block. @@ -484,7 +484,7 @@ // Delete each unique out-of-loop (and thus dead) predecessor. for (BasicBlock *P : BadPreds) { - DEBUG(dbgs() << "LoopSimplify: Deleting edge from dead predecessor " + LLVM_DEBUG(dbgs() << "LoopSimplify: Deleting edge from dead predecessor " << P->getName() << "\n"); // Zap the dead pred's terminator and replace it with unreachable. @@ -504,7 +504,7 @@ if (BI->isConditional()) { if (UndefValue *Cond = dyn_cast(BI->getCondition())) { - DEBUG(dbgs() << "LoopSimplify: Resolving \"br i1 undef\" to exit in " + LLVM_DEBUG(dbgs() << "LoopSimplify: Resolving \"br i1 undef\" to exit in " << ExitingBlock->getName() << "\n"); BI->setCondition(ConstantInt::get(Cond->getType(), @@ -648,7 +648,7 @@ // Success. The block is now dead, so remove it from the loop, // update the dominator tree and delete it. - DEBUG(dbgs() << "LoopSimplify: Eliminating exiting block " + LLVM_DEBUG(dbgs() << "LoopSimplify: Eliminating exiting block " << ExitingBlock->getName() << "\n"); // Notify ScalarEvolution before deleting this block. Currently assume the Index: lib/Transforms/Utils/LoopUnroll.cpp =================================================================== --- lib/Transforms/Utils/LoopUnroll.cpp +++ lib/Transforms/Utils/LoopUnroll.cpp @@ -116,7 +116,7 @@ if (OnlyPred->getTerminator()->getNumSuccessors() != 1) return nullptr; - DEBUG(dbgs() << "Merging: " << *BB << "into: " << *OnlyPred); + LLVM_DEBUG(dbgs() << "Merging: " << *BB << "into: " << *OnlyPred); // Resolve any PHI nodes at the start of the block. They are all // guaranteed to have exactly one entry if they exist, unless there are @@ -310,19 +310,19 @@ BasicBlock *Preheader = L->getLoopPreheader(); if (!Preheader) { - DEBUG(dbgs() << " Can't unroll; loop preheader-insertion failed.\n"); + LLVM_DEBUG(dbgs() << " Can't unroll; loop preheader-insertion failed.\n"); return LoopUnrollResult::Unmodified; } BasicBlock *LatchBlock = L->getLoopLatch(); if (!LatchBlock) { - DEBUG(dbgs() << " Can't unroll; loop exit-block-insertion failed.\n"); + LLVM_DEBUG(dbgs() << " Can't unroll; loop exit-block-insertion failed.\n"); return LoopUnrollResult::Unmodified; } // Loops with indirectbr cannot be cloned. if (!L->isSafeToClone()) { - DEBUG(dbgs() << " Can't unroll; Loop body cannot be cloned.\n"); + LLVM_DEBUG(dbgs() << " Can't unroll; Loop body cannot be cloned.\n"); return LoopUnrollResult::Unmodified; } @@ -335,7 +335,7 @@ if (!BI || BI->isUnconditional()) { // The loop-rotate pass can be helpful to avoid this in many cases. - DEBUG(dbgs() << + LLVM_DEBUG(dbgs() << " Can't unroll; loop not terminated by a conditional branch.\n"); return LoopUnrollResult::Unmodified; } @@ -345,22 +345,22 @@ }; if (!CheckSuccessors(0, 1) && !CheckSuccessors(1, 0)) { - DEBUG(dbgs() << "Can't unroll; only loops with one conditional latch" + LLVM_DEBUG(dbgs() << "Can't unroll; only loops with one conditional latch" " exiting the loop can be unrolled\n"); return LoopUnrollResult::Unmodified; } if (Header->hasAddressTaken()) { // The loop-rotate pass can be helpful to avoid this in many cases. - DEBUG(dbgs() << + LLVM_DEBUG(dbgs() << " Won't unroll loop: address of header block is taken.\n"); return LoopUnrollResult::Unmodified; } if (TripCount != 0) - DEBUG(dbgs() << " Trip Count = " << TripCount << "\n"); + LLVM_DEBUG(dbgs() << " Trip Count = " << TripCount << "\n"); if (TripMultiple != 1) - DEBUG(dbgs() << " Trip Multiple = " << TripMultiple << "\n"); + LLVM_DEBUG(dbgs() << " Trip Multiple = " << TripMultiple << "\n"); // Effectively "DCE" unrolled iterations that are beyond the tripcount // and will never be executed. @@ -369,7 +369,7 @@ // Don't enter the unroll code if there is nothing to do. if (TripCount == 0 && Count < 2 && PeelCount == 0) { - DEBUG(dbgs() << "Won't unroll; almost nothing to do\n"); + LLVM_DEBUG(dbgs() << "Won't unroll; almost nothing to do\n"); return LoopUnrollResult::Unmodified; } @@ -419,7 +419,7 @@ // Loops containing convergent instructions must have a count that divides // their TripMultiple. - DEBUG( + LLVM_DEBUG( { bool HasConvergent = false; for (auto &BB : L->blocks()) @@ -442,7 +442,7 @@ if (Force) RuntimeTripCount = false; else { - DEBUG( + LLVM_DEBUG( dbgs() << "Wont unroll; remainder loop could not be generated" "when assuming runtime trip count\n"); return LoopUnrollResult::Unmodified; @@ -468,7 +468,7 @@ using namespace ore; // Report the unrolling decision. if (CompletelyUnroll) { - DEBUG(dbgs() << "COMPLETELY UNROLLING loop %" << Header->getName() + LLVM_DEBUG(dbgs() << "COMPLETELY UNROLLING loop %" << Header->getName() << " with trip count " << TripCount << "!\n"); if (ORE) ORE->emit([&]() { @@ -478,7 +478,7 @@ << NV("UnrollCount", TripCount) << " iterations"; }); } else if (PeelCount) { - DEBUG(dbgs() << "PEELING loop %" << Header->getName() + LLVM_DEBUG(dbgs() << "PEELING loop %" << Header->getName() << " with iteration count " << PeelCount << "!\n"); if (ORE) ORE->emit([&]() { @@ -495,29 +495,29 @@ << NV("UnrollCount", Count); }; - DEBUG(dbgs() << "UNROLLING loop %" << Header->getName() + LLVM_DEBUG(dbgs() << "UNROLLING loop %" << Header->getName() << " by " << Count); if (TripMultiple == 0 || BreakoutTrip != TripMultiple) { - DEBUG(dbgs() << " with a breakout at trip " << BreakoutTrip); + LLVM_DEBUG(dbgs() << " with a breakout at trip " << BreakoutTrip); if (ORE) ORE->emit([&]() { return DiagBuilder() << " with a breakout at trip " << NV("BreakoutTrip", BreakoutTrip); }); } else if (TripMultiple != 1) { - DEBUG(dbgs() << " with " << TripMultiple << " trips per branch"); + LLVM_DEBUG(dbgs() << " with " << TripMultiple << " trips per branch"); if (ORE) ORE->emit([&]() { return DiagBuilder() << " with " << NV("TripMultiple", TripMultiple) << " trips per branch"; }); } else if (RuntimeTripCount) { - DEBUG(dbgs() << " with run-time trip count"); + LLVM_DEBUG(dbgs() << " with run-time trip count"); if (ORE) ORE->emit( [&]() { return DiagBuilder() << " with run-time trip count"; }); } - DEBUG(dbgs() << "!\n"); + LLVM_DEBUG(dbgs() << "!\n"); } bool ContinueOnTrue = L->contains(BI->getSuccessor(0)); Index: lib/Transforms/Utils/LoopUnrollPeel.cpp =================================================================== --- lib/Transforms/Utils/LoopUnrollPeel.cpp +++ lib/Transforms/Utils/LoopUnrollPeel.cpp @@ -177,7 +177,7 @@ DesiredPeelCount = std::min(DesiredPeelCount, MaxPeelCount); // Consider max peel count limitation. assert(DesiredPeelCount > 0 && "Wrong loop size estimation?"); - DEBUG(dbgs() << "Peel " << DesiredPeelCount << " iteration(s) to turn" + LLVM_DEBUG(dbgs() << "Peel " << DesiredPeelCount << " iteration(s) to turn" << " some Phis into invariants.\n"); UP.PeelCount = DesiredPeelCount; return; @@ -192,7 +192,7 @@ // If the user provided a peel count, use that. bool UserPeelCount = UnrollForcePeelCount.getNumOccurrences() > 0; if (UserPeelCount) { - DEBUG(dbgs() << "Force-peeling first " << UnrollForcePeelCount + LLVM_DEBUG(dbgs() << "Force-peeling first " << UnrollForcePeelCount << " iterations.\n"); UP.PeelCount = UnrollForcePeelCount; return; @@ -208,20 +208,20 @@ if (!PeelCount) return; - DEBUG(dbgs() << "Profile-based estimated trip count is " << *PeelCount + LLVM_DEBUG(dbgs() << "Profile-based estimated trip count is " << *PeelCount << "\n"); if (*PeelCount) { if ((*PeelCount <= UnrollPeelMaxCount) && (LoopSize * (*PeelCount + 1) <= UP.Threshold)) { - DEBUG(dbgs() << "Peeling first " << *PeelCount << " iterations.\n"); + LLVM_DEBUG(dbgs() << "Peeling first " << *PeelCount << " iterations.\n"); UP.PeelCount = *PeelCount; return; } - DEBUG(dbgs() << "Requested peel count: " << *PeelCount << "\n"); - DEBUG(dbgs() << "Max peel count: " << UnrollPeelMaxCount << "\n"); - DEBUG(dbgs() << "Peel cost: " << LoopSize * (*PeelCount + 1) << "\n"); - DEBUG(dbgs() << "Max peel cost: " << UP.Threshold << "\n"); + LLVM_DEBUG(dbgs() << "Requested peel count: " << *PeelCount << "\n"); + LLVM_DEBUG(dbgs() << "Max peel count: " << UnrollPeelMaxCount << "\n"); + LLVM_DEBUG(dbgs() << "Peel cost: " << LoopSize * (*PeelCount + 1) << "\n"); + LLVM_DEBUG(dbgs() << "Max peel cost: " << UP.Threshold << "\n"); } } } Index: lib/Transforms/Utils/LoopUnrollRuntime.cpp =================================================================== --- lib/Transforms/Utils/LoopUnrollRuntime.cpp +++ lib/Transforms/Utils/LoopUnrollRuntime.cpp @@ -418,7 +418,7 @@ // UnrollRuntimeMultiExit is true. This will need updating the logic in // connectEpilog/connectProlog. if (!LatchExit->getSinglePredecessor()) { - DEBUG(dbgs() << "Bailout for multi-exit handling when latch exit has >1 " + LLVM_DEBUG(dbgs() << "Bailout for multi-exit handling when latch exit has >1 " "predecessor.\n"); return false; } @@ -528,14 +528,14 @@ LoopInfo *LI, ScalarEvolution *SE, DominatorTree *DT, AssumptionCache *AC, bool PreserveLCSSA) { - DEBUG(dbgs() << "Trying runtime unrolling on Loop: \n"); - DEBUG(L->dump()); - DEBUG(UseEpilogRemainder ? dbgs() << "Using epilog remainder.\n" : + LLVM_DEBUG(dbgs() << "Trying runtime unrolling on Loop: \n"); + LLVM_DEBUG(L->dump()); + LLVM_DEBUG(UseEpilogRemainder ? dbgs() << "Using epilog remainder.\n" : dbgs() << "Using prolog remainder.\n"); // Make sure the loop is in canonical form. if (!L->isLoopSimplifyForm()) { - DEBUG(dbgs() << "Not in simplify form!\n"); + LLVM_DEBUG(dbgs() << "Not in simplify form!\n"); return false; } @@ -561,7 +561,7 @@ // Support only single exit and exiting block unless multi-exit loop unrolling is enabled. if (!isMultiExitUnrollingEnabled && (!L->getExitingBlock() || OtherExits.size())) { - DEBUG( + LLVM_DEBUG( dbgs() << "Multiple exit/exiting blocks in loop and multi-exit unrolling not " "enabled!\n"); @@ -581,7 +581,7 @@ const SCEV *BECountSC = SE->getExitCount(L, Latch); if (isa(BECountSC) || !BECountSC->getType()->isIntegerTy()) { - DEBUG(dbgs() << "Could not compute exit block SCEV\n"); + LLVM_DEBUG(dbgs() << "Could not compute exit block SCEV\n"); return false; } @@ -591,7 +591,7 @@ const SCEV *TripCountSC = SE->getAddExpr(BECountSC, SE->getConstant(BECountSC->getType(), 1)); if (isa(TripCountSC)) { - DEBUG(dbgs() << "Could not compute trip count SCEV.\n"); + LLVM_DEBUG(dbgs() << "Could not compute trip count SCEV.\n"); return false; } @@ -601,14 +601,14 @@ SCEVExpander Expander(*SE, DL, "loop-unroll"); if (!AllowExpensiveTripCount && Expander.isHighCostExpansion(TripCountSC, L, PreHeaderBR)) { - DEBUG(dbgs() << "High cost for expanding trip count scev!\n"); + LLVM_DEBUG(dbgs() << "High cost for expanding trip count scev!\n"); return false; } // This constraint lets us deal with an overflowing trip count easily; see the // comment on ModVal below. if (Log2_32(Count) > BEWidth) { - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "Count failed constraint on overflow trip count calculation.\n"); return false; } @@ -897,7 +897,7 @@ } if (remainderLoop && UnrollRemainder) { - DEBUG(dbgs() << "Unrolling remainder loop\n"); + LLVM_DEBUG(dbgs() << "Unrolling remainder loop\n"); UnrollLoop(remainderLoop, /*Count*/ Count - 1, /*TripCount*/ Count - 1, /*Force*/ false, /*AllowRuntime*/ false, /*AllowExpensiveTripCount*/ false, /*PreserveCondBr*/ true, Index: lib/Transforms/Utils/LoopUtils.cpp =================================================================== --- lib/Transforms/Utils/LoopUtils.cpp +++ lib/Transforms/Utils/LoopUtils.cpp @@ -553,47 +553,47 @@ if (AddReductionVar(Phi, RK_IntegerAdd, TheLoop, HasFunNoNaNAttr, RedDes, DB, AC, DT)) { - DEBUG(dbgs() << "Found an ADD reduction PHI." << *Phi << "\n"); + LLVM_DEBUG(dbgs() << "Found an ADD reduction PHI." << *Phi << "\n"); return true; } if (AddReductionVar(Phi, RK_IntegerMult, TheLoop, HasFunNoNaNAttr, RedDes, DB, AC, DT)) { - DEBUG(dbgs() << "Found a MUL reduction PHI." << *Phi << "\n"); + LLVM_DEBUG(dbgs() << "Found a MUL reduction PHI." << *Phi << "\n"); return true; } if (AddReductionVar(Phi, RK_IntegerOr, TheLoop, HasFunNoNaNAttr, RedDes, DB, AC, DT)) { - DEBUG(dbgs() << "Found an OR reduction PHI." << *Phi << "\n"); + LLVM_DEBUG(dbgs() << "Found an OR reduction PHI." << *Phi << "\n"); return true; } if (AddReductionVar(Phi, RK_IntegerAnd, TheLoop, HasFunNoNaNAttr, RedDes, DB, AC, DT)) { - DEBUG(dbgs() << "Found an AND reduction PHI." << *Phi << "\n"); + LLVM_DEBUG(dbgs() << "Found an AND reduction PHI." << *Phi << "\n"); return true; } if (AddReductionVar(Phi, RK_IntegerXor, TheLoop, HasFunNoNaNAttr, RedDes, DB, AC, DT)) { - DEBUG(dbgs() << "Found a XOR reduction PHI." << *Phi << "\n"); + LLVM_DEBUG(dbgs() << "Found a XOR reduction PHI." << *Phi << "\n"); return true; } if (AddReductionVar(Phi, RK_IntegerMinMax, TheLoop, HasFunNoNaNAttr, RedDes, DB, AC, DT)) { - DEBUG(dbgs() << "Found a MINMAX reduction PHI." << *Phi << "\n"); + LLVM_DEBUG(dbgs() << "Found a MINMAX reduction PHI." << *Phi << "\n"); return true; } if (AddReductionVar(Phi, RK_FloatMult, TheLoop, HasFunNoNaNAttr, RedDes, DB, AC, DT)) { - DEBUG(dbgs() << "Found an FMult reduction PHI." << *Phi << "\n"); + LLVM_DEBUG(dbgs() << "Found an FMult reduction PHI." << *Phi << "\n"); return true; } if (AddReductionVar(Phi, RK_FloatAdd, TheLoop, HasFunNoNaNAttr, RedDes, DB, AC, DT)) { - DEBUG(dbgs() << "Found an FAdd reduction PHI." << *Phi << "\n"); + LLVM_DEBUG(dbgs() << "Found an FAdd reduction PHI." << *Phi << "\n"); return true; } if (AddReductionVar(Phi, RK_FloatMinMax, TheLoop, HasFunNoNaNAttr, RedDes, DB, AC, DT)) { - DEBUG(dbgs() << "Found an float MINMAX reduction PHI." << *Phi << "\n"); + LLVM_DEBUG(dbgs() << "Found an float MINMAX reduction PHI." << *Phi << "\n"); return true; } // Not a reduction of known type. @@ -1050,7 +1050,7 @@ AR = PSE.getAsAddRec(Phi); if (!AR) { - DEBUG(dbgs() << "LV: PHI is not a poly recurrence.\n"); + LLVM_DEBUG(dbgs() << "LV: PHI is not a poly recurrence.\n"); return false; } @@ -1084,14 +1084,14 @@ const SCEVAddRecExpr *AR = dyn_cast(PhiScev); if (!AR) { - DEBUG(dbgs() << "LV: PHI is not a poly recurrence.\n"); + LLVM_DEBUG(dbgs() << "LV: PHI is not a poly recurrence.\n"); return false; } if (AR->getLoop() != TheLoop) { // FIXME: We should treat this as a uniform. Unfortunately, we // don't currently know how to handled uniform PHIs. - DEBUG(dbgs() << "LV: PHI is a recurrence with respect to an outer loop.\n"); + LLVM_DEBUG(dbgs() << "LV: PHI is a recurrence with respect to an outer loop.\n"); return false; } @@ -1172,10 +1172,10 @@ BB, InLoopPredecessors, ".loopexit", DT, LI, PreserveLCSSA); if (!NewExitBB) - DEBUG(dbgs() << "WARNING: Can't create a dedicated exit block for loop: " + LLVM_DEBUG(dbgs() << "WARNING: Can't create a dedicated exit block for loop: " << *L << "\n"); else - DEBUG(dbgs() << "LoopSimplify: Creating dedicated exit block " + LLVM_DEBUG(dbgs() << "LoopSimplify: Creating dedicated exit block " << NewExitBB->getName() << "\n"); return true; }; Index: lib/Transforms/Utils/LowerSwitch.cpp =================================================================== --- lib/Transforms/Utils/LowerSwitch.cpp +++ lib/Transforms/Utils/LowerSwitch.cpp @@ -245,12 +245,12 @@ unsigned Mid = Size / 2; std::vector LHS(Begin, Begin + Mid); - DEBUG(dbgs() << "LHS: " << LHS << "\n"); + LLVM_DEBUG(dbgs() << "LHS: " << LHS << "\n"); std::vector RHS(Begin + Mid, End); - DEBUG(dbgs() << "RHS: " << RHS << "\n"); + LLVM_DEBUG(dbgs() << "RHS: " << RHS << "\n"); CaseRange &Pivot = *(Begin + Mid); - DEBUG(dbgs() << "Pivot ==> " + LLVM_DEBUG(dbgs() << "Pivot ==> " << Pivot.Low->getValue() << " -" << Pivot.High->getValue() << "\n"); @@ -274,7 +274,7 @@ NewUpperBound = LHS.back().High; } - DEBUG(dbgs() << "LHS Bounds ==> "; + LLVM_DEBUG(dbgs() << "LHS Bounds ==> "; if (LowerBound) { dbgs() << LowerBound->getSExtValue(); } else { @@ -443,9 +443,9 @@ // Prepare cases vector. CaseVector Cases; unsigned numCmps = Clusterify(Cases, SI); - DEBUG(dbgs() << "Clusterify finished. Total clusters: " << Cases.size() + LLVM_DEBUG(dbgs() << "Clusterify finished. Total clusters: " << Cases.size() << ". Total compares: " << numCmps << "\n"); - DEBUG(dbgs() << "Cases: " << Cases << "\n"); + LLVM_DEBUG(dbgs() << "Cases: " << Cases << "\n"); (void)numCmps; ConstantInt *LowerBound = nullptr; Index: lib/Transforms/Utils/PredicateInfo.cpp =================================================================== --- lib/Transforms/Utils/PredicateInfo.cpp +++ lib/Transforms/Utils/PredicateInfo.cpp @@ -625,14 +625,14 @@ // we want to. bool PossibleCopy = VD.PInfo != nullptr; if (RenameStack.empty()) { - DEBUG(dbgs() << "Rename Stack is empty\n"); + LLVM_DEBUG(dbgs() << "Rename Stack is empty\n"); } else { - DEBUG(dbgs() << "Rename Stack Top DFS numbers are (" + LLVM_DEBUG(dbgs() << "Rename Stack Top DFS numbers are (" << RenameStack.back().DFSIn << "," << RenameStack.back().DFSOut << ")\n"); } - DEBUG(dbgs() << "Current DFS numbers are (" << VD.DFSIn << "," + LLVM_DEBUG(dbgs() << "Current DFS numbers are (" << VD.DFSIn << "," << VD.DFSOut << ")\n"); bool ShouldPush = (VD.Def || PossibleCopy); @@ -652,7 +652,7 @@ if (VD.Def || PossibleCopy) continue; if (!DebugCounter::shouldExecute(RenameCounter)) { - DEBUG(dbgs() << "Skipping execution due to debug counter\n"); + LLVM_DEBUG(dbgs() << "Skipping execution due to debug counter\n"); continue; } ValueDFS &Result = RenameStack.back(); @@ -663,7 +663,7 @@ if (!Result.Def) Result.Def = materializeStack(Counter, RenameStack, Op); - DEBUG(dbgs() << "Found replacement " << *Result.Def << " for " + LLVM_DEBUG(dbgs() << "Found replacement " << *Result.Def << " for " << *VD.U->get() << " in " << *(VD.U->getUser()) << "\n"); assert(DT.dominates(cast(Result.Def), *VD.U) && "Predicateinfo def should have dominated this use"); Index: lib/Transforms/Utils/SSAUpdater.cpp =================================================================== --- lib/Transforms/Utils/SSAUpdater.cpp +++ lib/Transforms/Utils/SSAUpdater.cpp @@ -178,7 +178,7 @@ // If the client wants to know about all new instructions, tell it. if (InsertedPHIs) InsertedPHIs->push_back(InsertedPHI); - DEBUG(dbgs() << " Inserted PHI: " << *InsertedPHI << "\n"); + LLVM_DEBUG(dbgs() << " Inserted PHI: " << *InsertedPHI << "\n"); return InsertedPHI; } Index: lib/Transforms/Utils/SimplifyCFG.cpp =================================================================== --- lib/Transforms/Utils/SimplifyCFG.cpp +++ lib/Transforms/Utils/SimplifyCFG.cpp @@ -847,7 +847,7 @@ // Remove PHI node entries for the dead edge. ThisCases[0].Dest->removePredecessor(TI->getParent()); - DEBUG(dbgs() << "Threading pred instr: " << *Pred->getTerminator() + LLVM_DEBUG(dbgs() << "Threading pred instr: " << *Pred->getTerminator() << "Through successor TI: " << *TI << "Leaving: " << *NI << "\n"); @@ -861,7 +861,7 @@ for (unsigned i = 0, e = PredCases.size(); i != e; ++i) DeadCases.insert(PredCases[i].Value); - DEBUG(dbgs() << "Threading pred instr: " << *Pred->getTerminator() + LLVM_DEBUG(dbgs() << "Threading pred instr: " << *Pred->getTerminator() << "Through successor TI: " << *TI); // Collect branch weights into a vector. @@ -888,7 +888,7 @@ if (HasWeight && Weights.size() >= 2) setBranchWeights(SI, Weights); - DEBUG(dbgs() << "Leaving: " << *TI << "\n"); + LLVM_DEBUG(dbgs() << "Leaving: " << *TI << "\n"); return true; } @@ -929,7 +929,7 @@ Instruction *NI = Builder.CreateBr(TheRealDest); (void)NI; - DEBUG(dbgs() << "Threading pred instr: " << *Pred->getTerminator() + LLVM_DEBUG(dbgs() << "Threading pred instr: " << *Pred->getTerminator() << "Through successor TI: " << *TI << "Leaving: " << *NI << "\n"); @@ -1728,7 +1728,7 @@ LockstepReverseIterator LRI(UnconditionalPreds); while (LRI.isValid() && canSinkInstructions(*LRI, PHIOperands)) { - DEBUG(dbgs() << "SINK: instruction can be sunk: " << *(*LRI)[0] << "\n"); + LLVM_DEBUG(dbgs() << "SINK: instruction can be sunk: " << *(*LRI)[0] << "\n"); InstructionsToSink.insert((*LRI).begin(), (*LRI).end()); ++ScanIdx; --LRI; @@ -1740,7 +1740,7 @@ for (auto *V : PHIOperands[I]) if (InstructionsToSink.count(V) == 0) ++NumPHIdValues; - DEBUG(dbgs() << "SINK: #phid values: " << NumPHIdValues << "\n"); + LLVM_DEBUG(dbgs() << "SINK: #phid values: " << NumPHIdValues << "\n"); unsigned NumPHIInsts = NumPHIdValues / UnconditionalPreds.size(); if ((NumPHIdValues % UnconditionalPreds.size()) != 0) NumPHIInsts++; @@ -1768,7 +1768,7 @@ if (!Profitable) return false; - DEBUG(dbgs() << "SINK: Splitting edge\n"); + LLVM_DEBUG(dbgs() << "SINK: Splitting edge\n"); // We have a conditional edge and we're going to sink some instructions. // Insert a new block postdominating all blocks we're going to sink from. if (!SplitBlockPredecessors(BB, UnconditionalPreds, ".sink.split")) @@ -1790,7 +1790,7 @@ // and never actually sink it which means we produce more PHIs than intended. // This is unlikely in practice though. for (unsigned SinkIdx = 0; SinkIdx != ScanIdx; ++SinkIdx) { - DEBUG(dbgs() << "SINK: Sink: " + LLVM_DEBUG(dbgs() << "SINK: Sink: " << *UnconditionalPreds[0]->getTerminator()->getPrevNode() << "\n"); @@ -1799,7 +1799,7 @@ LRI.reset(); if (!ProfitableToSinkInstruction(LRI)) { // Too many PHIs would be created. - DEBUG(dbgs() << "SINK: stopping here, too many PHIs would be created!\n"); + LLVM_DEBUG(dbgs() << "SINK: stopping here, too many PHIs would be created!\n"); break; } @@ -2045,7 +2045,7 @@ return false; // If we get here, we can hoist the instruction and if-convert. - DEBUG(dbgs() << "SPECULATIVELY EXECUTING BB" << *ThenBB << "\n";); + LLVM_DEBUG(dbgs() << "SPECULATIVELY EXECUTING BB" << *ThenBB << "\n";); // Insert a select of the value of the speculated store. if (SpeculatedStoreValue) { @@ -2350,7 +2350,7 @@ } } - DEBUG(dbgs() << "FOUND IF CONDITION! " << *IfCond << " T: " + LLVM_DEBUG(dbgs() << "FOUND IF CONDITION! " << *IfCond << " T: " << IfTrue->getName() << " F: " << IfFalse->getName() << "\n"); // If we can still promote the PHI nodes after this gauntlet of tests, @@ -2475,7 +2475,7 @@ (void)RI; - DEBUG(dbgs() << "\nCHANGING BRANCH TO TWO RETURNS INTO SELECT:" + LLVM_DEBUG(dbgs() << "\nCHANGING BRANCH TO TWO RETURNS INTO SELECT:" << "\n " << *BI << "NewRet = " << *RI << "TRUEBLOCK: " << *TrueSucc << "FALSEBLOCK: " << *FalseSucc); @@ -2650,7 +2650,7 @@ continue; } - DEBUG(dbgs() << "FOLDING BRANCH TO COMMON DEST:\n" << *PBI << *BB); + LLVM_DEBUG(dbgs() << "FOLDING BRANCH TO COMMON DEST:\n" << *PBI << *BB); IRBuilder<> Builder(PBI); // If we need to invert the condition in the pred block to match, do so now. @@ -3261,7 +3261,7 @@ // Finally, if everything is ok, fold the branches to logical ops. BasicBlock *OtherDest = BI->getSuccessor(BIOp ^ 1); - DEBUG(dbgs() << "FOLDING BRs:" << *PBI->getParent() + LLVM_DEBUG(dbgs() << "FOLDING BRs:" << *PBI->getParent() << "AND: " << *BI->getParent()); // If OtherDest *is* BB, then BB is a basic block with a single conditional @@ -3280,7 +3280,7 @@ OtherDest = InfLoopBlock; } - DEBUG(dbgs() << *PBI->getParent()->getParent()); + LLVM_DEBUG(dbgs() << *PBI->getParent()->getParent()); // BI may have other predecessors. Because of this, we leave // it alone, but modify PBI. @@ -3364,8 +3364,8 @@ } } - DEBUG(dbgs() << "INTO: " << *PBI->getParent()); - DEBUG(dbgs() << *PBI->getParent()->getParent()); + LLVM_DEBUG(dbgs() << "INTO: " << *PBI->getParent()); + LLVM_DEBUG(dbgs() << *PBI->getParent()->getParent()); // This basic block is probably dead. We know it has at least // one fewer predecessor. @@ -3665,7 +3665,7 @@ BasicBlock *BB = BI->getParent(); - DEBUG(dbgs() << "Converting 'icmp' chain with " << Values.size() + LLVM_DEBUG(dbgs() << "Converting 'icmp' chain with " << Values.size() << " cases into SWITCH. BB is:\n" << *BB); @@ -3690,7 +3690,7 @@ // for the edge we just added. AddPredecessorToBlock(EdgeBB, BB, NewBB); - DEBUG(dbgs() << " ** 'icmp' chain unhandled condition: " << *ExtraCase + LLVM_DEBUG(dbgs() << " ** 'icmp' chain unhandled condition: " << *ExtraCase << "\nEXTRABB = " << *BB); BB = NewBB; } @@ -3722,7 +3722,7 @@ // Erase the old branch instruction. EraseTerminatorInstAndDCECond(BI); - DEBUG(dbgs() << " ** 'icmp' chain result is:\n" << *BB << '\n'); + LLVM_DEBUG(dbgs() << " ** 'icmp' chain result is:\n" << *BB << '\n'); return true; } @@ -4049,7 +4049,7 @@ if (!UncondBranchPreds.empty() && DupRet) { while (!UncondBranchPreds.empty()) { BasicBlock *Pred = UncondBranchPreds.pop_back_val(); - DEBUG(dbgs() << "FOLDING: " << *BB + LLVM_DEBUG(dbgs() << "FOLDING: " << *BB << "INTO UNCOND BRANCH PRED: " << *Pred); (void)FoldReturnIntoUncondBranch(RI, BB, Pred); } @@ -4374,7 +4374,7 @@ if (Known.Zero.intersects(CaseVal) || !Known.One.isSubsetOf(CaseVal) || (CaseVal.getMinSignedBits() > MaxSignificantBitsInCond)) { DeadCases.push_back(Case.getCaseValue()); - DEBUG(dbgs() << "SimplifyCFG: switch case " << CaseVal << " is dead.\n"); + LLVM_DEBUG(dbgs() << "SimplifyCFG: switch case " << CaseVal << " is dead.\n"); } } @@ -4390,7 +4390,7 @@ if (HasDefault && DeadCases.empty() && NumUnknownBits < 64 /* avoid overflow */ && SI->getNumCases() == (1ULL << NumUnknownBits)) { - DEBUG(dbgs() << "SimplifyCFG: switch default is dead.\n"); + LLVM_DEBUG(dbgs() << "SimplifyCFG: switch default is dead.\n"); BasicBlock *NewDefault = SplitBlockPredecessors(SI->getDefaultDest(), SI->getParent(), ""); SI->setDefaultDest(&*NewDefault); @@ -5986,7 +5986,7 @@ // or that just have themself as a predecessor. These are unreachable. if ((pred_empty(BB) && BB != &BB->getParent()->getEntryBlock()) || BB->getSinglePredecessor() == BB) { - DEBUG(dbgs() << "Removing BB: \n" << *BB); + LLVM_DEBUG(dbgs() << "Removing BB: \n" << *BB); DeleteDeadBlock(BB); return true; } Index: lib/Transforms/Utils/SimplifyIndVar.cpp =================================================================== --- lib/Transforms/Utils/SimplifyIndVar.cpp +++ lib/Transforms/Utils/SimplifyIndVar.cpp @@ -147,7 +147,7 @@ if (SE->getSCEV(UseInst) != FoldedExpr) return nullptr; - DEBUG(dbgs() << "INDVARS: Eliminated IV operand: " << *IVOperand + LLVM_DEBUG(dbgs() << "INDVARS: Eliminated IV operand: " << *IVOperand << " -> " << *UseInst << '\n'); UseInst->setOperand(OperIdx, IVSrc); @@ -221,7 +221,7 @@ // for now. return false; - DEBUG(dbgs() << "INDVARS: Simplified comparison: " << *ICmp << '\n'); + LLVM_DEBUG(dbgs() << "INDVARS: Simplified comparison: " << *ICmp << '\n'); ICmp->setPredicate(InvariantPredicate); ICmp->setOperand(0, NewLHS); ICmp->setOperand(1, NewRHS); @@ -252,11 +252,11 @@ if (SE->isKnownPredicate(Pred, S, X)) { ICmp->replaceAllUsesWith(ConstantInt::getTrue(ICmp->getContext())); DeadInsts.emplace_back(ICmp); - DEBUG(dbgs() << "INDVARS: Eliminated comparison: " << *ICmp << '\n'); + LLVM_DEBUG(dbgs() << "INDVARS: Eliminated comparison: " << *ICmp << '\n'); } else if (SE->isKnownPredicate(ICmpInst::getInversePredicate(Pred), S, X)) { ICmp->replaceAllUsesWith(ConstantInt::getFalse(ICmp->getContext())); DeadInsts.emplace_back(ICmp); - DEBUG(dbgs() << "INDVARS: Eliminated comparison: " << *ICmp << '\n'); + LLVM_DEBUG(dbgs() << "INDVARS: Eliminated comparison: " << *ICmp << '\n'); } else if (makeIVComparisonInvariant(ICmp, IVOperand)) { // fallthrough to end of function } else if (ICmpInst::isSigned(OriginalPred) && @@ -267,7 +267,7 @@ // we turn the instruction's predicate to its unsigned version. Note that // we cannot rely on Pred here unless we check if we have swapped it. assert(ICmp->getPredicate() == OriginalPred && "Predicate changed?"); - DEBUG(dbgs() << "INDVARS: Turn to unsigned comparison: " << *ICmp << '\n'); + LLVM_DEBUG(dbgs() << "INDVARS: Turn to unsigned comparison: " << *ICmp << '\n'); ICmp->setPredicate(ICmpInst::getUnsignedPredicate(OriginalPred)); } else return; @@ -293,7 +293,7 @@ SDiv->getName() + ".udiv", SDiv); UDiv->setIsExact(SDiv->isExact()); SDiv->replaceAllUsesWith(UDiv); - DEBUG(dbgs() << "INDVARS: Simplified sdiv: " << *SDiv << '\n'); + LLVM_DEBUG(dbgs() << "INDVARS: Simplified sdiv: " << *SDiv << '\n'); ++NumSimplifiedSDiv; Changed = true; DeadInsts.push_back(SDiv); @@ -309,7 +309,7 @@ auto *URem = BinaryOperator::Create(BinaryOperator::URem, N, D, Rem->getName() + ".urem", Rem); Rem->replaceAllUsesWith(URem); - DEBUG(dbgs() << "INDVARS: Simplified srem: " << *Rem << '\n'); + LLVM_DEBUG(dbgs() << "INDVARS: Simplified srem: " << *Rem << '\n'); ++NumSimplifiedSRem; Changed = true; DeadInsts.emplace_back(Rem); @@ -318,7 +318,7 @@ // i % n --> i if i is in [0,n). void SimplifyIndvar::replaceRemWithNumerator(BinaryOperator *Rem) { Rem->replaceAllUsesWith(Rem->getOperand(0)); - DEBUG(dbgs() << "INDVARS: Simplified rem: " << *Rem << '\n'); + LLVM_DEBUG(dbgs() << "INDVARS: Simplified rem: " << *Rem << '\n'); ++NumElimRem; Changed = true; DeadInsts.emplace_back(Rem); @@ -332,7 +332,7 @@ SelectInst *Sel = SelectInst::Create(ICmp, ConstantInt::get(T, 0), N, "iv.rem", Rem); Rem->replaceAllUsesWith(Sel); - DEBUG(dbgs() << "INDVARS: Simplified rem: " << *Rem << '\n'); + LLVM_DEBUG(dbgs() << "INDVARS: Simplified rem: " << *Rem << '\n'); ++NumElimRem; Changed = true; DeadInsts.emplace_back(Rem); @@ -548,7 +548,7 @@ auto *Invariant = Rewriter.expandCodeFor(S, I->getType(), IP); I->replaceAllUsesWith(Invariant); - DEBUG(dbgs() << "INDVARS: Replace IV user: " << *I + LLVM_DEBUG(dbgs() << "INDVARS: Replace IV user: " << *I << " with loop invariant: " << *S << '\n'); ++NumFoldedUser; Changed = true; @@ -589,7 +589,7 @@ if (!LI->replacementPreservesLCSSAForm(UseInst, IVOperand)) return false; - DEBUG(dbgs() << "INDVARS: Eliminated identity: " << *UseInst << '\n'); + LLVM_DEBUG(dbgs() << "INDVARS: Eliminated identity: " << *UseInst << '\n'); UseInst->replaceAllUsesWith(IVOperand); ++NumElimIdentity; Index: lib/Transforms/Utils/SplitModule.cpp =================================================================== --- lib/Transforms/Utils/SplitModule.cpp +++ lib/Transforms/Utils/SplitModule.cpp @@ -101,7 +101,7 @@ // At this point module should have the proper mix of globals and locals. // As we attempt to partition this module, we must not change any // locals to globals. - DEBUG(dbgs() << "Partition module with (" << M->size() << ")functions\n"); + LLVM_DEBUG(dbgs() << "Partition module with (" << M->size() << ")functions\n"); ClusterMapType GVtoClusterMap; ComdatMembersType ComdatMembers; @@ -192,7 +192,7 @@ unsigned CurrentClusterSize = BalancinQueue.top().second; BalancinQueue.pop(); - DEBUG(dbgs() << "Root[" << CurrentClusterID << "] cluster_size(" << I.first + LLVM_DEBUG(dbgs() << "Root[" << CurrentClusterID << "] cluster_size(" << I.first << ") ----> " << I.second->getData()->getName() << "\n"); for (ClusterMapType::member_iterator MI = @@ -200,7 +200,7 @@ MI != GVtoClusterMap.member_end(); ++MI) { if (!Visited.insert(*MI).second) continue; - DEBUG(dbgs() << "----> " << (*MI)->getName() + LLVM_DEBUG(dbgs() << "----> " << (*MI)->getName() << ((*MI)->hasLocalLinkage() ? " l " : " e ") << "\n"); Visited.insert(*MI); ClusterIDMap[*MI] = CurrentClusterID; Index: lib/Transforms/Utils/VNCoercion.cpp =================================================================== --- lib/Transforms/Utils/VNCoercion.cpp +++ lib/Transforms/Utils/VNCoercion.cpp @@ -389,8 +389,8 @@ NewLoad->takeName(SrcVal); NewLoad->setAlignment(SrcVal->getAlignment()); - DEBUG(dbgs() << "GVN WIDENED LOAD: " << *SrcVal << "\n"); - DEBUG(dbgs() << "TO: " << *NewLoad << "\n"); + LLVM_DEBUG(dbgs() << "GVN WIDENED LOAD: " << *SrcVal << "\n"); + LLVM_DEBUG(dbgs() << "TO: " << *NewLoad << "\n"); // Replace uses of the original load with the wider load. On a big endian // system, we need to shift down to get the relevant bits. Index: lib/Transforms/Vectorize/LoadStoreVectorizer.cpp =================================================================== --- lib/Transforms/Vectorize/LoadStoreVectorizer.cpp +++ lib/Transforms/Vectorize/LoadStoreVectorizer.cpp @@ -517,7 +517,7 @@ SmallVector ChainInstrs; bool IsLoadChain = isa(Chain[0]); - DEBUG({ + LLVM_DEBUG({ for (Instruction *I : Chain) { if (IsLoadChain) assert(isa(I) && @@ -539,10 +539,10 @@ Intrinsic::sideeffect) { // Ignore llvm.sideeffect calls. } else if (IsLoadChain && (I.mayWriteToMemory() || I.mayThrow())) { - DEBUG(dbgs() << "LSV: Found may-write/throw operation: " << I << '\n'); + LLVM_DEBUG(dbgs() << "LSV: Found may-write/throw operation: " << I << '\n'); break; } else if (!IsLoadChain && (I.mayReadOrWriteMemory() || I.mayThrow())) { - DEBUG(dbgs() << "LSV: Found may-read/write/throw operation: " << I + LLVM_DEBUG(dbgs() << "LSV: Found may-read/write/throw operation: " << I << '\n'); break; } @@ -587,7 +587,7 @@ if (!AA.isNoAlias(MemoryLocation::get(MemInstr), MemoryLocation::get(ChainInstr))) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "LSV: Found alias:\n" " Aliasing instruction and pointer:\n" << " " << *MemInstr << '\n' @@ -735,7 +735,7 @@ if (Size < 2) continue; - DEBUG(dbgs() << "LSV: Analyzing a chain of length " << Size << ".\n"); + LLVM_DEBUG(dbgs() << "LSV: Analyzing a chain of length " << Size << ".\n"); // Process the stores in chunks of 64. for (unsigned CI = 0, CE = Size; CI < CE; CI += 64) { @@ -749,7 +749,7 @@ } bool Vectorizer::vectorizeInstructions(ArrayRef Instrs) { - DEBUG(dbgs() << "LSV: Vectorizing " << Instrs.size() << " instructions.\n"); + LLVM_DEBUG(dbgs() << "LSV: Vectorizing " << Instrs.size() << " instructions.\n"); SmallVector Heads, Tails; int ConsecutiveChain[64]; @@ -885,14 +885,14 @@ // vector factor, break it into two pieces. unsigned TargetVF = TTI.getStoreVectorFactor(VF, Sz, SzInBytes, VecTy); if (ChainSize > VF || (VF != TargetVF && TargetVF < ChainSize)) { - DEBUG(dbgs() << "LSV: Chain doesn't match with the vector factor." + LLVM_DEBUG(dbgs() << "LSV: Chain doesn't match with the vector factor." " Creating two separate arrays.\n"); return vectorizeStoreChain(Chain.slice(0, TargetVF), InstructionsProcessed) | vectorizeStoreChain(Chain.slice(TargetVF), InstructionsProcessed); } - DEBUG({ + LLVM_DEBUG({ dbgs() << "LSV: Stores to vectorize:\n"; for (Instruction *I : Chain) dbgs() << " " << *I << "\n"; @@ -1033,7 +1033,7 @@ // vector factor, break it into two pieces. unsigned TargetVF = TTI.getLoadVectorFactor(VF, Sz, SzInBytes, VecTy); if (ChainSize > VF || (VF != TargetVF && TargetVF < ChainSize)) { - DEBUG(dbgs() << "LSV: Chain doesn't match with the vector factor." + LLVM_DEBUG(dbgs() << "LSV: Chain doesn't match with the vector factor." " Creating two separate arrays.\n"); return vectorizeLoadChain(Chain.slice(0, TargetVF), InstructionsProcessed) | vectorizeLoadChain(Chain.slice(TargetVF), InstructionsProcessed); @@ -1057,7 +1057,7 @@ Alignment = NewAlign; } - DEBUG({ + LLVM_DEBUG({ dbgs() << "LSV: Loads to vectorize:\n"; for (Instruction *I : Chain) I->dump(); @@ -1140,7 +1140,7 @@ bool Allows = TTI.allowsMisalignedMemoryAccesses(F.getParent()->getContext(), SzInBytes * 8, AddressSpace, Alignment, &Fast); - DEBUG(dbgs() << "LSV: Target said misaligned is allowed? " << Allows + LLVM_DEBUG(dbgs() << "LSV: Target said misaligned is allowed? " << Allows << " and fast? " << Fast << "\n";); return !Allows || !Fast; } Index: lib/Transforms/Vectorize/LoopVectorize.cpp =================================================================== --- lib/Transforms/Vectorize/LoopVectorize.cpp +++ lib/Transforms/Vectorize/LoopVectorize.cpp @@ -293,8 +293,8 @@ make_range(scc_iterator::begin(L), scc_iterator::end(L))) { if (SCC.size() > 1) { - DEBUG(dbgs() << "LVL: Detected a cycle in the loop body:\n"); - DEBUG(L.dump()); + LLVM_DEBUG(dbgs() << "LVL: Detected a cycle in the loop body:\n"); + LLVM_DEBUG(L.dump()); return true; } } @@ -1264,7 +1264,7 @@ // consider the loop to have been already vectorized because there's // nothing more that we can do. IsVectorized.Value = Width.Value == 1 && Interleave.Value == 1; - DEBUG(if (DisableInterleaving && Interleave.Value == 1) dbgs() + LLVM_DEBUG(if (DisableInterleaving && Interleave.Value == 1) dbgs() << "LV: Interleaving disabled by the pass manager\n"); } @@ -1277,19 +1277,19 @@ bool allowVectorization(Function *F, Loop *L, bool AlwaysVectorize) const { if (getForce() == LoopVectorizeHints::FK_Disabled) { - DEBUG(dbgs() << "LV: Not vectorizing: #pragma vectorize disable.\n"); + LLVM_DEBUG(dbgs() << "LV: Not vectorizing: #pragma vectorize disable.\n"); emitRemarkWithHints(); return false; } if (!AlwaysVectorize && getForce() != LoopVectorizeHints::FK_Enabled) { - DEBUG(dbgs() << "LV: Not vectorizing: No #pragma vectorize enable.\n"); + LLVM_DEBUG(dbgs() << "LV: Not vectorizing: No #pragma vectorize enable.\n"); emitRemarkWithHints(); return false; } if (getIsVectorized() == 1) { - DEBUG(dbgs() << "LV: Not vectorizing: Disabled/already vectorized.\n"); + LLVM_DEBUG(dbgs() << "LV: Not vectorizing: Disabled/already vectorized.\n"); // FIXME: Add interleave.disable metadata. This will allow // vectorize.disable to be used without disabling the pass and errors // to differentiate between disabled vectorization and a width of 1. @@ -1428,7 +1428,7 @@ if (H->validate(Val)) H->Value = Val; else - DEBUG(dbgs() << "LV: ignoring invalid hint '" << Name << "'\n"); + LLVM_DEBUG(dbgs() << "LV: ignoring invalid hint '" << Name << "'\n"); break; } } @@ -2283,7 +2283,7 @@ << "loop not vectorized: cannot prove it is safe to reorder " "memory operations"; }); - DEBUG(dbgs() << "LV: Too many memory checks needed.\n"); + LLVM_DEBUG(dbgs() << "LV: Too many memory checks needed.\n"); Failed = true; } @@ -4759,7 +4759,7 @@ default: // This instruction is not vectorized by simple widening. - DEBUG(dbgs() << "LV: Found an unhandled instruction: " << I); + LLVM_DEBUG(dbgs() << "LV: Found an unhandled instruction: " << I); llvm_unreachable("Unhandled instruction!"); } // end of switch. } @@ -4777,7 +4777,7 @@ DT->addNewBlock(LoopScalarPreHeader, LoopBypassBlocks[0]); DT->changeImmediateDominator(LoopScalarBody, LoopScalarPreHeader); DT->changeImmediateDominator(LoopExitBlock, LoopBypassBlocks[0]); - DEBUG(DT->verifyDomTree()); + LLVM_DEBUG(DT->verifyDomTree()); } /// \brief Check whether it is safe to if-convert this phi node. @@ -4853,7 +4853,7 @@ // We must have a loop in canonical form. Loops with indirectbr in them cannot // be canonicalized. if (!TheLoop->getLoopPreheader()) { - DEBUG(dbgs() << "LV: Loop doesn't have a legal pre-header.\n"); + LLVM_DEBUG(dbgs() << "LV: Loop doesn't have a legal pre-header.\n"); ORE->emit(createMissedAnalysis("CFGNotUnderstood") << "loop control flow is not understood by vectorizer"); if (DoExtraAnalysis) @@ -4908,13 +4908,13 @@ } // We need to have a loop header. - DEBUG(dbgs() << "LV: Found a loop: " << TheLoop->getHeader()->getName() + LLVM_DEBUG(dbgs() << "LV: Found a loop: " << TheLoop->getHeader()->getName() << '\n'); // Check if we can if-convert non-single-bb loops. unsigned NumBlocks = TheLoop->getNumBlocks(); if (NumBlocks != 1 && !canVectorizeWithIfConvert()) { - DEBUG(dbgs() << "LV: Can't if-convert the loop.\n"); + LLVM_DEBUG(dbgs() << "LV: Can't if-convert the loop.\n"); if (DoExtraAnalysis) Result = false; else @@ -4923,7 +4923,7 @@ // Check if we can vectorize the instructions and CFG in this loop. if (!canVectorizeInstrs()) { - DEBUG(dbgs() << "LV: Can't vectorize the instructions or CFG\n"); + LLVM_DEBUG(dbgs() << "LV: Can't vectorize the instructions or CFG\n"); if (DoExtraAnalysis) Result = false; else @@ -4932,14 +4932,14 @@ // Go over each instruction and look at memory deps. if (!canVectorizeMemory()) { - DEBUG(dbgs() << "LV: Can't vectorize due to memory conflicts\n"); + LLVM_DEBUG(dbgs() << "LV: Can't vectorize due to memory conflicts\n"); if (DoExtraAnalysis) Result = false; else return false; } - DEBUG(dbgs() << "LV: We can vectorize this loop" + LLVM_DEBUG(dbgs() << "LV: We can vectorize this loop" << (LAI->getRuntimePointerChecking()->Need ? " (with a runtime bound check)" : "") @@ -4963,7 +4963,7 @@ ORE->emit(createMissedAnalysis("TooManySCEVRunTimeChecks") << "Too many SCEV assumptions need to be made and checked " << "at runtime"); - DEBUG(dbgs() << "LV: Too many SCEV checks needed.\n"); + LLVM_DEBUG(dbgs() << "LV: Too many SCEV checks needed.\n"); if (DoExtraAnalysis) Result = false; else @@ -5009,7 +5009,7 @@ Instruction *UI = cast(U); // This user may be a reduction exit value. if (!TheLoop->contains(UI)) { - DEBUG(dbgs() << "LV: Found an outside user for : " << *UI << '\n'); + LLVM_DEBUG(dbgs() << "LV: Found an outside user for : " << *UI << '\n'); return true; } } @@ -5065,7 +5065,7 @@ AllowedExit.insert(Phi->getIncomingValueForBlock(TheLoop->getLoopLatch())); } - DEBUG(dbgs() << "LV: Found an induction variable.\n"); + LLVM_DEBUG(dbgs() << "LV: Found an induction variable.\n"); } bool LoopVectorizationLegality::canVectorizeInstrs() { @@ -5087,7 +5087,7 @@ !PhiTy->isPointerTy()) { ORE->emit(createMissedAnalysis("CFGNotUnderstood", Phi) << "loop control flow is not understood by vectorizer"); - DEBUG(dbgs() << "LV: Found an non-int non-pointer PHI.\n"); + LLVM_DEBUG(dbgs() << "LV: Found an non-int non-pointer PHI.\n"); return false; } @@ -5109,7 +5109,7 @@ if (Phi->getNumIncomingValues() != 2) { ORE->emit(createMissedAnalysis("CFGNotUnderstood", Phi) << "control flow not understood by vectorizer"); - DEBUG(dbgs() << "LV: Found an invalid PHI.\n"); + LLVM_DEBUG(dbgs() << "LV: Found an invalid PHI.\n"); return false; } @@ -5147,7 +5147,7 @@ ORE->emit(createMissedAnalysis("NonReductionValueUsedOutsideLoop", Phi) << "value that could not be identified as " "reduction is used outside the loop"); - DEBUG(dbgs() << "LV: Found an unidentified PHI." << *Phi << "\n"); + LLVM_DEBUG(dbgs() << "LV: Found an unidentified PHI." << *Phi << "\n"); return false; } // end of PHI handling @@ -5162,7 +5162,7 @@ TLI->isFunctionVectorizable(CI->getCalledFunction()->getName()))) { ORE->emit(createMissedAnalysis("CantVectorizeCall", CI) << "call instruction cannot be vectorized"); - DEBUG(dbgs() << "LV: Found a non-intrinsic, non-libfunc callsite.\n"); + LLVM_DEBUG(dbgs() << "LV: Found a non-intrinsic, non-libfunc callsite.\n"); return false; } @@ -5174,7 +5174,7 @@ if (!SE->isLoopInvariant(PSE.getSCEV(CI->getOperand(1)), TheLoop)) { ORE->emit(createMissedAnalysis("CantVectorizeIntrinsic", CI) << "intrinsic instruction cannot be vectorized"); - DEBUG(dbgs() << "LV: Found unvectorizable intrinsic " << *CI << "\n"); + LLVM_DEBUG(dbgs() << "LV: Found unvectorizable intrinsic " << *CI << "\n"); return false; } } @@ -5186,7 +5186,7 @@ isa(I)) { ORE->emit(createMissedAnalysis("CantVectorizeInstructionReturnType", &I) << "instruction return type cannot be vectorized"); - DEBUG(dbgs() << "LV: Found unvectorizable type.\n"); + LLVM_DEBUG(dbgs() << "LV: Found unvectorizable type.\n"); return false; } @@ -5206,7 +5206,7 @@ // semantics. } else if (I.getType()->isFloatingPointTy() && (CI || I.isBinaryOp()) && !I.isFast()) { - DEBUG(dbgs() << "LV: Found FP op with unsafe algebra.\n"); + LLVM_DEBUG(dbgs() << "LV: Found FP op with unsafe algebra.\n"); Hints->setPotentiallyUnsafe(); } @@ -5221,7 +5221,7 @@ } if (!PrimaryInduction) { - DEBUG(dbgs() << "LV: Did not find one integer induction var.\n"); + LLVM_DEBUG(dbgs() << "LV: Did not find one integer induction var.\n"); if (Inductions.empty()) { ORE->emit(createMissedAnalysis("NoInductionVariable") << "loop induction variable could not be identified"); @@ -5329,7 +5329,7 @@ } for (auto *I : ScalarPtrs) if (!PossibleNonScalarPtrs.count(I)) { - DEBUG(dbgs() << "LV: Found scalar instruction: " << *I << "\n"); + LLVM_DEBUG(dbgs() << "LV: Found scalar instruction: " << *I << "\n"); Worklist.insert(I); } @@ -5346,8 +5346,8 @@ continue; Worklist.insert(Ind); Worklist.insert(IndUpdate); - DEBUG(dbgs() << "LV: Found scalar instruction: " << *Ind << "\n"); - DEBUG(dbgs() << "LV: Found scalar instruction: " << *IndUpdate << "\n"); + LLVM_DEBUG(dbgs() << "LV: Found scalar instruction: " << *Ind << "\n"); + LLVM_DEBUG(dbgs() << "LV: Found scalar instruction: " << *IndUpdate << "\n"); } // Insert the forced scalars. @@ -5374,7 +5374,7 @@ isScalarUse(J, Src)); })) { Worklist.insert(Src); - DEBUG(dbgs() << "LV: Found scalar instruction: " << *Src << "\n"); + LLVM_DEBUG(dbgs() << "LV: Found scalar instruction: " << *Src << "\n"); } } @@ -5414,8 +5414,8 @@ // The induction variable and its update instruction will remain scalar. Worklist.insert(Ind); Worklist.insert(IndUpdate); - DEBUG(dbgs() << "LV: Found scalar instruction: " << *Ind << "\n"); - DEBUG(dbgs() << "LV: Found scalar instruction: " << *IndUpdate << "\n"); + LLVM_DEBUG(dbgs() << "LV: Found scalar instruction: " << *Ind << "\n"); + LLVM_DEBUG(dbgs() << "LV: Found scalar instruction: " << *IndUpdate << "\n"); } Scalars[VF].insert(Worklist.begin(), Worklist.end()); @@ -5499,7 +5499,7 @@ auto *Cmp = dyn_cast(Latch->getTerminator()->getOperand(0)); if (Cmp && TheLoop->contains(Cmp) && Cmp->hasOneUse()) { Worklist.insert(Cmp); - DEBUG(dbgs() << "LV: Found uniform instruction: " << *Cmp << "\n"); + LLVM_DEBUG(dbgs() << "LV: Found uniform instruction: " << *Cmp << "\n"); } // Holds consecutive and consecutive-like pointers. Consecutive-like pointers @@ -5560,7 +5560,7 @@ // aren't also identified as possibly non-uniform. for (auto *V : ConsecutiveLikePtrs) if (!PossibleNonUniformPtrs.count(V)) { - DEBUG(dbgs() << "LV: Found uniform instruction: " << *V << "\n"); + LLVM_DEBUG(dbgs() << "LV: Found uniform instruction: " << *V << "\n"); Worklist.insert(V); } @@ -5582,7 +5582,7 @@ (OI == getPointerOperand(J) && isUniformDecision(J, VF)); })) { Worklist.insert(OI); - DEBUG(dbgs() << "LV: Found uniform instruction: " << *OI << "\n"); + LLVM_DEBUG(dbgs() << "LV: Found uniform instruction: " << *OI << "\n"); } } } @@ -5627,8 +5627,8 @@ // The induction variable and its update instruction will remain uniform. Worklist.insert(Ind); Worklist.insert(IndUpdate); - DEBUG(dbgs() << "LV: Found uniform instruction: " << *Ind << "\n"); - DEBUG(dbgs() << "LV: Found uniform instruction: " << *IndUpdate << "\n"); + LLVM_DEBUG(dbgs() << "LV: Found uniform instruction: " << *Ind << "\n"); + LLVM_DEBUG(dbgs() << "LV: Found uniform instruction: " << *IndUpdate << "\n"); } Uniforms[VF].insert(Worklist.begin(), Worklist.end()); @@ -5650,7 +5650,7 @@ if (LAI->hasStoreToLoopInvariantAddress()) { ORE->emit(createMissedAnalysis("CantVectorizeStoreToLoopInvariantAddress") << "write to a loop invariant address could not be vectorized"); - DEBUG(dbgs() << "LV: We don't allow storing to uniform addresses\n"); + LLVM_DEBUG(dbgs() << "LV: We don't allow storing to uniform addresses\n"); return false; } @@ -5826,7 +5826,7 @@ // bottom-up order does not imply that WAW dependences should not be checked. void InterleavedAccessInfo::analyzeInterleaving( const ValueToValueMap &Strides) { - DEBUG(dbgs() << "LV: Analyzing interleaved accesses...\n"); + LLVM_DEBUG(dbgs() << "LV: Analyzing interleaved accesses...\n"); // Holds all accesses with a constant stride. MapVector AccessStrideInfo; @@ -5867,7 +5867,7 @@ if (isStrided(DesB.Stride)) { Group = getInterleaveGroup(B); if (!Group) { - DEBUG(dbgs() << "LV: Creating an interleave group with:" << *B << '\n'); + LLVM_DEBUG(dbgs() << "LV: Creating an interleave group with:" << *B << '\n'); Group = createInterleaveGroup(B, DesB.Stride, DesB.Align); } if (B->mayWriteToMemory()) @@ -5970,7 +5970,7 @@ // Try to insert A into B's group. if (Group->insertMember(A, IndexA, DesA.Align)) { - DEBUG(dbgs() << "LV: Inserted:" << *A << '\n' + LLVM_DEBUG(dbgs() << "LV: Inserted:" << *A << '\n' << " into the interleave group with" << *B << '\n'); InterleaveGroupMap[A] = Group; @@ -5984,7 +5984,7 @@ // Remove interleaved store groups with gaps. for (InterleaveGroup *Group : StoreGroups) if (Group->getNumMembers() != Group->getFactor()) { - DEBUG(dbgs() << "LV: Invalidate candidate interleaved store group due " + LLVM_DEBUG(dbgs() << "LV: Invalidate candidate interleaved store group due " "to gaps.\n"); releaseGroup(Group); } @@ -6017,7 +6017,7 @@ Value *FirstMemberPtr = getPointerOperand(Group->getMember(0)); if (!getPtrStride(PSE, FirstMemberPtr, TheLoop, Strides, /*Assume=*/false, /*ShouldCheckWrap=*/true)) { - DEBUG(dbgs() << "LV: Invalidate candidate interleaved group due to " + LLVM_DEBUG(dbgs() << "LV: Invalidate candidate interleaved group due to " "first group member potentially pointer-wrapping.\n"); releaseGroup(Group); continue; @@ -6027,7 +6027,7 @@ Value *LastMemberPtr = getPointerOperand(LastMember); if (!getPtrStride(PSE, LastMemberPtr, TheLoop, Strides, /*Assume=*/false, /*ShouldCheckWrap=*/true)) { - DEBUG(dbgs() << "LV: Invalidate candidate interleaved group due to " + LLVM_DEBUG(dbgs() << "LV: Invalidate candidate interleaved group due to " "last group member potentially pointer-wrapping.\n"); releaseGroup(Group); } @@ -6038,12 +6038,12 @@ // to look for a member at index factor - 1, since every group must have // a member at index zero. if (Group->isReverse()) { - DEBUG(dbgs() << "LV: Invalidate candidate interleaved group due to " + LLVM_DEBUG(dbgs() << "LV: Invalidate candidate interleaved group due to " "a reverse access with gaps.\n"); releaseGroup(Group); continue; } - DEBUG(dbgs() << "LV: Interleaved group requires epilogue iteration.\n"); + LLVM_DEBUG(dbgs() << "LV: Interleaved group requires epilogue iteration.\n"); RequiresScalarEpilogue = true; } } @@ -6053,14 +6053,14 @@ if (!EnableCondStoresVectorization && Legal->getNumPredStores()) { ORE->emit(createMissedAnalysis("ConditionalStore") << "store that is conditionally executed prevents vectorization"); - DEBUG(dbgs() << "LV: No vectorization. There are conditional stores.\n"); + LLVM_DEBUG(dbgs() << "LV: No vectorization. There are conditional stores.\n"); return None; } if (Legal->getRuntimePointerChecking()->Need && TTI.hasBranchDivergence()) { // TODO: It may by useful to do since it's still likely to be dynamically // uniform if the target can skip. - DEBUG(dbgs() << "LV: Not inserting runtime ptr check for divergent target"); + LLVM_DEBUG(dbgs() << "LV: Not inserting runtime ptr check for divergent target"); ORE->emit( createMissedAnalysis("CantVersionLoopWithDivergentTarget") @@ -6078,20 +6078,20 @@ << "runtime pointer checks needed. Enable vectorization of this " "loop with '#pragma clang loop vectorize(enable)' when " "compiling with -Os/-Oz"); - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "LV: Aborting. Runtime ptr check is required with -Os/-Oz.\n"); return None; } // If we optimize the program for size, avoid creating the tail loop. - DEBUG(dbgs() << "LV: Found trip count: " << TC << '\n'); + LLVM_DEBUG(dbgs() << "LV: Found trip count: " << TC << '\n'); // If we don't know the precise trip count, don't try to vectorize. if (TC < 2) { ORE->emit( createMissedAnalysis("UnknownLoopCountComplexCFG") << "unable to calculate the loop count due to complex control flow"); - DEBUG(dbgs() << "LV: Aborting. A tail loop is required with -Os/-Oz.\n"); + LLVM_DEBUG(dbgs() << "LV: Aborting. A tail loop is required with -Os/-Oz.\n"); return None; } @@ -6109,7 +6109,7 @@ "same time. Enable vectorization of this loop " "with '#pragma clang loop vectorize(enable)' " "when compiling with -Os/-Oz"); - DEBUG(dbgs() << "LV: Aborting. A tail loop is required with -Os/-Oz.\n"); + LLVM_DEBUG(dbgs() << "LV: Aborting. A tail loop is required with -Os/-Oz.\n"); return None; } @@ -6134,22 +6134,22 @@ unsigned MaxVectorSize = WidestRegister / WidestType; - DEBUG(dbgs() << "LV: The Smallest and Widest types: " << SmallestType << " / " + LLVM_DEBUG(dbgs() << "LV: The Smallest and Widest types: " << SmallestType << " / " << WidestType << " bits.\n"); - DEBUG(dbgs() << "LV: The Widest register safe to use is: " << WidestRegister + LLVM_DEBUG(dbgs() << "LV: The Widest register safe to use is: " << WidestRegister << " bits.\n"); assert(MaxVectorSize <= 64 && "Did not expect to pack so many elements" " into one vector!"); if (MaxVectorSize == 0) { - DEBUG(dbgs() << "LV: The target has no vector registers.\n"); + LLVM_DEBUG(dbgs() << "LV: The target has no vector registers.\n"); MaxVectorSize = 1; return MaxVectorSize; } else if (ConstTripCount && ConstTripCount < MaxVectorSize && isPowerOf2_32(ConstTripCount)) { // We need to clamp the VF to be the ConstTripCount. There is no point in // choosing a higher viable VF as done in the loop below. - DEBUG(dbgs() << "LV: Clamping the MaxVF to the constant trip count: " + LLVM_DEBUG(dbgs() << "LV: Clamping the MaxVF to the constant trip count: " << ConstTripCount << "\n"); MaxVectorSize = ConstTripCount; return MaxVectorSize; @@ -6187,7 +6187,7 @@ const float ScalarCost = Cost; #endif /* NDEBUG */ unsigned Width = 1; - DEBUG(dbgs() << "LV: Scalar loop costs: " << (int)ScalarCost << ".\n"); + LLVM_DEBUG(dbgs() << "LV: Scalar loop costs: " << (int)ScalarCost << ".\n"); bool ForceVectorization = Hints->getForce() == LoopVectorizeHints::FK_Enabled; // Ignore scalar width, because the user explicitly wants vectorization. @@ -6202,10 +6202,10 @@ // the vector elements. VectorizationCostTy C = expectedCost(i); float VectorCost = C.first / (float)i; - DEBUG(dbgs() << "LV: Vector loop of width " << i + LLVM_DEBUG(dbgs() << "LV: Vector loop of width " << i << " costs: " << (int)VectorCost << ".\n"); if (!C.second && !ForceVectorization) { - DEBUG( + LLVM_DEBUG( dbgs() << "LV: Not considering vector loop of width " << i << " because it will not generate any vector instructions.\n"); continue; @@ -6216,10 +6216,10 @@ } } - DEBUG(if (ForceVectorization && Width > 1 && Cost >= ScalarCost) dbgs() + LLVM_DEBUG(if (ForceVectorization && Width > 1 && Cost >= ScalarCost) dbgs() << "LV: Vectorization seems to be not beneficial, " << "but was forced by a user.\n"); - DEBUG(dbgs() << "LV: Selecting VF: " << Width << ".\n"); + LLVM_DEBUG(dbgs() << "LV: Selecting VF: " << Width << ".\n"); VectorizationFactor Factor = {Width, (unsigned)(Width * Cost)}; return Factor; } @@ -6311,7 +6311,7 @@ return 1; unsigned TargetNumRegisters = TTI.getNumberOfRegisters(VF > 1); - DEBUG(dbgs() << "LV: The target has " << TargetNumRegisters + LLVM_DEBUG(dbgs() << "LV: The target has " << TargetNumRegisters << " registers\n"); if (VF == 1) { @@ -6371,7 +6371,7 @@ // Interleave if we vectorized this loop and there is a reduction that could // benefit from interleaving. if (VF > 1 && !Legal->getReductionVars()->empty()) { - DEBUG(dbgs() << "LV: Interleaving because of reductions.\n"); + LLVM_DEBUG(dbgs() << "LV: Interleaving because of reductions.\n"); return IC; } @@ -6382,7 +6382,7 @@ // We want to interleave small loops in order to reduce the loop overhead and // potentially expose ILP opportunities. - DEBUG(dbgs() << "LV: Loop cost is " << LoopCost << '\n'); + LLVM_DEBUG(dbgs() << "LV: Loop cost is " << LoopCost << '\n'); if (!InterleavingRequiresRuntimePointerCheck && LoopCost < SmallLoopCost) { // We assume that the cost overhead is 1 and we use the cost model // to estimate the cost of the loop and interleave until the cost of the @@ -6410,11 +6410,11 @@ if (EnableLoadStoreRuntimeInterleave && std::max(StoresIC, LoadsIC) > SmallIC) { - DEBUG(dbgs() << "LV: Interleaving to saturate store or load ports.\n"); + LLVM_DEBUG(dbgs() << "LV: Interleaving to saturate store or load ports.\n"); return std::max(StoresIC, LoadsIC); } - DEBUG(dbgs() << "LV: Interleaving to reduce branch cost.\n"); + LLVM_DEBUG(dbgs() << "LV: Interleaving to reduce branch cost.\n"); return SmallIC; } @@ -6422,11 +6422,11 @@ // this point) that could benefit from interleaving. bool HasReductions = !Legal->getReductionVars()->empty(); if (TTI.enableAggressiveInterleaving(HasReductions)) { - DEBUG(dbgs() << "LV: Interleaving to expose ILP.\n"); + LLVM_DEBUG(dbgs() << "LV: Interleaving to expose ILP.\n"); return IC; } - DEBUG(dbgs() << "LV: Not Interleaving.\n"); + LLVM_DEBUG(dbgs() << "LV: Not Interleaving.\n"); return 1; } @@ -6518,7 +6518,7 @@ SmallVector RUs(VFs.size()); SmallVector MaxUsages(VFs.size(), 0); - DEBUG(dbgs() << "LV(REG): Calculating max register usage:\n"); + LLVM_DEBUG(dbgs() << "LV(REG): Calculating max register usage:\n"); // A lambda that gets the register usage for the given type and VF. auto GetRegUsage = [&DL, WidestRegister](Type *Ty, unsigned VF) { @@ -6563,7 +6563,7 @@ MaxUsages[j] = std::max(MaxUsages[j], RegUsage); } - DEBUG(dbgs() << "LV(REG): At #" << i << " Interval # " + LLVM_DEBUG(dbgs() << "LV(REG): At #" << i << " Interval # " << OpenIntervals.size() << '\n'); // Add the current instruction to the list of open intervals. @@ -6579,10 +6579,10 @@ Invariant += GetRegUsage(Inst->getType(), VFs[i]); } - DEBUG(dbgs() << "LV(REG): VF = " << VFs[i] << '\n'); - DEBUG(dbgs() << "LV(REG): Found max usage: " << MaxUsages[i] << '\n'); - DEBUG(dbgs() << "LV(REG): Found invariant usage: " << Invariant << '\n'); - DEBUG(dbgs() << "LV(REG): LoopSize: " << RU.NumInstructions << '\n'); + LLVM_DEBUG(dbgs() << "LV(REG): VF = " << VFs[i] << '\n'); + LLVM_DEBUG(dbgs() << "LV(REG): Found max usage: " << MaxUsages[i] << '\n'); + LLVM_DEBUG(dbgs() << "LV(REG): Found invariant usage: " << Invariant << '\n'); + LLVM_DEBUG(dbgs() << "LV(REG): LoopSize: " << RU.NumInstructions << '\n'); RU.LoopInvariantRegs = Invariant; RU.MaxLocalUsers = MaxUsages[i]; @@ -6765,7 +6765,7 @@ BlockCost.first += C.first; BlockCost.second |= C.second; - DEBUG(dbgs() << "LV: Found an estimated cost of " << C.first << " for VF " + LLVM_DEBUG(dbgs() << "LV: Found an estimated cost of " << C.first << " for VF " << VF << " For instruction: " << I << '\n'); } @@ -7410,13 +7410,13 @@ return NoVectorization; if (UserVF) { - DEBUG(dbgs() << "LV: Using user VF " << UserVF << ".\n"); + LLVM_DEBUG(dbgs() << "LV: Using user VF " << UserVF << ".\n"); assert(isPowerOf2_32(UserVF) && "VF needs to be a power of two"); // Collect the instructions (and their associated costs) that will be more // profitable to scalarize. CM.selectUserVectorizationFactor(UserVF); buildVPlans(UserVF, UserVF); - DEBUG(printPlans(dbgs())); + LLVM_DEBUG(printPlans(dbgs())); return {UserVF, 0}; } @@ -7434,7 +7434,7 @@ } buildVPlans(1, MaxVF); - DEBUG(printPlans(dbgs())); + LLVM_DEBUG(printPlans(dbgs())); if (MaxVF == 1) return NoVectorization; @@ -7443,7 +7443,7 @@ } void LoopVectorizationPlanner::setBestPlan(unsigned VF, unsigned UF) { - DEBUG(dbgs() << "Setting best plan to VF=" << VF << ", UF=" << UF << '\n'); + LLVM_DEBUG(dbgs() << "Setting best plan to VF=" << VF << ", UF=" << UF << '\n'); BestVF = VF; BestUF = UF; @@ -7919,11 +7919,11 @@ // Finalize the recipe for Instr, first if it is not predicated. if (!IsPredicated) { - DEBUG(dbgs() << "LV: Scalarizing:" << *I << "\n"); + LLVM_DEBUG(dbgs() << "LV: Scalarizing:" << *I << "\n"); VPBB->appendRecipe(Recipe); return VPBB; } - DEBUG(dbgs() << "LV: Scalarizing and predicating:" << *I << "\n"); + LLVM_DEBUG(dbgs() << "LV: Scalarizing and predicating:" << *I << "\n"); assert(VPBB->getSuccessors().empty() && "VPBB has successors when handling predicated replication."); // Record predicated instructions for above packing optimizations. @@ -8036,7 +8036,7 @@ // should follow. auto SAIt = SinkAfter.find(Instr); if (SAIt != SinkAfter.end()) { - DEBUG(dbgs() << "Sinking" << *SAIt->first << " after" << *SAIt->second + LLVM_DEBUG(dbgs() << "Sinking" << *SAIt->first << " after" << *SAIt->second << " to vectorize a 1st order recurrence.\n"); SinkAfterInverse[SAIt->second] = Instr; continue; @@ -8301,13 +8301,13 @@ const std::string DebugLocStr = getDebugLocString(L); #endif /* NDEBUG */ - DEBUG(dbgs() << "\nLV: Checking a loop in \"" + LLVM_DEBUG(dbgs() << "\nLV: Checking a loop in \"" << L->getHeader()->getParent()->getName() << "\" from " << DebugLocStr << "\n"); LoopVectorizeHints Hints(L, DisableUnrolling, *ORE); - DEBUG(dbgs() << "LV: Loop hints:" + LLVM_DEBUG(dbgs() << "LV: Loop hints:" << " force=" << (Hints.getForce() == LoopVectorizeHints::FK_Disabled ? "disabled" @@ -8329,7 +8329,7 @@ // benefit from vectorization, respectively. if (!Hints.allowVectorization(F, L, AlwaysVectorize)) { - DEBUG(dbgs() << "LV: Loop hints prevent vectorization.\n"); + LLVM_DEBUG(dbgs() << "LV: Loop hints prevent vectorization.\n"); return false; } @@ -8340,7 +8340,7 @@ LoopVectorizationLegality LVL(L, PSE, DT, TLI, AA, F, TTI, GetLAA, LI, ORE, &Requirements, &Hints, DB, AC); if (!LVL.canVectorize()) { - DEBUG(dbgs() << "LV: Not vectorizing: Cannot prove legality.\n"); + LLVM_DEBUG(dbgs() << "LV: Not vectorizing: Cannot prove legality.\n"); emitMissedWarning(F, L, Hints, ORE); return false; } @@ -8380,13 +8380,13 @@ } if (HasExpectedTC && ExpectedTC < TinyTripCountVectorThreshold) { - DEBUG(dbgs() << "LV: Found a loop with a very small trip count. " + LLVM_DEBUG(dbgs() << "LV: Found a loop with a very small trip count. " << "This loop is worth vectorizing only if no scalar " << "iteration overheads are incurred."); if (Hints.getForce() == LoopVectorizeHints::FK_Enabled) - DEBUG(dbgs() << " But vectorizing was explicitly forced.\n"); + LLVM_DEBUG(dbgs() << " But vectorizing was explicitly forced.\n"); else { - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n"); // Loops with a very small trip count are considered for vectorization // under OptForSize, thereby making sure the cost of their loop body is // dominant, free of runtime guards and scalar iteration overheads. @@ -8399,7 +8399,7 @@ // an integer loop and the vector instructions selected are purely integer // vector instructions? if (F->hasFnAttribute(Attribute::NoImplicitFloat)) { - DEBUG(dbgs() << "LV: Can't vectorize when the NoImplicitFloat" + LLVM_DEBUG(dbgs() << "LV: Can't vectorize when the NoImplicitFloat" "attribute is used.\n"); ORE->emit(createMissedAnalysis(Hints.vectorizeAnalysisPassName(), "NoImplicitFloat", L) @@ -8414,7 +8414,7 @@ // additional fp-math flags can help. if (Hints.isPotentiallyUnsafe() && TTI->isFPVectorizationPotentiallyUnsafe()) { - DEBUG(dbgs() << "LV: Potentially unsafe FP op prevents vectorization.\n"); + LLVM_DEBUG(dbgs() << "LV: Potentially unsafe FP op prevents vectorization.\n"); ORE->emit( createMissedAnalysis(Hints.vectorizeAnalysisPassName(), "UnsafeFP", L) << "loop not vectorized due to unsafe FP support."); @@ -8446,14 +8446,14 @@ std::pair VecDiagMsg, IntDiagMsg; bool VectorizeLoop = true, InterleaveLoop = true; if (Requirements.doesNotMeet(F, L, Hints)) { - DEBUG(dbgs() << "LV: Not vectorizing: loop did not meet vectorization " + LLVM_DEBUG(dbgs() << "LV: Not vectorizing: loop did not meet vectorization " "requirements.\n"); emitMissedWarning(F, L, Hints, ORE); return false; } if (VF.Width == 1) { - DEBUG(dbgs() << "LV: Vectorization is possible but not beneficial.\n"); + LLVM_DEBUG(dbgs() << "LV: Vectorization is possible but not beneficial.\n"); VecDiagMsg = std::make_pair( "VectorizationNotBeneficial", "the cost-model indicates that vectorization is not beneficial"); @@ -8462,7 +8462,7 @@ if (IC == 1 && UserIC <= 1) { // Tell the user interleaving is not beneficial. - DEBUG(dbgs() << "LV: Interleaving is not beneficial.\n"); + LLVM_DEBUG(dbgs() << "LV: Interleaving is not beneficial.\n"); IntDiagMsg = std::make_pair( "InterleavingNotBeneficial", "the cost-model indicates that interleaving is not beneficial"); @@ -8474,7 +8474,7 @@ } } else if (IC > 1 && UserIC == 1) { // Tell the user interleaving is beneficial, but it explicitly disabled. - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "LV: Interleaving is beneficial but is explicitly disabled."); IntDiagMsg = std::make_pair( "InterleavingBeneficialButDisabled", @@ -8502,14 +8502,14 @@ }); return false; } else if (!VectorizeLoop && InterleaveLoop) { - DEBUG(dbgs() << "LV: Interleave Count is " << IC << '\n'); + LLVM_DEBUG(dbgs() << "LV: Interleave Count is " << IC << '\n'); ORE->emit([&]() { return OptimizationRemarkAnalysis(VAPassName, VecDiagMsg.first, L->getStartLoc(), L->getHeader()) << VecDiagMsg.second; }); } else if (VectorizeLoop && !InterleaveLoop) { - DEBUG(dbgs() << "LV: Found a vectorizable loop (" << VF.Width << ") in " + LLVM_DEBUG(dbgs() << "LV: Found a vectorizable loop (" << VF.Width << ") in " << DebugLocStr << '\n'); ORE->emit([&]() { return OptimizationRemarkAnalysis(LV_NAME, IntDiagMsg.first, @@ -8517,9 +8517,9 @@ << IntDiagMsg.second; }); } else if (VectorizeLoop && InterleaveLoop) { - DEBUG(dbgs() << "LV: Found a vectorizable loop (" << VF.Width << ") in " + LLVM_DEBUG(dbgs() << "LV: Found a vectorizable loop (" << VF.Width << ") in " << DebugLocStr << '\n'); - DEBUG(dbgs() << "LV: Interleave Count is " << IC << '\n'); + LLVM_DEBUG(dbgs() << "LV: Interleave Count is " << IC << '\n'); } LVP.setBestPlan(VF.Width, IC); @@ -8566,7 +8566,7 @@ // Mark the loop as already vectorized to avoid vectorizing again. Hints.setAlreadyVectorized(); - DEBUG(verifyFunction(*L->getHeader()->getParent())); + LLVM_DEBUG(verifyFunction(*L->getHeader()->getParent())); return true; } Index: lib/Transforms/Vectorize/SLPVectorizer.cpp =================================================================== --- lib/Transforms/Vectorize/SLPVectorizer.cpp +++ lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -1039,7 +1039,7 @@ template void schedule(ScheduleData *SD, ReadyListType &ReadyList) { SD->IsScheduled = true; - DEBUG(dbgs() << "SLP: schedule " << *SD << "\n"); + LLVM_DEBUG(dbgs() << "SLP: schedule " << *SD << "\n"); ScheduleData *BundleMember = SD; while (BundleMember) { @@ -1062,7 +1062,7 @@ assert(!DepBundle->IsScheduled && "already scheduled bundle gets ready"); ReadyList.insert(DepBundle); - DEBUG(dbgs() + LLVM_DEBUG(dbgs() << "SLP: gets ready (def): " << *DepBundle << "\n"); } }); @@ -1076,7 +1076,7 @@ assert(!DepBundle->IsScheduled && "already scheduled bundle gets ready"); ReadyList.insert(DepBundle); - DEBUG(dbgs() << "SLP: gets ready (mem): " << *DepBundle + LLVM_DEBUG(dbgs() << "SLP: gets ready (mem): " << *DepBundle << "\n"); } } @@ -1102,7 +1102,7 @@ doForAllOpcodes(I, [&](ScheduleData *SD) { if (SD->isSchedulingEntity() && SD->isReady()) { ReadyList.insert(SD); - DEBUG(dbgs() << "SLP: initially in ready list: " << *I << "\n"); + LLVM_DEBUG(dbgs() << "SLP: initially in ready list: " << *I << "\n"); } }); } @@ -1350,12 +1350,12 @@ // Check if the scalar is externally used as an extra arg. auto ExtI = ExternallyUsedValues.find(Scalar); if (ExtI != ExternallyUsedValues.end()) { - DEBUG(dbgs() << "SLP: Need to extract: Extra arg from lane " << + LLVM_DEBUG(dbgs() << "SLP: Need to extract: Extra arg from lane " << Lane << " from " << *Scalar << ".\n"); ExternalUses.emplace_back(Scalar, nullptr, FoundLane); } for (User *U : Scalar->users()) { - DEBUG(dbgs() << "SLP: Checking user:" << *U << ".\n"); + LLVM_DEBUG(dbgs() << "SLP: Checking user:" << *U << ".\n"); Instruction *UserInst = dyn_cast(U); if (!UserInst) @@ -1369,7 +1369,7 @@ // be used. if (UseScalar != U || !InTreeUserNeedToExtract(Scalar, UserInst, TLI)) { - DEBUG(dbgs() << "SLP: \tInternal user will be removed:" << *U + LLVM_DEBUG(dbgs() << "SLP: \tInternal user will be removed:" << *U << ".\n"); assert(!UseEntry->NeedToGather && "Bad state"); continue; @@ -1380,7 +1380,7 @@ if (is_contained(UserIgnoreList, UserInst)) continue; - DEBUG(dbgs() << "SLP: Need to extract:" << *U << " from lane " << + LLVM_DEBUG(dbgs() << "SLP: Need to extract:" << *U << " from lane " << Lane << " from " << *Scalar << ".\n"); ExternalUses.push_back(ExternalUser(Scalar, U, FoundLane)); } @@ -1394,28 +1394,28 @@ InstructionsState S = getSameOpcode(VL); if (Depth == RecursionMaxDepth) { - DEBUG(dbgs() << "SLP: Gathering due to max recursion depth.\n"); + LLVM_DEBUG(dbgs() << "SLP: Gathering due to max recursion depth.\n"); newTreeEntry(VL, false, UserTreeIdx); return; } // Don't handle vectors. if (S.OpValue->getType()->isVectorTy()) { - DEBUG(dbgs() << "SLP: Gathering due to vector type.\n"); + LLVM_DEBUG(dbgs() << "SLP: Gathering due to vector type.\n"); newTreeEntry(VL, false, UserTreeIdx); return; } if (StoreInst *SI = dyn_cast(S.OpValue)) if (SI->getValueOperand()->getType()->isVectorTy()) { - DEBUG(dbgs() << "SLP: Gathering due to store vector type.\n"); + LLVM_DEBUG(dbgs() << "SLP: Gathering due to store vector type.\n"); newTreeEntry(VL, false, UserTreeIdx); return; } // If all of the operands are identical or constant we have a simple solution. if (allConstant(VL) || isSplat(VL) || !allSameBlock(VL) || !S.Opcode) { - DEBUG(dbgs() << "SLP: Gathering due to C,S,B,O. \n"); + LLVM_DEBUG(dbgs() << "SLP: Gathering due to C,S,B,O. \n"); newTreeEntry(VL, false, UserTreeIdx); return; } @@ -1426,7 +1426,7 @@ // Don't vectorize ephemeral values. for (unsigned i = 0, e = VL.size(); i != e; ++i) { if (EphValues.count(VL[i])) { - DEBUG(dbgs() << "SLP: The instruction (" << *VL[i] << + LLVM_DEBUG(dbgs() << "SLP: The instruction (" << *VL[i] << ") is ephemeral.\n"); newTreeEntry(VL, false, UserTreeIdx); return; @@ -1435,16 +1435,16 @@ // Check if this is a duplicate of another entry. if (TreeEntry *E = getTreeEntry(S.OpValue)) { - DEBUG(dbgs() << "SLP: \tChecking bundle: " << *S.OpValue << ".\n"); + LLVM_DEBUG(dbgs() << "SLP: \tChecking bundle: " << *S.OpValue << ".\n"); if (!E->isSame(VL)) { - DEBUG(dbgs() << "SLP: Gathering due to partial overlap.\n"); + LLVM_DEBUG(dbgs() << "SLP: Gathering due to partial overlap.\n"); newTreeEntry(VL, false, UserTreeIdx); return; } // Record the reuse of the tree node. FIXME, currently this is only used to // properly draw the graph rather than for the actual vectorization. E->UserTreeIndices.push_back(UserTreeIdx); - DEBUG(dbgs() << "SLP: Perfect diamond merge at " << *S.OpValue << ".\n"); + LLVM_DEBUG(dbgs() << "SLP: Perfect diamond merge at " << *S.OpValue << ".\n"); return; } @@ -1454,7 +1454,7 @@ if (!I) continue; if (getTreeEntry(I)) { - DEBUG(dbgs() << "SLP: The instruction (" << *VL[i] << + LLVM_DEBUG(dbgs() << "SLP: The instruction (" << *VL[i] << ") is already in tree.\n"); newTreeEntry(VL, false, UserTreeIdx); return; @@ -1465,7 +1465,7 @@ // we need to gather the scalars. for (unsigned i = 0, e = VL.size(); i != e; ++i) { if (MustGather.count(VL[i])) { - DEBUG(dbgs() << "SLP: Gathering due to gathered scalar.\n"); + LLVM_DEBUG(dbgs() << "SLP: Gathering due to gathered scalar.\n"); newTreeEntry(VL, false, UserTreeIdx); return; } @@ -1479,7 +1479,7 @@ if (!DT->isReachableFromEntry(BB)) { // Don't go into unreachable blocks. They may contain instructions with // dependency cycles which confuse the final scheduling. - DEBUG(dbgs() << "SLP: bundle in unreachable block.\n"); + LLVM_DEBUG(dbgs() << "SLP: bundle in unreachable block.\n"); newTreeEntry(VL, false, UserTreeIdx); return; } @@ -1497,9 +1497,9 @@ if (UniqueValues.size() == VL.size()) { ReuseShuffleIndicies.clear(); } else { - DEBUG(dbgs() << "SLP: Shuffle for reused scalars.\n"); + LLVM_DEBUG(dbgs() << "SLP: Shuffle for reused scalars.\n"); if (UniqueValues.size() <= 1 || !llvm::isPowerOf2_32(UniqueValues.size())) { - DEBUG(dbgs() << "SLP: Scalar used twice in bundle.\n"); + LLVM_DEBUG(dbgs() << "SLP: Scalar used twice in bundle.\n"); newTreeEntry(VL, false, UserTreeIdx); return; } @@ -1513,14 +1513,14 @@ BlockScheduling &BS = *BSRef.get(); if (!BS.tryScheduleBundle(VL, this, VL0)) { - DEBUG(dbgs() << "SLP: We are not able to schedule this bundle!\n"); + LLVM_DEBUG(dbgs() << "SLP: We are not able to schedule this bundle!\n"); assert((!BS.getScheduleData(VL0) || !BS.getScheduleData(VL0)->isPartOfBundle()) && "tryScheduleBundle should cancelScheduling on failure"); newTreeEntry(VL, false, UserTreeIdx, ReuseShuffleIndicies); return; } - DEBUG(dbgs() << "SLP: We are able to schedule this bundle.\n"); + LLVM_DEBUG(dbgs() << "SLP: We are able to schedule this bundle.\n"); unsigned ShuffleOrOp = S.IsAltShuffle ? (unsigned) Instruction::ShuffleVector : S.Opcode; @@ -1534,7 +1534,7 @@ TerminatorInst *Term = dyn_cast( cast(VL[j])->getIncomingValueForBlock(PH->getIncomingBlock(i))); if (Term) { - DEBUG(dbgs() << "SLP: Need to swizzle PHINodes (TerminatorInst use).\n"); + LLVM_DEBUG(dbgs() << "SLP: Need to swizzle PHINodes (TerminatorInst use).\n"); BS.cancelScheduling(VL, VL0); newTreeEntry(VL, false, UserTreeIdx, ReuseShuffleIndicies); return; @@ -1542,7 +1542,7 @@ } newTreeEntry(VL, true, UserTreeIdx, ReuseShuffleIndicies); - DEBUG(dbgs() << "SLP: added a vector of PHINodes.\n"); + LLVM_DEBUG(dbgs() << "SLP: added a vector of PHINodes.\n"); for (unsigned i = 0, e = PH->getNumIncomingValues(); i < e; ++i) { ValueList Operands; @@ -1559,7 +1559,7 @@ case Instruction::ExtractElement: { bool Reuse = canReuseExtract(VL, VL0); if (Reuse) { - DEBUG(dbgs() << "SLP: Reusing or shuffling extract sequence.\n"); + LLVM_DEBUG(dbgs() << "SLP: Reusing or shuffling extract sequence.\n"); ++NumOpsWantToKeepOrder[S.Opcode]; } else { SmallVector ReverseVL(VL.rbegin(), VL.rend()); @@ -1583,7 +1583,7 @@ DL->getTypeAllocSizeInBits(ScalarTy)) { BS.cancelScheduling(VL, VL0); newTreeEntry(VL, false, UserTreeIdx, ReuseShuffleIndicies); - DEBUG(dbgs() << "SLP: Gathering loads of non-packed type.\n"); + LLVM_DEBUG(dbgs() << "SLP: Gathering loads of non-packed type.\n"); return; } @@ -1594,7 +1594,7 @@ if (!L->isSimple()) { BS.cancelScheduling(VL, VL0); newTreeEntry(VL, false, UserTreeIdx, ReuseShuffleIndicies); - DEBUG(dbgs() << "SLP: Gathering non-simple loads.\n"); + LLVM_DEBUG(dbgs() << "SLP: Gathering non-simple loads.\n"); return; } } @@ -1616,7 +1616,7 @@ if (Consecutive) { ++NumOpsWantToKeepOrder[S.Opcode]; newTreeEntry(VL, true, UserTreeIdx, ReuseShuffleIndicies); - DEBUG(dbgs() << "SLP: added a vector of loads.\n"); + LLVM_DEBUG(dbgs() << "SLP: added a vector of loads.\n"); return; } @@ -1632,11 +1632,11 @@ if (ReverseConsecutive) { --NumOpsWantToKeepOrder[S.Opcode]; newTreeEntry(VL, true, UserTreeIdx, ReuseShuffleIndicies); - DEBUG(dbgs() << "SLP: added a vector of reversed loads.\n"); + LLVM_DEBUG(dbgs() << "SLP: added a vector of reversed loads.\n"); return; } - DEBUG(dbgs() << "SLP: Gathering non-consecutive loads.\n"); + LLVM_DEBUG(dbgs() << "SLP: Gathering non-consecutive loads.\n"); BS.cancelScheduling(VL, VL0); newTreeEntry(VL, false, UserTreeIdx, ReuseShuffleIndicies); return; @@ -1659,12 +1659,12 @@ if (Ty != SrcTy || !isValidElementType(Ty)) { BS.cancelScheduling(VL, VL0); newTreeEntry(VL, false, UserTreeIdx, ReuseShuffleIndicies); - DEBUG(dbgs() << "SLP: Gathering casts with different src types.\n"); + LLVM_DEBUG(dbgs() << "SLP: Gathering casts with different src types.\n"); return; } } newTreeEntry(VL, true, UserTreeIdx, ReuseShuffleIndicies); - DEBUG(dbgs() << "SLP: added a vector of casts.\n"); + LLVM_DEBUG(dbgs() << "SLP: added a vector of casts.\n"); for (unsigned i = 0, e = VL0->getNumOperands(); i < e; ++i) { ValueList Operands; @@ -1687,13 +1687,13 @@ Cmp->getOperand(0)->getType() != ComparedTy) { BS.cancelScheduling(VL, VL0); newTreeEntry(VL, false, UserTreeIdx, ReuseShuffleIndicies); - DEBUG(dbgs() << "SLP: Gathering cmp with different predicate.\n"); + LLVM_DEBUG(dbgs() << "SLP: Gathering cmp with different predicate.\n"); return; } } newTreeEntry(VL, true, UserTreeIdx, ReuseShuffleIndicies); - DEBUG(dbgs() << "SLP: added a vector of compares.\n"); + LLVM_DEBUG(dbgs() << "SLP: added a vector of compares.\n"); for (unsigned i = 0, e = VL0->getNumOperands(); i < e; ++i) { ValueList Operands; @@ -1725,7 +1725,7 @@ case Instruction::Or: case Instruction::Xor: newTreeEntry(VL, true, UserTreeIdx, ReuseShuffleIndicies); - DEBUG(dbgs() << "SLP: added a vector of bin op.\n"); + LLVM_DEBUG(dbgs() << "SLP: added a vector of bin op.\n"); // Sort operands of the instructions so that each side is more likely to // have the same opcode. @@ -1751,7 +1751,7 @@ // We don't combine GEPs with complicated (nested) indexing. for (unsigned j = 0; j < VL.size(); ++j) { if (cast(VL[j])->getNumOperands() != 2) { - DEBUG(dbgs() << "SLP: not-vectorizable GEP (nested indexes).\n"); + LLVM_DEBUG(dbgs() << "SLP: not-vectorizable GEP (nested indexes).\n"); BS.cancelScheduling(VL, VL0); newTreeEntry(VL, false, UserTreeIdx, ReuseShuffleIndicies); return; @@ -1764,7 +1764,7 @@ for (unsigned j = 0; j < VL.size(); ++j) { Type *CurTy = cast(VL[j])->getOperand(0)->getType(); if (Ty0 != CurTy) { - DEBUG(dbgs() << "SLP: not-vectorizable GEP (different types).\n"); + LLVM_DEBUG(dbgs() << "SLP: not-vectorizable GEP (different types).\n"); BS.cancelScheduling(VL, VL0); newTreeEntry(VL, false, UserTreeIdx, ReuseShuffleIndicies); return; @@ -1775,7 +1775,7 @@ for (unsigned j = 0; j < VL.size(); ++j) { auto Op = cast(VL[j])->getOperand(1); if (!isa(Op)) { - DEBUG( + LLVM_DEBUG( dbgs() << "SLP: not-vectorizable GEP (non-constant indexes).\n"); BS.cancelScheduling(VL, VL0); newTreeEntry(VL, false, UserTreeIdx, ReuseShuffleIndicies); @@ -1784,7 +1784,7 @@ } newTreeEntry(VL, true, UserTreeIdx, ReuseShuffleIndicies); - DEBUG(dbgs() << "SLP: added a vector of GEPs.\n"); + LLVM_DEBUG(dbgs() << "SLP: added a vector of GEPs.\n"); for (unsigned i = 0, e = 2; i < e; ++i) { ValueList Operands; // Prepare the operand vector. @@ -1801,12 +1801,12 @@ if (!isConsecutiveAccess(VL[i], VL[i + 1], *DL, *SE)) { BS.cancelScheduling(VL, VL0); newTreeEntry(VL, false, UserTreeIdx, ReuseShuffleIndicies); - DEBUG(dbgs() << "SLP: Non-consecutive store.\n"); + LLVM_DEBUG(dbgs() << "SLP: Non-consecutive store.\n"); return; } newTreeEntry(VL, true, UserTreeIdx, ReuseShuffleIndicies); - DEBUG(dbgs() << "SLP: added a vector of stores.\n"); + LLVM_DEBUG(dbgs() << "SLP: added a vector of stores.\n"); ValueList Operands; for (Value *j : VL) @@ -1824,7 +1824,7 @@ if (!isTriviallyVectorizable(ID)) { BS.cancelScheduling(VL, VL0); newTreeEntry(VL, false, UserTreeIdx, ReuseShuffleIndicies); - DEBUG(dbgs() << "SLP: Non-vectorizable call.\n"); + LLVM_DEBUG(dbgs() << "SLP: Non-vectorizable call.\n"); return; } Function *Int = CI->getCalledFunction(); @@ -1838,7 +1838,7 @@ !CI->hasIdenticalOperandBundleSchema(*CI2)) { BS.cancelScheduling(VL, VL0); newTreeEntry(VL, false, UserTreeIdx, ReuseShuffleIndicies); - DEBUG(dbgs() << "SLP: mismatched calls:" << *CI << "!=" << *VL[i] + LLVM_DEBUG(dbgs() << "SLP: mismatched calls:" << *CI << "!=" << *VL[i] << "\n"); return; } @@ -1849,7 +1849,7 @@ if (A1I != A1J) { BS.cancelScheduling(VL, VL0); newTreeEntry(VL, false, UserTreeIdx, ReuseShuffleIndicies); - DEBUG(dbgs() << "SLP: mismatched arguments in call:" << *CI + LLVM_DEBUG(dbgs() << "SLP: mismatched arguments in call:" << *CI << " argument "<< A1I<<"!=" << A1J << "\n"); return; @@ -1862,7 +1862,7 @@ CI2->op_begin() + CI2->getBundleOperandsStartIndex())) { BS.cancelScheduling(VL, VL0); newTreeEntry(VL, false, UserTreeIdx, ReuseShuffleIndicies); - DEBUG(dbgs() << "SLP: mismatched bundle operands in calls:" << *CI << "!=" + LLVM_DEBUG(dbgs() << "SLP: mismatched bundle operands in calls:" << *CI << "!=" << *VL[i] << '\n'); return; } @@ -1886,11 +1886,11 @@ if (!S.IsAltShuffle) { BS.cancelScheduling(VL, VL0); newTreeEntry(VL, false, UserTreeIdx, ReuseShuffleIndicies); - DEBUG(dbgs() << "SLP: ShuffleVector are not vectorized.\n"); + LLVM_DEBUG(dbgs() << "SLP: ShuffleVector are not vectorized.\n"); return; } newTreeEntry(VL, true, UserTreeIdx, ReuseShuffleIndicies); - DEBUG(dbgs() << "SLP: added a ShuffleVector op.\n"); + LLVM_DEBUG(dbgs() << "SLP: added a ShuffleVector op.\n"); // Reorder operands if reordering would enable vectorization. if (isa(VL0)) { @@ -1914,7 +1914,7 @@ default: BS.cancelScheduling(VL, VL0); newTreeEntry(VL, false, UserTreeIdx, ReuseShuffleIndicies); - DEBUG(dbgs() << "SLP: Gathering unknown instruction.\n"); + LLVM_DEBUG(dbgs() << "SLP: Gathering unknown instruction.\n"); return; } } @@ -2291,7 +2291,7 @@ int VecCallCost = TTI->getIntrinsicInstrCost(ID, CI->getType(), Args, FMF, VecTy->getNumElements()); - DEBUG(dbgs() << "SLP: Call cost "<< VecCallCost - ScalarCallCost + LLVM_DEBUG(dbgs() << "SLP: Call cost "<< VecCallCost - ScalarCallCost << " (" << VecCallCost << "-" << ScalarCallCost << ")" << " for " << *CI << "\n"); @@ -2345,7 +2345,7 @@ } bool BoUpSLP::isFullyVectorizableTinyTree() { - DEBUG(dbgs() << "SLP: Check whether the tree with height " << + LLVM_DEBUG(dbgs() << "SLP: Check whether the tree with height " << VectorizableTree.size() << " is fully vectorizable .\n"); // We only handle trees of heights 1 and 2. @@ -2416,7 +2416,7 @@ LiveValues.insert(cast(&*J)); } - DEBUG( + LLVM_DEBUG( dbgs() << "SLP: #LV: " << LiveValues.size(); for (auto *X : LiveValues) dbgs() << " " << X->getName(); @@ -2452,14 +2452,14 @@ int BoUpSLP::getTreeCost() { int Cost = 0; - DEBUG(dbgs() << "SLP: Calculating cost for tree of size " << + LLVM_DEBUG(dbgs() << "SLP: Calculating cost for tree of size " << VectorizableTree.size() << ".\n"); unsigned BundleWidth = VectorizableTree[0].Scalars.size(); for (TreeEntry &TE : VectorizableTree) { int C = getEntryCost(&TE); - DEBUG(dbgs() << "SLP: Adding cost " << C << " for bundle that starts with " + LLVM_DEBUG(dbgs() << "SLP: Adding cost " << C << " for bundle that starts with " << *TE.Scalars[0] << ".\n"); Cost += C; } @@ -2505,7 +2505,7 @@ << "SLP: Extract Cost = " << ExtractCost << ".\n" << "SLP: Total Cost = " << Cost << ".\n"; } - DEBUG(dbgs() << Str); + LLVM_DEBUG(dbgs() << Str); if (ViewSLPTree) ViewGraph(this, "SLP" + F->getName(), false, Str); @@ -2927,7 +2927,7 @@ IRBuilder<>::InsertPointGuard Guard(Builder); if (E->VectorizedValue) { - DEBUG(dbgs() << "SLP: Diamond merged for " << *E->Scalars[0] << ".\n"); + LLVM_DEBUG(dbgs() << "SLP: Diamond merged for " << *E->Scalars[0] << ".\n"); return E->VectorizedValue; } @@ -3071,7 +3071,7 @@ Value *InVec = vectorizeTree(INVL); if (E->VectorizedValue) { - DEBUG(dbgs() << "SLP: Diamond merged for " << *VL0 << ".\n"); + LLVM_DEBUG(dbgs() << "SLP: Diamond merged for " << *VL0 << ".\n"); return E->VectorizedValue; } @@ -3099,7 +3099,7 @@ Value *R = vectorizeTree(RHSV); if (E->VectorizedValue) { - DEBUG(dbgs() << "SLP: Diamond merged for " << *VL0 << ".\n"); + LLVM_DEBUG(dbgs() << "SLP: Diamond merged for " << *VL0 << ".\n"); return E->VectorizedValue; } @@ -3134,7 +3134,7 @@ Value *False = vectorizeTree(FalseVec); if (E->VectorizedValue) { - DEBUG(dbgs() << "SLP: Diamond merged for " << *VL0 << ".\n"); + LLVM_DEBUG(dbgs() << "SLP: Diamond merged for " << *VL0 << ".\n"); return E->VectorizedValue; } @@ -3182,7 +3182,7 @@ Value *RHS = vectorizeTree(RHSVL); if (E->VectorizedValue) { - DEBUG(dbgs() << "SLP: Diamond merged for " << *VL0 << ".\n"); + LLVM_DEBUG(dbgs() << "SLP: Diamond merged for " << *VL0 << ".\n"); return E->VectorizedValue; } @@ -3339,7 +3339,7 @@ } Value *OpVec = vectorizeTree(OpVL); - DEBUG(dbgs() << "SLP: OpVec[" << j << "]: " << *OpVec << "\n"); + LLVM_DEBUG(dbgs() << "SLP: OpVec[" << j << "]: " << *OpVec << "\n"); OpVecs.push_back(OpVec); } @@ -3377,7 +3377,7 @@ Value *RHS = vectorizeTree(RHSVL); if (E->VectorizedValue) { - DEBUG(dbgs() << "SLP: Diamond merged for " << *VL0 << ".\n"); + LLVM_DEBUG(dbgs() << "SLP: Diamond merged for " << *VL0 << ".\n"); return E->VectorizedValue; } @@ -3457,7 +3457,7 @@ VectorizableTree[0].VectorizedValue = Trunc; } - DEBUG(dbgs() << "SLP: Extracting " << ExternalUses.size() << " values .\n"); + LLVM_DEBUG(dbgs() << "SLP: Extracting " << ExternalUses.size() << " values .\n"); // If necessary, sign-extend or zero-extend ScalarRoot to the larger type // specified by ScalarType. @@ -3543,7 +3543,7 @@ User->replaceUsesOfWith(Scalar, Ex); } - DEBUG(dbgs() << "SLP: Replaced:" << *User << ".\n"); + LLVM_DEBUG(dbgs() << "SLP: Replaced:" << *User << ".\n"); } // For each vectorized value: @@ -3564,7 +3564,7 @@ if (!Ty->isVoidTy()) { #ifndef NDEBUG for (User *U : Scalar->users()) { - DEBUG(dbgs() << "SLP: \tvalidating user:" << *U << ".\n"); + LLVM_DEBUG(dbgs() << "SLP: \tvalidating user:" << *U << ".\n"); // It is legal to replace users in the ignorelist by undef. assert((getTreeEntry(U) || is_contained(UserIgnoreList, U)) && @@ -3574,7 +3574,7 @@ Value *Undef = UndefValue::get(Ty); Scalar->replaceAllUsesWith(Undef); } - DEBUG(dbgs() << "SLP: \tErasing scalar:" << *Scalar << ".\n"); + LLVM_DEBUG(dbgs() << "SLP: \tErasing scalar:" << *Scalar << ".\n"); eraseInstruction(cast(Scalar)); } } @@ -3585,7 +3585,7 @@ } void BoUpSLP::optimizeGatherSequence() { - DEBUG(dbgs() << "SLP: Optimizing " << GatherSeq.size() + LLVM_DEBUG(dbgs() << "SLP: Optimizing " << GatherSeq.size() << " gather sequences instructions.\n"); // LICM InsertElementInst sequences. for (Instruction *I : GatherSeq) { @@ -3679,7 +3679,7 @@ ScheduleData *PrevInBundle = nullptr; ScheduleData *Bundle = nullptr; bool ReSchedule = false; - DEBUG(dbgs() << "SLP: bundle: " << *OpValue << "\n"); + LLVM_DEBUG(dbgs() << "SLP: bundle: " << *OpValue << "\n"); // Make sure that the scheduling region contains all // instructions of the bundle. @@ -3696,7 +3696,7 @@ // A bundle member was scheduled as single instruction before and now // needs to be scheduled as part of the bundle. We just get rid of the // existing schedule. - DEBUG(dbgs() << "SLP: reset schedule because " << *BundleMember + LLVM_DEBUG(dbgs() << "SLP: reset schedule because " << *BundleMember << " was already scheduled\n"); ReSchedule = true; } @@ -3732,7 +3732,7 @@ initialFillReadyList(ReadyInsts); } - DEBUG(dbgs() << "SLP: try schedule bundle " << *Bundle << " in block " + LLVM_DEBUG(dbgs() << "SLP: try schedule bundle " << *Bundle << " in block " << BB->getName() << "\n"); calculateDependencies(Bundle, true, SLP); @@ -3763,7 +3763,7 @@ return; ScheduleData *Bundle = getScheduleData(OpValue); - DEBUG(dbgs() << "SLP: cancel scheduling of " << *Bundle << "\n"); + LLVM_DEBUG(dbgs() << "SLP: cancel scheduling of " << *Bundle << "\n"); assert(!Bundle->IsScheduled && "Can't cancel bundle which is already scheduled"); assert(Bundle->isSchedulingEntity() && Bundle->isPartOfBundle() && @@ -3822,7 +3822,7 @@ if (isOneOf(OpValue, I) != I) CheckSheduleForI(I); assert(ScheduleEnd && "tried to vectorize a TerminatorInst?"); - DEBUG(dbgs() << "SLP: initialize schedule region to " << *I << "\n"); + LLVM_DEBUG(dbgs() << "SLP: initialize schedule region to " << *I << "\n"); return true; } // Search up and down at the same time, because we don't know if the new @@ -3834,7 +3834,7 @@ BasicBlock::iterator LowerEnd = BB->end(); while (true) { if (++ScheduleRegionSize > ScheduleRegionSizeLimit) { - DEBUG(dbgs() << "SLP: exceeded schedule region size limit\n"); + LLVM_DEBUG(dbgs() << "SLP: exceeded schedule region size limit\n"); return false; } @@ -3844,7 +3844,7 @@ ScheduleStart = I; if (isOneOf(OpValue, I) != I) CheckSheduleForI(I); - DEBUG(dbgs() << "SLP: extend schedule region start to " << *I << "\n"); + LLVM_DEBUG(dbgs() << "SLP: extend schedule region start to " << *I << "\n"); return true; } UpIter++; @@ -3857,7 +3857,7 @@ if (isOneOf(OpValue, I) != I) CheckSheduleForI(I); assert(ScheduleEnd && "tried to vectorize a TerminatorInst?"); - DEBUG(dbgs() << "SLP: extend schedule region end to " << *I << "\n"); + LLVM_DEBUG(dbgs() << "SLP: extend schedule region end to " << *I << "\n"); return true; } DownIter++; @@ -3921,7 +3921,7 @@ assert(isInSchedulingRegion(BundleMember)); if (!BundleMember->hasValidDependencies()) { - DEBUG(dbgs() << "SLP: update deps of " << *BundleMember << "\n"); + LLVM_DEBUG(dbgs() << "SLP: update deps of " << *BundleMember << "\n"); BundleMember->Dependencies = 0; BundleMember->resetUnscheduledDeps(); @@ -4022,7 +4022,7 @@ } if (InsertInReadyList && SD->isReady()) { ReadyInsts.push_back(SD); - DEBUG(dbgs() << "SLP: gets ready on update: " << *SD->Inst << "\n"); + LLVM_DEBUG(dbgs() << "SLP: gets ready on update: " << *SD->Inst << "\n"); } } } @@ -4045,7 +4045,7 @@ if (!BS->ScheduleStart) return; - DEBUG(dbgs() << "SLP: schedule block " << BS->BB->getName() << "\n"); + LLVM_DEBUG(dbgs() << "SLP: schedule block " << BS->BB->getName() << "\n"); BS->resetSchedule(); @@ -4489,7 +4489,7 @@ if (F.hasFnAttribute(Attribute::NoImplicitFloat)) return false; - DEBUG(dbgs() << "SLP: Analyzing blocks in " << F.getName() << ".\n"); + LLVM_DEBUG(dbgs() << "SLP: Analyzing blocks in " << F.getName() << ".\n"); // Use the bottom up slp vectorizer to construct chains that start with // store instructions. @@ -4504,7 +4504,7 @@ // Vectorize trees that end at stores. if (!Stores.empty()) { - DEBUG(dbgs() << "SLP: Found stores for " << Stores.size() + LLVM_DEBUG(dbgs() << "SLP: Found stores for " << Stores.size() << " underlying objects.\n"); Changed |= vectorizeStoreChains(R); } @@ -4516,7 +4516,7 @@ // is primarily intended to catch gather-like idioms ending at // non-consecutive loads. if (!GEPs.empty()) { - DEBUG(dbgs() << "SLP: Found GEPs for " << GEPs.size() + LLVM_DEBUG(dbgs() << "SLP: Found GEPs for " << GEPs.size() << " underlying objects.\n"); Changed |= vectorizeGEPIndices(BB, R); } @@ -4524,8 +4524,8 @@ if (Changed) { R.optimizeGatherSequence(); - DEBUG(dbgs() << "SLP: vectorized \"" << F.getName() << "\"\n"); - DEBUG(verifyFunction(F)); + LLVM_DEBUG(dbgs() << "SLP: vectorized \"" << F.getName() << "\"\n"); + LLVM_DEBUG(verifyFunction(F)); } return Changed; } @@ -4546,7 +4546,7 @@ bool SLPVectorizerPass::vectorizeStoreChain(ArrayRef Chain, BoUpSLP &R, unsigned VecRegSize) { const unsigned ChainLen = Chain.size(); - DEBUG(dbgs() << "SLP: Analyzing a store chain of length " << ChainLen + LLVM_DEBUG(dbgs() << "SLP: Analyzing a store chain of length " << ChainLen << "\n"); const unsigned Sz = R.getVectorElementSize(Chain[0]); const unsigned VF = VecRegSize / Sz; @@ -4565,7 +4565,7 @@ if (hasValueBeenRAUWed(Chain, TrackValues, i, VF)) continue; - DEBUG(dbgs() << "SLP: Analyzing " << VF << " stores at offset " << i + LLVM_DEBUG(dbgs() << "SLP: Analyzing " << VF << " stores at offset " << i << "\n"); ArrayRef Operands = Chain.slice(i, VF); @@ -4577,9 +4577,9 @@ int Cost = R.getTreeCost(); - DEBUG(dbgs() << "SLP: Found cost=" << Cost << " for VF=" << VF << "\n"); + LLVM_DEBUG(dbgs() << "SLP: Found cost=" << Cost << " for VF=" << VF << "\n"); if (Cost < -SLPCostThreshold) { - DEBUG(dbgs() << "SLP: Decided to vectorize cost=" << Cost << "\n"); + LLVM_DEBUG(dbgs() << "SLP: Decided to vectorize cost=" << Cost << "\n"); using namespace ore; @@ -4724,7 +4724,7 @@ if (VL.size() < 2) return false; - DEBUG(dbgs() << "SLP: Trying to vectorize a list of length = " << VL.size() + LLVM_DEBUG(dbgs() << "SLP: Trying to vectorize a list of length = " << VL.size() << ".\n"); // Check that all of the parts are scalar instructions of the same type. @@ -4810,7 +4810,7 @@ if (hasValueBeenRAUWed(VL, TrackValues, I, OpsWidth)) continue; - DEBUG(dbgs() << "SLP: Analyzing " << OpsWidth << " operations " + LLVM_DEBUG(dbgs() << "SLP: Analyzing " << OpsWidth << " operations " << "\n"); ArrayRef Ops = VL.slice(I, OpsWidth); @@ -4834,7 +4834,7 @@ MinCost = std::min(MinCost, Cost); if (Cost < -SLPCostThreshold) { - DEBUG(dbgs() << "SLP: Vectorizing list at cost:" << Cost << ".\n"); + LLVM_DEBUG(dbgs() << "SLP: Vectorizing list at cost:" << Cost << ".\n"); R.getORE()->emit(OptimizationRemark(SV_NAME, "VectorizedList", cast(Ops[0])) << "SLP vectorized with cost " << ore::NV("Cost", Cost) @@ -5586,7 +5586,7 @@ break; } - DEBUG(dbgs() << "SLP: Vectorizing horizontal reduction at cost:" << Cost + LLVM_DEBUG(dbgs() << "SLP: Vectorizing horizontal reduction at cost:" << Cost << ". (HorRdx)\n"); V.getORE()->emit([&]() { return OptimizationRemark( @@ -5708,7 +5708,7 @@ } ScalarReduxCost *= (ReduxWidth - 1); - DEBUG(dbgs() << "SLP: Adding cost " << VecReduxCost - ScalarReduxCost + LLVM_DEBUG(dbgs() << "SLP: Adding cost " << VecReduxCost - ScalarReduxCost << " for reduction that starts with " << *FirstReducedVal << " (It is a " << (IsPairwiseReduction ? "pairwise" : "splitting") @@ -5979,7 +5979,7 @@ if (!findBuildAggregate(IVI, BuildVectorOpds)) return false; - DEBUG(dbgs() << "SLP: array mappable to vector: " << *IVI << "\n"); + LLVM_DEBUG(dbgs() << "SLP: array mappable to vector: " << *IVI << "\n"); // Aggregate value is unlikely to be processed in vector register, we need to // extract scalars into scalar registers, so NeedExtraction is set true. return tryToVectorizeList(BuildVectorOpds, R); @@ -6069,7 +6069,7 @@ // Try to vectorize them. unsigned NumElts = (SameTypeIt - IncIt); - DEBUG(errs() << "SLP: Trying to vectorize starting at PHIs (" << NumElts << ")\n"); + LLVM_DEBUG(errs() << "SLP: Trying to vectorize starting at PHIs (" << NumElts << ")\n"); // The order in which the phi nodes appear in the program does not matter. // So allow tryToVectorizeList to reorder them if it is beneficial. This // is done when there are exactly two elements since tryToVectorizeList @@ -6170,7 +6170,7 @@ if (Entry.second.size() < 2) continue; - DEBUG(dbgs() << "SLP: Analyzing a getelementptr list of length " + LLVM_DEBUG(dbgs() << "SLP: Analyzing a getelementptr list of length " << Entry.second.size() << ".\n"); // We process the getelementptr list in chunks of 16 (like we do for @@ -6253,7 +6253,7 @@ if (it->second.size() < 2) continue; - DEBUG(dbgs() << "SLP: Analyzing a store chain of length " + LLVM_DEBUG(dbgs() << "SLP: Analyzing a store chain of length " << it->second.size() << ".\n"); // Process the stores in chunks of 16. Index: lib/Transforms/Vectorize/VPlan.cpp =================================================================== --- lib/Transforms/Vectorize/VPlan.cpp +++ lib/Transforms/Vectorize/VPlan.cpp @@ -116,7 +116,7 @@ BasicBlock *PrevBB = CFG.PrevBB; BasicBlock *NewBB = BasicBlock::Create(PrevBB->getContext(), getName(), PrevBB->getParent(), CFG.LastBB); - DEBUG(dbgs() << "LV: created " << NewBB->getName() << '\n'); + LLVM_DEBUG(dbgs() << "LV: created " << NewBB->getName() << '\n'); // Hook up the new basic block to its predecessors. for (VPBlockBase *PredVPBlock : getHierarchicalPredecessors()) { @@ -125,7 +125,7 @@ BasicBlock *PredBB = CFG.VPBB2IRBB[PredVPBB]; assert(PredBB && "Predecessor basic-block not found building successor."); auto *PredBBTerminator = PredBB->getTerminator(); - DEBUG(dbgs() << "LV: draw edge from" << PredBB->getName() << '\n'); + LLVM_DEBUG(dbgs() << "LV: draw edge from" << PredBB->getName() << '\n'); if (isa(PredBBTerminator)) { assert(PredVPSuccessors.size() == 1 && "Predecessor ending w/o branch must have single successor."); @@ -175,7 +175,7 @@ } // 2. Fill the IR basic block with IR instructions. - DEBUG(dbgs() << "LV: vectorizing VPBB:" << getName() + LLVM_DEBUG(dbgs() << "LV: vectorizing VPBB:" << getName() << " in BB:" << NewBB->getName() << '\n'); State->CFG.VPBB2IRBB[this] = NewBB; @@ -184,7 +184,7 @@ for (VPRecipeBase &Recipe : Recipes) Recipe.execute(*State); - DEBUG(dbgs() << "LV: filled BB:" << *NewBB); + LLVM_DEBUG(dbgs() << "LV: filled BB:" << *NewBB); } void VPRegionBlock::execute(VPTransformState *State) { @@ -193,7 +193,7 @@ if (!isReplicator()) { // Visit the VPBlocks connected to "this", starting from it. for (VPBlockBase *Block : RPOT) { - DEBUG(dbgs() << "LV: VPBlock in RPO " << Block->getName() << '\n'); + LLVM_DEBUG(dbgs() << "LV: VPBlock in RPO " << Block->getName() << '\n'); Block->execute(State); } return; @@ -210,7 +210,7 @@ State->Instance->Lane = Lane; // Visit the VPBlocks connected to \p this, starting from it. for (VPBlockBase *Block : RPOT) { - DEBUG(dbgs() << "LV: VPBlock in RPO " << Block->getName() << '\n'); + LLVM_DEBUG(dbgs() << "LV: VPBlock in RPO " << Block->getName() << '\n'); Block->execute(State); } } Index: tools/bugpoint/ExtractFunction.cpp =================================================================== --- tools/bugpoint/ExtractFunction.cpp +++ tools/bugpoint/ExtractFunction.cpp @@ -324,9 +324,9 @@ std::set TestFunctions; for (unsigned i = 0, e = F.size(); i != e; ++i) { Function *TNOF = cast(VMap[F[i]]); - DEBUG(errs() << "Removing function "); - DEBUG(TNOF->printAsOperand(errs(), false)); - DEBUG(errs() << "\n"); + LLVM_DEBUG(errs() << "Removing function "); + LLVM_DEBUG(TNOF->printAsOperand(errs(), false)); + LLVM_DEBUG(errs() << "\n"); TestFunctions.insert(cast(NewVMap[TNOF])); DeleteFunctionBody(TNOF); // Function is now external in this module! } Index: tools/bugpoint/OptimizerDriver.cpp =================================================================== --- tools/bugpoint/OptimizerDriver.cpp +++ tools/bugpoint/OptimizerDriver.cpp @@ -226,7 +226,7 @@ Args.push_back(*ExtraArgs); Args.push_back(nullptr); - DEBUG(errs() << "\nAbout to run:\t"; + LLVM_DEBUG(errs() << "\nAbout to run:\t"; for (unsigned i = 0, e = Args.size() - 1; i != e; ++i) errs() << " " << Args[i]; errs() << "\n";); Index: tools/bugpoint/ToolRunner.cpp =================================================================== --- tools/bugpoint/ToolRunner.cpp +++ tools/bugpoint/ToolRunner.cpp @@ -194,7 +194,7 @@ outs() << ""; outs().flush(); - DEBUG(errs() << "\nAbout to run:\t"; + LLVM_DEBUG(errs() << "\nAbout to run:\t"; for (unsigned i = 0, e = LLIArgs.size() - 1; i != e; ++i) errs() << " " << LLIArgs[i]; errs() << "\n";); @@ -481,7 +481,7 @@ outs() << (UseIntegratedAssembler ? "" : ""); outs().flush(); - DEBUG(errs() << "\nAbout to run:\t"; + LLVM_DEBUG(errs() << "\nAbout to run:\t"; for (unsigned i = 0, e = LLCArgs.size() - 1; i != e; ++i) errs() << " " << LLCArgs[i]; errs() << "\n";); @@ -601,11 +601,11 @@ outs() << ""; outs().flush(); - DEBUG(errs() << "\nAbout to run:\t"; + LLVM_DEBUG(errs() << "\nAbout to run:\t"; for (unsigned i = 0, e = JITArgs.size() - 1; i != e; ++i) errs() << " " << JITArgs[i]; errs() << "\n";); - DEBUG(errs() << "\nSending output to " << OutputFile << "\n"); + LLVM_DEBUG(errs() << "\nSending output to " << OutputFile << "\n"); return RunProgramWithTimeout(LLIPath, &JITArgs[0], InputFile, OutputFile, OutputFile, Timeout, MemoryLimit); } @@ -710,7 +710,7 @@ outs() << ""; outs().flush(); - DEBUG(errs() << "\nAbout to run:\t"; + LLVM_DEBUG(errs() << "\nAbout to run:\t"; for (unsigned i = 0, e = CCArgs.size() - 1; i != e; ++i) errs() << " " << CCArgs[i]; errs() << "\n";); @@ -758,7 +758,7 @@ // Now that we have a binary, run it! outs() << ""; outs().flush(); - DEBUG(errs() << "\nAbout to run:\t"; + LLVM_DEBUG(errs() << "\nAbout to run:\t"; for (unsigned i = 0, e = ProgramArgs.size() - 1; i != e; ++i) errs() << " " << ProgramArgs[i]; errs() << "\n";); @@ -766,7 +766,7 @@ FileRemover OutputBinaryRemover(OutputBinary.str(), !SaveTemps); if (RemoteClientPath.empty()) { - DEBUG(errs() << ""); + LLVM_DEBUG(errs() << ""); std::string Error; int ExitCode = RunProgramWithTimeout(OutputBinary.str(), &ProgramArgs[0], InputFile, OutputFile, OutputFile, @@ -855,7 +855,7 @@ outs() << ""; outs().flush(); - DEBUG(errs() << "\nAbout to run:\t"; + LLVM_DEBUG(errs() << "\nAbout to run:\t"; for (unsigned i = 0, e = CCArgs.size() - 1; i != e; ++i) errs() << " " << CCArgs[i]; errs() << "\n";); Index: tools/lli/lli.cpp =================================================================== --- tools/lli/lli.cpp +++ tools/lli/lli.cpp @@ -632,7 +632,7 @@ // FIXME: argv and envp handling. JITTargetAddress Entry = EE->getFunctionAddress(EntryFn->getName().str()); EE->finalizeObject(); - DEBUG(dbgs() << "Executing '" << EntryFn->getName() << "' at 0x" + LLVM_DEBUG(dbgs() << "Executing '" << EntryFn->getName() << "' at 0x" << format("%llx", Entry) << "\n"); Result = ExitOnErr(R->callIntVoid(Entry)); Index: tools/llvm-dwarfdump/Statistics.cpp =================================================================== --- tools/llvm-dwarfdump/Statistics.cpp +++ tools/llvm-dwarfdump/Statistics.cpp @@ -165,11 +165,11 @@ /// \{ static void printDatum(raw_ostream &OS, const char *Key, StringRef Value) { OS << ",\"" << Key << "\":\"" << Value << '"'; - DEBUG(llvm::dbgs() << Key << ": " << Value << '\n'); + LLVM_DEBUG(llvm::dbgs() << Key << ": " << Value << '\n'); } static void printDatum(raw_ostream &OS, const char *Key, uint64_t Value) { OS << ",\"" << Key << "\":" << Value; - DEBUG(llvm::dbgs() << Key << ": " << Value << '\n'); + LLVM_DEBUG(llvm::dbgs() << Key << ": " << Value << '\n'); } /// \} @@ -206,7 +206,7 @@ VarWithLoc += Stats.TotalVarWithLoc + Constants; VarTotal += TotalVars + Constants; VarUnique += Stats.VarsInFunction.size(); - DEBUG(for (auto V : Stats.VarsInFunction) + LLVM_DEBUG(for (auto V : Stats.VarsInFunction) llvm::dbgs() << Entry.getKey() << ": " << V << "\n"); NumFunctions += Stats.IsFunction; NumInlinedFunctions += Stats.IsFunction * Stats.NumFnInlined; @@ -215,7 +215,7 @@ // Print summary. OS.SetBufferSize(1024); OS << "{\"version\":\"" << Version << '"'; - DEBUG(llvm::dbgs() << "Variable location quality metrics\n"; + LLVM_DEBUG(llvm::dbgs() << "Variable location quality metrics\n"; llvm::dbgs() << "---------------------------------\n"); printDatum(OS, "file", Filename.str()); printDatum(OS, "format", FormatName); @@ -228,7 +228,7 @@ GlobalStats.ScopeBytesFromFirstDefinition); printDatum(OS, "scope bytes covered", GlobalStats.ScopeBytesCovered); OS << "}\n"; - DEBUG( + LLVM_DEBUG( llvm::dbgs() << "Total Availability: " << (int)std::round((VarWithLoc * 100.0) / VarTotal) << "%\n"; llvm::dbgs() << "PC Ranges covered: " Index: tools/verify-uselistorder/verify-uselistorder.cpp =================================================================== --- tools/verify-uselistorder/verify-uselistorder.cpp +++ tools/verify-uselistorder/verify-uselistorder.cpp @@ -109,7 +109,7 @@ bool TempFile::init(const std::string &Ext) { SmallVector Vector; - DEBUG(dbgs() << " - create-temp-file\n"); + LLVM_DEBUG(dbgs() << " - create-temp-file\n"); if (auto EC = sys::fs::createTemporaryFile("uselistorder", Ext, Vector)) { errs() << "verify-uselistorder: error: " << EC.message() << "\n"; return true; @@ -124,7 +124,7 @@ } bool TempFile::writeBitcode(const Module &M) const { - DEBUG(dbgs() << " - write bitcode\n"); + LLVM_DEBUG(dbgs() << " - write bitcode\n"); std::error_code EC; raw_fd_ostream OS(Filename, EC, sys::fs::F_None); if (EC) { @@ -137,7 +137,7 @@ } bool TempFile::writeAssembly(const Module &M) const { - DEBUG(dbgs() << " - write assembly\n"); + LLVM_DEBUG(dbgs() << " - write assembly\n"); std::error_code EC; raw_fd_ostream OS(Filename, EC, sys::fs::F_Text); if (EC) { @@ -150,7 +150,7 @@ } std::unique_ptr TempFile::readBitcode(LLVMContext &Context) const { - DEBUG(dbgs() << " - read bitcode\n"); + LLVM_DEBUG(dbgs() << " - read bitcode\n"); ErrorOr> BufferOr = MemoryBuffer::getFile(Filename); if (!BufferOr) { @@ -171,7 +171,7 @@ } std::unique_ptr TempFile::readAssembly(LLVMContext &Context) const { - DEBUG(dbgs() << " - read assembly\n"); + LLVM_DEBUG(dbgs() << " - read assembly\n"); SMDiagnostic Err; std::unique_ptr M = parseAssemblyFile(Filename, Err, Context); if (!M.get()) @@ -290,9 +290,9 @@ #endif static bool matches(const ValueMapping &LM, const ValueMapping &RM) { - DEBUG(dbgs() << "compare value maps\n"); + LLVM_DEBUG(dbgs() << "compare value maps\n"); if (LM.Values.size() != RM.Values.size()) { - DEBUG(debugSizeMismatch(LM, RM)); + LLVM_DEBUG(debugSizeMismatch(LM, RM)); return false; } @@ -319,22 +319,22 @@ while (LU != LE) { if (RU == RE) { - DEBUG(debugUserMismatch(LM, RM, I)); + LLVM_DEBUG(debugUserMismatch(LM, RM, I)); return false; } if (LM.lookup(LU->getUser()) != RM.lookup(RU->getUser())) { - DEBUG(debugUserMismatch(LM, RM, I)); + LLVM_DEBUG(debugUserMismatch(LM, RM, I)); return false; } if (LU->getOperandNo() != RU->getOperandNo()) { - DEBUG(debugUserMismatch(LM, RM, I)); + LLVM_DEBUG(debugUserMismatch(LM, RM, I)); return false; } skipUnmappedUsers(++LU, LE, LM); skipUnmappedUsers(++RU, RE, RM); } if (RU != RE) { - DEBUG(debugUserMismatch(LM, RM, I)); + LLVM_DEBUG(debugUserMismatch(LM, RM, I)); return false; } } @@ -399,7 +399,7 @@ // Generate random numbers between 10 and 99, which will line up nicely in // debug output. We're not worried about collisons here. - DEBUG(dbgs() << "V = "; V->dump()); + LLVM_DEBUG(dbgs() << "V = "; V->dump()); std::uniform_int_distribution Dist(10, 99); SmallDenseMap Order; auto compareUses = @@ -408,16 +408,16 @@ for (const Use &U : V->uses()) { auto I = Dist(Gen); Order[&U] = I; - DEBUG(dbgs() << " - order: " << I << ", op = " << U.getOperandNo() + LLVM_DEBUG(dbgs() << " - order: " << I << ", op = " << U.getOperandNo() << ", U = "; U.getUser()->dump()); } } while (std::is_sorted(V->use_begin(), V->use_end(), compareUses)); - DEBUG(dbgs() << " => shuffle\n"); + LLVM_DEBUG(dbgs() << " => shuffle\n"); V->sortUseList(compareUses); - DEBUG({ + LLVM_DEBUG({ for (const Use &U : V->uses()) { dbgs() << " - order: " << Order.lookup(&U) << ", op = " << U.getOperandNo() << ", U = "; @@ -439,7 +439,7 @@ // Nothing to shuffle for 0 or 1 users. return; - DEBUG({ + LLVM_DEBUG({ dbgs() << "V = "; V->dump(); for (const Use &U : V->uses()) { @@ -451,7 +451,7 @@ V->reverseUseList(); - DEBUG({ + LLVM_DEBUG({ for (const Use &U : V->uses()) { dbgs() << " - order: op = " << U.getOperandNo() << ", U = "; U.getUser()->dump(); @@ -517,13 +517,13 @@ std::minstd_rand0 Gen(std::minstd_rand0::default_seed + SeedOffset); DenseSet Seen; changeUseLists(M, [&](Value *V) { shuffleValueUseLists(V, Gen, Seen); }); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n"); } static void reverseUseLists(Module &M) { DenseSet Seen; changeUseLists(M, [&](Value *V) { reverseValueUseLists(V, Seen); }); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n"); } int main(int argc, char **argv) { Index: unittests/IR/CFGBuilder.cpp =================================================================== --- unittests/IR/CFGBuilder.cpp +++ unittests/IR/CFGBuilder.cpp @@ -36,7 +36,7 @@ } static void ConnectBlocks(BasicBlock *From, BasicBlock *To) { - DEBUG(dbgs() << "Creating BB arc " << From->getName() << " -> " + LLVM_DEBUG(dbgs() << "Creating BB arc " << From->getName() << " -> " << To->getName() << "\n"; dbgs().flush()); auto *IntTy = IntegerType::get(From->getContext(), 32); @@ -57,7 +57,7 @@ } static void DisconnectBlocks(BasicBlock *From, BasicBlock *To) { - DEBUG(dbgs() << "Deleting BB arc " << From->getName() << " -> " + LLVM_DEBUG(dbgs() << "Deleting BB arc " << From->getName() << " -> " << To->getName() << "\n"; dbgs().flush()); SwitchInst *SI = cast(From->getTerminator()); Index: unittests/IR/DominatorTreeBatchUpdatesTest.cpp =================================================================== --- unittests/IR/DominatorTreeBatchUpdatesTest.cpp +++ unittests/IR/DominatorTreeBatchUpdatesTest.cpp @@ -62,9 +62,9 @@ {Insert, B, D}, {Delete, C, D}, {Delete, A, B}}; SmallVector Legalized; DomSNCA::LegalizeUpdates(Updates, Legalized); - DEBUG(dbgs() << "Legalized updates:\t"); - DEBUG(for (auto &U : Legalized) dbgs() << U << ", "); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Legalized updates:\t"); + LLVM_DEBUG(for (auto &U : Legalized) dbgs() << U << ", "); + LLVM_DEBUG(dbgs() << "\n"); EXPECT_EQ(Legalized.size(), 3UL); EXPECT_NE(llvm::find(Legalized, DomUpdate{Insert, B, C}), Legalized.end()); EXPECT_NE(llvm::find(Legalized, DomUpdate{Insert, B, D}), Legalized.end()); @@ -85,9 +85,9 @@ {Insert, B, D}, {Delete, C, D}, {Delete, A, B}}; SmallVector Legalized; PostDomSNCA::LegalizeUpdates(Updates, Legalized); - DEBUG(dbgs() << "Legalized postdom updates:\t"); - DEBUG(for (auto &U : Legalized) dbgs() << U << ", "); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "Legalized postdom updates:\t"); + LLVM_DEBUG(for (auto &U : Legalized) dbgs() << U << ", "); + LLVM_DEBUG(dbgs() << "\n"); EXPECT_EQ(Legalized.size(), 3UL); EXPECT_NE(llvm::find(Legalized, DomUpdate{Insert, C, B}), Legalized.end()); EXPECT_NE(llvm::find(Legalized, DomUpdate{Insert, D, B}), Legalized.end()); Index: utils/TableGen/AsmMatcherEmitter.cpp =================================================================== --- utils/TableGen/AsmMatcherEmitter.cpp +++ utils/TableGen/AsmMatcherEmitter.cpp @@ -1090,7 +1090,7 @@ // Verify that any operand is only mentioned once. // We reject aliases and ignore instructions for now. if (!IsAlias && Tok[0] == '$' && !OperandNames.insert(Tok).second) { - DEBUG({ + LLVM_DEBUG({ errs() << "warning: '" << TheDef->getName() << "': " << "ignoring instruction with tied operand '" << Tok << "'\n"; @@ -1476,7 +1476,7 @@ SubtargetFeaturePairs.end()); #ifndef NDEBUG for (const auto &Pair : SubtargetFeatures) - DEBUG(Pair.second.dump()); + LLVM_DEBUG(Pair.second.dump()); #endif // NDEBUG assert(SubtargetFeatures.size() <= 64 && "Too many subtarget features!"); Index: utils/TableGen/AsmWriterEmitter.cpp =================================================================== --- utils/TableGen/AsmWriterEmitter.cpp +++ utils/TableGen/AsmWriterEmitter.cpp @@ -351,7 +351,7 @@ // If we don't have enough bits for this operand, don't include it. if (NumBits > BitsLeft) { - DEBUG(errs() << "Not enough bits to densely encode " << NumBits + LLVM_DEBUG(errs() << "Not enough bits to densely encode " << NumBits << " more bits\n"); break; } Index: utils/TableGen/CodeGenDAGPatterns.cpp =================================================================== --- utils/TableGen/CodeGenDAGPatterns.cpp +++ utils/TableGen/CodeGenDAGPatterns.cpp @@ -3018,7 +3018,7 @@ ThePat.resetError(); // If debugging, print out the pattern fragment result. - DEBUG(ThePat.dump()); + LLVM_DEBUG(ThePat.dump()); } } @@ -3633,7 +3633,7 @@ const DAGInstruction &DI = parseInstructionPattern(CGI, LI, Instructions); (void)DI; - DEBUG(DI.getPattern()->dump()); + LLVM_DEBUG(DI.getPattern()->dump()); } // If we can, convert the instructions to be patterns that are matched! @@ -4171,13 +4171,13 @@ /// Dump the dependent variable set: static void DumpDepVars(MultipleUseVarSet &DepVars) { if (DepVars.empty()) { - DEBUG(errs() << ""); + LLVM_DEBUG(errs() << ""); } else { - DEBUG(errs() << "[ "); + LLVM_DEBUG(errs() << "[ "); for (const auto &DepVar : DepVars) { - DEBUG(errs() << DepVar.getKey() << " "); + LLVM_DEBUG(errs() << DepVar.getKey() << " "); } - DEBUG(errs() << "]"); + LLVM_DEBUG(errs() << "]"); } } #endif @@ -4201,7 +4201,7 @@ bool NotDone; do { #ifndef NDEBUG - DEBUG(if (!Idxs.empty()) { + LLVM_DEBUG(if (!Idxs.empty()) { errs() << Orig->getOperator()->getName() << ": Idxs = [ "; for (unsigned Idx : Idxs) { errs() << Idx << " "; @@ -4410,7 +4410,7 @@ // GenerateVariants - Generate variants. For example, commutative patterns can // match multiple ways. Add them to PatternsToMatch as well. void CodeGenDAGPatterns::GenerateVariants() { - DEBUG(errs() << "Generating instruction variants.\n"); + LLVM_DEBUG(errs() << "Generating instruction variants.\n"); // Loop over all of the patterns we've collected, checking to see if we can // generate variants of the instruction, through the exploitation of @@ -4425,9 +4425,9 @@ MultipleUseVarSet DepVars; std::vector Variants; FindDepVars(PatternsToMatch[i].getSrcPattern(), DepVars); - DEBUG(errs() << "Dependent/multiply used variables: "); - DEBUG(DumpDepVars(DepVars)); - DEBUG(errs() << "\n"); + LLVM_DEBUG(errs() << "Dependent/multiply used variables: "); + LLVM_DEBUG(DumpDepVars(DepVars)); + LLVM_DEBUG(errs() << "\n"); GenerateVariantsOf(PatternsToMatch[i].getSrcPattern(), Variants, *this, DepVars); @@ -4435,14 +4435,14 @@ if (Variants.size() == 1) // No additional variants for this pattern. continue; - DEBUG(errs() << "FOUND VARIANTS OF: "; + LLVM_DEBUG(errs() << "FOUND VARIANTS OF: "; PatternsToMatch[i].getSrcPattern()->dump(); errs() << "\n"); for (unsigned v = 0, e = Variants.size(); v != e; ++v) { TreePatternNode *Variant = Variants[v]; - DEBUG(errs() << " VAR#" << v << ": "; + LLVM_DEBUG(errs() << " VAR#" << v << ": "; Variant->dump(); errs() << "\n"); @@ -4456,7 +4456,7 @@ // Check to see if this variant already exists. if (Variant->isIsomorphicTo(PatternsToMatch[p].getSrcPattern(), DepVars)) { - DEBUG(errs() << " *** ALREADY EXISTS, ignoring variant.\n"); + LLVM_DEBUG(errs() << " *** ALREADY EXISTS, ignoring variant.\n"); AlreadyExists = true; break; } @@ -4472,6 +4472,6 @@ PatternsToMatch[i].getAddedComplexity(), Record::getNewUID())); } - DEBUG(errs() << "\n"); + LLVM_DEBUG(errs() << "\n"); } } Index: utils/TableGen/CodeGenRegisters.cpp =================================================================== --- utils/TableGen/CodeGenRegisters.cpp +++ utils/TableGen/CodeGenRegisters.cpp @@ -1564,7 +1564,7 @@ if (Weight > MaxWeight) MaxWeight = Weight; if (I->Weight != MaxWeight) { - DEBUG( + LLVM_DEBUG( dbgs() << "UberSet " << I - UberSets.begin() << " Weight " << MaxWeight; for (auto &Unit : I->Regs) dbgs() << " " << Unit->getName(); @@ -1734,7 +1734,7 @@ && (SubSet.Units.size() + 3 > SuperSet.Units.size()) && UnitWeight == RegUnits[SuperSet.Units[0]].Weight && UnitWeight == RegUnits[SuperSet.Units.back()].Weight) { - DEBUG(dbgs() << "UnitSet " << SubIdx << " subsumed by " << SuperIdx + LLVM_DEBUG(dbgs() << "UnitSet " << SubIdx << " subsumed by " << SuperIdx << "\n"); // We can pick any of the set names for the merged set. Go for the // shortest one to avoid picking the name of one of the classes that are @@ -1788,7 +1788,7 @@ RegUnitSets.pop_back(); } - DEBUG(dbgs() << "\nBefore pruning:\n"; + LLVM_DEBUG(dbgs() << "\nBefore pruning:\n"; for (unsigned USIdx = 0, USEnd = RegUnitSets.size(); USIdx < USEnd; ++USIdx) { dbgs() << "UnitSet " << USIdx << " " << RegUnitSets[USIdx].Name @@ -1801,7 +1801,7 @@ // Iteratively prune unit sets. pruneUnitSets(); - DEBUG(dbgs() << "\nBefore union:\n"; + LLVM_DEBUG(dbgs() << "\nBefore union:\n"; for (unsigned USIdx = 0, USEnd = RegUnitSets.size(); USIdx < USEnd; ++USIdx) { dbgs() << "UnitSet " << USIdx << " " << RegUnitSets[USIdx].Name @@ -1850,7 +1850,7 @@ if (SetI != std::prev(RegUnitSets.end())) RegUnitSets.pop_back(); else { - DEBUG(dbgs() << "UnitSet " << RegUnitSets.size()-1 + LLVM_DEBUG(dbgs() << "UnitSet " << RegUnitSets.size()-1 << " " << RegUnitSets.back().Name << ":"; for (auto &U : RegUnitSets.back().Units) printRegUnitName(U); @@ -1862,7 +1862,7 @@ // Iteratively prune unit sets after inferring supersets. pruneUnitSets(); - DEBUG(dbgs() << "\n"; + LLVM_DEBUG(dbgs() << "\n"; for (unsigned USIdx = 0, USEnd = RegUnitSets.size(); USIdx < USEnd; ++USIdx) { dbgs() << "UnitSet " << USIdx << " " << RegUnitSets[USIdx].Name @@ -1888,7 +1888,7 @@ if (RCRegUnits.empty()) continue; - DEBUG(dbgs() << "RC " << RC.getName() << " Units: \n"; + LLVM_DEBUG(dbgs() << "RC " << RC.getName() << " Units: \n"; for (auto U : RCRegUnits) printRegUnitName(U); dbgs() << "\n UnitSetIDs:"); @@ -1897,11 +1897,11 @@ for (unsigned USIdx = 0, USEnd = RegUnitSets.size(); USIdx != USEnd; ++USIdx) { if (isRegUnitSubSet(RCRegUnits, RegUnitSets[USIdx].Units)) { - DEBUG(dbgs() << " " << USIdx); + LLVM_DEBUG(dbgs() << " " << USIdx); RegClassUnitSets[RCIdx].push_back(USIdx); } } - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n"); assert(!RegClassUnitSets[RCIdx].empty() && "missing unit set for regclass"); } Index: utils/TableGen/CodeGenSchedule.cpp =================================================================== --- utils/TableGen/CodeGenSchedule.cpp +++ utils/TableGen/CodeGenSchedule.cpp @@ -194,7 +194,7 @@ // Populate each CodeGenProcModel's WriteResDefs, ReadAdvanceDefs, and // ProcResourceDefs. - DEBUG(dbgs() << "\n+++ RESOURCE DEFINITIONS (collectProcResources) +++\n"); + LLVM_DEBUG(dbgs() << "\n+++ RESOURCE DEFINITIONS (collectProcResources) +++\n"); collectProcResources(); checkCompleteness(); @@ -215,7 +215,7 @@ ProcModelMap[NoModelDef] = 0; // For each processor, find a unique machine model. - DEBUG(dbgs() << "+++ PROCESSOR MODELs (addProcModel) +++\n"); + LLVM_DEBUG(dbgs() << "+++ PROCESSOR MODELs (addProcModel) +++\n"); for (Record *ProcRecord : ProcRecords) addProcModel(ProcRecord); } @@ -239,7 +239,7 @@ ProcModels.emplace_back(ProcModels.size(), Name, ProcDef->getValueAsDef("SchedModel"), ModelKey); } - DEBUG(ProcModels.back().dump()); + LLVM_DEBUG(ProcModels.back().dump()); } // Recursively find all reachable SchedReadWrite records. @@ -367,7 +367,7 @@ PrintFatalError(ADef->getLoc(), "Cannot Alias an Alias"); RW.Aliases.push_back(ADef); } - DEBUG( + LLVM_DEBUG( dbgs() << "\n+++ SCHED READS and WRITES (collectSchedRW) +++\n"; for (unsigned WIdx = 0, WEnd = SchedWrites.size(); WIdx != WEnd; ++WIdx) { dbgs() << WIdx << ": "; @@ -582,14 +582,14 @@ // Create classes for InstRW defs. RecVec InstRWDefs = Records.getAllDerivedDefinitions("InstRW"); std::sort(InstRWDefs.begin(), InstRWDefs.end(), LessRecord()); - DEBUG(dbgs() << "\n+++ SCHED CLASSES (createInstRWClass) +++\n"); + LLVM_DEBUG(dbgs() << "\n+++ SCHED CLASSES (createInstRWClass) +++\n"); for (Record *RWDef : InstRWDefs) createInstRWClass(RWDef); NumInstrSchedClasses = SchedClasses.size(); bool EnableDump = false; - DEBUG(EnableDump = true); + LLVM_DEBUG(EnableDump = true); if (!EnableDump) return; @@ -782,7 +782,7 @@ if (OrigNumInstrs == InstDefs.size()) { assert(SchedClasses[OldSCIdx].ProcIndices[0] == 0 && "expected a generic SchedClass"); - DEBUG(dbgs() << "InstRW: Reuse SC " << OldSCIdx << ":" + LLVM_DEBUG(dbgs() << "InstRW: Reuse SC " << OldSCIdx << ":" << SchedClasses[OldSCIdx].Name << " on " << InstRWDef->getValueAsDef("SchedModel")->getName() << "\n"); SchedClasses[OldSCIdx].InstRWs.push_back(InstRWDef); @@ -795,7 +795,7 @@ CodeGenSchedClass &SC = SchedClasses.back(); SC.Index = SCIdx; SC.Name = createSchedClassName(InstDefs); - DEBUG(dbgs() << "InstRW: New SC " << SCIdx << ":" << SC.Name << " on " + LLVM_DEBUG(dbgs() << "InstRW: New SC " << SCIdx << ":" << SC.Name << " on " << InstRWDef->getValueAsDef("SchedModel")->getName() << "\n"); // Preserve ItinDef and Writes/Reads for processors without an InstRW entry. @@ -839,7 +839,7 @@ // Gather the processor itineraries. void CodeGenSchedModels::collectProcItins() { - DEBUG(dbgs() << "\n+++ PROBLEM ITINERARIES (collectProcItins) +++\n"); + LLVM_DEBUG(dbgs() << "\n+++ PROBLEM ITINERARIES (collectProcItins) +++\n"); for (CodeGenProcModel &ProcModel : ProcModels) { if (!ProcModel.hasItineraries()) continue; @@ -864,13 +864,13 @@ } } if (!FoundClass) { - DEBUG(dbgs() << ProcModel.ItinsDef->getName() + LLVM_DEBUG(dbgs() << ProcModel.ItinsDef->getName() << " missing class for itinerary " << ItinDef->getName() << '\n'); } } // Check for missing itinerary entries. assert(!ProcModel.ItinDefList[0] && "NoItinerary class can't have rec"); - DEBUG( + LLVM_DEBUG( for (unsigned i = 1, N = ProcModel.ItinDefList.size(); i < N; ++i) { if (!ProcModel.ItinDefList[i]) dbgs() << ProcModel.ItinsDef->getName() @@ -909,8 +909,8 @@ /// Infer new classes from existing classes. In the process, this may create new /// SchedWrites from sequences of existing SchedWrites. void CodeGenSchedModels::inferSchedClasses() { - DEBUG(dbgs() << "\n+++ INFERRING SCHED CLASSES (inferSchedClasses) +++\n"); - DEBUG(dbgs() << NumInstrSchedClasses << " instr sched classes.\n"); + LLVM_DEBUG(dbgs() << "\n+++ INFERRING SCHED CLASSES (inferSchedClasses) +++\n"); + LLVM_DEBUG(dbgs() << NumInstrSchedClasses << " instr sched classes.\n"); // Visit all existing classes and newly created classes. for (unsigned Idx = 0; Idx != SchedClasses.size(); ++Idx) { @@ -1400,7 +1400,7 @@ ArrayRef OperReads, unsigned FromClassIdx, ArrayRef ProcIndices) { - DEBUG(dbgs() << "INFER RW proc("; dumpIdxVec(ProcIndices); dbgs() << ") "); + LLVM_DEBUG(dbgs() << "INFER RW proc("; dumpIdxVec(ProcIndices); dbgs() << ") "); // Create a seed transition with an empty PredTerm and the expanded sequences // of SchedWrites for the current SchedClass. @@ -1417,9 +1417,9 @@ SmallVectorImpl &Seq = LastTransitions[0].WriteSequences[Idx]; for (IdxIter WI = WriteSeq.begin(), WE = WriteSeq.end(); WI != WE; ++WI) Seq.push_back(*WI); - DEBUG(dbgs() << "("; dumpIdxVec(Seq); dbgs() << ") "); + LLVM_DEBUG(dbgs() << "("; dumpIdxVec(Seq); dbgs() << ") "); } - DEBUG(dbgs() << " Reads: "); + LLVM_DEBUG(dbgs() << " Reads: "); for (unsigned ReadIdx : OperReads) { IdxVec ReadSeq; expandRWSequence(ReadIdx, ReadSeq, /*IsRead=*/true); @@ -1428,9 +1428,9 @@ SmallVectorImpl &Seq = LastTransitions[0].ReadSequences[Idx]; for (IdxIter RI = ReadSeq.begin(), RE = ReadSeq.end(); RI != RE; ++RI) Seq.push_back(*RI); - DEBUG(dbgs() << "("; dumpIdxVec(Seq); dbgs() << ") "); + LLVM_DEBUG(dbgs() << "("; dumpIdxVec(Seq); dbgs() << ") "); } - DEBUG(dbgs() << '\n'); + LLVM_DEBUG(dbgs() << '\n'); // Collect all PredTransitions for individual operands. // Iterate until no variant writes remain. @@ -1441,7 +1441,7 @@ I != E; ++I) { Transitions.substituteVariants(*I); } - DEBUG(Transitions.dump()); + LLVM_DEBUG(Transitions.dump()); LastTransitions.swap(Transitions.TransVec); } // If the first transition has no variants, nothing to do. @@ -1580,7 +1580,7 @@ LessRecord()); std::sort(PM.ProcResourceDefs.begin(), PM.ProcResourceDefs.end(), LessRecord()); - DEBUG( + LLVM_DEBUG( PM.dump(); dbgs() << "WriteResDefs: "; for (RecIter RI = PM.WriteResDefs.begin(), Index: utils/TableGen/DAGISelEmitter.cpp =================================================================== --- utils/TableGen/DAGISelEmitter.cpp +++ utils/TableGen/DAGISelEmitter.cpp @@ -137,7 +137,7 @@ "// When neither of the GET_DAGISEL* macros is defined, the functions\n" "// are emitted inline.\n\n"; - DEBUG(errs() << "\n\nALL PATTERNS TO MATCH:\n\n"; + LLVM_DEBUG(errs() << "\n\nALL PATTERNS TO MATCH:\n\n"; for (CodeGenDAGPatterns::ptm_iterator I = CGP.ptm_begin(), E = CGP.ptm_end(); I != E; ++I) { errs() << "PATTERN: "; I->getSrcPattern()->dump(); Index: utils/TableGen/DAGISelMatcherOpt.cpp =================================================================== --- utils/TableGen/DAGISelMatcherOpt.cpp +++ utils/TableGen/DAGISelMatcherOpt.cpp @@ -293,7 +293,7 @@ if (Scan != e && // Don't print it's obvious nothing extra could be merged anyway. Scan+1 != e) { - DEBUG(errs() << "Couldn't merge this:\n"; + LLVM_DEBUG(errs() << "Couldn't merge this:\n"; Optn->print(errs(), 4); errs() << "into this:\n"; OptionsToMatch[Scan]->print(errs(), 4); Index: utils/TableGen/DFAPacketizerEmitter.cpp =================================================================== --- utils/TableGen/DFAPacketizerEmitter.cpp +++ utils/TableGen/DFAPacketizerEmitter.cpp @@ -278,30 +278,30 @@ // dbgsInsnClass - When debugging, print instruction class stages. // void dbgsInsnClass(const std::vector &InsnClass) { - DEBUG(dbgs() << "InsnClass: "); + LLVM_DEBUG(dbgs() << "InsnClass: "); for (unsigned i = 0; i < InsnClass.size(); ++i) { if (i > 0) { - DEBUG(dbgs() << ", "); + LLVM_DEBUG(dbgs() << ", "); } - DEBUG(dbgs() << "0x" << Twine::utohexstr(InsnClass[i])); + LLVM_DEBUG(dbgs() << "0x" << Twine::utohexstr(InsnClass[i])); } DFAInput InsnInput = getDFAInsnInput(InsnClass); - DEBUG(dbgs() << " (input: 0x" << Twine::utohexstr(InsnInput) << ")"); + LLVM_DEBUG(dbgs() << " (input: 0x" << Twine::utohexstr(InsnInput) << ")"); } // // dbgsStateInfo - When debugging, print the set of state info. // void dbgsStateInfo(const std::set &stateInfo) { - DEBUG(dbgs() << "StateInfo: "); + LLVM_DEBUG(dbgs() << "StateInfo: "); unsigned i = 0; for (std::set::iterator SI = stateInfo.begin(); SI != stateInfo.end(); ++SI, ++i) { unsigned thisState = *SI; if (i > 0) { - DEBUG(dbgs() << ", "); + LLVM_DEBUG(dbgs() << ", "); } - DEBUG(dbgs() << "0x" << Twine::utohexstr(thisState)); + LLVM_DEBUG(dbgs() << "0x" << Twine::utohexstr(thisState)); } } @@ -310,7 +310,7 @@ // void dbgsIndent(unsigned indent) { for (unsigned i = 0; i < indent; ++i) { - DEBUG(dbgs() << " "); + LLVM_DEBUG(dbgs() << " "); } } #endif // NDEBUG @@ -361,7 +361,7 @@ DenseSet VisitedResourceStates; - DEBUG(dbgs() << " thisState: 0x" << Twine::utohexstr(thisState) << "\n"); + LLVM_DEBUG(dbgs() << " thisState: 0x" << Twine::utohexstr(thisState) << "\n"); AddInsnClassStages(InsnClass, ComboBitToBitsMap, numstages - 1, numstages, thisState, thisState, @@ -378,7 +378,7 @@ assert((chkstage < numstages) && "AddInsnClassStages: stage out of range"); unsigned thisStage = InsnClass[chkstage]; - DEBUG({ + LLVM_DEBUG({ dbgsIndent((1 + numstages - chkstage) << 1); dbgs() << "AddInsnClassStages " << chkstage << " (0x" << Twine::utohexstr(thisStage) << ") from "; @@ -395,7 +395,7 @@ if (resourceMask & thisStage) { unsigned combo = ComboBitToBitsMap[resourceMask]; if (combo && ((~prevState & combo) != combo)) { - DEBUG(dbgs() << "\tSkipped Add 0x" << Twine::utohexstr(prevState) + LLVM_DEBUG(dbgs() << "\tSkipped Add 0x" << Twine::utohexstr(prevState) << " - combo op 0x" << Twine::utohexstr(resourceMask) << " (0x" << Twine::utohexstr(combo) << ") cannot be scheduled\n"); @@ -406,7 +406,7 @@ // resource state if that resource was used. // unsigned ResultingResourceState = prevState | resourceMask | combo; - DEBUG({ + LLVM_DEBUG({ dbgsIndent((2 + numstages - chkstage) << 1); dbgs() << "0x" << Twine::utohexstr(prevState) << " | 0x" << Twine::utohexstr(resourceMask); @@ -433,13 +433,13 @@ if (VisitedResourceStates.count(ResultingResourceState) == 0) { VisitedResourceStates.insert(ResultingResourceState); PossibleStates.insert(ResultingResourceState); - DEBUG(dbgs() << "\tResultingResourceState: 0x" + LLVM_DEBUG(dbgs() << "\tResultingResourceState: 0x" << Twine::utohexstr(ResultingResourceState) << "\n"); } else { - DEBUG(dbgs() << "\tSkipped Add - state already seen\n"); + LLVM_DEBUG(dbgs() << "\tSkipped Add - state already seen\n"); } } else { - DEBUG(dbgs() << "\tSkipped Add - no final resources available\n"); + LLVM_DEBUG(dbgs() << "\tSkipped Add - no final resources available\n"); } } else { // @@ -447,13 +447,13 @@ // stage in InsnClass for available resources. // if (ResultingResourceState != prevState) { - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n"); AddInsnClassStages(InsnClass, ComboBitToBitsMap, chkstage - 1, numstages, ResultingResourceState, origState, VisitedResourceStates, PossibleStates); } else { - DEBUG(dbgs() << "\tSkipped Add - no resources available\n"); + LLVM_DEBUG(dbgs() << "\tSkipped Add - no resources available\n"); } } } @@ -494,7 +494,7 @@ // These cases are caught later in AddInsnClass. unsigned combo = ComboBitToBitsMap[InsnClass[i]]; if (combo && ((~resources & combo) != combo)) { - DEBUG(dbgs() << "\tSkipped canMaybeAdd 0x" + LLVM_DEBUG(dbgs() << "\tSkipped canMaybeAdd 0x" << Twine::utohexstr(resources) << " - combo op 0x" << Twine::utohexstr(InsnClass[i]) << " (0x" << Twine::utohexstr(combo) << ") cannot be scheduled\n"); @@ -537,9 +537,9 @@ int maxResources, int numCombos, int maxStages) { unsigned numStates = states.size(); - DEBUG(dbgs() << "-----------------------------------------------------------------------------\n"); - DEBUG(dbgs() << "writeTableAndAPI\n"); - DEBUG(dbgs() << "Total states: " << numStates << "\n"); + LLVM_DEBUG(dbgs() << "-----------------------------------------------------------------------------\n"); + LLVM_DEBUG(dbgs() << "writeTableAndAPI\n"); + LLVM_DEBUG(dbgs() << "Total states: " << numStates << "\n"); OS << "namespace llvm {\n"; @@ -647,9 +647,9 @@ std::map &FUNameToBitsMap, int &maxFUs, raw_ostream &OS) { - DEBUG(dbgs() << "-----------------------------------------------------------------------------\n"); - DEBUG(dbgs() << "collectAllFuncUnits"); - DEBUG(dbgs() << " (" << ProcItinList.size() << " itineraries)\n"); + LLVM_DEBUG(dbgs() << "-----------------------------------------------------------------------------\n"); + LLVM_DEBUG(dbgs() << "collectAllFuncUnits"); + LLVM_DEBUG(dbgs() << " (" << ProcItinList.size() << " itineraries)\n"); int totalFUs = 0; // Parse functional units for all the itineraries. @@ -657,7 +657,7 @@ Record *Proc = ProcItinList[i]; std::vector FUs = Proc->getValueAsListOfDefs("FU"); - DEBUG(dbgs() << " FU:" << i + LLVM_DEBUG(dbgs() << " FU:" << i << " (" << FUs.size() << " FUs) " << Proc->getName()); @@ -669,14 +669,14 @@ "Exceeded maximum number of representable resources"); unsigned FuncResources = (unsigned) (1U << j); FUNameToBitsMap[FUs[j]->getName()] = FuncResources; - DEBUG(dbgs() << " " << FUs[j]->getName() << ":0x" + LLVM_DEBUG(dbgs() << " " << FUs[j]->getName() << ":0x" << Twine::utohexstr(FuncResources)); } if (((int) numFUs) > maxFUs) { maxFUs = numFUs; } totalFUs += numFUs; - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n"); } return totalFUs; } @@ -690,16 +690,16 @@ std::map &FUNameToBitsMap, std::map &ComboBitToBitsMap, raw_ostream &OS) { - DEBUG(dbgs() << "-----------------------------------------------------------------------------\n"); - DEBUG(dbgs() << "collectAllComboFuncs"); - DEBUG(dbgs() << " (" << ComboFuncList.size() << " sets)\n"); + LLVM_DEBUG(dbgs() << "-----------------------------------------------------------------------------\n"); + LLVM_DEBUG(dbgs() << "collectAllComboFuncs"); + LLVM_DEBUG(dbgs() << " (" << ComboFuncList.size() << " sets)\n"); int numCombos = 0; for (unsigned i = 0, N = ComboFuncList.size(); i < N; ++i) { Record *Func = ComboFuncList[i]; std::vector FUs = Func->getValueAsListOfDefs("CFD"); - DEBUG(dbgs() << " CFD:" << i + LLVM_DEBUG(dbgs() << " CFD:" << i << " (" << FUs.size() << " combo FUs) " << Func->getName() << "\n"); @@ -714,18 +714,18 @@ const std::string &ComboFuncName = ComboFunc->getName(); unsigned ComboBit = FUNameToBitsMap[ComboFuncName]; unsigned ComboResources = ComboBit; - DEBUG(dbgs() << " combo: " << ComboFuncName << ":0x" + LLVM_DEBUG(dbgs() << " combo: " << ComboFuncName << ":0x" << Twine::utohexstr(ComboResources) << "\n"); for (unsigned k = 0, M = FuncList.size(); k < M; ++k) { std::string FuncName = FuncList[k]->getName(); unsigned FuncResources = FUNameToBitsMap[FuncName]; - DEBUG(dbgs() << " " << FuncName << ":0x" + LLVM_DEBUG(dbgs() << " " << FuncName << ":0x" << Twine::utohexstr(FuncResources) << "\n"); ComboResources |= FuncResources; } ComboBitToBitsMap[ComboBit] = ComboResources; numCombos++; - DEBUG(dbgs() << " => combo bits: " << ComboFuncName << ":0x" + LLVM_DEBUG(dbgs() << " => combo bits: " << ComboFuncName << ":0x" << Twine::utohexstr(ComboBit) << " = 0x" << Twine::utohexstr(ComboResources) << "\n"); } @@ -747,7 +747,7 @@ // The number of stages. unsigned NStages = StageList.size(); - DEBUG(dbgs() << " " << ItinData->getValueAsDef("TheClass")->getName() + LLVM_DEBUG(dbgs() << " " << ItinData->getValueAsDef("TheClass")->getName() << "\n"); std::vector UnitBits; @@ -760,7 +760,7 @@ const std::vector &UnitList = Stage->getValueAsListOfDefs("Units"); - DEBUG(dbgs() << " stage:" << i + LLVM_DEBUG(dbgs() << " stage:" << i << " [" << UnitList.size() << " units]:"); unsigned dbglen = 26; // cursor after stage dbgs @@ -769,7 +769,7 @@ for (unsigned j = 0, M = UnitList.size(); j < M; ++j) { // Conduct bitwise or. std::string UnitName = UnitList[j]->getName(); - DEBUG(dbgs() << " " << j << ":" << UnitName); + LLVM_DEBUG(dbgs() << " " << j << ":" << UnitName); dbglen += 3 + UnitName.length(); assert(FUNameToBitsMap.count(UnitName)); UnitBitValue |= FUNameToBitsMap[UnitName]; @@ -780,15 +780,15 @@ while (dbglen <= 64) { // line up bits dbgs dbglen += 8; - DEBUG(dbgs() << "\t"); + LLVM_DEBUG(dbgs() << "\t"); } - DEBUG(dbgs() << " (bits: 0x" << Twine::utohexstr(UnitBitValue) << ")\n"); + LLVM_DEBUG(dbgs() << " (bits: 0x" << Twine::utohexstr(UnitBitValue) << ")\n"); } if (!UnitBits.empty()) allInsnClasses.push_back(UnitBits); - DEBUG({ + LLVM_DEBUG({ dbgs() << " "; dbgsInsnClass(UnitBits); dbgs() << "\n"; @@ -811,7 +811,7 @@ unsigned M = ItinDataList.size(); int numInsnClasses = 0; - DEBUG(dbgs() << "-----------------------------------------------------------------------------\n" + LLVM_DEBUG(dbgs() << "-----------------------------------------------------------------------------\n" << "collectAllInsnClasses " << ProcName << " (" << M << " classes)\n"); @@ -914,7 +914,7 @@ // while (!WorkList.empty()) { const State *current = WorkList.pop_back_val(); - DEBUG({ + LLVM_DEBUG({ dbgs() << "---------------------\n"; dbgs() << "Processing state: " << current->stateNum << " - "; dbgsStateInfo(current->stateInfo); @@ -922,7 +922,7 @@ }); for (unsigned i = 0; i < allInsnClasses.size(); i++) { std::vector InsnClass = allInsnClasses[i]; - DEBUG({ + LLVM_DEBUG({ dbgs() << i << " "; dbgsInsnClass(InsnClass); dbgs() << "\n"; @@ -938,11 +938,11 @@ const State *NewState = nullptr; current->AddInsnClass(InsnClass, ComboBitToBitsMap, NewStateResources); if (NewStateResources.empty()) { - DEBUG(dbgs() << " Skipped - no new states generated\n"); + LLVM_DEBUG(dbgs() << " Skipped - no new states generated\n"); continue; } - DEBUG({ + LLVM_DEBUG({ dbgs() << "\t"; dbgsStateInfo(NewStateResources); dbgs() << "\n"; @@ -954,7 +954,7 @@ auto VI = Visited.find(NewStateResources); if (VI != Visited.end()) { NewState = VI->second; - DEBUG({ + LLVM_DEBUG({ dbgs() << "\tFound existing state: " << NewState->stateNum << " - "; dbgsStateInfo(NewState->stateInfo); @@ -965,7 +965,7 @@ NewState->stateInfo = NewStateResources; Visited[NewStateResources] = NewState; WorkList.push_back(NewState); - DEBUG({ + LLVM_DEBUG({ dbgs() << "\tAccepted new state: " << NewState->stateNum << " - "; dbgsStateInfo(NewState->stateInfo); dbgs() << "\n"; Index: utils/TableGen/FixedLenDecoderEmitter.cpp =================================================================== --- utils/TableGen/FixedLenDecoderEmitter.cpp +++ utils/TableGen/FixedLenDecoderEmitter.cpp @@ -1860,7 +1860,7 @@ CGI.Operands.getSubOperandNumber(OpIdx); const std::string &Name = CGI.Operands[SO.first].Name; - DEBUG(dbgs() << "Numbered operand mapping for " << Def.getName() << ": " << + LLVM_DEBUG(dbgs() << "Numbered operand mapping for " << Def.getName() << ": " << Name << "(" << SO.first << ", " << SO.second << ") => " << Vals[i].getName() << "\n"); @@ -2026,7 +2026,7 @@ Operands[Opc] = InsnOperands; #if 0 - DEBUG({ + LLVM_DEBUG({ // Dumps the instruction encoding bits. dumpBits(errs(), Bits); @@ -2088,7 +2088,7 @@ << " unsigned Len = *++Ptr;\n" << " ++Ptr;\n" << " CurFieldValue = fieldFromInstruction(insn, Start, Len);\n" - << " DEBUG(dbgs() << Loc << \": OPC_ExtractField(\" << Start << \", \"\n" + << " LLVM_DEBUG(dbgs() << Loc << \": OPC_ExtractField(\" << Start << \", \"\n" << " << Len << \"): \" << CurFieldValue << \"\\n\");\n" << " break;\n" << " }\n" @@ -2104,7 +2104,7 @@ << " // Perform the filter operation.\n" << " if (Val != CurFieldValue)\n" << " Ptr += NumToSkip;\n" - << " DEBUG(dbgs() << Loc << \": OPC_FilterValue(\" << Val << \", \" << NumToSkip\n" + << " LLVM_DEBUG(dbgs() << Loc << \": OPC_FilterValue(\" << Val << \", \" << NumToSkip\n" << " << \"): \" << ((Val != CurFieldValue) ? \"FAIL:\" : \"PASS:\")\n" << " << \" continuing at \" << (Ptr - DecodeTable) << \"\\n\");\n" << "\n" @@ -2124,7 +2124,7 @@ << " // If the actual and expected values don't match, skip.\n" << " if (ExpectedValue != FieldValue)\n" << " Ptr += NumToSkip;\n" - << " DEBUG(dbgs() << Loc << \": OPC_CheckField(\" << Start << \", \"\n" + << " LLVM_DEBUG(dbgs() << Loc << \": OPC_CheckField(\" << Start << \", \"\n" << " << Len << \", \" << ExpectedValue << \", \" << NumToSkip\n" << " << \"): FieldValue = \" << FieldValue << \", ExpectedValue = \"\n" << " << ExpectedValue << \": \"\n" @@ -2144,7 +2144,7 @@ << " if (!(Pred = checkDecoderPredicate(PIdx, Bits)))\n" << " Ptr += NumToSkip;\n" << " (void)Pred;\n" - << " DEBUG(dbgs() << Loc << \": OPC_CheckPredicate(\" << PIdx << \"): \"\n" + << " LLVM_DEBUG(dbgs() << Loc << \": OPC_CheckPredicate(\" << PIdx << \"): \"\n" << " << (Pred ? \"PASS\\n\" : \"FAIL\\n\"));\n" << "\n" << " break;\n" @@ -2163,7 +2163,7 @@ << " S = decodeToMCInst(S, DecodeIdx, insn, MI, Address, DisAsm, DecodeComplete);\n" << " assert(DecodeComplete);\n" << "\n" - << " DEBUG(dbgs() << Loc << \": OPC_Decode: opcode \" << Opc\n" + << " LLVM_DEBUG(dbgs() << Loc << \": OPC_Decode: opcode \" << Opc\n" << " << \", using decoder \" << DecodeIdx << \": \"\n" << " << (S != MCDisassembler::Fail ? \"PASS\" : \"FAIL\") << \"\\n\");\n" << " return S;\n" @@ -2184,19 +2184,19 @@ << " TmpMI.setOpcode(Opc);\n" << " bool DecodeComplete;\n" << " S = decodeToMCInst(S, DecodeIdx, insn, TmpMI, Address, DisAsm, DecodeComplete);\n" - << " DEBUG(dbgs() << Loc << \": OPC_TryDecode: opcode \" << Opc\n" + << " LLVM_DEBUG(dbgs() << Loc << \": OPC_TryDecode: opcode \" << Opc\n" << " << \", using decoder \" << DecodeIdx << \": \");\n" << "\n" << " if (DecodeComplete) {\n" << " // Decoding complete.\n" - << " DEBUG(dbgs() << (S != MCDisassembler::Fail ? \"PASS\" : \"FAIL\") << \"\\n\");\n" + << " LLVM_DEBUG(dbgs() << (S != MCDisassembler::Fail ? \"PASS\" : \"FAIL\") << \"\\n\");\n" << " MI = TmpMI;\n" << " return S;\n" << " } else {\n" << " assert(S == MCDisassembler::Fail);\n" << " // If the decoding was incomplete, skip.\n" << " Ptr += NumToSkip;\n" - << " DEBUG(dbgs() << \"FAIL: continuing at \" << (Ptr - DecodeTable) << \"\\n\");\n" + << " LLVM_DEBUG(dbgs() << \"FAIL: continuing at \" << (Ptr - DecodeTable) << \"\\n\");\n" << " // Reset decode status. This also drops a SoftFail status that could be\n" << " // set before the decode attempt.\n" << " S = MCDisassembler::Success;\n" @@ -2213,11 +2213,11 @@ << " bool Fail = (insn & PositiveMask) || (~insn & NegativeMask);\n" << " if (Fail)\n" << " S = MCDisassembler::SoftFail;\n" - << " DEBUG(dbgs() << Loc << \": OPC_SoftFail: \" << (Fail ? \"FAIL\\n\":\"PASS\\n\"));\n" + << " LLVM_DEBUG(dbgs() << Loc << \": OPC_SoftFail: \" << (Fail ? \"FAIL\\n\":\"PASS\\n\"));\n" << " break;\n" << " }\n" << " case MCD::OPC_Fail: {\n" - << " DEBUG(dbgs() << Loc << \": OPC_Fail\\n\");\n" + << " LLVM_DEBUG(dbgs() << Loc << \": OPC_Fail\\n\");\n" << " return MCDisassembler::Fail;\n" << " }\n" << " }\n" Index: utils/TableGen/GlobalISelEmitter.cpp =================================================================== --- utils/TableGen/GlobalISelEmitter.cpp +++ utils/TableGen/GlobalISelEmitter.cpp @@ -882,7 +882,7 @@ // We currently don't hoist the record of instruction properly. // Therefore we can only work on the orig instruction (InsnVarID // == 0). - DEBUG(dbgs() << "Non-zero instr ID not supported yet\n"); + LLVM_DEBUG(dbgs() << "Non-zero instr ID not supported yet\n"); return false; } return B.getKind() == getKind() && InsnVarID == B.InsnVarID && @@ -3671,7 +3671,7 @@ OptRules.push_back(CurrentGroup.get()); StorageGroupMatcher.emplace_back(std::move(CurrentGroup)); } - DEBUG(dbgs() << "NbGroup: " << NbGroup << "\n"); + LLVM_DEBUG(dbgs() << "NbGroup: " << NbGroup << "\n"); return OptRules; } Index: utils/TableGen/PseudoLoweringEmitter.cpp =================================================================== --- utils/TableGen/PseudoLoweringEmitter.cpp +++ utils/TableGen/PseudoLoweringEmitter.cpp @@ -120,13 +120,13 @@ } void PseudoLoweringEmitter::evaluateExpansion(Record *Rec) { - DEBUG(dbgs() << "Pseudo definition: " << Rec->getName() << "\n"); + LLVM_DEBUG(dbgs() << "Pseudo definition: " << Rec->getName() << "\n"); // Validate that the result pattern has the corrent number and types // of arguments for the instruction it references. DagInit *Dag = Rec->getValueAsDag("ResultInst"); assert(Dag && "Missing result instruction in pseudo expansion!"); - DEBUG(dbgs() << " Result: " << *Dag << "\n"); + LLVM_DEBUG(dbgs() << " Result: " << *Dag << "\n"); DefInit *OpDef = dyn_cast(Dag->getOperator()); if (!OpDef) @@ -170,7 +170,7 @@ for (unsigned i = 0, e = SourceInsn.Operands.size(); i != e; ++i) SourceOperands[SourceInsn.Operands[i].Name] = i; - DEBUG(dbgs() << " Operand mapping:\n"); + LLVM_DEBUG(dbgs() << " Operand mapping:\n"); for (unsigned i = 0, e = Insn.Operands.size(); i != e; ++i) { // We've already handled constant values. Just map instruction operands // here. @@ -188,7 +188,7 @@ OperandMap[Insn.Operands[i].MIOperandNo + I].Data.Operand = SourceOp->getValue(); - DEBUG(dbgs() << " " << SourceOp->getValue() << " ==> " << i << "\n"); + LLVM_DEBUG(dbgs() << " " << SourceOp->getValue() << " ==> " << i << "\n"); } Expansions.push_back(PseudoExpansion(SourceInsn, Insn, OperandMap)); Index: utils/TableGen/RegisterBankEmitter.cpp =================================================================== --- utils/TableGen/RegisterBankEmitter.cpp +++ utils/TableGen/RegisterBankEmitter.cpp @@ -291,7 +291,7 @@ visitRegisterBankClasses( RegisterClassHierarchy, RC, "explicit", [&Bank](const CodeGenRegisterClass *RC, StringRef Kind) { - DEBUG(dbgs() << "Added " << RC->getName() << "(" << Kind << ")\n"); + LLVM_DEBUG(dbgs() << "Added " << RC->getName() << "(" << Kind << ")\n"); Bank.addRegisterClass(RC); }, VisitedRCs); } Index: utils/TableGen/SubtargetEmitter.cpp =================================================================== --- utils/TableGen/SubtargetEmitter.cpp +++ utils/TableGen/SubtargetEmitter.cpp @@ -820,9 +820,9 @@ return; std::vector &SCTab = SchedTables.ProcSchedClasses.back(); - DEBUG(dbgs() << "\n+++ SCHED CLASSES (GenSchedClassTables) +++\n"); + LLVM_DEBUG(dbgs() << "\n+++ SCHED CLASSES (GenSchedClassTables) +++\n"); for (const CodeGenSchedClass &SC : SchedModels.schedClasses()) { - DEBUG(SC.dump(&SchedModels)); + LLVM_DEBUG(SC.dump(&SchedModels)); SCTab.resize(SCTab.size() + 1); MCSchedClassDesc &SCDesc = SCTab.back(); @@ -888,7 +888,7 @@ } } if (Writes.empty()) { - DEBUG(dbgs() << ProcModel.ModelName + LLVM_DEBUG(dbgs() << ProcModel.ModelName << " does not have resources for class " << SC.Name << '\n'); } } @@ -1366,8 +1366,8 @@ << "void llvm::"; OS << Target; OS << "Subtarget::ParseSubtargetFeatures(StringRef CPU, StringRef FS) {\n" - << " DEBUG(dbgs() << \"\\nFeatures:\" << FS);\n" - << " DEBUG(dbgs() << \"\\nCPU:\" << CPU << \"\\n\\n\");\n"; + << " LLVM_DEBUG(dbgs() << \"\\nFeatures:\" << FS);\n" + << " LLVM_DEBUG(dbgs() << \"\\nCPU:\" << CPU << \"\\n\\n\");\n"; if (Features.empty()) { OS << "}\n";