Skip to content

Commit 46776f7

Browse files
committed
Fix warnings about variables that are set but only used in debug mode
Add void casts to mark the variables used, next to the places where they are used in assert or `LLVM_DEBUG()` expressions. Differential Revision: https://reviews.llvm.org/D123117
1 parent 1558cdd commit 46776f7

17 files changed

+19
-1
lines changed

lld/wasm/InputFiles.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,7 @@ void ArchiveFile::parse() {
689689
++count;
690690
}
691691
LLVM_DEBUG(dbgs() << "Read " << count << " symbols\n");
692+
(void) count;
692693
}
693694

694695
void ArchiveFile::addMember(const Archive::Symbol *sym) {

lld/wasm/SyntheticSections.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ void ElemSection::writeBody() {
589589
uint32_t tableIndex = config->tableBase;
590590
for (const FunctionSymbol *sym : indirectFunctions) {
591591
assert(sym->getTableIndex() == tableIndex);
592+
(void) tableIndex;
592593
writeUleb128(os, sym->getFunctionIndex(), "function index");
593594
++tableIndex;
594595
}

llvm/lib/Analysis/LoopInfo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,7 @@ void UnloopUpdater::updateBlockParents() {
736736
bool Changed = FoundIB;
737737
for (unsigned NIters = 0; Changed; ++NIters) {
738738
assert(NIters < Unloop.getNumBlocks() && "runaway iterative algorithm");
739+
(void) NIters;
739740

740741
// Iterate over the postorder list of blocks, propagating the nearest loop
741742
// from successors to predecessors as before.

llvm/lib/CodeGen/MIRFSDiscriminator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ bool MIRAddFSDiscriminators::runOnMachineFunction(MachineFunction &MF) {
135135
if (Changed) {
136136
createFSDiscriminatorVariable(MF.getFunction().getParent());
137137
LLVM_DEBUG(dbgs() << "Num of FS Discriminators: " << NumNewD << "\n");
138+
(void) NumNewD;
138139
}
139140

140141
return Changed;

llvm/lib/CodeGen/RegAllocPBQP.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,7 @@ bool RegAllocPBQP::runOnMachineFunction(MachineFunction &MF) {
847847

848848
while (!PBQPAllocComplete) {
849849
LLVM_DEBUG(dbgs() << " PBQP Regalloc round " << Round << ":\n");
850+
(void) Round;
850851

851852
PBQPRAGraph G(PBQPRAGraph::GraphMetadata(MF, LIS, MBFI));
852853
initializeGraph(G, VRM, *VRegSpiller);

llvm/lib/CodeGen/StackColoring.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,9 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
11431143
LLVM_DEBUG(dbgs() << "Fixed " << FixedMemOp << " machine memory operands.\n");
11441144
LLVM_DEBUG(dbgs() << "Fixed " << FixedDbg << " debug locations.\n");
11451145
LLVM_DEBUG(dbgs() << "Fixed " << FixedInstr << " machine instructions.\n");
1146+
(void) FixedMemOp;
1147+
(void) FixedDbg;
1148+
(void) FixedInstr;
11461149
}
11471150

11481151
void StackColoring::removeInvalidSlotRanges() {

llvm/lib/Target/AArch64/AArch64A53Fix835769.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ AArch64A53Fix835769::runOnBasicBlock(MachineBasicBlock &MBB) {
223223
if (isFirstInstructionInSequence(PrevInstr) &&
224224
isSecondInstructionInSequence(CurrInstr)) {
225225
LLVM_DEBUG(dbgs() << " ** pattern found at Idx " << Idx << "!\n");
226+
(void) Idx;
226227
Sequences.push_back(CurrInstr);
227228
}
228229
}

llvm/lib/Target/X86/X86FastTileConfig.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ MachineInstr *X86FastTileConfig::getKeyAMXInstr(MachineInstr *MI) {
154154

155155
if (isAMXInstr(*II)) {
156156
assert((KeyAMXNum == 0) && "Too many Key AMX instruction!");
157+
(void) KeyAMXNum;
157158
KeyAMXNum++;
158159
KeyMI = &*II;
159160
}

llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,7 @@ void PGOUseFunc::populateCounters() {
14571457
}
14581458

14591459
LLVM_DEBUG(dbgs() << "Populate counts in " << NumPasses << " passes.\n");
1460+
(void) NumPasses;
14601461
#ifndef NDEBUG
14611462
// Assert every BB has a valid counter.
14621463
for (auto &BB : F) {

llvm/lib/Transforms/Scalar/GVN.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2593,6 +2593,7 @@ bool GVNPass::runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT,
25932593
unsigned Iteration = 0;
25942594
while (ShouldContinue) {
25952595
LLVM_DEBUG(dbgs() << "GVN iteration: " << Iteration << "\n");
2596+
(void) Iteration;
25962597
ShouldContinue = iterateOnFunction(F);
25972598
Changed |= ShouldContinue;
25982599
++Iteration;

llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,6 +2087,7 @@ static void relocationViaAlloca(
20872087

20882088
assert(PromotableAllocas.size() == Live.size() + NumRematerializedValues &&
20892089
"we must have the same allocas with lives");
2090+
(void) NumRematerializedValues;
20902091
if (!PromotableAllocas.empty()) {
20912092
// Apply mem2reg to promote alloca to SSA
20922093
PromoteMemToReg(PromotableAllocas, DT);

llvm/lib/Transforms/Utils/SimplifyIndVar.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,7 @@ void SimplifyIndvar::simplifyUsers(PHINode *CurrIV, IVVisitor *V) {
870870
Instruction *IVOperand = UseOper.second;
871871
for (unsigned N = 0; IVOperand; ++N) {
872872
assert(N <= Simplified.size() && "runaway iteration");
873+
(void) N;
873874

874875
Value *NewOper = foldIVUser(UseInst, IVOperand);
875876
if (!NewOper)

llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ int main(int argc, char *argv[]) {
338338
assert(TLIandSDKboth + TLIandSDKneither + TLIdoesSDKdoesnt +
339339
TLIdoesntSDKdoes ==
340340
LibFunc::NumLibFuncs);
341+
(void) TLIandSDKneither;
341342
outs() << "<< Total TLI yes SDK no: " << TLIdoesSDKdoesnt
342343
<< "\n>> Total TLI no SDK yes: " << TLIdoesntSDKdoes
343344
<< "\n== Total TLI yes SDK yes: " << TLIandSDKboth;

llvm/utils/TableGen/CodeGenRegisters.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,6 +1814,7 @@ void CodeGenRegBank::computeRegUnitWeights() {
18141814
unsigned NumIters = 0;
18151815
for (bool Changed = true; Changed; ++NumIters) {
18161816
assert(NumIters <= NumNativeRegUnits && "Runaway register unit weights");
1817+
(void) NumIters;
18171818
Changed = false;
18181819
for (auto &Reg : Registers) {
18191820
CodeGenRegister::RegUnitList NormalUnits;

llvm/utils/TableGen/DFAEmitter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ void Automaton::emit(raw_ostream &OS) {
305305
}
306306
LLVM_DEBUG(dbgs() << " NFA automaton has " << SeenStates.size()
307307
<< " states with " << NumTransitions << " transitions.\n");
308+
(void) NumTransitions;
308309

309310
const auto &ActionTypes = Transitions.back().getTypes();
310311
OS << "// The type of an action in the " << Name << " automaton.\n";

llvm/utils/TableGen/GlobalISelEmitter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5534,6 +5534,7 @@ std::vector<Matcher *> GlobalISelEmitter::optimizeRules(
55345534
ProcessCurrentGroup();
55355535

55365536
LLVM_DEBUG(dbgs() << "NumGroups: " << NumGroups << "\n");
5537+
(void) NumGroups;
55375538
assert(CurrentGroup->empty() && "The last group wasn't properly processed");
55385539
return OptRules;
55395540
}

llvm/utils/TableGen/RegisterInfoEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ RegisterInfoEmitter::emitComposeSubRegIndices(raw_ostream &OS,
753753
}
754754
OS << " };\n\n";
755755

756-
OS << " --IdxA; assert(IdxA < " << SubRegIndicesSize << ");\n"
756+
OS << " --IdxA; assert(IdxA < " << SubRegIndicesSize << "); (void) IdxA;\n"
757757
<< " --IdxB; assert(IdxB < " << SubRegIndicesSize << ");\n";
758758
if (Rows.size() > 1)
759759
OS << " return Rows[RowMap[IdxA]][IdxB];\n";

0 commit comments

Comments
 (0)