Skip to content

[NFC][MLIR] Add {} for else when if body has {} #139422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mlir/lib/Analysis/Presburger/IntegerRelation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2398,8 +2398,9 @@ bool IntegerRelation::removeDuplicateConstraints() {
addEquality(getInequality(k));
removeInequality(k);
removeInequality(l);
} else
} else {
*this = getEmpty(getSpace());
}
break;
}

Expand Down
3 changes: 2 additions & 1 deletion mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,8 +896,9 @@ class VectorReductionOpConversion
} else if (kind == vector::CombiningKind::MAXNUMF) {
result = createFPReductionComparisonOpLowering<LLVM::vector_reduce_fmax>(
rewriter, loc, llvmType, operand, acc, fmf);
} else
} else {
return failure();
}

rewriter.replaceOp(reductionOp, result);
return success();
Expand Down
3 changes: 2 additions & 1 deletion mlir/lib/Dialect/Affine/Analysis/LoopAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,9 @@ std::optional<uint64_t> mlir::affine::getConstantTripCount(AffineForOp forOp) {
std::min(*tripCount, static_cast<uint64_t>(constExpr.getValue()));
else
tripCount = constExpr.getValue();
} else
} else {
return std::nullopt;
}
}
return tripCount;
}
Expand Down
3 changes: 2 additions & 1 deletion mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4266,8 +4266,9 @@ void ElementwiseOp::regionBuilder(ImplicitLocOpBuilder &b, Block &block,
result = helper.buildTernaryFn(kind.ternaryFn, block.getArgument(0),
block.getArgument(1), block.getArgument(2));

} else
} else {
assert(false && "found unhandled category in elemwise");
}

yields.push_back(result);
helper.yieldOutputs(yields);
Expand Down
3 changes: 2 additions & 1 deletion mlir/lib/Dialect/Mesh/Interfaces/ShardingInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ checkOperandAffineExprRecursively(AffineExpr expr,
} else if (rhs.getKind() == AffineExprKind::DimId &&
lhs.getKind() == AffineExprKind::Constant) {
dimExpr = rhs;
} else
} else {
return failure();
}
unsigned position = cast<AffineDimExpr>(dimExpr).getPosition();
if ((size_t)position >= seenIds.size() || seenIds[position])
return failure();
Expand Down
3 changes: 2 additions & 1 deletion mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,9 @@ static ParseResult parseClauseWithRegionArgs(
parser.parseInteger(mapIndicesVec.emplace_back()) ||
parser.parseRSquare())
return failure();
} else
} else {
mapIndicesVec.push_back(-1);
}
}

return success();
Expand Down
3 changes: 2 additions & 1 deletion mlir/lib/Dialect/SCF/TransformOps/SCFTransformOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,10 @@ transform::LoopFuseSiblingOp::apply(transform::TransformRewriter &rewriter,
} else if (isForallWithIdenticalConfiguration(target, source)) {
fusedLoop = fuseIndependentSiblingForallLoops(
cast<scf::ForallOp>(target), cast<scf::ForallOp>(source), rewriter);
} else
} else {
return emitSilenceableFailure(target->getLoc())
<< "operations cannot be fused";
}

assert(fusedLoop && "failed to fuse operations");

Expand Down
3 changes: 2 additions & 1 deletion mlir/lib/Dialect/SCF/Transforms/LoopPipelining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,9 @@ scf::ForOp LoopPipelinerInternal::createKernelLoop(
[maxStage - defStage->second];
assert(valueVersion);
newLoopArg.push_back(valueVersion);
} else
} else {
newLoopArg.push_back(forOp.getInitArgs()[retVal.index()]);
}
}
for (auto escape : crossStageValues) {
LiverangeInfo &info = escape.second;
Expand Down
3 changes: 2 additions & 1 deletion mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ static bool haveNoReadsAfterWriteExceptSameIndex(
OperationEquivalence::Flags::IgnoreLocations)) {
return WalkResult::interrupt();
}
} else
} else {
return WalkResult::interrupt();
}
}
}
return WalkResult::advance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ void LayoutInfo::print(raw_ostream &os) const {
laneLayout.print(os);
os << ", lane_data: ";
laneData.print(os);
} else
} else {
os << "Not assigned.";
}
}

LayoutInfo LayoutInfo::meet(const LayoutInfo &lhs, const LayoutInfo &rhs) {
Expand Down
3 changes: 2 additions & 1 deletion mlir/lib/ExecutionEngine/SyclRuntimeWrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ static sycl::device getDefaultDevice() {
return syclDevice;
}
throw std::runtime_error("getDefaultDevice failed");
} else
} else {
return syclDevice;
}
}

static sycl::context getDefaultContext() {
Expand Down
3 changes: 2 additions & 1 deletion mlir/lib/Target/LLVM/NVVM/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,10 @@ NVPTXSerializer::compileToBinaryNVPTX(const std::string &ptxCode) {
nvPTXCompilerGetErrorLog(compiler, log.data()));
emitError(loc) << "NVPTX compiler invocation failed, error log: "
<< log.data();
} else
} else {
emitError(loc) << "NVPTX compiler invocation failed with error code: "
<< status;
}
return std::nullopt;
}

Expand Down
3 changes: 2 additions & 1 deletion mlir/lib/Target/LLVMIR/ModuleImport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2680,8 +2680,9 @@ ModuleImport::convertParameterAttribute(llvm::AttributeSet llvmParamAttrs,
const llvm::ConstantRange &value = llvmAttr.getValueAsConstantRange();
mlirAttr = builder.getAttr<LLVM::ConstantRangeAttr>(value.getLower(),
value.getUpper());
} else
} else {
llvm_unreachable("unexpected parameter attribute kind");
}
paramAttrs.push_back(builder.getNamedAttr(mlirName, mlirAttr));
}

Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Transforms/OpStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ void PrintOpStatsPass::runOnOperation() {
// Compute the operation statistics for the currently visited operation.
getOperation()->walk(
[&](Operation *op) { ++opCount[op->getName().getStringRef()]; });
if (printAsJSON) {
if (printAsJSON)
printSummaryInJSON();
} else
else
printSummary();
markAllAnalysesPreserved();
}
Expand Down
8 changes: 4 additions & 4 deletions mlir/test/Dialect/SCF/canonicalize.mlir
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if you really want to do these modifications in the tests. I suggest to abstain from touching these

Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func.func @one_unused(%cond: i1) -> (index) {
// CHECK: call @side_effect() : () -> ()
// CHECK: [[C1:%.*]] = "test.value1"
// CHECK: scf.yield [[C1]] : index
// CHECK: } else
// CHECK: } else {
// CHECK: [[C3:%.*]] = "test.value3"
// CHECK: scf.yield [[C3]] : index
// CHECK: }
Expand Down Expand Up @@ -185,12 +185,12 @@ func.func @nested_unused(%cond1: i1, %cond2: i1) -> (index) {
// CHECK: call @side_effect() : () -> ()
// CHECK: [[C1:%.*]] = "test.value1"
// CHECK: scf.yield [[C1]] : index
// CHECK: } else
// CHECK: } else {
// CHECK: [[C3:%.*]] = "test.value3"
// CHECK: scf.yield [[C3]] : index
// CHECK: }
// CHECK: scf.yield [[V1]] : index
// CHECK: } else
// CHECK: } else {
// CHECK: [[C1_2:%.*]] = "test.value1_2"
// CHECK: scf.yield [[C1_2]] : index
// CHECK: }
Expand All @@ -215,7 +215,7 @@ func.func @all_unused(%cond: i1) {
// CHECK-LABEL: func @all_unused
// CHECK: scf.if %{{.*}} {
// CHECK: call @side_effect() : () -> ()
// CHECK: } else
// CHECK: } else {
// CHECK: call @side_effect() : () -> ()
// CHECK: }
// CHECK: return
Expand Down
3 changes: 2 additions & 1 deletion mlir/test/lib/Dialect/Test/TestOpDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,9 @@ void TestReflectBoundsOp::inferResultRanges(
unsigned bitwidth = intTy.getWidth();
sIntTy = b.getIntegerType(bitwidth, /*isSigned=*/true);
uIntTy = b.getIntegerType(bitwidth, /*isSigned=*/false);
} else
} else {
sIntTy = uIntTy = type;
}

setUminAttr(b.getIntegerAttr(uIntTy, range.umin()));
setUmaxAttr(b.getIntegerAttr(uIntTy, range.umax()));
Expand Down