[Mlir-commits] [mlir] [MLIR][LLVMIR] Fixing how ZeroInitializers are converted to undef instead of constant zero type when importing from LLVMIR to llvm.mlir (PR #171107)
Tobias Gysi
llvmlistbot at llvm.org
Mon Dec 8 07:49:24 PST 2025
================
@@ -1765,31 +1765,33 @@ FailureOr<Value> ModuleImport::convertConstant(llvm::Constant *constant) {
return lookupValue(inst);
}
+ // Convert zero-initialized aggregates to ZeroOp.
+ if (auto *aggregateZero = dyn_cast<llvm::ConstantAggregateZero>(constant)) {
+ Type type = convertType(aggregateZero->getType());
+ return ZeroOp::create(builder, loc, type).getResult();
+ }
+
// Convert aggregate constants.
- if (isa<llvm::ConstantAggregate>(constant) ||
- isa<llvm::ConstantAggregateZero>(constant)) {
+ if (isa<llvm::ConstantAggregate>(constant)) {
----------------
gysit wrote:
```suggestion
if (auto *constAgg = dyn_cast<llvm::ConstantAggregate>(constant)) {
```
nit: maybe use a dyncast here and use constAgg directly below?
https://github.com/llvm/llvm-project/pull/171107
More information about the Mlir-commits
mailing list