Skip to content

Commit 9073ddb

Browse files
committed
use structured bindings and simplify dyn_cast
1 parent 3086e55 commit 9073ddb

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

mlir/lib/Target/LLVMIR/ModuleImport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ ModuleImport::convertGlobalCtorsAndDtors(llvm::GlobalVariable *globalVar) {
10801080

10811081
SmallVector<Attribute> funcs;
10821082
SmallVector<int32_t> priorities;
1083-
if (auto caInit = dyn_cast<llvm::ConstantArray>(initializer)) {
1083+
if (isa<llvm::ConstantArray>(initializer)) {
10841084
for (llvm::Value *operand : initializer->operands()) {
10851085
auto *aggregate = dyn_cast<llvm::ConstantAggregate>(operand);
10861086
if (!aggregate || aggregate->getNumOperands() != 3)

mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,13 +1281,11 @@ LogicalResult ModuleTranslation::convertGlobalsAndAliases() {
12811281
: llvm::zip(dtorOp.getDtors(), dtorOp.getPriorities());
12821282
auto appendGlobalFn =
12831283
ctorOp ? llvm::appendToGlobalCtors : llvm::appendToGlobalDtors;
1284-
for (auto symbolAndPriority : range) {
1285-
llvm::Function *f = lookupFunction(
1286-
cast<FlatSymbolRefAttr>(std::get<0>(symbolAndPriority)).getValue());
1287-
appendGlobalFn(
1288-
*llvmModule, f,
1289-
cast<IntegerAttr>(std::get<1>(symbolAndPriority)).getInt(),
1290-
/*Data=*/nullptr);
1284+
for (const auto &[sym, prio] : range) {
1285+
llvm::Function *f =
1286+
lookupFunction(cast<FlatSymbolRefAttr>(sym).getValue());
1287+
appendGlobalFn(*llvmModule, f, cast<IntegerAttr>(prio).getInt(),
1288+
/*Data=*/nullptr);
12911289
}
12921290
}
12931291
}

0 commit comments

Comments
 (0)