Can't find free registers #36
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Error:
panic: no free registers
goroutine 67 [running]:
git.urbach.dev/cli/q/src/codegen.(*Function).findFreeRegister(0xc0001023d0, 0xc0003f1118)
Code:
This is called register spilling and it's on the roadmap.
In the meantime, you can try to reduce the variables that are alive at the same time.
Here are 3 tips:
1:
This could potentially avoid register spilling (a stack allocation) if you rewrite it to let the variables die early:
However that only works for this particular case. In reality you'd want all of them to be alive.
2:
Sometimes splitting a big function into multiple functions also works, although (!) the reverse effect is also possible. So you have to apply this logic:
Does the function already call other functions?
3:
Another way to reduce the number of live values is to just hold a single pointer value to a struct in memory.
Your pointer lives in a single register and gives you access to everything you need.
This is basically manual spilling by using
new(Struct).Thank for the explanation. Since this was alredy on roadmap issue I think we can close this issue