[Mlir-commits] [mlir] [MLIR] Add index bitwidth to the DataLayout (PR #85927)

Tobias Gysi llvmlistbot at llvm.org
Wed Mar 20 08:13:33 PDT 2024


================
@@ -280,10 +280,9 @@ translateDataLayout(DataLayoutSpecInterface attribute,
               uint64_t abi = dataLayout.getTypeABIAlignment(type) * 8u;
               uint64_t preferred =
                   dataLayout.getTypePreferredAlignment(type) * 8u;
-              layoutStream << size << ":" << abi << ":" << preferred;
-              if (std::optional<uint64_t> index = extractPointerSpecValue(
-                      entry.getValue(), PtrDLEntryPos::Index))
-                layoutStream << ":" << *index;
+              uint64_t index = *dataLayout.getTypeIndexBitwidth(type);
----------------
gysit wrote:

It goes through the data layout interface of pointer type which has different execution path but as a last result will return the default pointer size. There is also a test where we check that the index bitwidth is exported if the pointer does not specify any (data-layout.mlir).

If we want to be on the safe side I can keep the if but I do not see a code path where this ever executes (until I am proven wrong...).

 Do you understand why there is ptrType and type in this Case of the type switch? I think ptrType could just be renamed to type?

https://github.com/llvm/llvm-project/pull/85927


More information about the Mlir-commits mailing list