aboutsummaryrefslogtreecommitdiff
path: root/src/internal
diff options
context:
space:
mode:
authorRaj Barik <rajbarik@uber.com>2022-09-09 11:29:32 -0700
committerMichael Pratt <mpratt@google.com>2022-10-28 14:23:26 +0000
commit99862cd57dd9406180f238e8fa2fcc1d435fb163 (patch)
tree237c8c84a594eff60d06c1a65039d3403d23cdea /src/internal
parent537c4354cb9fdf8812c0448bd8f8a3b9f9ab1736 (diff)
downloadgo-99862cd57dd9406180f238e8fa2fcc1d435fb163.tar.xz
cmd/compile: Enables PGO in Go and performs profile-guided inlining
For #55022 Change-Id: I51f1ba166d5a66dcaf4b280756be4a6bf9545c5e Reviewed-on: https://go-review.googlesource.com/c/go/+/429863 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/profile/legacy_profile.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/internal/profile/legacy_profile.go b/src/internal/profile/legacy_profile.go
index 0ac350a888..b102c95904 100644
--- a/src/internal/profile/legacy_profile.go
+++ b/src/internal/profile/legacy_profile.go
@@ -722,7 +722,7 @@ func parseCppContention(r *bytes.Buffer) (*Profile, error) {
var l string
var err error
// Parse text of the form "attribute = value" before the samples.
- const delimiter = "="
+ const delimiter = '='
for {
l, err = r.ReadString('\n')
if err != nil {
@@ -746,10 +746,13 @@ func parseCppContention(r *bytes.Buffer) (*Profile, error) {
break
}
- key, val, ok := strings.Cut(l, delimiter)
- if !ok {
+ index := strings.IndexByte(l, delimiter)
+ if index < 0 {
break
}
+ key := l[:index]
+ val := l[index+1:]
+
key, val = strings.TrimSpace(key), strings.TrimSpace(val)
var err error
switch key {
@@ -1023,7 +1026,7 @@ func (p *Profile) ParseMemoryMap(rd io.Reader) error {
var attrs []string
var r *strings.Replacer
- const delimiter = "="
+ const delimiter = '='
for {
l, err := b.ReadString('\n')
if err != nil {
@@ -1046,7 +1049,10 @@ func (p *Profile) ParseMemoryMap(rd io.Reader) error {
if err == errUnrecognized {
// Recognize assignments of the form: attr=value, and replace
// $attr with value on subsequent mappings.
- if attr, value, ok := strings.Cut(l, delimiter); ok {
+ idx := strings.IndexByte(l, delimiter)
+ if idx >= 0 {
+ attr := l[:idx]
+ value := l[idx+1:]
attrs = append(attrs, "$"+strings.TrimSpace(attr), strings.TrimSpace(value))
r = strings.NewReplacer(attrs...)
}