Commit 3f341ee
[CIR][Lowering] Fix static array lowering (#838)
Consider the following code snippet `test.c`:
```
int test(int x) {
static int arr[10] = {0, 1, 0, 0};
return arr[x];
}
```
When lowering from CIR to LLVM using `bin/clang test.c -Xclang -fclangir
-Xclang -emit-llvm -S -o -` It produces:
```
clangir/mlir/lib/IR/BuiltinAttributes.cpp:1015: static mlir::DenseElementsAttr mlir::DenseElementsAttr::get(mlir::ShapedType, llvm::ArrayRef<llvm::APInt>): Assertion `hasSameElementsOrSplat(type, values)' failed.
```
I traced the bug back to `Lowering/LoweringHelpers.cpp` where we fill
trailing zeros, and I believe this PR does it the right way. I have also
added a very simple test for verification.1 parent 5051e46 commit 3f341ee
File tree
2 files changed
+9
-1
lines changed- clang
- lib/CIR/Lowering
- test/CIR/Lowering
2 files changed
+9
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
0 commit comments