From 53eb6371159ff20ff9f69727977b48219ca7237a Mon Sep 17 00:00:00 2001 From: Don Hinton Date: Wed, 27 Sep 2017 21:19:56 +0000 Subject: [PATCH] Cleanup some problems with LLVM_ENABLE_DUMP in release builds, and always set LLVM_ENABLE_DUMP=ON for +Asserts builds. Differential Revision: https://reviews.llvm.org/D38306 llvm-svn: 314346 --- llvm/CMakeLists.txt | 8 ++++++-- llvm/cmake/modules/HandleLLVMOptions.cmake | 4 ---- llvm/include/llvm/CodeGen/MachineRegisterInfo.h | 2 -- llvm/include/llvm/CodeGen/MachineScheduler.h | 2 -- llvm/include/llvm/CodeGen/TargetSchedule.h | 2 +- llvm/include/llvm/Config/config.h.cmake | 3 +++ llvm/include/llvm/MC/MCSchedule.h | 4 ++-- llvm/lib/CodeGen/LiveDebugVariables.cpp | 2 +- llvm/lib/CodeGen/ScoreboardHazardRecognizer.cpp | 1 + llvm/utils/TableGen/SubtargetEmitter.cpp | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index b5454499df38..410c6afa17e9 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -388,15 +388,19 @@ option(LLVM_ENABLE_LLD "Use lld as C and C++ linker." OFF) option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) +option(LLVM_ENABLE_DUMP "Enable dump functions in release builds" OFF) + if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" ) option(LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF) else() option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON) endif() -option(LLVM_ENABLE_EXPENSIVE_CHECKS "Enable expensive checks" OFF) +if( LLVM_ENABLE_ASSERTIONS ) + set(LLVM_ENABLE_DUMP ON) +endif() -option(LLVM_ENABLE_DUMP "Enable dump functions in release builds" OFF) +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/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index bd5e8989596a..76683c351d81 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -84,10 +84,6 @@ if(LLVM_ENABLE_EXPENSIVE_CHECKS) add_definitions(-D_GLIBCXX_DEBUG) endif() -if(LLVM_ENABLE_DUMP) - add_definitions(-DLLVM_ENABLE_DUMP) -endif() - string(TOUPPER "${LLVM_ABI_BREAKING_CHECKS}" uppercase_LLVM_ABI_BREAKING_CHECKS) if( uppercase_LLVM_ABI_BREAKING_CHECKS STREQUAL "WITH_ASSERTS" ) diff --git a/llvm/include/llvm/CodeGen/MachineRegisterInfo.h b/llvm/include/llvm/CodeGen/MachineRegisterInfo.h index 5ef0ac90e3c2..74fd81c14395 100644 --- a/llvm/include/llvm/CodeGen/MachineRegisterInfo.h +++ b/llvm/include/llvm/CodeGen/MachineRegisterInfo.h @@ -575,9 +575,7 @@ public: /// preserve conservative kill flag information. void clearKillFlags(unsigned Reg) const; -#ifndef NDEBUG void dumpUses(unsigned RegNo) const; -#endif /// Returns true if PhysReg is unallocatable and constant throughout the /// function. Writing to a constant register has no effect. diff --git a/llvm/include/llvm/CodeGen/MachineScheduler.h b/llvm/include/llvm/CodeGen/MachineScheduler.h index c983d6ccf2cd..e327881de13a 100644 --- a/llvm/include/llvm/CodeGen/MachineScheduler.h +++ b/llvm/include/llvm/CodeGen/MachineScheduler.h @@ -776,9 +776,7 @@ public: /// available instruction, or NULL if there are multiple candidates. SUnit *pickOnlyChoice(); -#ifndef NDEBUG void dumpScheduledState() const; -#endif }; /// Base class for GenericScheduler. This class maintains information about diff --git a/llvm/include/llvm/CodeGen/TargetSchedule.h b/llvm/include/llvm/CodeGen/TargetSchedule.h index f23667976468..733693e1b584 100644 --- a/llvm/include/llvm/CodeGen/TargetSchedule.h +++ b/llvm/include/llvm/CodeGen/TargetSchedule.h @@ -116,7 +116,7 @@ public: return SchedModel.getProcResource(PIdx); } -#ifndef NDEBUG +#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) const char *getResourceName(unsigned PIdx) const { if (!PIdx) return "MOps"; diff --git a/llvm/include/llvm/Config/config.h.cmake b/llvm/include/llvm/Config/config.h.cmake index 4163d7d9c440..d0d1e0985cca 100644 --- a/llvm/include/llvm/Config/config.h.cmake +++ b/llvm/include/llvm/Config/config.h.cmake @@ -347,6 +347,9 @@ /* Has gcc/MSVC atomic intrinsics */ #cmakedefine01 LLVM_HAS_ATOMICS +/* Define if LLVM_ENABLE_DUMP is enabled */ +#cmakedefine LLVM_ENABLE_DUMP + /* Host triple LLVM will be executed on */ #cmakedefine LLVM_HOST_TRIPLE "${LLVM_HOST_TRIPLE}" diff --git a/llvm/include/llvm/MC/MCSchedule.h b/llvm/include/llvm/MC/MCSchedule.h index 37728797f626..a79afe163e6c 100644 --- a/llvm/include/llvm/MC/MCSchedule.h +++ b/llvm/include/llvm/MC/MCSchedule.h @@ -24,7 +24,7 @@ struct InstrItinerary; /// Define a kind of processor resource that will be modeled by the scheduler. struct MCProcResourceDesc { -#ifndef NDEBUG +#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) const char *Name; #endif unsigned NumUnits; // Number of resource of this kind @@ -102,7 +102,7 @@ struct MCSchedClassDesc { static const unsigned short InvalidNumMicroOps = UINT16_MAX; static const unsigned short VariantNumMicroOps = UINT16_MAX - 1; -#ifndef NDEBUG +#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) const char* Name; #endif unsigned short NumMicroOps; diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp index 37ff30a92a04..9a82e3c42ddd 100644 --- a/llvm/lib/CodeGen/LiveDebugVariables.cpp +++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp @@ -355,7 +355,7 @@ public: } // end anonymous namespace -#ifndef NDEBUG +#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) static void printDebugLoc(const DebugLoc &DL, raw_ostream &CommentOS, const LLVMContext &Ctx) { if (!DL) diff --git a/llvm/lib/CodeGen/ScoreboardHazardRecognizer.cpp b/llvm/lib/CodeGen/ScoreboardHazardRecognizer.cpp index b3d83d5313af..e2cb8cad6e18 100644 --- a/llvm/lib/CodeGen/ScoreboardHazardRecognizer.cpp +++ b/llvm/lib/CodeGen/ScoreboardHazardRecognizer.cpp @@ -32,6 +32,7 @@ ScoreboardHazardRecognizer::ScoreboardHazardRecognizer( const char *ParentDebugType) : ScheduleHazardRecognizer(), DebugType(ParentDebugType), ItinData(II), DAG(SchedDAG) { + (void)DebugType; // Determine the maximum depth of any itinerary. This determines the depth of // the scoreboard. We always make the scoreboard at least 1 cycle deep to // avoid dealing with the boundary condition. diff --git a/llvm/utils/TableGen/SubtargetEmitter.cpp b/llvm/utils/TableGen/SubtargetEmitter.cpp index cc46481a8133..4cb941cfecce 100644 --- a/llvm/utils/TableGen/SubtargetEmitter.cpp +++ b/llvm/utils/TableGen/SubtargetEmitter.cpp @@ -1237,7 +1237,7 @@ void SubtargetEmitter::EmitSchedModel(raw_ostream &OS) { OS << "#ifdef DBGFIELD\n" << "#error \"GenSubtargetInfo.inc requires a DBGFIELD macro\"\n" << "#endif\n" - << "#ifndef NDEBUG\n" + << "#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)\n" << "#define DBGFIELD(x) x,\n" << "#else\n" << "#define DBGFIELD(x)\n" -- GitLab