google / google/xls

Bad error diagnostics (internal RET_CHECK failure) for parametric top

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

Description

**Describe the bug**
When trying to IR convert a parametric top, you can get `XLS_RET_CHECK` failures that don't do a good job of explaining what is actionable from the user.

Examples:

* `Error: INTERNAL: XLS_RET_CHECK failure (xls/dslx/ir_convert/function_converter.cc:2917) parametric_value.has_value()`
* `Error: INTERNAL: XLS_RET_CHECK failure (xls/dslx/ir_convert/extract_conversion_order.cc:364) callee_info->type_info != nullptr`

**To Reproduce**

For the first error, borrowing an XLS example:

```
fn muladd(a: u8, b: u8, c: u8) -> u8 {
a * b + c
}

#[test]
fn muladd_test() {
assert_eq(muladd(u8:1, u8:2, u8:3), u8:5);
assert_eq(muladd(u8:4, u8:4, u8:4), u8:20);
assert_eq(muladd(u8:127, u8:2, u8:2), u8:0);
}
```

I'm not totally sure how to generate a repro for the second, as I can't share the actual code, but the stack trace is:

```
0x562b5152f721: xabsl::StatusBuilder::CreateStatusAndConditionallyLog()
0x562b50e4794e: xls::dslx::InvocationVisitor::HandleInvocation()
0x562b50e46cad: xls::dslx::InvocationVisitor::HandleInvocation()
0x562b50e47c41: xls::dslx::InvocationVisitor::HandleMatch()
0x562b50e47b98: xls::dslx::InvocationVisitor::HandleLet()
0x562b50e46936: xls::dslx::InvocationVisitor::HandleStatementBlock()
0x562b50e45fd3: xls::dslx::GetCallees()
0x562b50e428b7: xls::dslx::AddToReady()
0x562b50e422ac: xls::dslx::GetOrderForEntry()
0x562b50e36975: xls::dslx::ConvertOneFunctionIntoPackageInternal<>()
0x562b50e38748: xls::dslx::ConvertFilesToPackage()
0x562b50e31a81: main
0x7f06804df3d4: __libc_start_main
0x562b50e3102a: _start
Error: INTERNAL: XLS_RET_CHECK failure (xls/dslx/ir_convert/extract_conversion_order.cc:364) callee_info->type_info != nullptr
=== Source Location Trace: ===
xls/common/status/status_builder.cc:197
xls/dslx/ir_convert/extract_conversion_order.cc:364
xls/dslx/ir_convert/extract_conversion_order.cc:288
xls/dslx/ir_convert/extract_conversion_order.cc:388
xls/dslx/ir_convert/extract_conversion_order.cc:381
xls/dslx/ir_convert/extract_conversion_order.cc:226
xls/dslx/ir_convert/extract_conversion_order.cc:594
xls/dslx/ir_convert/extract_conversion_order.cc:640
xls/dslx/ir_convert/extract_conversion_order.cc:830
xls/dslx/ir_convert/ir_converter.cc:446
xls/dslx/ir_convert/ir_converter.cc:583
xls/dslx/ir_convert/ir_converter.cc:653
xls/dslx/ir_convert/ir_converter_main.cc:141
```

**Expected behavior**
The error should point to the lack of support for parametric tops (https://github.com/google/xls/issues/2527).

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.