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
cmd/compile: principled line numbering #16943
Comments
For what it's worth, your two rules are exactly what I do in gccgo (which does have column information). |
SGTM. Line numbers have never been sacrosanct; preserving the quirks of existing behavior is not a priority. Matching gccgo would be a nice bonus. I'm curious how well the SSA handling of line numbers preserves your rules. One small data point I'd like to see is binary size before/after. The pclntab is the single largest component of binaries, and its size is tied directly to line-numbering decisions in the compiler. I don't expect much change, but it'd be good to keep an eye on it. |
Cool.
I am too. At least optimizations are inherently lossy about source information like line numbers, and users seem to understand/appreciate that. Also, since the current line numbering is often so ad hoc, I don't think there's any particular rush to implement/guarantee these rules. My goal with this issue is more to agree on a long-term ideal to strive towards.
Ack, I don't expect much change either, but I'll keep an eye out. |
Something to consider in optimizer-land might be to notice which instruction "commits" a line, and then arrange that all the preceding instructions match it, up to the previous commit. This fails for lines with more than one store, but such is life -- plenty of lines become visible with a single store. Single-stepping in a debugger will be slightly less confusing. |
I was also thinking about ways to do a more concise job of recording line On Fri, Sep 2, 2016 at 7:55 AM, dr2chase notifications@github.com wrote:
|
On 2 September 2016 at 11:25, Keith Randall notifications@github.com
I think that's a good approach. There is no perfect answer for many |
CL https://golang.org/cl/37017 mentions this issue. |
Currently, cmd/compile assigns line numbers somewhat ad-hocly based on whatever the global
lineno
value happens to be set at when it callsNod
. With the new parser, @griesemer and I want to do a better job at this. I think this will be especially useful if/once we start tracking/reporting column information; e.g., in error messages for #10324, or in export data for something like golang.org/cl/22936.I want to propose two simple rules:
var x int = 3
, we associate the newly declared int variable with the position of thex
identifier.x + y
is associated with the+
token, notx
ory
. This ensures that compound expressions likex + y + z
are unambiguous (at least when column position is available).Contrived example:
Implications:
a
andb
are associated with the line numbers their respective identifiers.a
andb
would be associated with thevar
keyword (though in practice I expect they'd be optimized away).+
token.f()
is associated with the(
token.a
andb
would be associated with the=
token.As a near-term plan I'm trying to match the old behavior as much as possible to ease transition, and I'm now to the point where
go build -a -toolexec='toolstash -cmp' std cmd
passes with enabling the new parser. I can continue matching more obscure line number behaviors, but unless people think line numbering compatibility is really important, I don't think it's worthwhile. I'd rather focus on making sure performance is acceptable so we can switch over and continue cleaning up the compiler./cc @griesemer @ianlancetaylor @alandonovan
The text was updated successfully, but these errors were encountered: