google / google/xls

OOM when type checking with array slices

Open
#4,162 0 comments 0 reactions 0 assignees View on GitHub
dslx
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

**Describe the bug**
This is related to #4160 and #4161. I don't actually know what the root cause is.

If you write the following code:

```
pub fn array_rotl_fixed
(x: bits[ELEMENT_SZ][ARRAY_SZ]) -> bits[ELEMENT_SZ][ARRAY_SZ] {
const K = K % ARRAY_SZ;
const if K == 0 || K == ARRAY_SZ {
x
} else {
let left = array_slice(x, u32:0, zero!());
let right = array_slice(x, K, zero!());
array_rev(array_rev(left) ++ array_rev(right))
}
}

#[test]
fn array_rotl_fixed_test() {
let x = u8[4]:[0, 1, 2, 3];
assert_eq(array_rotl_fixed<1>(x), u8[4]:[1, 2, 3, 0]);
assert_eq(array_rotl_fixed<2>(x), u8[4]:[2, 3, 0, 1]);
assert_eq(array_rotl_fixed<4>(x), u8[4]:[0, 1, 2, 3]);
assert_eq(array_rotl_fixed<5>(x), u8[4]:[1, 2, 3, 0]);
}
```

we get an OOM at 12G of memory executing ParseAndTypeCheckDSLXSourceFile command.

**To Reproduce**
See above.

**Expected behavior**
An error message for what is wrong.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.