diff --git a/flang/lib/Optimizer/CodeGen/TypeConverter.h b/flang/lib/Optimizer/CodeGen/TypeConverter.h --- a/flang/lib/Optimizer/CodeGen/TypeConverter.h +++ b/flang/lib/Optimizer/CodeGen/TypeConverter.h @@ -73,6 +73,11 @@ // Convert to i32 because of LLVM GEP indexing restriction. return mlir::IntegerType::get(field.getContext(), 32); }); + addConversion([&](fir::LenType field) { + // Get size of len paramter from the descriptor. + return getModel()( + &getContext()); + }); addConversion( [&](fir::ComplexType cmplx) { return convertComplexType(cmplx); }); addConversion( diff --git a/flang/test/Fir/types-to-llvm.fir b/flang/test/Fir/types-to-llvm.fir --- a/flang/test/Fir/types-to-llvm.fir +++ b/flang/test/Fir/types-to-llvm.fir @@ -293,3 +293,11 @@ func private @foo0(%arg0: !fir.field) // CHECK-LABEL: foo0 // CHECK-SAME: i32 + +// ----- + +// Test `!fir.len` conversion. + +func private @foo0(%arg0: !fir.len) +// CHECK-LABEL: foo0 +// CHECK-SAME: i64