[all-commits] [llvm/llvm-project] 428b9b: [mlir] Align num elements type to LLVM ArrayType (...
Valentin Clement (バレンタイン クレメン) via All-commits
all-commits at lists.llvm.org
Wed May 29 13:06:06 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 428b9be6484404183f51de08d2503570bade2287
https://github.com/llvm/llvm-project/commit/428b9be6484404183f51de08d2503570bade2287
Author: Valentin Clement (バレンタイン クレメン) <clementval at gmail.com>
Date: 2024-05-29 (Wed, 29 May 2024)
Changed paths:
M flang/test/Fir/convert-to-llvm.fir
M mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.td
M mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
M mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
M mlir/test/Target/LLVMIR/llvmir.mlir
Log Message:
-----------
[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.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list