Skip to content

Commit 0716d31

Browse files
authored
[RISCV][NFC] Use maybe_unused instead of casting to void to fix unused variable warning. (#80651)
1 parent 397e91f commit 0716d31

File tree

7 files changed

+29
-33
lines changed

7 files changed

+29
-33
lines changed

llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1222,8 +1222,8 @@ struct RISCVOperand final : public MCParsedAsmOperand {
12221222
int64_t Imm = 0;
12231223
if (Kind == KindTy::Immediate) {
12241224
RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_RISCV_None;
1225-
bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
1226-
(void)IsConstantImm;
1225+
[[maybe_unused]] bool IsConstantImm =
1226+
evaluateConstantImm(getImm(), Imm, VK);
12271227
assert(IsConstantImm && "Invalid VTypeI Operand!");
12281228
} else {
12291229
Imm = getVType();

llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,8 @@ static DecodeStatus decodeRVCInstrRdRs1ImmZero(MCInst &Inst, uint32_t Insn,
380380
uint64_t Address,
381381
const MCDisassembler *Decoder) {
382382
uint32_t Rd = fieldFromInstruction(Insn, 7, 5);
383-
DecodeStatus Result = DecodeGPRNoX0RegisterClass(Inst, Rd, Address, Decoder);
384-
(void)Result;
383+
[[maybe_unused]] DecodeStatus Result =
384+
DecodeGPRNoX0RegisterClass(Inst, Rd, Address, Decoder);
385385
assert(Result == MCDisassembler::Success && "Invalid register");
386386
Inst.addOperand(Inst.getOperand(0));
387387
Inst.addOperand(MCOperand::createImm(0));
@@ -392,8 +392,8 @@ static DecodeStatus decodeCSSPushPopchk(MCInst &Inst, uint32_t Insn,
392392
uint64_t Address,
393393
const MCDisassembler *Decoder) {
394394
uint32_t Rs1 = fieldFromInstruction(Insn, 7, 5);
395-
DecodeStatus Result = DecodeGPRX1X5RegisterClass(Inst, Rs1, Address, Decoder);
396-
(void)Result;
395+
[[maybe_unused]] DecodeStatus Result =
396+
DecodeGPRX1X5RegisterClass(Inst, Rs1, Address, Decoder);
397397
assert(Result == MCDisassembler::Success && "Invalid register");
398398
return MCDisassembler::Success;
399399
}
@@ -404,8 +404,8 @@ static DecodeStatus decodeRVCInstrRdSImm(MCInst &Inst, uint32_t Insn,
404404
Inst.addOperand(MCOperand::createReg(RISCV::X0));
405405
uint32_t SImm6 =
406406
fieldFromInstruction(Insn, 12, 1) << 5 | fieldFromInstruction(Insn, 2, 5);
407-
DecodeStatus Result = decodeSImmOperand<6>(Inst, SImm6, Address, Decoder);
408-
(void)Result;
407+
[[maybe_unused]] DecodeStatus Result =
408+
decodeSImmOperand<6>(Inst, SImm6, Address, Decoder);
409409
assert(Result == MCDisassembler::Success && "Invalid immediate");
410410
return MCDisassembler::Success;
411411
}
@@ -417,8 +417,8 @@ static DecodeStatus decodeRVCInstrRdRs1UImm(MCInst &Inst, uint32_t Insn,
417417
Inst.addOperand(Inst.getOperand(0));
418418
uint32_t UImm6 =
419419
fieldFromInstruction(Insn, 12, 1) << 5 | fieldFromInstruction(Insn, 2, 5);
420-
DecodeStatus Result = decodeUImmOperand<6>(Inst, UImm6, Address, Decoder);
421-
(void)Result;
420+
[[maybe_unused]] DecodeStatus Result =
421+
decodeUImmOperand<6>(Inst, UImm6, Address, Decoder);
422422
assert(Result == MCDisassembler::Success && "Invalid immediate");
423423
return MCDisassembler::Success;
424424
}
@@ -454,8 +454,8 @@ static DecodeStatus decodeXTHeadMemPair(MCInst &Inst, uint32_t Insn,
454454
DecodeGPRRegisterClass(Inst, Rd1, Address, Decoder);
455455
DecodeGPRRegisterClass(Inst, Rd2, Address, Decoder);
456456
DecodeGPRRegisterClass(Inst, Rs1, Address, Decoder);
457-
DecodeStatus Result = decodeUImmOperand<2>(Inst, UImm2, Address, Decoder);
458-
(void)Result;
457+
[[maybe_unused]] DecodeStatus Result =
458+
decodeUImmOperand<2>(Inst, UImm2, Address, Decoder);
459459
assert(Result == MCDisassembler::Success && "Invalid immediate");
460460

461461
// Disassemble the final operand which is implicit.

llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,8 @@ void RISCVAsmBackend::relaxInstruction(MCInst &Inst,
186186
case RISCV::C_BNEZ:
187187
case RISCV::C_J:
188188
case RISCV::C_JAL: {
189-
bool Success = RISCVRVC::uncompress(Res, Inst, STI);
189+
[[maybe_unused]] bool Success = RISCVRVC::uncompress(Res, Inst, STI);
190190
assert(Success && "Can't uncompress instruction");
191-
(void)Success;
192191
break;
193192
}
194193
case RISCV::BEQ:
@@ -218,9 +217,9 @@ bool RISCVAsmBackend::relaxDwarfLineAddr(MCDwarfLineAddrFragment &DF,
218217
size_t OldSize = Data.size();
219218

220219
int64_t Value;
221-
bool IsAbsolute = AddrDelta.evaluateKnownAbsolute(Value, Layout);
220+
[[maybe_unused]] bool IsAbsolute =
221+
AddrDelta.evaluateKnownAbsolute(Value, Layout);
222222
assert(IsAbsolute && "CFA with invalid expression");
223-
(void)IsAbsolute;
224223

225224
Data.clear();
226225
Fixups.clear();
@@ -283,9 +282,9 @@ bool RISCVAsmBackend::relaxDwarfCFA(MCDwarfCallFrameFragment &DF,
283282
int64_t Value;
284283
if (AddrDelta.evaluateAsAbsolute(Value, Layout.getAssembler()))
285284
return false;
286-
bool IsAbsolute = AddrDelta.evaluateKnownAbsolute(Value, Layout);
285+
[[maybe_unused]] bool IsAbsolute =
286+
AddrDelta.evaluateKnownAbsolute(Value, Layout);
287287
assert(IsAbsolute && "CFA with invalid expression");
288-
(void)IsAbsolute;
289288

290289
Data.clear();
291290
Fixups.clear();

llvm/lib/Target/RISCV/RISCVFoldMasks.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ bool RISCVFoldMasks::convertToUnmasked(MachineInstr &MI,
146146
// everything else. See the comment on RISCVMaskedPseudo for details.
147147
const unsigned Opc = I->UnmaskedPseudo;
148148
const MCInstrDesc &MCID = TII->get(Opc);
149-
const bool HasPolicyOp = RISCVII::hasVecPolicyOp(MCID.TSFlags);
149+
[[maybe_unused]] const bool HasPolicyOp =
150+
RISCVII::hasVecPolicyOp(MCID.TSFlags);
150151
const bool HasPassthru = RISCVII::isFirstDefTiedToFirstUse(MCID);
151152
#ifndef NDEBUG
152153
const MCInstrDesc &MaskedMCID = TII->get(MI.getOpcode());

llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -2081,10 +2081,10 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
20812081
break;
20822082

20832083
RISCVII::VLMUL SubVecLMUL = RISCVTargetLowering::getLMUL(SubVecContainerVT);
2084-
bool IsSubVecPartReg = SubVecLMUL == RISCVII::VLMUL::LMUL_F2 ||
2085-
SubVecLMUL == RISCVII::VLMUL::LMUL_F4 ||
2086-
SubVecLMUL == RISCVII::VLMUL::LMUL_F8;
2087-
(void)IsSubVecPartReg; // Silence unused variable warning without asserts.
2084+
[[maybe_unused]] bool IsSubVecPartReg =
2085+
SubVecLMUL == RISCVII::VLMUL::LMUL_F2 ||
2086+
SubVecLMUL == RISCVII::VLMUL::LMUL_F4 ||
2087+
SubVecLMUL == RISCVII::VLMUL::LMUL_F8;
20882088
assert((!IsSubVecPartReg || V.isUndef()) &&
20892089
"Expecting lowering to have created legal INSERT_SUBVECTORs when "
20902090
"the subvector is smaller than a full-sized register");
@@ -2263,9 +2263,8 @@ bool RISCVDAGToDAGISel::SelectInlineAsmMemoryOperand(
22632263
case InlineAsm::ConstraintCode::o:
22642264
case InlineAsm::ConstraintCode::m: {
22652265
SDValue Op0, Op1;
2266-
bool Found = SelectAddrRegImm(Op, Op0, Op1);
2266+
[[maybe_unused]] bool Found = SelectAddrRegImm(Op, Op0, Op1);
22672267
assert(Found && "SelectAddrRegImm should always succeed");
2268-
(void)Found;
22692268
OutOps.push_back(Op0);
22702269
OutOps.push_back(Op1);
22712270
return false;

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

+5-7
Original file line numberDiff line numberDiff line change
@@ -8512,12 +8512,12 @@ static SDValue lowerGetVectorLength(SDNode *N, SelectionDAG &DAG,
85128512
// Determine the VF that corresponds to LMUL 1 for ElementWidth.
85138513
unsigned LMul1VF = RISCV::RVVBitsPerBlock / ElementWidth;
85148514
// We don't support VF==1 with ELEN==32.
8515-
unsigned MinVF = RISCV::RVVBitsPerBlock / Subtarget.getELen();
8515+
[[maybe_unused]] unsigned MinVF =
8516+
RISCV::RVVBitsPerBlock / Subtarget.getELen();
85168517

8517-
unsigned VF = N->getConstantOperandVal(2);
8518+
[[maybe_unused]] unsigned VF = N->getConstantOperandVal(2);
85188519
assert(VF >= MinVF && VF <= (LMul1VF * 8) && isPowerOf2_32(VF) &&
85198520
"Unexpected VF");
8520-
(void)MinVF;
85218521

85228522
bool Fractional = VF < LMul1VF;
85238523
unsigned LMulVal = Fractional ? LMul1VF / VF : VF / LMul1VF;
@@ -11227,7 +11227,7 @@ SDValue RISCVTargetLowering::lowerMaskedGather(SDValue Op,
1122711227
SDValue Chain = MemSD->getChain();
1122811228
SDValue BasePtr = MemSD->getBasePtr();
1122911229

11230-
ISD::LoadExtType LoadExtType;
11230+
[[maybe_unused]] ISD::LoadExtType LoadExtType;
1123111231
SDValue Index, Mask, PassThru, VL;
1123211232

1123311233
if (auto *VPGN = dyn_cast<VPGatherSDNode>(Op.getNode())) {
@@ -11255,7 +11255,6 @@ SDValue RISCVTargetLowering::lowerMaskedGather(SDValue Op,
1125511255
// Targets have to explicitly opt-in for extending vector loads.
1125611256
assert(LoadExtType == ISD::NON_EXTLOAD &&
1125711257
"Unexpected extending MGATHER/VP_GATHER");
11258-
(void)LoadExtType;
1125911258

1126011259
// If the mask is known to be all ones, optimize to an unmasked intrinsic;
1126111260
// the selection of the masked intrinsics doesn't do this for us.
@@ -11325,7 +11324,7 @@ SDValue RISCVTargetLowering::lowerMaskedScatter(SDValue Op,
1132511324
SDValue Chain = MemSD->getChain();
1132611325
SDValue BasePtr = MemSD->getBasePtr();
1132711326

11328-
bool IsTruncatingStore = false;
11327+
[[maybe_unused]] bool IsTruncatingStore = false;
1132911328
SDValue Index, Mask, Val, VL;
1133011329

1133111330
if (auto *VPSN = dyn_cast<VPScatterSDNode>(Op.getNode())) {
@@ -11354,7 +11353,6 @@ SDValue RISCVTargetLowering::lowerMaskedScatter(SDValue Op,
1135411353
// Targets have to explicitly opt-in for extending vector loads and
1135511354
// truncating vector stores.
1135611355
assert(!IsTruncatingStore && "Unexpected truncating MSCATTER/VP_SCATTER");
11357-
(void)IsTruncatingStore;
1135811356

1135911357
// If the mask is known to be all ones, optimize to an unmasked intrinsic;
1136011358
// the selection of the masked intrinsics doesn't do this for us.

llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,6 @@ bool RISCVInstrInfo::optimizeCondBranch(MachineInstr &MI) const {
11721172
SmallVector<MachineOperand, 3> Cond;
11731173
if (analyzeBranch(*MBB, TBB, FBB, Cond, /*AllowModify=*/false))
11741174
return false;
1175-
(void)FBB;
11761175

11771176
RISCVCC::CondCode CC = static_cast<RISCVCC::CondCode>(Cond[0].getImm());
11781177
assert(CC != RISCVCC::COND_INVALID);

0 commit comments

Comments
 (0)