Index: clang/lib/Sema/TypeLocBuilder.h =================================================================== --- clang/lib/Sema/TypeLocBuilder.h +++ clang/lib/Sema/TypeLocBuilder.h @@ -32,7 +32,7 @@ /// The index of the first occupied byte in the buffer. size_t Index; -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS /// The last type pushed on this builder. QualType LastTy; #endif @@ -73,7 +73,7 @@ /// Resets this builder to the newly-initialized state. void clear() { -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS LastTy = QualType(); #endif Index = Capacity; @@ -83,7 +83,7 @@ /// Tell the TypeLocBuilder that the type it is storing has been /// modified in some safe way that doesn't affect type-location information. void TypeWasModifiedSafely(QualType T) { -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS LastTy = T; #endif } @@ -99,7 +99,7 @@ /// Creates a TypeSourceInfo for the given type. TypeSourceInfo *getTypeSourceInfo(ASTContext& Context, QualType T) { -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS assert(T == LastTy && "type doesn't match last type pushed!"); #endif @@ -112,7 +112,7 @@ /// Copies the type-location information to the given AST context and /// returns a \c TypeLoc referring into the AST context. TypeLoc getTypeLocInContext(ASTContext &Context, QualType T) { -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS assert(T == LastTy && "type doesn't match last type pushed!"); #endif @@ -136,7 +136,7 @@ /// \c TypeLocBuilder is active and has not had more type information /// pushed into it. TypeLoc getTemporaryTypeLoc(QualType T) { -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS assert(LastTy == T && "type doesn't match last type pushed!"); #endif return TypeLoc(T, &Buffer[Index]); Index: clang/lib/Sema/TypeLocBuilder.cpp =================================================================== --- clang/lib/Sema/TypeLocBuilder.cpp +++ clang/lib/Sema/TypeLocBuilder.cpp @@ -60,7 +60,7 @@ } TypeLoc TypeLocBuilder::pushImpl(QualType T, size_t LocalSize, unsigned LocalAlignment) { -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS QualType TLast = TypeLoc(T, nullptr).getNextTypeLoc().getType(); assert(TLast == LastTy && "mismatch between last type and new type's inner type"); 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 @@ -186,7 +186,7 @@ : RS(Other.RS), NumOpts(Other.NumOpts), DeniedOpts(Other.DeniedOpts), OptUnsafeEdges(new unsigned[NumOpts]), VReg(Other.VReg), AllowedRegs(Other.AllowedRegs) -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS , everConservativelyAllocatable(Other.everConservativelyAllocatable) #endif { @@ -217,7 +217,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 +247,7 @@ &OptUnsafeEdges[NumOpts]); } -#ifndef NDEBUG +#if LLVM_ENABLE_ABI_BREAKING_CHECKS bool wasConservativelyAllocatable() const { return everConservativelyAllocatable; } @@ -261,7 +261,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::setGraphAttrs 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 } Index: llvm/lib/Target/SystemZ/SystemZHazardRecognizer.h =================================================================== --- llvm/lib/Target/SystemZ/SystemZHazardRecognizer.h +++ llvm/lib/Target/SystemZ/SystemZHazardRecognizer.h @@ -141,6 +141,7 @@ /// a negative value means it would be good to schedule SU next. int resourcesCost(SUnit *SU); + // TODO: place CurGroupDbg undef #if LLVM_ENABLE_ABI_BREAKING_CHECKS #ifndef NDEBUG // Debug dumping. std::string CurGroupDbg; // current group as text Index: mlir/lib/Target/SPIRV/Deserialization/Deserializer.h =================================================================== --- mlir/lib/Target/SPIRV/Deserialization/Deserializer.h +++ mlir/lib/Target/SPIRV/Deserialization/Deserializer.h @@ -598,6 +598,7 @@ /// A list of all structs which have unresolved member types. SmallVector deferredStructTypesInfos; + // TODO: place logger undef #if LLVM_ENABLE_ABI_BREAKING_CHECKS #ifndef NDEBUG /// A logger used to emit information during the deserialzation process. llvm::ScopedPrinter logger;