[Mlir-commits] [mlir] 03e7ce9 - [MLIR] Apply clang-tidy fixes for llvm-else-after-return in ModuleTranslation.cpp (NFC)
Mehdi Amini
llvmlistbot at llvm.org
Mon Oct 27 22:24:40 PDT 2025
Author: Mehdi Amini
Date: 2025-10-27T22:22:54-07:00
New Revision: 03e7ce95a605f2792c06e2cbe0ed968224c8944c
URL: https://github.com/llvm/llvm-project/commit/03e7ce95a605f2792c06e2cbe0ed968224c8944c
DIFF: https://github.com/llvm/llvm-project/commit/03e7ce95a605f2792c06e2cbe0ed968224c8944c.diff
LOG: [MLIR] Apply clang-tidy fixes for llvm-else-after-return in ModuleTranslation.cpp (NFC)
Added:
Modified:
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index 2acbd036a020a..64e3c5f085bb3 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -649,40 +649,38 @@ llvm::Constant *mlir::LLVM::detail::getLLVMConstant(
auto *arrayType = llvm::ArrayType::get(elementType, numElements);
if (child->isZeroValue() && !elementType->isFPOrFPVectorTy()) {
return llvm::ConstantAggregateZero::get(arrayType);
- } else {
- if (llvm::ConstantDataSequential::isElementTypeCompatible(
- elementType)) {
- // TODO: Handle all compatible types. This code only handles integer.
- if (isa<llvm::IntegerType>(elementType)) {
- if (llvm::ConstantInt *ci = dyn_cast<llvm::ConstantInt>(child)) {
- if (ci->getBitWidth() == 8) {
- SmallVector<int8_t> constants(numElements, ci->getZExtValue());
- return llvm::ConstantDataArray::get(elementType->getContext(),
- constants);
- }
- if (ci->getBitWidth() == 16) {
- SmallVector<int16_t> constants(numElements, ci->getZExtValue());
- return llvm::ConstantDataArray::get(elementType->getContext(),
- constants);
- }
- if (ci->getBitWidth() == 32) {
- SmallVector<int32_t> constants(numElements, ci->getZExtValue());
- return llvm::ConstantDataArray::get(elementType->getContext(),
- constants);
- }
- if (ci->getBitWidth() == 64) {
- SmallVector<int64_t> constants(numElements, ci->getZExtValue());
- return llvm::ConstantDataArray::get(elementType->getContext(),
- constants);
- }
+ }
+ if (llvm::ConstantDataSequential::isElementTypeCompatible(elementType)) {
+ // TODO: Handle all compatible types. This code only handles integer.
+ if (isa<llvm::IntegerType>(elementType)) {
+ if (llvm::ConstantInt *ci = dyn_cast<llvm::ConstantInt>(child)) {
+ if (ci->getBitWidth() == 8) {
+ SmallVector<int8_t> constants(numElements, ci->getZExtValue());
+ return llvm::ConstantDataArray::get(elementType->getContext(),
+ constants);
+ }
+ if (ci->getBitWidth() == 16) {
+ SmallVector<int16_t> constants(numElements, ci->getZExtValue());
+ return llvm::ConstantDataArray::get(elementType->getContext(),
+ constants);
+ }
+ if (ci->getBitWidth() == 32) {
+ SmallVector<int32_t> constants(numElements, ci->getZExtValue());
+ return llvm::ConstantDataArray::get(elementType->getContext(),
+ constants);
+ }
+ if (ci->getBitWidth() == 64) {
+ SmallVector<int64_t> constants(numElements, ci->getZExtValue());
+ return llvm::ConstantDataArray::get(elementType->getContext(),
+ constants);
}
}
}
+ }
// std::vector is used here to accomodate large number of elements that
// exceed SmallVector capacity.
std::vector<llvm::Constant *> constants(numElements, child);
return llvm::ConstantArray::get(arrayType, constants);
- }
}
}
More information about the Mlir-commits
mailing list