diff --git a/bolt/src/BinaryContext.cpp b/bolt/src/BinaryContext.cpp index c8b16cfe3cf0..246745a1acf3 100644 --- a/bolt/src/BinaryContext.cpp +++ b/bolt/src/BinaryContext.cpp @@ -1750,6 +1750,7 @@ BinaryContext::getSectionNameForAddress(uint64_t Address) const { BinarySection &BinaryContext::registerSection(BinarySection *Section) { auto Res = Sections.insert(Section); + (void)Res; assert(Res.second && "can't register the same section twice."); // Only register allocatable sections in the AddressToSection map. @@ -1787,6 +1788,7 @@ BinarySection &BinaryContext::registerOrUpdateSection(StringRef Name, LLVM_DEBUG(dbgs() << "BOLT-DEBUG: updating " << *Section << " -> "); const bool Flag = Section->isAllocatable(); + (void)Flag; Section->update(Data, Size, Alignment, ELFType, ELFFlags); LLVM_DEBUG(dbgs() << *Section << "\n"); // FIXME: Fix section flags/attributes for MachO. diff --git a/bolt/src/BinaryFunction.cpp b/bolt/src/BinaryFunction.cpp index e0a9dd1e10c0..c3c1f01118da 100644 --- a/bolt/src/BinaryFunction.cpp +++ b/bolt/src/BinaryFunction.cpp @@ -3926,6 +3926,7 @@ bool BinaryFunction::replaceJumpTableEntryIn(BinaryBasicBlock *BB, assert(JT && "No jump table structure for this indirect branch"); bool Patched = JT->replaceDestination(JTAddress, OldDest->getLabel(), NewDest->getLabel()); + (void)Patched; assert(Patched && "Invalid entry to be replaced in jump table"); return true; } diff --git a/bolt/src/DWARFRewriter.cpp b/bolt/src/DWARFRewriter.cpp index d85b34a35f09..bd00da372842 100644 --- a/bolt/src/DWARFRewriter.cpp +++ b/bolt/src/DWARFRewriter.cpp @@ -168,6 +168,7 @@ void DWARFRewriter::updateDebugInfo() { uint64_t AttrOffset = 0; Optional ValDwoName = DIE.find(dwarf::DW_AT_GNU_dwo_name, &AttrOffset); + (void)ValDwoName; assert(ValDwoName && "Skeleton CU doesn't have dwo_name."); std::string ObjectName = getDWOName(Unit, &NameToIndexMap, DWOIdToName); @@ -176,6 +177,7 @@ void DWARFRewriter::updateDebugInfo() { Optional ValCompDir = DIE.find(dwarf::DW_AT_comp_dir, &AttrOffset); + (void)ValCompDir; assert(ValCompDir && "DW_AT_comp_dir is not in Skeleton CU."); if (!opts::DwoOutputPath.empty()) { uint32_t NewOffset = StrWriter->addString(opts::DwoOutputPath.c_str()); diff --git a/bolt/src/DebugData.cpp b/bolt/src/DebugData.cpp index 43cbd9d12f3b..4681a27cfd50 100644 --- a/bolt/src/DebugData.cpp +++ b/bolt/src/DebugData.cpp @@ -228,6 +228,7 @@ AddressSectionBuffer DebugAddrWriter::finalize() { switch (AddrSize) { default: assert(false && "Address Size is invalid."); + break; case 4: support::endian::write(AddressStream, static_cast(Address), support::little); diff --git a/bolt/src/ParallelUtilities.cpp b/bolt/src/ParallelUtilities.cpp index 45a13724196e..1fc0935c36a9 100644 --- a/bolt/src/ParallelUtilities.cpp +++ b/bolt/src/ParallelUtilities.cpp @@ -212,6 +212,7 @@ void runOnEachFunctionWithUniqueAllocId( if (!BC.MIB->checkAllocatorExists(AllocId)) { MCPlusBuilder::AllocatorIdTy Id = BC.MIB->initializeNewAnnotationAllocator(); + (void)Id; assert(AllocId == Id && "unexpected allocator id created"); } Pool.async(runBlock, BlockBegin, std::next(It), AllocId); @@ -224,6 +225,7 @@ void runOnEachFunctionWithUniqueAllocId( if (!BC.MIB->checkAllocatorExists(AllocId)) { MCPlusBuilder::AllocatorIdTy Id = BC.MIB->initializeNewAnnotationAllocator(); + (void)Id; assert(AllocId == Id && "unexpected allocator id created"); } diff --git a/bolt/src/Passes/ExtTSPReorderAlgorithm.cpp b/bolt/src/Passes/ExtTSPReorderAlgorithm.cpp index 8e0c9788eb29..89f3c6c29942 100644 --- a/bolt/src/Passes/ExtTSPReorderAlgorithm.cpp +++ b/bolt/src/Passes/ExtTSPReorderAlgorithm.cpp @@ -785,6 +785,7 @@ private: Block *BB2 = ChainPred->blocks()[Offset]; // Does the splitting break FT successors? if (BB1->FallthroughSucc != nullptr) { + (void)BB2; assert(BB1->FallthroughSucc == BB2 && "Fallthrough not preserved"); continue; } @@ -850,8 +851,6 @@ private: return MergedChain(BeginY, EndY, BeginX2, EndX2, BeginX1, EndX1); case MergeTypeTy::X2_X1_Y: return MergedChain(BeginX2, EndX2, BeginX1, EndX1, BeginY, EndY); - default: - llvm_unreachable("unexpected merge type"); } } diff --git a/bolt/src/Passes/IndirectCallPromotion.cpp b/bolt/src/Passes/IndirectCallPromotion.cpp index 92968641fa98..1dc4eba4b9df 100644 --- a/bolt/src/Passes/IndirectCallPromotion.cpp +++ b/bolt/src/Passes/IndirectCallPromotion.cpp @@ -1550,6 +1550,7 @@ void IndirectCallPromotion::runOnFunctions(BinaryContext &BC) { std::max(TotalIndexBasedCandidates, 1)) << "%\n"; + (void)verifyProfile; #ifndef NDEBUG verifyProfile(BFs); #endif diff --git a/bolt/src/Passes/ShrinkWrapping.cpp b/bolt/src/Passes/ShrinkWrapping.cpp index ed3496c6fdd7..11440e720510 100644 --- a/bolt/src/Passes/ShrinkWrapping.cpp +++ b/bolt/src/Passes/ShrinkWrapping.cpp @@ -1303,6 +1303,7 @@ void ShrinkWrapping::moveSaveRestores() { const FrameIndexEntry *FIESave = CSA.SaveFIEByReg[I]; const FrameIndexEntry *FIELoad = CSA.LoadFIEByReg[I]; + (void)FIELoad; assert(FIESave && FIELoad); StackPointerTracking &SPT = Info.getStackPointerTracking(); const std::pair SPFP = *SPT.getStateBefore(*BestPosSave); @@ -2003,6 +2004,7 @@ bool ShrinkWrapping::perform() { processDeletions(); if (foldIdenticalSplitEdges()) { const std::pair Stats = BF.eraseInvalidBBs(); + (void)Stats; LLVM_DEBUG(dbgs() << "Deleted " << Stats.first << " redundant split edge BBs (" << Stats.second << " bytes) for " << BF.getPrintName() << "\n"); diff --git a/bolt/src/RewriteInstance.cpp b/bolt/src/RewriteInstance.cpp index c16470f7cf71..cf9e2ee0344d 100644 --- a/bolt/src/RewriteInstance.cpp +++ b/bolt/src/RewriteInstance.cpp @@ -1944,6 +1944,7 @@ bool RewriteInstance::analyzeRelocation(const RelocationRef &Rel, truncateToSize(SymbolAddress + Addend - PCRelOffset, RelSize); }; + (void)verifyExtractedValue; assert(verifyExtractedValue() && "mismatched extracted relocation value"); return true; @@ -2164,9 +2165,8 @@ void RewriteInstance::processLKBugTable() { "Reading valid PC-relative offset for a __bug_table entry"); const int32_t SignedOffset = *Offset; const uint64_t RefAddress = EntryAddress + SignedOffset; - BinaryFunction *ContainingBF = - BC->getBinaryFunctionContainingAddress(RefAddress); - assert(ContainingBF && "__bug_table entries should point to a function"); + assert(BC->getBinaryFunctionContainingAddress(RefAddress) && + "__bug_table entries should point to a function"); insertLKMarker(RefAddress, I, SignedOffset, true, "__bug_table"); } @@ -2205,9 +2205,11 @@ void RewriteInstance::processLKSMPLocks() { void RewriteInstance::readDynamicRelocations(const SectionRef &Section) { assert(BinarySection(*BC, Section).isAllocatable() && "allocatable expected"); - StringRef SectionName = cantFail(Section.getName()); - LLVM_DEBUG(dbgs() << "BOLT-DEBUG: reading relocations for section " - << SectionName << ":\n"); + LLVM_DEBUG({ + StringRef SectionName = cantFail(Section.getName()); + dbgs() << "BOLT-DEBUG: reading relocations for section " << SectionName + << ":\n"; + }); for (const RelocationRef &Rel : Section.relocations()) { uint64_t RType = Rel.getType(); @@ -2243,9 +2245,11 @@ void RewriteInstance::readDynamicRelocations(const SectionRef &Section) { } void RewriteInstance::readRelocations(const SectionRef &Section) { - StringRef SectionName = cantFail(Section.getName()); - LLVM_DEBUG(dbgs() << "BOLT-DEBUG: reading relocations for section " - << SectionName << ":\n"); + LLVM_DEBUG({ + StringRef SectionName = cantFail(Section.getName()); + dbgs() << "BOLT-DEBUG: reading relocations for section " << SectionName + << ":\n"; + }); if (BinarySection(*BC, Section).isAllocatable()) { LLVM_DEBUG(dbgs() << "BOLT-DEBUG: ignoring runtime relocations\n"); return;