Lower typed inputs in expression-form inline assembly without internal errors
- Dominant language
- Rust
- Stars
- 53
- Forks
- 16
- Avg merge
- 4h 22m
- Merged PRs (30d)
- 46
Description
## Reproduction
The following program passes `wavec check` but fails `wavec build --emit=obj` on Linux amd64:
```wave
fun main() -> i32 {
var source: i32 = 7;
var sink: i64 = 0;
var result: i64 = asm {
"mov rax, rdi"
in("rdi") source as i64
out("rax") sink
clobber("nostack")
};
return (result - 7) as i32;
}
```
Actual diagnostic:
```text
error[E9001]: compiler internal error during code generation (object-emission)
Unsupported asm input expr: Cast { expr: Variable("source"), target_type: Int(64) }
compiler panic location: llvm/src/expression/rvalue/asm.rs:258:18
```
## Cause and scope
#502 fixed typed input evaluation for **statement** assembly. The expression path in `llvm/src/expression/rvalue/asm.rs::eval_asm_in_expr` retains a separate restricted AST match and decimal-only literal handling. This is a remaining expression-form defect, not a request to revert the statement fix from #491.
## Acceptance
- [ ] Use normal typed expression lowering for expression-form asm operands, preserving signedness and evaluation order.
- [ ] Cover casts, radix literals, fields, arithmetic and side-effecting call inputs accepted by the frontend.
- [ ] Keep output constraints, explicit clobbers and the expression form's single-result restrictions enforced.
- [ ] Add `check` plus IR/object and executable regressions for valid inputs, including negative narrow values.
- [ ] Retain statement-form coverage and feature-gate architecture-specific tests correctly.
The small example should build and return zero. #397 covers malformed asm parser diagnostics; #409 is the broader backend error-channel migration. This is a concrete valid-program lowering bug and is not labeled good first issue because operand widths and side effects require care.
Audited on canonical master `0c67f4cc0c3946cbf708c11ef79db927ec8f054e` (same source tree as #502 head). Executable reproductions used Fedora Linux amd64, Wave `0.2.1-pre-beta-dev`, LLVM 21.1.8.
Contributor guide
Research direction
Start in llvm/src/expression/rvalue/asm.rs at eval_asm_in_expr and compare its expression-form handling with the typed input evaluation added for statement assembly in #502. Run the supplied program with wavec check and wavec build --emit=obj, then add check, IR/object, and executable regressions covering the listed operand forms while retaining statement coverage and architecture gating.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux, rust
- Domain
- compilers, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100