Index: llvm/include/llvm/CodeGen/GlobalISel/GISelWorkList.h =================================================================== --- llvm/include/llvm/CodeGen/GlobalISel/GISelWorkList.h +++ llvm/include/llvm/CodeGen/GlobalISel/GISelWorkList.h @@ -28,7 +28,7 @@ SmallVector Worklist; DenseMap WorklistMap; -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS bool Finalized = true; #endif @@ -49,7 +49,7 @@ // of most passes. void deferred_insert(MachineInstr *I) { Worklist.push_back(I); -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS Finalized = false; #endif } @@ -65,21 +65,25 @@ for (unsigned i = 0; i < Worklist.size(); ++i) if (!WorklistMap.try_emplace(Worklist[i], i).second) llvm_unreachable("Duplicate elements in the list"); -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS Finalized = true; #endif } /// Add the specified instruction to the worklist if it isn't already in it. void insert(MachineInstr *I) { +#if LLVM_ENABLE_ABI_BREAKING_CHECKS assert(Finalized && "GISelWorkList used without finalizing"); +#endif if (WorklistMap.try_emplace(I, Worklist.size()).second) Worklist.push_back(I); } /// Remove I from the worklist if it exists. void remove(const MachineInstr *I) { +#if LLVM_ENABLE_ABI_BREAKING_CHECKS assert((Finalized || WorklistMap.empty()) && "Neither finalized nor empty"); +#endif auto It = WorklistMap.find(I); if (It == WorklistMap.end()) return; // Not in worklist. @@ -96,7 +100,9 @@ } MachineInstr *pop_back_val() { +#if LLVM_ENABLE_ABI_BREAKING_CHECKS assert(Finalized && "GISelWorkList used without finalizing"); +#endif MachineInstr *I; do { I = Worklist.pop_back_val(); Index: llvm/include/llvm/CodeGen/MachineScheduler.h =================================================================== --- llvm/include/llvm/CodeGen/MachineScheduler.h +++ llvm/include/llvm/CodeGen/MachineScheduler.h @@ -287,7 +287,7 @@ const SUnit *NextClusterPred = nullptr; const SUnit *NextClusterSucc = nullptr; -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS /// The number of instructions scheduled so far. Used to cut off the /// scheduler at the point determined by misched-cutoff. unsigned NumInstrsScheduled = 0; @@ -679,7 +679,7 @@ // For each PIdx, stores the resource group IDs of its subunits SmallVector ResourceGroupSubUnitMasks; -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS // Remember the greatest possible stall as an upper bound on the number of // times we should retry the pending queue because of a hazard. unsigned MaxObservedStall; Index: llvm/include/llvm/CodeGen/PBQP/ReductionRules.h =================================================================== --- llvm/include/llvm/CodeGen/PBQP/ReductionRules.h +++ llvm/include/llvm/CodeGen/PBQP/ReductionRules.h @@ -190,7 +190,7 @@ RawVector v = G.getNodeCosts(NId); -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS // Although a conservatively allocatable node can be allocated to a register, // spilling it may provide a lower cost solution. Assert here that spilling // is done by choice, not because there were no register available. Index: llvm/include/llvm/CodeGen/RegAllocPBQP.h =================================================================== --- llvm/include/llvm/CodeGen/RegAllocPBQP.h +++ llvm/include/llvm/CodeGen/RegAllocPBQP.h @@ -183,11 +183,12 @@ NodeMetadata() = default; NodeMetadata(const NodeMetadata &Other) - : RS(Other.RS), NumOpts(Other.NumOpts), DeniedOpts(Other.DeniedOpts), - OptUnsafeEdges(new unsigned[NumOpts]), VReg(Other.VReg), - AllowedRegs(Other.AllowedRegs) -#ifndef NDEBUG - , everConservativelyAllocatable(Other.everConservativelyAllocatable) + : RS(Other.RS), NumOpts(Other.NumOpts), DeniedOpts(Other.DeniedOpts), + OptUnsafeEdges(new unsigned[NumOpts]), VReg(Other.VReg), + AllowedRegs(Other.AllowedRegs) +#if LLVM_ENABLE_ABI_BREAKING_CHECKS + , + everConservativelyAllocatable(Other.everConservativelyAllocatable) #endif { if (NumOpts > 0) { @@ -217,7 +218,7 @@ assert(RS >= this->RS && "A node's reduction state can not be downgraded"); this->RS = RS; -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS // Remember this state to assert later that a non-infinite register // option was available. if (RS == ConservativelyAllocatable) @@ -247,7 +248,7 @@ &OptUnsafeEdges[NumOpts]); } -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS bool wasConservativelyAllocatable() const { return everConservativelyAllocatable; } @@ -261,7 +262,7 @@ Register VReg; GraphMetadata::AllowedRegVecRef AllowedRegs; -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS bool everConservativelyAllocatable = false; #endif }; Index: llvm/include/llvm/CodeGen/SelectionDAG.h =================================================================== --- llvm/include/llvm/CodeGen/SelectionDAG.h +++ llvm/include/llvm/CodeGen/SelectionDAG.h @@ -467,7 +467,7 @@ void viewGraph(const std::string &Title); void viewGraph(); -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS std::map NodeGraphAttrs; #endif Index: llvm/lib/CodeGen/MachineScheduler.cpp =================================================================== --- llvm/lib/CodeGen/MachineScheduler.cpp +++ llvm/lib/CodeGen/MachineScheduler.cpp @@ -752,7 +752,7 @@ } bool ScheduleDAGMI::checkSchedLimit() { -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS if (NumInstrsScheduled == MISchedCutoff && MISchedCutoff != ~0U) { CurrentTop = CurrentBottom; return false; @@ -2006,7 +2006,7 @@ ReservedCycles.clear(); ReservedCyclesIndex.clear(); ResourceGroupSubUnitMasks.clear(); -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS // Track the maximum number of stall cycles that could arise either from the // latency of a DAG edge or the number of cycles that a processor resource is // reserved (SchedBoundary::ReservedCycles). @@ -2194,7 +2194,7 @@ unsigned NRCycle, InstanceIdx; std::tie(NRCycle, InstanceIdx) = getNextResourceCycle(SC, ResIdx, Cycles); if (NRCycle > CurrCycle) { -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS MaxObservedStall = std::max(Cycles, MaxObservedStall); #endif LLVM_DEBUG(dbgs() << " SU(" << SU->NodeNum << ") " @@ -2261,7 +2261,7 @@ unsigned Idx) { assert(SU->getInstr() && "Scheduled SUnit must have instr"); -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS // ReadyCycle was been bumped up to the CurrCycle when this node was // scheduled, but CurrCycle may have been eagerly advanced immediately after // scheduling, so may now be greater than ReadyCycle. Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp @@ -181,11 +181,11 @@ /// clearGraphAttrs - Clear all previously defined node graph attributes. /// Intended to be used from a debugging tool (eg. gdb). void SelectionDAG::clearGraphAttrs() { -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS NodeGraphAttrs.clear(); #else - errs() << "SelectionDAG::clearGraphAttrs is only available in debug builds" - << " on systems with Graphviz or gv!\n"; + errs() << "SelectionDAG::clearGraphAttrs is only available in builds with " + << "ABI breaking checks enabled on systems with Graphviz or gv!\n"; #endif } @@ -193,11 +193,11 @@ /// setGraphAttrs - Set graph attributes for a node. (eg. "color=red".) /// void SelectionDAG::setGraphAttrs(const SDNode *N, const char *Attrs) { -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS NodeGraphAttrs[N] = Attrs; #else - errs() << "SelectionDAG::setGraphAttrs is only available in debug builds" - << " on systems with Graphviz or gv!\n"; + errs() << "SelectionDAG::setGraphAttrs is only available in builds with " + << "ABI breaking checks enabled on systems with Graphviz or gv!\n"; #endif } @@ -205,7 +205,7 @@ /// getGraphAttrs - Get graph attributes for a node. (eg. "color=red".) /// Used from getNodeAttributes. std::string SelectionDAG::getGraphAttrs(const SDNode *N) const { -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS std::map::const_iterator I = NodeGraphAttrs.find(N); @@ -214,8 +214,8 @@ else return ""; #else - errs() << "SelectionDAG::getGraphAttrs is only available in debug builds" - << " on systems with Graphviz or gv!\n"; + errs() << "SelectionDAG::getGraphAttrs is only available in builds with " + << "ABI breaking checks enabled on systems with Graphviz or gv!\n"; return std::string(); #endif } @@ -223,11 +223,11 @@ /// setGraphColor - Convenience for setting node color attribute. /// void SelectionDAG::setGraphColor(const SDNode *N, const char *Color) { -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS NodeGraphAttrs[N] = std::string("color=") + Color; #else - errs() << "SelectionDAG::setGraphColor is only available in debug builds" - << " on systems with Graphviz or gv!\n"; + errs() << "SelectionDAG::setGraphColor is only available in builds with " + << "ABI breaking checks enabled on systems with Graphviz or gv!\n"; #endif }