[mlir] Align num elements type to LLVM ArrayType (#93230)
MLIR LLMArrayType is using `unsigned` for the number of elements while LLVM ArrayType is using `uint64_t` https://github.com/llvm/llvm-project/blob/4ae896fe979b7db501cabde4b6b3504478958682/llvm/include/llvm/IR/DerivedTypes.h#L377 This leads to silent truncation when we use it for globals in flang. ``` program test integer(8), parameter :: large = 2**30 real, dimension(large) :: bigarray common /c/ bigarray bigarray(999) = 666 end ``` The above program would result in a segfault since the global would be of size 0 because of the silent truncation. ``` fir.global common @c_(dense<0> : vector<4294967296xi8>) : !fir.array<4294967296xi8> ``` became ``` llvm.mlir.global common @c_(dense<0> : vector<4294967296xi8>) {addr_space = 0 : i32} : !llvm.array<0 x i8> ``` This patch updates the definition of MLIR ArrayType to take `uint64_t` as argument of the number of elements to be compatible with LLVM.
parent
4e67f451
Please register or sign in to comment