[Mlir-commits] [mlir] 34312f1 - [mlir][LLVM] Support opaque pointers in data layout entries

Markus Böck llvmlistbot at llvm.org
Mon Apr 25 00:15:08 PDT 2022


Author: Markus Böck
Date: 2022-04-25T09:14:33+02:00
New Revision: 34312f1f0c4f56ae78577783ec62bee3fb5dab90

URL: https://github.com/llvm/llvm-project/commit/34312f1f0c4f56ae78577783ec62bee3fb5dab90
DIFF: https://github.com/llvm/llvm-project/commit/34312f1f0c4f56ae78577783ec62bee3fb5dab90.diff

LOG: [mlir][LLVM] Support opaque pointers in data layout entries

This is likely preferable to having it crash if one were to specify an opaque pointer type, and the actual element type is unused either way.

Differential Revision: https://reviews.llvm.org/D124334

Added: 
    

Modified: 
    mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
    mlir/test/Dialect/LLVMIR/layout.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
index 3cdcb3285e9ed..4dbfc8293a051 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
@@ -340,7 +340,7 @@ LogicalResult LLVMPointerType::verifyEntries(DataLayoutEntryListRef entries,
              << " to be a dense integer elements attribute with 3 or 4 "
                 "elements";
     }
-    if (!key.getElementType().isInteger(8)) {
+    if (key.getElementType() && !key.getElementType().isInteger(8)) {
       return emitError(loc) << "unexpected layout attribute for pointer to "
                             << key.getElementType();
     }

diff  --git a/mlir/test/Dialect/LLVMIR/layout.mlir b/mlir/test/Dialect/LLVMIR/layout.mlir
index 12b6c61fc0664..af471bb587ccd 100644
--- a/mlir/test/Dialect/LLVMIR/layout.mlir
+++ b/mlir/test/Dialect/LLVMIR/layout.mlir
@@ -46,7 +46,8 @@ module {
 
 module attributes { dlti.dl_spec = #dlti.dl_spec<
   #dlti.dl_entry<!llvm.ptr<i8>, dense<[32, 32, 64]> : vector<3xi32>>,
-  #dlti.dl_entry<!llvm.ptr<i8, 5>, dense<[64, 64, 64]> : vector<3xi32>>
+  #dlti.dl_entry<!llvm.ptr<i8, 5>, dense<[64, 64, 64]> : vector<3xi32>>,
+  #dlti.dl_entry<!llvm.ptr<4>, dense<[32, 64, 64]> : vector<3xi32>>
 >} {
   // CHECK: @spec
   func.func @spec() {
@@ -85,6 +86,11 @@ module attributes { dlti.dl_spec = #dlti.dl_spec<
     // CHECK: preferred = 8
     // CHECK: size = 4
     "test.data_layout_query"() : () -> !llvm.ptr<3>
+    // CHECK: alignment = 8
+	// CHECK: bitsize = 32
+    // CHECK: preferred = 8
+    // CHECK: size = 4
+	"test.data_layout_query"() : () -> !llvm.ptr<4>
     return
   }
 }


        


More information about the Mlir-commits mailing list