Skip to content

Commit

Permalink
Fix warnings about unused variables when assertions are disabled (NFC) (
Browse files Browse the repository at this point in the history
  • Loading branch information
maerhart authored Dec 12, 2024
1 parent a82f832 commit bac37a3
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions include/circt/Support/FVInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ class FVInt {
SmallString<16> toString(unsigned radix = 10, bool uppercase = true) const {
SmallString<16> str;
bool success = tryToString(str, radix, uppercase);
(void)success;
assert(success && "radix cannot represent FVInt");
return str;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/Dialect/AIG/Transforms/LowerVariadic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ static Value lowerVariadicAndInverterOp(AndInverterOp op, OperandRange operands,
inverts.drop_front(firstHalf), rewriter);
return rewriter.create<AndInverterOp>(op.getLoc(), lhs, rhs);
}

return Value();
}

struct VariadicOpConversion : OpRewritePattern<aig::AndInverterOp> {
Expand Down
3 changes: 1 addition & 2 deletions lib/Dialect/FIRRTL/Transforms/IMDeadCodeElim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,7 @@ void IMDeadCodeElimPass::visitSubelement(Operation *op) {
}

void IMDeadCodeElimPass::rewriteModuleBody(FModuleOp module) {
auto *body = module.getBodyBlock();
assert(isBlockExecutable(body) &&
assert(isBlockExecutable(module.getBodyBlock()) &&
"unreachable modules must be already deleted");

auto removeDeadNonLocalAnnotations = [&](int _, Annotation anno) -> bool {
Expand Down
1 change: 1 addition & 0 deletions lib/Dialect/LLHD/IR/LLHDOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ DeletionKind SigArrayGetOp::rewire(const DestructurableMemorySlot &slot,
const DataLayout &dataLayout) {
APInt idx;
bool result = matchPattern(getIndex(), m_ConstantInt(&idx));
(void)result;
assert(result);
auto index =
IntegerAttr::get(IndexType::get(getContext()), idx.getZExtValue());
Expand Down
1 change: 1 addition & 0 deletions lib/Dialect/LLHD/Transforms/TemporalCodeMotionPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ LogicalResult TemporalCodeMotionPass::runOnProcess(llhd::ProcessOp procOp) {
// TODO: consider the case where a wait brances to itself
for (unsigned currTR = 0; currTR < numTRs; ++currTR) {
unsigned numTRSuccs = trAnalysis.getNumTRSuccessors(currTR);
(void)numTRSuccs;
// NOTE: Above error checks make this impossible to trigger, but the above
// are changed this one might have to be promoted to a proper error message.
assert((numTRSuccs == 1 ||
Expand Down
20 changes: 10 additions & 10 deletions test/CAPI/firrtl.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ void testExport(MlirContext ctx) {
mlirModuleCreateParse(ctx, mlirStringRefCreateFromCString(testFIR));

MlirLogicalResult result = mlirExportFIRRTL(module, dumpCallback, NULL);
(void)result;
assert(mlirLogicalResultIsSuccess(result));

// CHECK: FIRRTL version 4.1.0
Expand Down Expand Up @@ -78,12 +79,11 @@ void testValueFoldFlow(MlirContext ctx) {
MlirBlock firModule = mlirRegionGetFirstBlock(
mlirOperationGetRegion(mlirBlockGetFirstOperation(firCircuit), 0));

MlirValue in = mlirBlockGetArgument(firModule, 0);
MlirValue out = mlirBlockGetArgument(firModule, 1);

assert(firrtlValueFoldFlow(in, FIRRTL_VALUE_FLOW_SOURCE) ==
assert(firrtlValueFoldFlow(mlirBlockGetArgument(firModule, 0),
FIRRTL_VALUE_FLOW_SOURCE) ==
FIRRTL_VALUE_FLOW_SOURCE);
assert(firrtlValueFoldFlow(out, FIRRTL_VALUE_FLOW_SOURCE) ==
assert(firrtlValueFoldFlow(mlirBlockGetArgument(firModule, 1),
FIRRTL_VALUE_FLOW_SOURCE) ==
FIRRTL_VALUE_FLOW_SINK);
}

Expand All @@ -107,6 +107,7 @@ void testImportAnnotations(MlirContext ctx) {
bool succeeded = firrtlImportAnnotationsFromJSONRaw(
ctx, mlirStringRefCreateFromCString(rawAnnotationsJSON),
&rawAnnotationsAttr);
(void)succeeded;
assert(succeeded);
mlirOperationSetAttributeByName(
firCircuit, mlirStringRefCreateFromCString("rawAnnotations"),
Expand Down Expand Up @@ -226,11 +227,10 @@ void testTypeGetMaskType(MlirContext ctx) {
.type = firrtlTypeGetUInt(ctx, 1),
},
};
MlirType lhsBundle =
firrtlTypeGetBundle(ctx, ARRAY_SIZE(lhsFields), lhsFields);
MlirType rhsBundle =
firrtlTypeGetBundle(ctx, ARRAY_SIZE(rhsFields), rhsFields);
assert(mlirTypeEqual(firrtlTypeGetMaskType(lhsBundle), rhsBundle));
assert(mlirTypeEqual(
firrtlTypeGetMaskType(
firrtlTypeGetBundle(ctx, ARRAY_SIZE(lhsFields), lhsFields)),
firrtlTypeGetBundle(ctx, ARRAY_SIZE(rhsFields), rhsFields)));
}

int main(void) {
Expand Down

0 comments on commit bac37a3

Please sign in to comment.