Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing error message with useless spill #778

Open
eponier opened this issue Apr 4, 2024 · 2 comments
Open

Confusing error message with useless spill #778

eponier opened this issue Apr 4, 2024 · 2 comments

Comments

@eponier
Copy link
Contributor

eponier commented Apr 4, 2024

The compilation of this program

export fn main () -> reg u64 {
  reg u64 res;
  res = 0;
  () = #spill(res);
  return res;
}

fails with error

compilation error:
variable allocation: variable “res.167” (declared at "file.jazz", line 4 (14-17)) may not be initialized

The spill is useless, but should the compiler fail? And the error message is wrong, the variable is not used, but it is initialized.

Using AT_none in the code generated by spill_prog (as hinted by the FIXME in lower_spill.v) fixes the issue. It enables the compiler to remove the useless spills. Is this the correct fix?

@eponier
Copy link
Contributor Author

eponier commented Apr 5, 2024

Debugging with Benjamin, we discovered that we don't need #spill to get the error.

export fn main () -> reg u64 {
  reg u64 res;
  stack u64 s;
  res = 0;
  s = #MOV(res);
  return res;
}

There are two orthogonal problems:

  • variables not removed by dead code elimination (because they appear in an instruction with tag AT_keep) but otherwise not used make varalloc fail
  • spill_prog produces such instructions, probably we don't want that but this is orthogonal

@vbgl
Copy link
Member

vbgl commented Apr 5, 2024

The first problem is duplicate of #680.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants