aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/logopt/logopt_test.go
AgeCommit message (Collapse)Author
2025-05-21cmd/compile/internal/escape: make escape analysis -m=2 logs more accessiblethepudds
This was the first CL in a series of CLs aimed at reducing how often interface arguments escape for the print functions in fmt. This CL makes some small improvements to the escape analysis logging. Here is a sample snippet of the current -m=2 logs: ./print.go:587:7: parameter p leaks to {heap} with derefs=0: ./print.go:587:7: flow: p = p: ./print.go:587:7: from (*pp).printArg(p, err, 'v') (call parameter) at ./print.go:613:13 ./print.go:587:7: flow: p = p: ./print.go:587:7: from (*pp).handleMethods(p, verb) (call parameter) at ./print.go:749:22 [..] If we attempt to tease apart some reasons why the -m=2 logs can be challenging to understand for the uninitiated: - The "flow" lines are very useful, but contain more-or-less abstracted pseudocode. The "from" lines most often use actual code. When first looking at the logs, that distinction might not be apparent, which can result in looking back to the original code to hunt for pseudocode that doesn't exist there. (The log example shows 'p = p', but there is no 'p = p' in the original source). - Escape analysis can be most interesting with inlining, but that can result in seeing overlapping short variable names (e.g., p, b, v...). - The directionality of the "flow" lines might not be obvious, including whether they build top-to-bottom or bottom-to-top. - The use of '{' and '}' in the -m=2 logs somewhat intersects with Go literals (e.g., if the log says "{temp}", an initial thought might be that represents some temp inside of some Go literal). - And of course, escape analysis itself is subtle. This CL: - Adds the function name to the first -m=2 line to provide more context and reduce how often the reader needs to lookup line numbers. - Uses the Unicode left arrow '←' rather than '=' on the flow lines to make it clearer that these lines are abstracted away from the original Go code and to help the directionality jump out. In the future, we can consider changing "{heap}", "{temp}", "{storage for foo}" to something else, but we leave them as is for now. Two examples with the modifications: ./f1.go:3:9: parameter inptr leaks to outptr for func1 with derefs=0: ./f1.go:3:9: flow: localptr ← inptr: ./f1.go:3:9: from localptr := inptr (assign) at ./f1.go:4:11 ./f1.go:3:9: flow: outptr ← localptr: ./f1.go:3:9: from return localptr (return) at ./f1.go:5:2 ./b.go:14:20: []byte{...} escapes to heap in byteOrderExample: ./b.go:14:20: flow: b ← &{storage for []byte{...}}: ./b.go:14:20: from []byte{...} (spill) at ./byteorder.go:14:20 ./b.go:14:20: from b := []byte{...} (assign) at ./byteorder.go:14:11 ./b.go:14:20: flow: <heap> ← b: ./b.go:14:20: from byteOrder.Uint32(b) (call parameter) at ./byteorder.go:15:32 These changes only affect the -m=2 output and leave the -m=1 output as is. Updates #8618 Updates #62653 Change-Id: Ic082a371c3d3fa0d8fd8bfbe4d64ec3e1e53c173 Reviewed-on: https://go-review.googlesource.com/c/go/+/524937 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2023-09-14cmd/compile/internal/ir: add Func.DeclareParamsMatthew Dempsky
There's several copies of this function. We only need one. While here, normalize so that we always declare parameters, and always use the names ~pNN for params and ~rNN for results. Change-Id: I49e90d3fd1820f3c07936227ed5cfefd75d49a1c Reviewed-on: https://go-review.googlesource.com/c/go/+/528415 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com>
2023-02-06cmd/compile: replace os.MkdirTemp with T.TempDirOleksandr Redko
Updates #45402 Change-Id: Ieffd1c8b0b5e4e63024b5be2e1f910fb4411eb94 GitHub-Last-Rev: fa7418c8eb977b7214311e774f9df7a1220a3dfd GitHub-Pull-Request: golang/go#57940 Reviewed-on: https://go-review.googlesource.com/c/go/+/462896 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org>
2022-11-15cmd/compile: use testenv.Command instead of exec.Command in testsBryan C. Mills
testenv.Command sets a default timeout based on the test's deadline and sends SIGQUIT (where supported) in case of a hang. Change-Id: I084b324a20d5ecf733b2cb95f160947a7410a805 Reviewed-on: https://go-review.googlesource.com/c/go/+/450696 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com>
2022-09-20all: replace package ioutil with os and io in srcAndy Pan
For #45557 Change-Id: I56824135d86452603dd4ed4bab0e24c201bb0683 Reviewed-on: https://go-review.googlesource.com/c/go/+/426257 Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Andy Pan <panjf2000@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-13cmd/compile/internal: fix test error on loong64Xiaodong Liu
For TestLogOpt test case, add loong64 support to test the host architecture and os. The Ctz64 is not intrinsified on loong64 for TestIntendedInlining. Contributors to the loong64 port are: Weining Lu <luweining@loongson.cn> Lei Wang <wanglei@loongson.cn> Lingqin Gong <gonglingqin@loongson.cn> Xiaolin Zhao <zhaoxiaolin@loongson.cn> Meidan Li <limeidan@loongson.cn> Xiaojuan Zhai <zhaixiaojuan@loongson.cn> Qiyuan Pu <puqiyuan@loongson.cn> Guoqi Chen <chenguoqi@loongson.cn> This port has been updated to Go 1.15.6: https://github.com/loongson/go Updates #46229 Change-Id: I42280e89a337dbfde55a01a134820f8ae94f6b47 Reviewed-on: https://go-review.googlesource.com/c/go/+/400237 Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-04-12Revert "cmd/compile/internal: fix test error on loong64"Bryan Mills
This reverts CL 367043. Reason for revert: auto-submitted prematurely, breaking tests on most builders. Change-Id: I6da319fb042b629bcd6f549be638497a357e7d28 Reviewed-on: https://go-review.googlesource.com/c/go/+/399795 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-12cmd/compile/internal: fix test error on loong64Xiaodong Liu
For TestLogOpt test case, add loong64 support to test the host architecture and os. The Ctz64 is not intrinsified on loong64 for TestIntendedInlining. Contributors to the loong64 port are: Weining Lu <luweining@loongson.cn> Lei Wang <wanglei@loongson.cn> Lingqin Gong <gonglingqin@loongson.cn> Xiaolin Zhao <zhaoxiaolin@loongson.cn> Meidan Li <limeidan@loongson.cn> Xiaojuan Zhai <zhaixiaojuan@loongson.cn> Qiyuan Pu <puqiyuan@loongson.cn> Guoqi Chen <chenguoqi@loongson.cn> This port has been updated to Go 1.15.6: https://github.com/loongson/go Updates #46229 Change-Id: I4ca290bf725425a9a6ac2c6767a5bf4ff2339d0e Reviewed-on: https://go-review.googlesource.com/c/go/+/367043 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> Auto-Submit: Russ Cox <rsc@golang.org>
2022-03-09cmd/compile: require -p flagRuss Cox
The -p flag specifies the import path of the package being compiled. This CL makes it required when invoking the compiler and adjusts tests that invoke the compiler directly to conform to this new requirement. The go command already passes the flag, so it is unmodified in this CL. It is expected that any other Go build systems also already pass -p, or else they will need to arrange to do so before updating to Go 1.19. Of particular note, Bazel already does for rules with an importpath= attribute, which includes all Gazelle-generated rules. There is more cleanup possible now in cmd/compile, cmd/link, and other consumers of Go object files, but that is left to future CLs. Additional historical background follows but can be ignored. Long ago, before the go command, or modules, or any kind of versioning, symbols in Go archive files were named using just the package name, so that for example func F in math/rand and func F in crypto/rand would both be the object file symbol 'rand.F'. This led to collisions even in small source trees, which made certain packages unusable in the presence of other packages and generally was a problem for Go's goal of scaling to very large source trees. Fixing this problem required changing from package names to import paths in symbol names, which was mostly straightforward. One wrinkle, though, is that the compiler did not know the import path of the package being compiled; it only knew the package name. At the time, there was no go command, just Makefiles that people had invoking 6g (now “go tool compile”) and then copying the resulting object file to an importable location. That is, everyone had a custom build setup for Go, because there was no standard one. So it was not particularly attractive to change how the compiler was invoked, since that would break approximately every Go user at the time. Instead, we arranged for the compiler to emit, and other tools reading object files to recognize, a special import path (the empty string, it turned out) denoting “the import path of this object file”. This worked well enough at the time and maintained complete command-line compatibility with existing Go usage. The changes implementing this transition can be found by searching the Git history for “package global name space”, which is what they eliminated. In particular, CL 190076 (a6736fa4), CL 186263 (758f2bc5), CL 193080 (1cecac81), CL 194053 (19126320), and CL 194071 (531e6b77) did the bulk of this transformation in January 2010. Later, in September 2011, we added the -p flag to the compiler for diagnostic purposes. The problem was that it was easy to create import cycles, especially in tests, and these could not be diagnosed until link time. You'd really want the compiler to diagnose these, for example if the compilation of package sort noticed it was importing a package that itself imported "sort". But the compilation of package sort didn't know its own import path, and so it could not tell whether it had found itself as a transitive dependency. Adding the -p flag solved this problem, and its use was optional, since the linker would still diagnose the import cycle in builds that had not updated to start passing -p. This was CL 4972057 (1e480cd1). There was still no go command at this point, but when we introduced the go command we made it pass -p, which it has for many years at this point. Over time, parts of the compiler began to depend on the presence of the -p flag for various reasonable purposes. For example: In CL 6497074 (041fc8bf; Oct 2012), the race detector used -p to detect packages that should not have race annotations, such as runtime/race and sync/atomic. In CL 13367052 (7276c02b; Sep 2013), a bug fix used -p to detect the compilation of package reflect. In CL 30539 (8aadcc55; Oct 2016), the compiler started using -p to identify package math, to be able to intrinsify calls to Sqrt inside that package. In CL 61019 (9daee931; Sep 2017), CL 71430 (2c1d2e06; Oct 2017), and later related CLs, the compiler started using the -p value when creating various DWARF debugging information. In CL 174657 (cc5eaf93; May 2019), the compiler started writing symbols without the magic empty string whenever -p was used, to reduce the amount of work required in the linker. In CL 179861 (dde7c770; Jun 2019), the compiler made the second argument to //go:linkname optional when -p is used, because in that case the compiler can derive an appropriate default. There are more examples. Today it is impossible to compile the Go standard library without using -p, and DWARF debug information is incomplete without using -p. All known Go build systems pass -p. In particular, the go command does, which is what nearly all Go developers invoke to build Go code. And Bazel does, for go_library rules that set the importpath attribute, which is all rules generated by Gazelle. Gccgo has an equivalent of -p and has required its use in order to disambiguate packages with the same name but different import paths since 2010. On top of all this, various parts of code generation for generics are made more complicated by needing to cope with the case where -p is not specified, even though it's essentially always specified. In summary, the current state is: - Use of the -p flag with cmd/compile is required for building the standard library, and for complete DWARF information, and to enable certain linker speedups. - The go command and Bazel, which we expect account for just about 100% of Go builds, both invoke cmd/compile with -p. - The code in cmd/compile to support builds without -p is complex and has become more complex with generics, but it is almost always dead code and therefore not worth maintaining. - Gccgo already requires its equivalent of -p in any build where two packages have the same name. All this supports the change in this CL, which makes -p required and adjusts tests that invoke cmd/compile to add -p appropriately. Future CLs will be able to remove all the code dealing with the possibility of -p not having been specified. Change-Id: I6b95b9d4cffe59c7bac82eb273ef6c4a67bb0e43 Reviewed-on: https://go-review.googlesource.com/c/go/+/391014 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-07-03[dev.typeparams] cmd/compile: flatten OINLCALL in walkMatthew Dempsky
Inlining replaces inlined calls with OINLCALL nodes, and then somewhat clumsily tries to rewrite these in place without messing up order-of-evaluation rules. But handling these rules cleanly is much easier to do during order, and escape analysis is the only major pass between inlining and order. It's simpler to teach escape analysis how to analyze OINLCALL nodes than to try to hide them from escape analysis. Does not pass toolstash -cmp, but seems to just be line number changes. Change-Id: I1986cea39793e3e1ed5e887ba29d46364c6c532e Reviewed-on: https://go-review.googlesource.com/c/go/+/332649 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Trust: Matthew Dempsky <mdempsky@google.com>
2021-05-26[dev.typeparams] cmd/compile: simplify ~r/~b namingMatthew Dempsky
The compiler renames anonymous and blank result parameters to ~rN or ~bN, but the current semantics for computing N are rather annoying and difficult to reproduce cleanly. They also lead to difficult to read escape analysis results in tests. This CL changes N to always be calculated as the parameter's index within the function's result parameter tuple. E.g., if a function has a single result, it will now always be named "~r0". The normative change to this CL is fairly simple, but it requires updating a lot of test expectations. Change-Id: I58a3c94de00cb822cb94efe52d115531193c993c Reviewed-on: https://go-review.googlesource.com/c/go/+/323010 Trust: Matthew Dempsky <mdempsky@google.com> Trust: Dan Scales <danscales@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
2020-12-14Merge branch 'master' into dev.regabiAlexander Rakoczy
Change-Id: I098acdbc5e2676aeb8700d935e796a9c29d04b88
2020-12-09cmd/compile: fix message typoIkko Ashimine
occurences -> occurrences Change-Id: Ia81671f5de8a24ddd303a77b4580e8c726f29122 GitHub-Last-Rev: 11f9ab9f8c2c9acd70bcf170930426547d9b63eb GitHub-Pull-Request: golang/go#43097 Reviewed-on: https://go-review.googlesource.com/c/go/+/276612 Reviewed-by: Robert Griesemer <gri@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2020-11-30[dev.regabi] cmd/compile: clean up in preparation for statement NodesRuss Cox
Using statement nodes restricts the set of valid SetOp operations, because you can't SetOp across representation. Rewrite various code to avoid crossing those as-yet-unintroduced boundaries. In particular, code like x, y := v.(T) x, y := f() x, y := m[k] x, y := <-c starts out with Op = OAS2, and then it turns into a specific Op OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV, and then later in walk is lowered to an OAS2 again. In the middle, the specific forms move the right-hand side from n.Rlist().First() to n.Right(), and then the conversion to OAS2 moves it back. This is unnecessary and makes it hard for these all to share an underlying Node implementation. This CL changes these specific forms to leave the right-hand side in n.Rlist().First(). Similarly, OSELRECV2 is really just a temporary form of OAS2. This CL changes it to use same fields too. Finally, this CL fixes the printing of OAS2 nodes in ir/fmt.go, which formerly printed n.Right() instead of n.Rlist(). This results in a (correct!) update to cmd/compile/internal/logopt's expected output: ~R0 = <N> becomes ~R0 = &y.b. Passes buildall w/ toolstash -cmp. Change-Id: I164aa2e17dc55bfb292024de53d7d250192ad64a Reviewed-on: https://go-review.googlesource.com/c/go/+/274105 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-01cmd/compile: fix recognition of unnamed return variablesMatthew Dempsky
In golang.org/cl/266199, I reused the existing code in inlining that recognizes anonymous variables. However, it turns out that code mistakenly recognizes anonymous return parameters as named when inlining a function from the same package. The issue is funcargs (which is only used for functions parsed from source) synthesizes ~r names for anonymous return parameters, but funcargs2 (which is only used for functions imported from export data) does not. This CL fixes the behavior so that anonymous return parameters are handled identically whether a function is inlined within the same package or across packages. It also adds a proper cross-package test case demonstrating #33160 is fixed in both cases. Change-Id: Iaa39a23f5666979a1f5ca6d09fc8c398e55b784c Reviewed-on: https://go-review.googlesource.com/c/go/+/266719 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: David Chase <drchase@google.com> Trust: Matthew Dempsky <mdempsky@google.com>
2020-10-15cmd/compile: use staticValue for inlining logicMatthew Dempsky
This CL replaces the ad hoc and duplicated logic for detecting inlinable calls with a single "inlCallee" function, which uses the "staticValue" helper function introduced in an earlier commit. Updates #41474. Change-Id: I103d4091b10366fce1344ef2501222b7df68f21d Reviewed-on: https://go-review.googlesource.com/c/go/+/256460 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Trust: Matthew Dempsky <mdempsky@google.com>
2020-10-15cmd/compile: set n.Name.Defn for inlined parametersMatthew Dempsky
Normally, when variables are declared and initialized using ":=", we set the variable's n.Name.Defn to point to the initialization assignment node (i.e., OAS or OAS2). Further, some frontend optimizations look for variables that are initialized but never reassigned. However, when inl.go inlines calls, it was declaring the inlined variables, and then separately assigning to them. This CL changes inl.go tweaks the AST to fit the combined declaration+initialization pattern. This isn't terribly useful by itself, but it allows further followup optimizations. Updates #41474. Change-Id: I62a9752c60414305679e0ed15a6563baa0224efa Reviewed-on: https://go-review.googlesource.com/c/go/+/256457 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2020-09-26cmd/compile: fix logopt log directory naming for windowsDavid Chase
Allow Windows absolute paths, also fixed URI decoding on Windows. Added a test, reorganized to make the test cleaner. Also put some doc comments on exported functions that did not have them. Fixes #41614. Change-Id: I2871be0e5183fbd53ffb309896d6fe56c15a7727 Reviewed-on: https://go-review.googlesource.com/c/go/+/257677 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-04-13cmd/compile: run TestLogOpt for riscv64 on amd64Joel Sing
Run TestLogOpt for riscv64 on amd64, as is done for other architectures. This would have caught the test failure on riscv64 introduced in 47ade08141b23cfeafed92943e16012d5dc5eb8b. Change-Id: If29dea2ef383b087154d046728f6d1c96811f5a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/227806 Run-TryBot: Joel Sing <joel@sing.id.au> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2020-04-11Revert "cmd/compile: make logopt test skip if cannot create scratch directory"Alex Brainman
This reverts commit 98534812bdcdd22b13469ea587e310187876b7d2. Reason for revert: The change does not really fixes issue #38251. CL 227497 is real fix. Change-Id: I9f556005baf1de968f059fb8dad89dae05330aa6 Reviewed-on: https://go-review.googlesource.com/c/go/+/227802 Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2020-04-11cmd/compile: add explanations to escape-analysis JSON/LSP loggingDavid Chase
For 1.15. From the test: {"range":{"start":{"line":7,"character":13},"end":{...},"severity":3,"code":"leaks","source":"go compiler","message":"parameter z leaks to ~r2 with derefs=0","relatedInformation":[ {"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":13},"end":{...}},"message":"escflow: flow: y = z:"}, {"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":13},"end":{...}},"message":"escflow: from y = \u003cN\u003e (assign-pair)"}, {"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":13},"end":{...}},"message":"escflow: flow: ~r1 = y:"}, {"location":{"uri":"file://T/file.go","range":{"start":{"line":4,"character":11},"end":{...}},"message":"inlineLoc"}, {"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":13},"end":{...}},"message":"escflow: from y.b (dot of pointer)"}, {"location":{"uri":"file://T/file.go","range":{"start":{"line":4,"character":11},"end":{...}},"message":"inlineLoc"}, {"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":13},"end":{...}},"message":"escflow: from \u0026y.b (address-of)"}, {"location":{"uri":"file://T/file.go","range":{"start":{"line":4,"character":9},"end":...}},"message":"inlineLoc"}, {"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":13},"end":{...}},"message":"escflow: from ~r1 = \u003cN\u003e (assign-pair)"}, {"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":3},"end":...}},"message":"escflow: flow: ~r2 = ~r1:"}, {"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":3},"end":...}},"message":"escflow: from return (*int)(~r1) (return)"}]} Change-Id: Idf02438801f63e487c35a928cf5a0b6d3cc48674 Reviewed-on: https://go-review.googlesource.com/c/go/+/206658 Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-10cmd/compile: change gc logging to report inline failure instead of successDavid Chase
I've been experimenting with this, success is the wrong thing to report even though it seems to log much less. Change-Id: I7c25a45d2f41e82b6c8dd8b0a56ba848c63fb21a Reviewed-on: https://go-review.googlesource.com/c/go/+/223298 Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-07cmd/compile/internal/logopt: preserve env while running commandEgon Elbre
The test was not preserving temporary directory flags leading to a failure on windows with: mkdir C:\WINDOWS\go-build315158903: Access is denied. Fixes #38251 Change-Id: I6ee31b31e84b7f6e75ea6ee0f3b8c094835bf5d2 Reviewed-on: https://go-review.googlesource.com/c/go/+/227497 Reviewed-by: David Chase <drchase@google.com>
2020-04-06cmd/compile: make logopt test skip if cannot create scratch directoryDavid Chase
Fixes #38251. Change-Id: Ic635843fb503484a1c9a230b0cca571393d3da5a Reviewed-on: https://go-review.googlesource.com/c/go/+/227339 Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2020-04-03cmd/compile: add logging for large (>= 128 byte) copiesDavid Chase
For 1.15, unless someone really wants it in 1.14. A performance-sensitive user thought this would be useful, though "large" was not well-defined. If 128 is large, there are 139 static instances of "large" copies in the compiler itself. Includes test. Change-Id: I81f20c62da59d37072429f3a22c1809e6fb2946d Reviewed-on: https://go-review.googlesource.com/c/go/+/205066 Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-11-12cmd/compile: enable optimizer logging for inline-related eventsDavid Chase
Change-Id: I72de8cb5e1df7a73e46a4b7e5b4e7290fcca4bc1 Reviewed-on: https://go-review.googlesource.com/c/go/+/204162 Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-11-10cmd/compile: enable optimizer logging for bounds checkingDavid Chase
Change-Id: Ic1fc271589b7212e7f604ece93cfe34feff909b2 Reviewed-on: https://go-review.googlesource.com/c/go/+/204160 Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-11-10cmd/compile: add framework for logging optimizer (non)actions to LSPDavid Chase
This is intended to allow IDEs to note where the optimizer was not able to improve users' code. There may be other applications for this, for example in studying effectiveness of optimizer changes more quickly than running benchmarks, or in verifying that code changes did not accidentally disable optimizations in performance-critical code. Logging of nilcheck (bad) for amd64 is implemented as proof-of-concept. In general, the intent is that optimizations that didn't happen are what will be logged, because that is believed to be what IDE users want. Added flag -json=version,dest Check that version=0. (Future compilers will support a few recent versions, I hope that version is always <=3.) Dest is expected to be one of: /path (or \path in Windows) will create directory /path and fill it w/ json files file://path will create directory path, intended either for I:\dont\know\enough\about\windows\paths trustme_I_know_what_I_am_doing_probably_testing Not passing an absolute path name usually leads to json splattered all over source directories, or failure when those directories are not writeable. If you want a foot-gun, you have to ask for it. The JSON output is directed to subdirectories of dest, where each subdirectory is net/url.PathEscape of the package name, and each for each foo.go in the package, net/url.PathEscape(foo).json is created. The first line of foo.json contains version and context information, and subsequent lines contains LSP-conforming JSON describing the missing optimizations. Change-Id: Ib83176a53a8c177ee9081aefc5ae05604ccad8a0 Reviewed-on: https://go-review.googlesource.com/c/go/+/204338 Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>