diff --git a/CMakeLists.txt b/CMakeLists.txt index fd6b81774b2..af38ed3d5f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -304,6 +304,8 @@ else() option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON) endif() +option(LLVM_ENABLE_EXPENSIVE_CHECKS "Enable expensive checks" OFF) + set(LLVM_ABI_BREAKING_CHECKS "WITH_ASSERTS" CACHE STRING "Enable abi-breaking checks. Can be WITH_ASSERTS, FORCE_ON or FORCE_OFF.") diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake index cc945e1e0cc..c41a0bb4228 100644 --- a/cmake/modules/HandleLLVMOptions.cmake +++ b/cmake/modules/HandleLLVMOptions.cmake @@ -44,6 +44,11 @@ if( LLVM_ENABLE_ASSERTIONS ) endif() endif() +if(LLVM_ENABLE_EXPENSIVE_CHECKS) + add_definitions(-DEXPENSIVE_CHECKS) + add_definitions(-D_GLIBCXX_DEBUG) +endif() + string(TOUPPER "${LLVM_ABI_BREAKING_CHECKS}" uppercase_LLVM_ABI_BREAKING_CHECKS) if( uppercase_LLVM_ABI_BREAKING_CHECKS STREQUAL "WITH_ASSERTS" ) diff --git a/include/llvm/Analysis/RegionInfoImpl.h b/include/llvm/Analysis/RegionInfoImpl.h index e8c95e26585..15dd1a2000e 100644 --- a/include/llvm/Analysis/RegionInfoImpl.h +++ b/include/llvm/Analysis/RegionInfoImpl.h @@ -665,7 +665,7 @@ typename Tr::RegionT *RegionInfoBase::createRegion(BlockT *entry, new RegionT(entry, exit, static_cast(this), DT); BBtoRegion.insert(std::make_pair(entry, region)); -#ifdef XDEBUG +#ifdef EXPENSIVE_CHECKS region->verifyRegion(); #else DEBUG(region->verifyRegion()); @@ -764,7 +764,7 @@ void RegionInfoBase::buildRegionsTree(DomTreeNodeT *N, RegionT *region) { } } -#ifdef XDEBUG +#ifdef EXPENSIVE_CHECKS template bool RegionInfoBase::VerifyRegionInfo = true; #else @@ -798,7 +798,7 @@ void RegionInfoBase::releaseMemory() { template void RegionInfoBase::verifyAnalysis() const { - // Do only verify regions if explicitely activated using XDEBUG or + // Do only verify regions if explicitely activated using EXPENSIVE_CHECKS or // -verify-region-info if (!RegionInfoBase::VerifyRegionInfo) return; diff --git a/include/llvm/Support/GenericDomTree.h b/include/llvm/Support/GenericDomTree.h index 8bae582d18c..6b65ff8205e 100644 --- a/include/llvm/Support/GenericDomTree.h +++ b/include/llvm/Support/GenericDomTree.h @@ -453,7 +453,7 @@ public: // Compare the result of the tree walk and the dfs numbers, if expensive // checks are enabled. -#ifdef XDEBUG +#ifdef EXPENSIVE_CHECKS assert((!DFSInfoValid || (dominatedBySlowTreeWalk(A, B) == B->DominatedBy(A))) && "Tree walk disagrees with dfs numbers!"); diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index e3e1a281a6c..277bd0dbb0f 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -38,7 +38,7 @@ template class llvm::LoopBase; template class llvm::LoopInfoBase; // Always verify loopinfo if expensive checking is enabled. -#ifdef XDEBUG +#ifdef EXPENSIVE_CHECKS static bool VerifyLoopInfo = true; #else static bool VerifyLoopInfo = false; diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 39ced1e6035..cfb9f5e24b2 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -111,7 +111,7 @@ MaxBruteForceIterations("scalar-evolution-max-iterations", cl::ReallyHidden, "derived loop"), cl::init(100)); -// FIXME: Enable this with XDEBUG when the test suite is clean. +// FIXME: Enable this with EXPENSIVE_CHECKS when the test suite is clean. static cl::opt VerifySCEV("verify-scev", cl::desc("Verify ScalarEvolution's backedge taken counts (slow)")); diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp index 2a0b0aa4479..853976eddc6 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp @@ -204,7 +204,7 @@ bool DAGTypeLegalizer::run() { // Now that we have a set of nodes to process, handle them all. while (!Worklist.empty()) { -#ifndef XDEBUG +#ifndef EXPENSIVE_CHECKS if (EnableExpensiveChecks) #endif PerformExpensiveChecks(); @@ -394,7 +394,7 @@ NodeDone: } } -#ifndef XDEBUG +#ifndef EXPENSIVE_CHECKS if (EnableExpensiveChecks) #endif PerformExpensiveChecks(); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index a07a33bd586..12aab9df2ae 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -7294,9 +7294,9 @@ void llvm::checkForCycles(const llvm::SDNode *N, bool force) { #ifndef NDEBUG bool check = force; -#ifdef XDEBUG +#ifdef EXPENSIVE_CHECKS check = true; -#endif // XDEBUG +#endif // EXPENSIVE_CHECKS if (check) { assert(N && "Checking nonexistent SDNode"); SmallPtrSet visited; diff --git a/lib/IR/Dominators.cpp b/lib/IR/Dominators.cpp index 37a4e68e6cd..0d2c70fe2c7 100644 --- a/lib/IR/Dominators.cpp +++ b/lib/IR/Dominators.cpp @@ -28,7 +28,7 @@ using namespace llvm; // Always verify dominfo if expensive checking is enabled. -#ifdef XDEBUG +#ifdef EXPENSIVE_CHECKS static bool VerifyDomInfo = true; #else static bool VerifyDomInfo = false; diff --git a/lib/Target/ARM/ARMFrameLowering.cpp b/lib/Target/ARM/ARMFrameLowering.cpp index 909a728e1f2..808a21fac0e 100644 --- a/lib/Target/ARM/ARMFrameLowering.cpp +++ b/lib/Target/ARM/ARMFrameLowering.cpp @@ -2155,7 +2155,7 @@ void ARMFrameLowering::adjustForSegmentedStacks( PrevStackMBB->addSuccessor(McrMBB); -#ifdef XDEBUG +#ifdef EXPENSIVE_CHECKS MF.verify(); #endif } diff --git a/lib/Target/Hexagon/HexagonCommonGEP.cpp b/lib/Target/Hexagon/HexagonCommonGEP.cpp index 2258f22cadf..c087b72b01f 100644 --- a/lib/Target/Hexagon/HexagonCommonGEP.cpp +++ b/lib/Target/Hexagon/HexagonCommonGEP.cpp @@ -1298,7 +1298,7 @@ bool HexagonCommonGEP::runOnFunction(Function &F) { materialize(Loc); removeDeadCode(); -#ifdef XDEBUG +#ifdef EXPENSIVE_CHECKS // Run this only when expensive checks are enabled. verifyFunction(F); #endif diff --git a/lib/Target/Sparc/SparcFrameLowering.cpp b/lib/Target/Sparc/SparcFrameLowering.cpp index 5e1e61ec919..87b01553b37 100644 --- a/lib/Target/Sparc/SparcFrameLowering.cpp +++ b/lib/Target/Sparc/SparcFrameLowering.cpp @@ -350,7 +350,7 @@ void SparcFrameLowering::remapRegsForLeafProc(MachineFunction &MF) const { } assert(verifyLeafProcRegUse(&MRI)); -#ifdef XDEBUG +#ifdef EXPENSIVE_CHECKS MF.verify(0, "After LeafProc Remapping"); #endif } diff --git a/lib/Target/X86/X86FrameLowering.cpp b/lib/Target/X86/X86FrameLowering.cpp index 155cb3c02b2..8a283775138 100644 --- a/lib/Target/X86/X86FrameLowering.cpp +++ b/lib/Target/X86/X86FrameLowering.cpp @@ -2279,7 +2279,7 @@ void X86FrameLowering::adjustForSegmentedStacks( checkMBB->addSuccessor(allocMBB); checkMBB->addSuccessor(&PrologueMBB); -#ifdef XDEBUG +#ifdef EXPENSIVE_CHECKS MF.verify(); #endif } @@ -2423,7 +2423,7 @@ void X86FrameLowering::adjustForHiPEPrologue( incStackMBB->addSuccessor(&PrologueMBB, {99, 100}); incStackMBB->addSuccessor(incStackMBB, {1, 100}); } -#ifdef XDEBUG +#ifdef EXPENSIVE_CHECKS MF.verify(); #endif } diff --git a/lib/Transforms/ObjCARC/BlotMapVector.h b/lib/Transforms/ObjCARC/BlotMapVector.h index d6439b69841..ef075bdccbf 100644 --- a/lib/Transforms/ObjCARC/BlotMapVector.h +++ b/lib/Transforms/ObjCARC/BlotMapVector.h @@ -31,7 +31,7 @@ public: const_iterator begin() const { return Vector.begin(); } const_iterator end() const { return Vector.end(); } -#ifdef XDEBUG +#ifdef EXPENSIVE_CHECKS ~BlotMapVector() { assert(Vector.size() >= Map.size()); // May differ due to blotting. for (typename MapTy::const_iterator I = Map.begin(), E = Map.end(); I != E; diff --git a/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp index a6793295dfa..dd806f27e75 100644 --- a/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ b/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -62,7 +62,7 @@ static cl::opt RematerializationThreshold("spp-rematerialization-threshold", cl::Hidden, cl::init(6)); -#ifdef XDEBUG +#ifdef EXPENSIVE_CHECKS static bool ClobberNonLive = true; #else static bool ClobberNonLive = false; diff --git a/lib/Transforms/Utils/MemorySSA.cpp b/lib/Transforms/Utils/MemorySSA.cpp index 90c23e1e144..97c728bbe20 100644 --- a/lib/Transforms/Utils/MemorySSA.cpp +++ b/lib/Transforms/Utils/MemorySSA.cpp @@ -805,7 +805,7 @@ void CachingMemorySSAWalker::invalidateInfo(MemoryAccess *MA) { CachedUpwardsClobberingAccess.clear(); } -#ifdef XDEBUG +#ifdef EXPENSIVE_CHECKS // Run this only when expensive checks are enabled. verifyRemoved(MA); #endif