diff --git a/mlir/lib/Conversion/ConvertToLLVM/ConvertToLLVMPass.cpp b/mlir/lib/Conversion/ConvertToLLVM/ConvertToLLVMPass.cpp index 764ad2e766c73..ab558d9a93be8 100644 --- a/mlir/lib/Conversion/ConvertToLLVM/ConvertToLLVMPass.cpp +++ b/mlir/lib/Conversion/ConvertToLLVM/ConvertToLLVMPass.cpp @@ -174,7 +174,9 @@ struct DynamicConvertToLLVM : public ConvertToLLVMPassInterface { target.addLegalDialect(); // Get the data layout analysis. const auto &dlAnalysis = manager.getAnalysis(); - LLVMTypeConverter typeConverter(context, &dlAnalysis); + const DataLayout &dl = dlAnalysis.getAtOrAbove(op); + LowerToLLVMOptions options(context, dl); + LLVMTypeConverter typeConverter(context, options, &dlAnalysis); // Configure the conversion with dialect level interfaces. for (ConvertToLLVMPatternInterface *iface : *interfaces) diff --git a/mlir/test/Conversion/FuncToLLVM/func-to-llvm-datalayout.mlir b/mlir/test/Conversion/FuncToLLVM/func-to-llvm-datalayout.mlir new file mode 100644 index 0000000000000..36c3cf39d3822 --- /dev/null +++ b/mlir/test/Conversion/FuncToLLVM/func-to-llvm-datalayout.mlir @@ -0,0 +1,39 @@ +// RUN: mlir-opt --convert-to-llvm="filter-dialects=func dynamic=true" --split-input-file %s + + +// CHECK-LABEL: llvm.func @test_default_index +// CHECK-SAME: (%{{.*}}: i64) -> i64 +func.func private @test_default_index(%arg0: index) -> index + +// ----- + +// CHECK-LABEL: module attributes {dlti.dl_spec = #dlti.dl_spec< +// CHECK-SAME: #dlti.dl_entry +// CHECK-SAME: >} +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry>} { + // CHECK-LABEL: llvm.func @test_32bit_index + // CHECK-SAME: (%{{.*}}: i32) -> i32 + func.func private @test_32bit_index(%arg0: index) -> index +} + +// ----- + +// CHECK-LABEL: module attributes {dlti.dl_spec = #dlti.dl_spec< +// CHECK-SAME: #dlti.dl_entry +// CHECK-SAME: >} +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry>} { + // CHECK-LABEL: llvm.func @test_64bit_index + // CHECK-SAME: (%{{.*}}: i64) -> i64 + func.func private @test_64bit_index(%arg0: index) -> index +} + +// ----- + +// CHECK-LABEL: module attributes {dlti.dl_spec = #dlti.dl_spec< +// CHECK-SAME: #dlti.dl_entry +// CHECK-SAME: >} +module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry>} { + // CHECK-LABEL: llvm.func @test_16bit_index + // CHECK-SAME: (%{{.*}}: i16) -> i16 + func.func private @test_16bit_index(%arg0: index) -> index +}