Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/compile: liveness analysis conservative for compound objects #28626
The compiler reports (with
The generated code contains:
Even though the code looks like it reads the length first, the compiler postpones that read until after the
Two solutions come to mind. One is to track liveness of individual pointer fields of variables, instead of whole variables. That would work, but could be expensive for variables which have lots of pointer fields. It also isn't possible to do precisely for variables which are arrays of pointers and have non-constant indexes.
The other solution is to ignore reads of scalars when doing the liveness analysis, as the results of the liveness analysis are only used by the GC. This is more of a hack but would be a simpler fix for the code in this issue.
It's not trivial to check the scalarness of a read in plive.go.
If we could extract the offset+size of the read, we could check in the type of the variable directly.