[go] cmd/compile: treat singly-assigned func vars as static in escape analysis

4 views
Skip to first unread message

Jake Bailey (Gerrit)

unread,
Apr 27, 2026, 4:55:49 PM (2 days ago) Apr 27
to goph...@pubsubhelper.golang.org, Keith Randall, David Chase, t hepudds, golang...@luci-project-accounts.iam.gserviceaccount.com, golang-co...@googlegroups.com
Attention needed from David Chase, Keith Randall and t hepudds

New activity on the change

Open in Gerrit

Related details

Attention is currently required from:
  • David Chase
  • Keith Randall
  • t hepudds
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
Gerrit-Change-Number: 771160
Gerrit-PatchSet: 1
Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
Gerrit-Reviewer: David Chase <drc...@google.com>
Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
Gerrit-Attention: Keith Randall <k...@golang.org>
Gerrit-Attention: David Chase <drc...@google.com>
Gerrit-Attention: t hepudds <thepud...@gmail.com>
Gerrit-Comment-Date: Mon, 27 Apr 2026 20:55:45 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
unsatisfied_requirement
satisfied_requirement
open
diffy

Jake Bailey (Gerrit)

unread,
Apr 27, 2026, 5:46:48 PM (2 days ago) Apr 27
to goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
Attention needed from David Chase, Keith Randall and t hepudds

Jake Bailey voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • David Chase
  • Keith Randall
  • t hepudds
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
Gerrit-Change-Number: 771160
Gerrit-PatchSet: 1
Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
Gerrit-Reviewer: David Chase <drc...@google.com>
Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Attention: Keith Randall <k...@golang.org>
Gerrit-Attention: David Chase <drc...@google.com>
Gerrit-Attention: t hepudds <thepud...@gmail.com>
Gerrit-Comment-Date: Mon, 27 Apr 2026 21:46:43 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Mateusz Poliwczak (Gerrit)

unread,
Apr 28, 2026, 3:23:34 AM (yesterday) Apr 28
to Jake Bailey, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
Attention needed from David Chase, Jake Bailey, Keith Randall and t hepudds

Mateusz Poliwczak added 1 comment

Commit Message
Line 26, Patchset 1 (Latest):There is a trick we can use here: a nil func cannot be called, because
Mateusz Poliwczak . resolved

FYI we use basically the same trick in the devirtualizer already.

Open in Gerrit

Related details

Attention is currently required from:
  • David Chase
  • Jake Bailey
  • Keith Randall
  • t hepudds
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
    Gerrit-Change-Number: 771160
    Gerrit-PatchSet: 1
    Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
    Gerrit-Reviewer: David Chase <drc...@google.com>
    Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
    Gerrit-Reviewer: Keith Randall <k...@golang.org>
    Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
    Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
    Gerrit-Attention: Jake Bailey <jacob.b...@gmail.com>
    Gerrit-Attention: Keith Randall <k...@golang.org>
    Gerrit-Attention: David Chase <drc...@google.com>
    Gerrit-Attention: t hepudds <thepud...@gmail.com>
    Gerrit-Comment-Date: Tue, 28 Apr 2026 07:23:27 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Mateusz Poliwczak (Gerrit)

    unread,
    Apr 28, 2026, 3:34:35 AM (yesterday) Apr 28
    to Jake Bailey, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
    Attention needed from David Chase, Jake Bailey, Keith Randall and t hepudds

    Mateusz Poliwczak added 1 comment

    File src/cmd/compile/internal/escape/call.go
    Line 48, Patchset 1 (Latest): // and assigned exactly once, we can use that
    Mateusz Poliwczak . unresolved

    Is that `exactly once` actually a problem? If we find all the assignments, then we can just analyze all of these functions that were assigned, right?

    That could solve #73132

    Open in Gerrit

    Related details

    Attention is currently required from:
    • David Chase
    • Jake Bailey
    • Keith Randall
    • t hepudds
    Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
      Gerrit-Change-Number: 771160
      Gerrit-PatchSet: 1
      Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
      Gerrit-Reviewer: David Chase <drc...@google.com>
      Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
      Gerrit-Reviewer: Keith Randall <k...@golang.org>
      Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
      Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
      Gerrit-Attention: Jake Bailey <jacob.b...@gmail.com>
      Gerrit-Attention: Keith Randall <k...@golang.org>
      Gerrit-Attention: David Chase <drc...@google.com>
      Gerrit-Attention: t hepudds <thepud...@gmail.com>
      Gerrit-Comment-Date: Tue, 28 Apr 2026 07:34:27 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Jake Bailey (Gerrit)

      unread,
      Apr 28, 2026, 3:37:11 AM (yesterday) Apr 28
      to goph...@pubsubhelper.golang.org, Mateusz Poliwczak, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
      Attention needed from David Chase, Keith Randall, Mateusz Poliwczak and t hepudds

      Jake Bailey added 1 comment

      File src/cmd/compile/internal/escape/call.go
      Line 48, Patchset 1 (Latest): // and assigned exactly once, we can use that
      Mateusz Poliwczak . unresolved

      Is that `exactly once` actually a problem? If we find all the assignments, then we can just analyze all of these functions that were assigned, right?

      That could solve #73132

      Jake Bailey

      That's actually something I thought about after sending it, I just wasn't sure if there was much real world use. I didn't realize there was an issue for it. I'll look into it!

      Open in Gerrit

      Related details

      Attention is currently required from:
      • David Chase
      • Keith Randall
      • Mateusz Poliwczak
      • t hepudds
      Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
      Gerrit-Change-Number: 771160
      Gerrit-PatchSet: 1
      Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
      Gerrit-Reviewer: David Chase <drc...@google.com>
      Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
      Gerrit-Reviewer: Keith Randall <k...@golang.org>
      Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
      Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
      Gerrit-Attention: Keith Randall <k...@golang.org>
      Gerrit-Attention: Mateusz Poliwczak <mpoliw...@gmail.com>
      Gerrit-Attention: David Chase <drc...@google.com>
      Gerrit-Attention: t hepudds <thepud...@gmail.com>
      Gerrit-Comment-Date: Tue, 28 Apr 2026 07:37:05 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Mateusz Poliwczak <mpoliw...@gmail.com>
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Mateusz Poliwczak (Gerrit)

      unread,
      Apr 28, 2026, 3:43:26 AM (yesterday) Apr 28
      to Jake Bailey, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
      Attention needed from David Chase, Jake Bailey, Keith Randall and t hepudds

      Mateusz Poliwczak added 1 comment

      File src/cmd/compile/internal/escape/call.go
      Line 48, Patchset 1 (Latest): // and assigned exactly once, we can use that
      Mateusz Poliwczak . unresolved

      Is that `exactly once` actually a problem? If we find all the assignments, then we can just analyze all of these functions that were assigned, right?

      That could solve #73132

      Mateusz Poliwczak

      FYI: I once did a POC for signature based optimizations for unexported interface method calls and it worked, but its been a while so i don't remember the details.

      https://go-review.googlesource.com/c/go/+/771280/2/src/cmd/compile/internal/escape/call.go#36

      Open in Gerrit

      Related details

      Attention is currently required from:
      • David Chase
      • Jake Bailey
      • Keith Randall
      • t hepudds
      Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
      Gerrit-Change-Number: 771160
      Gerrit-PatchSet: 1
      Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
      Gerrit-Reviewer: David Chase <drc...@google.com>
      Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
      Gerrit-Reviewer: Keith Randall <k...@golang.org>
      Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
      Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
      Gerrit-Attention: Jake Bailey <jacob.b...@gmail.com>
      Gerrit-Attention: Keith Randall <k...@golang.org>
      Gerrit-Attention: David Chase <drc...@google.com>
      Gerrit-Attention: t hepudds <thepud...@gmail.com>
      Gerrit-Comment-Date: Tue, 28 Apr 2026 07:43:20 +0000
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Mateusz Poliwczak (Gerrit)

      unread,
      Apr 28, 2026, 3:47:29 AM (yesterday) Apr 28
      to Jake Bailey, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
      Attention needed from David Chase, Jake Bailey, Keith Randall and t hepudds

      Mateusz Poliwczak added 1 comment

      File src/cmd/compile/internal/escape/call.go
      Line 48, Patchset 1 (Latest): // and assigned exactly once, we can use that
      Mateusz Poliwczak . unresolved

      Is that `exactly once` actually a problem? If we find all the assignments, then we can just analyze all of these functions that were assigned, right?

      That could solve #73132

      Mateusz Poliwczak

      FYI: I once did a POC for signature based optimizations for unexported interface method calls and it worked, but its been a while so i don't remember the details.

      https://go-review.googlesource.com/c/go/+/771280/2/src/cmd/compile/internal/escape/call.go#36

      Mateusz Poliwczak

      And that opt used similar idea.

      Gerrit-Comment-Date: Tue, 28 Apr 2026 07:47:21 +0000
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Alan Donovan (Gerrit)

      unread,
      Apr 28, 2026, 5:02:40 AM (yesterday) Apr 28
      to Jake Bailey, goph...@pubsubhelper.golang.org, Mateusz Poliwczak, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
      Attention needed from David Chase, Jake Bailey, Keith Randall and t hepudds

      Alan Donovan added 1 comment

      Commit Message
      Line 41, Patchset 1 (Latest):This optimization fires 7 times in std, 100 times in cmd, and 51
      Alan Donovan . unresolved

      And how many in x/tools? We use this a lot! :)

      Gerrit-CC: Alan Donovan <adon...@google.com>
      Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
      Gerrit-Attention: Jake Bailey <jacob.b...@gmail.com>
      Gerrit-Attention: Keith Randall <k...@golang.org>
      Gerrit-Attention: David Chase <drc...@google.com>
      Gerrit-Attention: t hepudds <thepud...@gmail.com>
      Gerrit-Comment-Date: Tue, 28 Apr 2026 09:02:31 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Jake Bailey (Gerrit)

      unread,
      Apr 28, 2026, 10:59:58 AM (18 hours ago) Apr 28
      to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
      Attention needed from David Chase, Jake Bailey, Keith Randall and t hepudds

      Jake Bailey uploaded new patchset

      Jake Bailey uploaded patch set #2 to this change.
      Open in Gerrit

      Related details

      Attention is currently required from:
      • David Chase
      • Jake Bailey
      • Keith Randall
      • t hepudds
      Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: newpatchset
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
      Gerrit-Change-Number: 771160
      Gerrit-PatchSet: 2
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Jake Bailey (Gerrit)

      unread,
      Apr 28, 2026, 11:01:21 AM (18 hours ago) Apr 28
      to goph...@pubsubhelper.golang.org, Alan Donovan, Mateusz Poliwczak, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
      Attention needed from Alan Donovan, David Chase, Keith Randall and t hepudds

      Jake Bailey added 1 comment

      Commit Message
      Line 41, Patchset 1:This optimization fires 7 times in std, 100 times in cmd, and 51
      Alan Donovan . unresolved

      And how many in x/tools? We use this a lot! :)

      Jake Bailey

      Wow, >750 times.

      However, my numbers are not perfect; this only counts how many times the new code is able to actually use the func for escape analysis. It doesn't count when that actually did anything. I'm trying to gather those numbers now.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Alan Donovan
      • David Chase
      • Keith Randall
      • t hepudds
      Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
      Gerrit-Change-Number: 771160
      Gerrit-PatchSet: 2
      Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
      Gerrit-Reviewer: David Chase <drc...@google.com>
      Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
      Gerrit-Reviewer: Keith Randall <k...@golang.org>
      Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
      Gerrit-CC: Alan Donovan <adon...@google.com>
      Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
      Gerrit-Attention: Keith Randall <k...@golang.org>
      Gerrit-Attention: David Chase <drc...@google.com>
      Gerrit-Attention: t hepudds <thepud...@gmail.com>
      Gerrit-Attention: Alan Donovan <adon...@google.com>
      Gerrit-Comment-Date: Tue, 28 Apr 2026 15:01:13 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Alan Donovan <adon...@google.com>
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Alan Donovan (Gerrit)

      unread,
      Apr 28, 2026, 11:20:18 AM (18 hours ago) Apr 28
      to Jake Bailey, goph...@pubsubhelper.golang.org, Mateusz Poliwczak, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
      Attention needed from David Chase, Jake Bailey, Keith Randall and t hepudds

      Alan Donovan added 1 comment

      Commit Message
      Line 41, Patchset 1:This optimization fires 7 times in std, 100 times in cmd, and 51
      Alan Donovan . resolved

      And how many in x/tools? We use this a lot! :)

      Jake Bailey

      Wow, >750 times.

      However, my numbers are not perfect; this only counts how many times the new code is able to actually use the func for escape analysis. It doesn't count when that actually did anything. I'm trying to gather those numbers now.

      Alan Donovan

      Wow, >750 times.

      Thanks. We do use it a lot! Happy to provide coverage. ;)

      Open in Gerrit

      Related details

      Attention is currently required from:
      • David Chase
      • Jake Bailey
      • Keith Randall
      • t hepudds
      Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
      Gerrit-Change-Number: 771160
      Gerrit-PatchSet: 2
      Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
      Gerrit-Reviewer: David Chase <drc...@google.com>
      Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
      Gerrit-Reviewer: Keith Randall <k...@golang.org>
      Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
      Gerrit-CC: Alan Donovan <adon...@google.com>
      Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
      Gerrit-Attention: Jake Bailey <jacob.b...@gmail.com>
      Gerrit-Attention: Keith Randall <k...@golang.org>
      Gerrit-Attention: David Chase <drc...@google.com>
      Gerrit-Attention: t hepudds <thepud...@gmail.com>
      Gerrit-Comment-Date: Tue, 28 Apr 2026 15:20:11 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Jake Bailey <jacob.b...@gmail.com>
      Comment-In-Reply-To: Alan Donovan <adon...@google.com>
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Jake Bailey (Gerrit)

      unread,
      Apr 28, 2026, 11:21:27 AM (18 hours ago) Apr 28
      to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
      Attention needed from David Chase, Jake Bailey, Keith Randall and t hepudds

      Jake Bailey uploaded new patchset

      Jake Bailey uploaded patch set #3 to this change.
      Open in Gerrit

      Related details

      Attention is currently required from:
      • David Chase
      • Jake Bailey
      • Keith Randall
      • t hepudds
      Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: newpatchset
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
      Gerrit-Change-Number: 771160
      Gerrit-PatchSet: 3
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Jake Bailey (Gerrit)

      unread,
      Apr 28, 2026, 11:22:11 AM (18 hours ago) Apr 28
      to goph...@pubsubhelper.golang.org, Alan Donovan, Mateusz Poliwczak, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
      Attention needed from Alan Donovan, David Chase, Keith Randall and t hepudds

      Jake Bailey voted and added 1 comment

      Votes added by Jake Bailey

      Commit-Queue+1

      1 comment

      Commit Message
      Line 41, Patchset 1:This optimization fires 7 times in std, 100 times in cmd, and 51
      Alan Donovan . resolved

      And how many in x/tools? We use this a lot! :)

      Jake Bailey

      Wow, >750 times.

      However, my numbers are not perfect; this only counts how many times the new code is able to actually use the func for escape analysis. It doesn't count when that actually did anything. I'm trying to gather those numbers now.

      Alan Donovan

      Wow, >750 times.

      Thanks. We do use it a lot! Happy to provide coverage. ;)

      Jake Bailey

      Unfortunately, it doesn't seem like very many allocs actually get eliminated. I'm looking into why I find so many funcs but they don't seem to impact much.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Alan Donovan
      • David Chase
      • Keith Randall
      • t hepudds
      Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
        Gerrit-Change-Number: 771160
        Gerrit-PatchSet: 3
        Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
        Gerrit-Reviewer: David Chase <drc...@google.com>
        Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
        Gerrit-Reviewer: Keith Randall <k...@golang.org>
        Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
        Gerrit-CC: Alan Donovan <adon...@google.com>
        Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
        Gerrit-Attention: Keith Randall <k...@golang.org>
        Gerrit-Attention: David Chase <drc...@google.com>
        Gerrit-Attention: t hepudds <thepud...@gmail.com>
        Gerrit-Attention: Alan Donovan <adon...@google.com>
        Gerrit-Comment-Date: Tue, 28 Apr 2026 15:22:07 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        unsatisfied_requirement
        open
        diffy

        Jake Bailey (Gerrit)

        unread,
        Apr 28, 2026, 12:11:49 PM (17 hours ago) Apr 28
        to goph...@pubsubhelper.golang.org, Alan Donovan, Mateusz Poliwczak, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
        Attention needed from Alan Donovan, David Chase, Keith Randall, Mateusz Poliwczak and t hepudds

        Jake Bailey voted and added 1 comment

        Votes added by Jake Bailey

        Commit-Queue+1

        1 comment

        File src/cmd/compile/internal/escape/call.go
        Line 48, Patchset 1: // and assigned exactly once, we can use that
        Mateusz Poliwczak . unresolved

        Is that `exactly once` actually a problem? If we find all the assignments, then we can just analyze all of these functions that were assigned, right?

        That could solve #73132

        Mateusz Poliwczak

        FYI: I once did a POC for signature based optimizations for unexported interface method calls and it worked, but its been a while so i don't remember the details.

        https://go-review.googlesource.com/c/go/+/771280/2/src/cmd/compile/internal/escape/call.go#36

        Mateusz Poliwczak

        And that opt used similar idea.

        Jake Bailey

        Yep, it's totally possible to generalize this: https://go-review.googlesource.com/c/go/+/771500

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Alan Donovan
        • David Chase
        • Keith Randall
        • Mateusz Poliwczak
        • t hepudds
        Submit Requirements:
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          • requirement satisfiedTryBots-Pass
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: go
          Gerrit-Branch: master
          Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
          Gerrit-Change-Number: 771160
          Gerrit-PatchSet: 3
          Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
          Gerrit-Reviewer: David Chase <drc...@google.com>
          Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
          Gerrit-Reviewer: Keith Randall <k...@golang.org>
          Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
          Gerrit-CC: Alan Donovan <adon...@google.com>
          Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
          Gerrit-Attention: Keith Randall <k...@golang.org>
          Gerrit-Attention: Mateusz Poliwczak <mpoliw...@gmail.com>
          Gerrit-Attention: David Chase <drc...@google.com>
          Gerrit-Attention: t hepudds <thepud...@gmail.com>
          Gerrit-Attention: Alan Donovan <adon...@google.com>
          Gerrit-Comment-Date: Tue, 28 Apr 2026 16:11:44 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          Comment-In-Reply-To: Mateusz Poliwczak <mpoliw...@gmail.com>
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Keith Randall (Gerrit)

          unread,
          Apr 28, 2026, 2:08:07 PM (15 hours ago) Apr 28
          to Jake Bailey, goph...@pubsubhelper.golang.org, Alan Donovan, Mateusz Poliwczak, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
          Attention needed from Alan Donovan, David Chase, Jake Bailey, Mateusz Poliwczak and t hepudds

          Keith Randall added 5 comments

          File src/cmd/compile/internal/ir/expr.go
          Line 1018, Patchset 3 (Latest):// non-nil RHS at the same function level (not inside a nested closure).
          Keith Randall . unresolved

          Inside a loop is ok?
          (i.e. this is Static Single Assignment.)

          Line 1084, Patchset 3 (Latest): closureDepth--
          Keith Randall . unresolved

          You could do this with a `defer`, then you don't need the `abort` flag. Just `return Any(n.Func, do)`.

          Line 1092, Patchset 3 (Latest): if Any(name.Curfn, do) {
          Keith Randall . unresolved

          This is going to be O(n^2), because this function is O(n) and we might call it O(n) times.
          Can we precompute this for a function for all variables? Similar to how ReassignOracle does it.

          Line 1102, Patchset 3 (Latest): if !ok || as.Y == nil {
          Keith Randall . unresolved

          as.Y == nil should return true? We use that for zero-initialization.

          Line 1106, Patchset 3 (Latest): for y.Op() == OCONVNOP {
          y = y.(*ConvExpr).X
          }
          Keith Randall . resolved

          Maybe this should be inside `IsZero`?
          (not necessary for this CL, just curious.)

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Alan Donovan
          • David Chase
          • Jake Bailey
          • Mateusz Poliwczak
          • t hepudds
          Submit Requirements:
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          • requirement satisfiedTryBots-Pass
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: go
          Gerrit-Branch: master
          Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
          Gerrit-Change-Number: 771160
          Gerrit-PatchSet: 3
          Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
          Gerrit-Reviewer: David Chase <drc...@google.com>
          Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
          Gerrit-Reviewer: Keith Randall <k...@golang.org>
          Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
          Gerrit-CC: Alan Donovan <adon...@google.com>
          Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
          Gerrit-Attention: Jake Bailey <jacob.b...@gmail.com>
          Gerrit-Attention: Mateusz Poliwczak <mpoliw...@gmail.com>
          Gerrit-Attention: David Chase <drc...@google.com>
          Gerrit-Attention: t hepudds <thepud...@gmail.com>
          Gerrit-Attention: Alan Donovan <adon...@google.com>
          Gerrit-Comment-Date: Tue, 28 Apr 2026 18:08:03 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Mateusz Poliwczak (Gerrit)

          unread,
          Apr 28, 2026, 2:09:01 PM (15 hours ago) Apr 28
          to Jake Bailey, goph...@pubsubhelper.golang.org, Alan Donovan, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
          Attention needed from Alan Donovan, David Chase, Jake Bailey and t hepudds

          Mateusz Poliwczak added 1 comment

          File src/cmd/compile/internal/escape/call.go
          Line 48, Patchset 1: // and assigned exactly once, we can use that
          Mateusz Poliwczak . resolved

          Is that `exactly once` actually a problem? If we find all the assignments, then we can just analyze all of these functions that were assigned, right?

          That could solve #73132

          Mateusz Poliwczak

          FYI: I once did a POC for signature based optimizations for unexported interface method calls and it worked, but its been a while so i don't remember the details.

          https://go-review.googlesource.com/c/go/+/771280/2/src/cmd/compile/internal/escape/call.go#36

          Mateusz Poliwczak

          And that opt used similar idea.

          Jake Bailey

          Yep, it's totally possible to generalize this: https://go-review.googlesource.com/c/go/+/771500

          Mateusz Poliwczak

          Thanks for doing this!

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Alan Donovan
          • David Chase
          • Jake Bailey
          • t hepudds
          Submit Requirements:
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          • requirement satisfiedTryBots-Pass
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: go
          Gerrit-Branch: master
          Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
          Gerrit-Change-Number: 771160
          Gerrit-PatchSet: 3
          Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
          Gerrit-Reviewer: David Chase <drc...@google.com>
          Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
          Gerrit-Reviewer: Keith Randall <k...@golang.org>
          Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
          Gerrit-CC: Alan Donovan <adon...@google.com>
          Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
          Gerrit-Attention: Jake Bailey <jacob.b...@gmail.com>
          Gerrit-Attention: David Chase <drc...@google.com>
          Gerrit-Attention: t hepudds <thepud...@gmail.com>
          Gerrit-Attention: Alan Donovan <adon...@google.com>
          Gerrit-Comment-Date: Tue, 28 Apr 2026 18:08:54 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Jake Bailey <jacob.b...@gmail.com>
          Comment-In-Reply-To: Mateusz Poliwczak <mpoliw...@gmail.com>
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Mateusz Poliwczak (Gerrit)

          unread,
          Apr 28, 2026, 2:19:28 PM (15 hours ago) Apr 28
          to Jake Bailey, goph...@pubsubhelper.golang.org, Alan Donovan, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
          Attention needed from Alan Donovan, David Chase, Jake Bailey and t hepudds

          Mateusz Poliwczak added 2 comments

          File src/cmd/compile/internal/ir/expr.go
          Line 1020, Patchset 3 (Latest):// assignments, has any complex assignments (OAS2, OASOP, ORANGE), or
          // is assigned inside a closure.
          Mateusz Poliwczak . unresolved

          Is there any reason behind that, other than reducing the complexity? Just curious.

          Line 1025, Patchset 3 (Latest):func SingleAssignment(name *Name) *AssignStmt {
          Mateusz Poliwczak . unresolved

          Why this returns `AssignStmt` instead of a `Node`? This could allow handling of `OAS2` and such easier.

          Maybe renaming this to `StaticValueSkipZeroVal` would be better?

          Gerrit-Comment-Date: Tue, 28 Apr 2026 18:19:21 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Jake Bailey (Gerrit)

          unread,
          Apr 28, 2026, 2:26:05 PM (15 hours ago) Apr 28
          to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
          Attention needed from Alan Donovan, David Chase, Jake Bailey and t hepudds

          Jake Bailey uploaded new patchset

          Jake Bailey uploaded patch set #4 to this change.
          Following approvals got outdated and were removed:
          Open in Gerrit

          Related details

          Attention is currently required from:
          • Alan Donovan
          • David Chase
          • Jake Bailey
          • t hepudds
          Submit Requirements:
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • requirement is not satisfiedReview-Enforcement
            • requirement is not satisfiedTryBots-Pass
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: newpatchset
            Gerrit-Project: go
            Gerrit-Branch: master
            Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
            Gerrit-Change-Number: 771160
            Gerrit-PatchSet: 4
            unsatisfied_requirement
            open
            diffy

            Jake Bailey (Gerrit)

            unread,
            Apr 28, 2026, 2:31:53 PM (15 hours ago) Apr 28
            to goph...@pubsubhelper.golang.org, Alan Donovan, Mateusz Poliwczak, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
            Attention needed from Alan Donovan, David Chase, Keith Randall, Mateusz Poliwczak and t hepudds

            Jake Bailey added 3 comments

            File src/cmd/compile/internal/ir/expr.go
            Line 1018, Patchset 3:// non-nil RHS at the same function level (not inside a nested closure).
            Keith Randall . unresolved

            Inside a loop is ok?
            (i.e. this is Static Single Assignment.)

            Jake Bailey

            Inside a loop is fine; really, any assignment is fine since we're not determining a static value, just what the escape analyzer sees.

            Line 1020, Patchset 3:// assignments, has any complex assignments (OAS2, OASOP, ORANGE), or

            // is assigned inside a closure.
            Mateusz Poliwczak . unresolved

            Is there any reason behind that, other than reducing the complexity? Just curious.

            Jake Bailey

            Largely it was to limit scope; I don't think the existing StaticValue handled that so what I stuck in this CL didn't either.

            Line 1092, Patchset 3: if Any(name.Curfn, do) {
            Keith Randall . unresolved

            This is going to be O(n^2), because this function is O(n) and we might call it O(n) times.
            Can we precompute this for a function for all variables? Similar to how ReassignOracle does it.

            Jake Bailey

            That's actually the next CL, where I stuck it into the oracle where I think it belongs.

            compilecmp didn't show that this CL negatively affected anything, however.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Alan Donovan
            • David Chase
            • Keith Randall
            • Mateusz Poliwczak
            • t hepudds
            Submit Requirements:
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • requirement is not satisfiedReview-Enforcement
            • requirement is not satisfiedTryBots-Pass
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: go
            Gerrit-Branch: master
            Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
            Gerrit-Change-Number: 771160
            Gerrit-PatchSet: 4
            Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
            Gerrit-Reviewer: David Chase <drc...@google.com>
            Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
            Gerrit-Reviewer: Keith Randall <k...@golang.org>
            Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
            Gerrit-CC: Alan Donovan <adon...@google.com>
            Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
            Gerrit-Attention: Keith Randall <k...@golang.org>
            Gerrit-Attention: Mateusz Poliwczak <mpoliw...@gmail.com>
            Gerrit-Attention: David Chase <drc...@google.com>
            Gerrit-Attention: t hepudds <thepud...@gmail.com>
            Gerrit-Attention: Alan Donovan <adon...@google.com>
            Gerrit-Comment-Date: Tue, 28 Apr 2026 18:31:48 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            Comment-In-Reply-To: Keith Randall <k...@golang.org>
            Comment-In-Reply-To: Mateusz Poliwczak <mpoliw...@gmail.com>
            unsatisfied_requirement
            open
            diffy

            Jake Bailey (Gerrit)

            unread,
            Apr 28, 2026, 2:39:32 PM (15 hours ago) Apr 28
            to goph...@pubsubhelper.golang.org, Alan Donovan, Mateusz Poliwczak, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
            Attention needed from Alan Donovan, David Chase, Keith Randall, Mateusz Poliwczak and t hepudds

            Jake Bailey added 1 comment

            File src/cmd/compile/internal/ir/expr.go
            Line 1020, Patchset 3:// assignments, has any complex assignments (OAS2, OASOP, ORANGE), or
            // is assigned inside a closure.
            Mateusz Poliwczak . unresolved

            Is there any reason behind that, other than reducing the complexity? Just curious.

            Jake Bailey

            Largely it was to limit scope; I don't think the existing StaticValue handled that so what I stuck in this CL didn't either.

            Jake Bailey

            I should eliminate this condition, yeah.

            I'm sort of thinking about pulling CL 771500 backward in the stack, though, as that is the more general change. The problem is just that we don't do the whole oracle thing yet and that's what the rest of my stack is trying to do.

            Gerrit-Comment-Date: Tue, 28 Apr 2026 18:39:27 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            unsatisfied_requirement
            open
            diffy

            Mateusz Poliwczak (Gerrit)

            unread,
            Apr 28, 2026, 2:40:23 PM (15 hours ago) Apr 28
            to Jake Bailey, goph...@pubsubhelper.golang.org, Alan Donovan, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
            Attention needed from Alan Donovan, David Chase, Jake Bailey, Keith Randall and t hepudds

            Mateusz Poliwczak added 2 comments

            File src/cmd/compile/internal/ir/expr.go
            Line 1020, Patchset 3:// assignments, has any complex assignments (OAS2, OASOP, ORANGE), or
            // is assigned inside a closure.
            Mateusz Poliwczak . unresolved

            Is there any reason behind that, other than reducing the complexity? Just curious.

            Jake Bailey

            Largely it was to limit scope; I don't think the existing StaticValue handled that so what I stuck in this CL didn't either.

            Mateusz Poliwczak

            Hmm, I think it does since it follows `OCLOSURE`?

            I just wonder whether removing the `closureDepth > 0` is just enough to support this.

            Line 1032, Patchset 3:
            Mateusz Poliwczak . unresolved

            StaticValue skips for non-PAUTO, should we do that also here? See L902 here.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Alan Donovan
            • David Chase
            • Jake Bailey
            • Keith Randall
            • t hepudds
            Submit Requirements:
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • requirement is not satisfiedReview-Enforcement
            • requirement is not satisfiedTryBots-Pass
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: go
            Gerrit-Branch: master
            Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
            Gerrit-Change-Number: 771160
            Gerrit-PatchSet: 4
            Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
            Gerrit-Reviewer: David Chase <drc...@google.com>
            Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
            Gerrit-Reviewer: Keith Randall <k...@golang.org>
            Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
            Gerrit-CC: Alan Donovan <adon...@google.com>
            Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
            Gerrit-Attention: Jake Bailey <jacob.b...@gmail.com>
            Gerrit-Attention: Keith Randall <k...@golang.org>
            Gerrit-Attention: David Chase <drc...@google.com>
            Gerrit-Attention: t hepudds <thepud...@gmail.com>
            Gerrit-Attention: Alan Donovan <adon...@google.com>
            Gerrit-Comment-Date: Tue, 28 Apr 2026 18:40:15 +0000
            unsatisfied_requirement
            open
            diffy

            Mateusz Poliwczak (Gerrit)

            unread,
            Apr 28, 2026, 2:42:20 PM (15 hours ago) Apr 28
            to Jake Bailey, goph...@pubsubhelper.golang.org, Alan Donovan, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
            Attention needed from Alan Donovan, David Chase, Jake Bailey, Keith Randall and t hepudds

            Mateusz Poliwczak added 1 comment

            Patchset-level comments
            File-level comment, Patchset 4 (Latest):
            Mateusz Poliwczak . resolved

            FYI you can take a look at `devirtualize.go` as we do similar things there, i.e. the `analyze` func.

            Gerrit-Comment-Date: Tue, 28 Apr 2026 18:42:13 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            unsatisfied_requirement
            open
            diffy

            Jake Bailey (Gerrit)

            unread,
            Apr 28, 2026, 2:44:24 PM (15 hours ago) Apr 28
            to goph...@pubsubhelper.golang.org, Alan Donovan, Mateusz Poliwczak, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
            Attention needed from Alan Donovan, David Chase, Jake Bailey, Keith Randall and t hepudds

            Jake Bailey added 1 comment

            Patchset-level comments
            Jake Bailey . unresolved

            So in general, this CL contains the "native" / minimal version of this change, but to do more, I think I'd really want to have switched over to the ReassignOracle to track these assignments. thepudds had told me that this will break things that aren't tested, though, so I'm not sure exactly how you all want me to do it.

            I certainly prefer the method in my last CL in this stack where I can merge the results from all assinged funcs, rather than special casing a single func.

            Gerrit-Comment-Date: Tue, 28 Apr 2026 18:44:20 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            unsatisfied_requirement
            open
            diffy

            Mateusz Poliwczak (Gerrit)

            unread,
            Apr 28, 2026, 2:52:59 PM (14 hours ago) Apr 28
            to Jake Bailey, goph...@pubsubhelper.golang.org, Alan Donovan, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
            Attention needed from Alan Donovan, David Chase, Jake Bailey, Keith Randall and t hepudds

            Mateusz Poliwczak added 1 comment

            Patchset-level comments
            Jake Bailey . unresolved

            So in general, this CL contains the "native" / minimal version of this change, but to do more, I think I'd really want to have switched over to the ReassignOracle to track these assignments. thepudds had told me that this will break things that aren't tested, though, so I'm not sure exactly how you all want me to do it.

            I certainly prefer the method in my last CL in this stack where I can merge the results from all assinged funcs, rather than special casing a single func.

            Mateusz Poliwczak

            Personally I think we might need a specialized oracle just for this usecase. I have done that for devirtualizer and it seems to serve us well.

            I think that we also have a low-hanging fruit in the escape analysis i.e. to track all possible types of interface variables, that then we can use the same trick as in the CL 771500 to improve escape analysis results. And that also seems like a specialized need (although seems like a re-use of devirtualizer logic, with tiny modifications)

            But i will defer that to @k...@golang.org.

            Gerrit-Comment-Date: Tue, 28 Apr 2026 18:52:52 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            Comment-In-Reply-To: Jake Bailey <jacob.b...@gmail.com>
            unsatisfied_requirement
            open
            diffy

            Mateusz Poliwczak (Gerrit)

            unread,
            Apr 28, 2026, 2:57:36 PM (14 hours ago) Apr 28
            to Jake Bailey, goph...@pubsubhelper.golang.org, Alan Donovan, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
            Attention needed from Alan Donovan, David Chase, Jake Bailey, Keith Randall and t hepudds

            Mateusz Poliwczak added 1 comment

            File src/cmd/compile/internal/escape/call.go
            Line 44, Patchset 4 (Latest): v := ir.StaticValue(call.Fun)
            Mateusz Poliwczak . unresolved

            If we called `FuncSingleAssignment` here instead of `StaticValue`, shouldn't that work?

            Gerrit-Comment-Date: Tue, 28 Apr 2026 18:57:28 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            unsatisfied_requirement
            open
            diffy

            Mateusz Poliwczak (Gerrit)

            unread,
            Apr 28, 2026, 3:07:33 PM (14 hours ago) Apr 28
            to Jake Bailey, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Alan Donovan, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
            Attention needed from Alan Donovan, David Chase, Jake Bailey, Keith Randall and t hepudds

            Mateusz Poliwczak added 1 comment

            File src/cmd/compile/internal/ir/expr.go
            Line 1049, Patchset 4 (Latest): switch n.Op() {
            Mateusz Poliwczak . unresolved

            I think we need to handle `OSWITCH`, for example:

            ```
            foo := any(func(a *int) {escape = a})
            switch foo := foo.(type) {
            case func(a *int):
            foo = func(a *int) {}
            foo(new(int)) // might not escape
            }
            ```

            I think it might miss the implicit var declaration.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Alan Donovan
            • David Chase
            • Jake Bailey
            • Keith Randall
            • t hepudds
            Submit Requirements:
              • requirement is not satisfiedCode-Review
              • requirement is not satisfiedNo-Unresolved-Comments
              • requirement is not satisfiedReview-Enforcement
              • requirement satisfiedTryBots-Pass
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: go
              Gerrit-Branch: master
              Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
              Gerrit-Change-Number: 771160
              Gerrit-PatchSet: 4
              Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
              Gerrit-Reviewer: David Chase <drc...@google.com>
              Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
              Gerrit-Reviewer: Keith Randall <k...@golang.org>
              Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
              Gerrit-CC: Alan Donovan <adon...@google.com>
              Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
              Gerrit-Attention: Jake Bailey <jacob.b...@gmail.com>
              Gerrit-Attention: Keith Randall <k...@golang.org>
              Gerrit-Attention: David Chase <drc...@google.com>
              Gerrit-Attention: t hepudds <thepud...@gmail.com>
              Gerrit-Attention: Alan Donovan <adon...@google.com>
              Gerrit-Comment-Date: Tue, 28 Apr 2026 19:07:25 +0000
              Gerrit-HasComments: Yes
              Gerrit-Has-Labels: No
              unsatisfied_requirement
              satisfied_requirement
              open
              diffy

              Jake Bailey (Gerrit)

              unread,
              Apr 28, 2026, 3:44:51 PM (14 hours ago) Apr 28
              to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
              Attention needed from Alan Donovan, David Chase, Jake Bailey, Keith Randall and t hepudds

              Jake Bailey uploaded new patchset

              Jake Bailey uploaded patch set #5 to this change.
              Following approvals got outdated and were removed:

              Related details

              Attention is currently required from:
              • Alan Donovan
              • David Chase
              • Jake Bailey
              • Keith Randall
              • t hepudds
              Submit Requirements:
                • requirement is not satisfiedCode-Review
                • requirement is not satisfiedNo-Unresolved-Comments
                • requirement is not satisfiedReview-Enforcement
                • requirement is not satisfiedTryBots-Pass
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: newpatchset
                Gerrit-Project: go
                Gerrit-Branch: master
                Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
                Gerrit-Change-Number: 771160
                Gerrit-PatchSet: 5
                unsatisfied_requirement
                open
                diffy

                Jake Bailey (Gerrit)

                unread,
                Apr 28, 2026, 3:53:31 PM (13 hours ago) Apr 28
                to goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Alan Donovan, Mateusz Poliwczak, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
                Attention needed from Alan Donovan, David Chase, Keith Randall, Mateusz Poliwczak and t hepudds

                Jake Bailey added 1 comment

                Patchset-level comments
                Jake Bailey . unresolved

                So in general, this CL contains the "native" / minimal version of this change, but to do more, I think I'd really want to have switched over to the ReassignOracle to track these assignments. thepudds had told me that this will break things that aren't tested, though, so I'm not sure exactly how you all want me to do it.

                I certainly prefer the method in my last CL in this stack where I can merge the results from all assinged funcs, rather than special casing a single func.

                Mateusz Poliwczak

                Personally I think we might need a specialized oracle just for this usecase. I have done that for devirtualizer and it seems to serve us well.

                I think that we also have a low-hanging fruit in the escape analysis i.e. to track all possible types of interface variables, that then we can use the same trick as in the CL 771500 to improve escape analysis results. And that also seems like a specialized need (although seems like a re-use of devirtualizer logic, with tiny modifications)

                But i will defer that to @k...@golang.org.

                Jake Bailey

                I think that's right, frankly. I'm going to kill the stack and just turn this CL into one with a new oracle, and actually handle the multi-assignment case. I think that will basically resolve all of the comments.

                Open in Gerrit

                Related details

                Attention is currently required from:
                • Alan Donovan
                • David Chase
                • Keith Randall
                • Mateusz Poliwczak
                • t hepudds
                Submit Requirements:
                • requirement is not satisfiedCode-Review
                • requirement is not satisfiedNo-Unresolved-Comments
                • requirement is not satisfiedReview-Enforcement
                • requirement is not satisfiedTryBots-Pass
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: comment
                Gerrit-Project: go
                Gerrit-Branch: master
                Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
                Gerrit-Change-Number: 771160
                Gerrit-PatchSet: 4
                Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
                Gerrit-Reviewer: David Chase <drc...@google.com>
                Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
                Gerrit-Reviewer: Keith Randall <k...@golang.org>
                Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
                Gerrit-CC: Alan Donovan <adon...@google.com>
                Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
                Gerrit-Attention: Keith Randall <k...@golang.org>
                Gerrit-Attention: Mateusz Poliwczak <mpoliw...@gmail.com>
                Gerrit-Attention: David Chase <drc...@google.com>
                Gerrit-Attention: t hepudds <thepud...@gmail.com>
                Gerrit-Attention: Alan Donovan <adon...@google.com>
                Gerrit-Comment-Date: Tue, 28 Apr 2026 19:53:26 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: No
                unsatisfied_requirement
                open
                diffy

                Mateusz Poliwczak (Gerrit)

                unread,
                Apr 28, 2026, 4:16:18 PM (13 hours ago) Apr 28
                to Jake Bailey, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Alan Donovan, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
                Attention needed from Alan Donovan, David Chase, Jake Bailey, Keith Randall and t hepudds

                Mateusz Poliwczak added 1 comment

                File src/cmd/compile/internal/ir/expr.go
                Line 1092, Patchset 3: if Any(name.Curfn, do) {
                Keith Randall . unresolved

                This is going to be O(n^2), because this function is O(n) and we might call it O(n) times.
                Can we precompute this for a function for all variables? Similar to how ReassignOracle does it.

                Jake Bailey

                That's actually the next CL, where I stuck it into the oracle where I think it belongs.

                compilecmp didn't show that this CL negatively affected anything, however.

                Mateusz Poliwczak

                But on the other hand, without this CL the `StaticValue` is used, which has the same running time, right? So maybe we don't need a oracle at all?

                Open in Gerrit

                Related details

                Attention is currently required from:
                • Alan Donovan
                • David Chase
                • Jake Bailey
                • Keith Randall
                • t hepudds
                Submit Requirements:
                • requirement is not satisfiedCode-Review
                • requirement is not satisfiedNo-Unresolved-Comments
                • requirement is not satisfiedReview-Enforcement
                • requirement is not satisfiedTryBots-Pass
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: comment
                Gerrit-Project: go
                Gerrit-Branch: master
                Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
                Gerrit-Change-Number: 771160
                Gerrit-PatchSet: 5
                Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
                Gerrit-Reviewer: David Chase <drc...@google.com>
                Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
                Gerrit-Reviewer: Keith Randall <k...@golang.org>
                Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
                Gerrit-CC: Alan Donovan <adon...@google.com>
                Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
                Gerrit-Attention: Jake Bailey <jacob.b...@gmail.com>
                Gerrit-Attention: Keith Randall <k...@golang.org>
                Gerrit-Attention: David Chase <drc...@google.com>
                Gerrit-Attention: t hepudds <thepud...@gmail.com>
                Gerrit-Attention: Alan Donovan <adon...@google.com>
                Gerrit-Comment-Date: Tue, 28 Apr 2026 20:16:09 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: No
                Comment-In-Reply-To: Jake Bailey <jacob.b...@gmail.com>
                Comment-In-Reply-To: Keith Randall <k...@golang.org>
                unsatisfied_requirement
                open
                diffy

                Mateusz Poliwczak (Gerrit)

                unread,
                Apr 28, 2026, 4:18:21 PM (13 hours ago) Apr 28
                to Jake Bailey, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Alan Donovan, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
                Attention needed from Alan Donovan, David Chase, Jake Bailey, Keith Randall and t hepudds

                Mateusz Poliwczak added 1 comment

                File src/cmd/compile/internal/ir/expr.go
                Line 1092, Patchset 3: if Any(name.Curfn, do) {
                Keith Randall . unresolved

                This is going to be O(n^2), because this function is O(n) and we might call it O(n) times.
                Can we precompute this for a function for all variables? Similar to how ReassignOracle does it.

                Jake Bailey

                That's actually the next CL, where I stuck it into the oracle where I think it belongs.

                compilecmp didn't show that this CL negatively affected anything, however.

                Mateusz Poliwczak

                But on the other hand, without this CL the `StaticValue` is used, which has the same running time, right? So maybe we don't need a oracle at all?

                Mateusz Poliwczak

                My point now is what if we only swapped that `StaticValue` call with a specialized `StaticValue` call that handles multiple-assignments? Maybe that is all we need?

                Gerrit-Comment-Date: Tue, 28 Apr 2026 20:18:13 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: No
                Comment-In-Reply-To: Jake Bailey <jacob.b...@gmail.com>
                Comment-In-Reply-To: Keith Randall <k...@golang.org>
                Comment-In-Reply-To: Mateusz Poliwczak <mpoliw...@gmail.com>
                unsatisfied_requirement
                open
                diffy

                Jake Bailey (Gerrit)

                unread,
                Apr 28, 2026, 4:18:41 PM (13 hours ago) Apr 28
                to goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Alan Donovan, Mateusz Poliwczak, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
                Attention needed from Alan Donovan, David Chase, Keith Randall, Mateusz Poliwczak and t hepudds

                Jake Bailey added 1 comment

                File src/cmd/compile/internal/ir/expr.go
                Line 1092, Patchset 3: if Any(name.Curfn, do) {
                Keith Randall . unresolved

                This is going to be O(n^2), because this function is O(n) and we might call it O(n) times.
                Can we precompute this for a function for all variables? Similar to how ReassignOracle does it.

                Jake Bailey

                That's actually the next CL, where I stuck it into the oracle where I think it belongs.

                compilecmp didn't show that this CL negatively affected anything, however.

                Mateusz Poliwczak

                But on the other hand, without this CL the `StaticValue` is used, which has the same running time, right? So maybe we don't need a oracle at all?

                Jake Bailey

                Yes, and the current version of this stack also only does its collection for func-typed nodes, which does limit things.

                Open in Gerrit

                Related details

                Attention is currently required from:
                • Alan Donovan
                • David Chase
                • Keith Randall
                • Mateusz Poliwczak
                • t hepudds
                Submit Requirements:
                • requirement is not satisfiedCode-Review
                • requirement is not satisfiedNo-Unresolved-Comments
                • requirement is not satisfiedReview-Enforcement
                • requirement is not satisfiedTryBots-Pass
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: comment
                Gerrit-Project: go
                Gerrit-Branch: master
                Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
                Gerrit-Change-Number: 771160
                Gerrit-PatchSet: 5
                Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
                Gerrit-Reviewer: David Chase <drc...@google.com>
                Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
                Gerrit-Reviewer: Keith Randall <k...@golang.org>
                Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
                Gerrit-CC: Alan Donovan <adon...@google.com>
                Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
                Gerrit-Attention: Keith Randall <k...@golang.org>
                Gerrit-Attention: Mateusz Poliwczak <mpoliw...@gmail.com>
                Gerrit-Attention: David Chase <drc...@google.com>
                Gerrit-Attention: t hepudds <thepud...@gmail.com>
                Gerrit-Attention: Alan Donovan <adon...@google.com>
                Gerrit-Comment-Date: Tue, 28 Apr 2026 20:18:36 +0000
                unsatisfied_requirement
                open
                diffy

                Jake Bailey (Gerrit)

                unread,
                Apr 28, 2026, 4:23:18 PM (13 hours ago) Apr 28
                to goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Alan Donovan, Mateusz Poliwczak, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
                Attention needed from Alan Donovan, David Chase, Keith Randall, Mateusz Poliwczak and t hepudds

                Jake Bailey added 1 comment

                File src/cmd/compile/internal/ir/expr.go
                Line 1092, Patchset 3: if Any(name.Curfn, do) {
                Keith Randall . unresolved

                This is going to be O(n^2), because this function is O(n) and we might call it O(n) times.
                Can we precompute this for a function for all variables? Similar to how ReassignOracle does it.

                Jake Bailey

                That's actually the next CL, where I stuck it into the oracle where I think it belongs.

                compilecmp didn't show that this CL negatively affected anything, however.

                Mateusz Poliwczak

                But on the other hand, without this CL the `StaticValue` is used, which has the same running time, right? So maybe we don't need a oracle at all?

                Jake Bailey

                Yes, and the current version of this stack also only does its collection for func-typed nodes, which does limit things.

                Jake Bailey

                Oh, I see what you mean. Yeah, though it isn't much work to encapsulate it into an "oracle" struct and save it in the rare case it's used. I'm making a new bespoke visitor now just to see and it's turning out fine so far...

                Gerrit-Comment-Date: Tue, 28 Apr 2026 20:23:14 +0000
                unsatisfied_requirement
                open
                diffy

                Jake Bailey (Gerrit)

                unread,
                Apr 28, 2026, 4:44:52 PM (13 hours ago) Apr 28
                to goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Alan Donovan, Mateusz Poliwczak, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
                Attention needed from Alan Donovan, David Chase, Keith Randall, Mateusz Poliwczak and t hepudds

                Jake Bailey added 1 comment

                File src/cmd/compile/internal/ir/expr.go
                Line 1092, Patchset 3: if Any(name.Curfn, do) {
                Keith Randall . unresolved

                This is going to be O(n^2), because this function is O(n) and we might call it O(n) times.
                Can we precompute this for a function for all variables? Similar to how ReassignOracle does it.

                Jake Bailey

                That's actually the next CL, where I stuck it into the oracle where I think it belongs.

                compilecmp didn't show that this CL negatively affected anything, however.

                Mateusz Poliwczak

                But on the other hand, without this CL the `StaticValue` is used, which has the same running time, right? So maybe we don't need a oracle at all?

                Jake Bailey

                Yes, and the current version of this stack also only does its collection for func-typed nodes, which does limit things.

                Jake Bailey

                Oh, I see what you mean. Yeah, though it isn't much work to encapsulate it into an "oracle" struct and save it in the rare case it's used. I'm making a new bespoke visitor now just to see and it's turning out fine so far...

                Jake Bailey

                It was not in fact fine; the problem is that StaticValue does some stuff that is actually needed, such that getting rid of it for this purpose (no longer special casing a single-assignment to a static value) breaks things downstream. Not sure what to do here, because all of the options are kinda bad.

                I can make a custom visitor/oracle that does _part_ of the work that StaticValue does, but it's quite literally 300 lines to get right even before you get to more edge cases. I could try and shove it into the ReassignOracle like I did in this PR, but that does imply actually using it for StaticValue too?

                I think the idea I have is clear, "find all assignments to a function, union up the escape analysis for all of them and don't worry about nil", but acutally laying it out is sort of what I'm not sure about here and would like some guidance.

                Gerrit-Comment-Date: Tue, 28 Apr 2026 20:44:49 +0000
                unsatisfied_requirement
                open
                diffy

                Mateusz Poliwczak (Gerrit)

                unread,
                Apr 28, 2026, 4:50:49 PM (12 hours ago) Apr 28
                to Jake Bailey, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Alan Donovan, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
                Attention needed from Alan Donovan, David Chase, Jake Bailey, Keith Randall and t hepudds

                Mateusz Poliwczak added 1 comment

                File src/cmd/compile/internal/ir/expr.go
                Line 1092, Patchset 3: if Any(name.Curfn, do) {
                Keith Randall . unresolved

                This is going to be O(n^2), because this function is O(n) and we might call it O(n) times.
                Can we precompute this for a function for all variables? Similar to how ReassignOracle does it.

                Jake Bailey

                That's actually the next CL, where I stuck it into the oracle where I think it belongs.

                compilecmp didn't show that this CL negatively affected anything, however.

                Mateusz Poliwczak

                But on the other hand, without this CL the `StaticValue` is used, which has the same running time, right? So maybe we don't need a oracle at all?

                Jake Bailey

                Yes, and the current version of this stack also only does its collection for func-typed nodes, which does limit things.

                Jake Bailey

                Oh, I see what you mean. Yeah, though it isn't much work to encapsulate it into an "oracle" struct and save it in the rare case it's used. I'm making a new bespoke visitor now just to see and it's turning out fine so far...

                Jake Bailey

                It was not in fact fine; the problem is that StaticValue does some stuff that is actually needed, such that getting rid of it for this purpose (no longer special casing a single-assignment to a static value) breaks things downstream. Not sure what to do here, because all of the options are kinda bad.

                I can make a custom visitor/oracle that does _part_ of the work that StaticValue does, but it's quite literally 300 lines to get right even before you get to more edge cases. I could try and shove it into the ReassignOracle like I did in this PR, but that does imply actually using it for StaticValue too?

                I think the idea I have is clear, "find all assignments to a function, union up the escape analysis for all of them and don't worry about nil", but acutally laying it out is sort of what I'm not sure about here and would like some guidance.

                Mateusz Poliwczak

                I think the idea I have is clear, "find all assignments to a function, union up the escape analysis for all of them and don't worry about nil", but acutally laying it out is sort of what I'm not sure about here and would like some guidance.

                I think that you could just copy https://github.com/golang/go/blob/f93915339a717ad3732976c2a28cd8251e0dfdfd/src/cmd/compile/internal/devirtualize/devirtualize.go#L181-L614 and adjust it to work with values instead of types + remove the `ifaceCallExprAssigns` and `InlinedCall` method.

                It basically does the same thing, but for types.

                Open in Gerrit

                Related details

                Attention is currently required from:
                • Alan Donovan
                • David Chase
                • Jake Bailey
                • Keith Randall
                • t hepudds
                Submit Requirements:
                • requirement is not satisfiedCode-Review
                • requirement is not satisfiedNo-Unresolved-Comments
                • requirement is not satisfiedReview-Enforcement
                • requirement is not satisfiedTryBots-Pass
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: comment
                Gerrit-Project: go
                Gerrit-Branch: master
                Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
                Gerrit-Change-Number: 771160
                Gerrit-PatchSet: 5
                Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
                Gerrit-Reviewer: David Chase <drc...@google.com>
                Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
                Gerrit-Reviewer: Keith Randall <k...@golang.org>
                Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
                Gerrit-CC: Alan Donovan <adon...@google.com>
                Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
                Gerrit-Attention: Jake Bailey <jacob.b...@gmail.com>
                Gerrit-Attention: Keith Randall <k...@golang.org>
                Gerrit-Attention: David Chase <drc...@google.com>
                Gerrit-Attention: t hepudds <thepud...@gmail.com>
                Gerrit-Attention: Alan Donovan <adon...@google.com>
                Gerrit-Comment-Date: Tue, 28 Apr 2026 20:50:42 +0000
                unsatisfied_requirement
                open
                diffy

                Jake Bailey (Gerrit)

                unread,
                Apr 28, 2026, 7:38:43 PM (10 hours ago) Apr 28
                to goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Alan Donovan, Mateusz Poliwczak, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
                Attention needed from Alan Donovan, David Chase, Keith Randall, Mateusz Poliwczak and t hepudds

                Jake Bailey added 1 comment

                File src/cmd/compile/internal/ir/expr.go
                Line 1049, Patchset 4: switch n.Op() {
                Mateusz Poliwczak . unresolved

                I think we need to handle `OSWITCH`, for example:

                ```
                foo := any(func(a *int) {escape = a})
                switch foo := foo.(type) {
                case func(a *int):
                foo = func(a *int) {}
                foo(new(int)) // might not escape
                }
                ```

                I think it might miss the implicit var declaration.

                Jake Bailey

                No, it gets followeed via DoChildren through Any, pretty sure

                Open in Gerrit

                Related details

                Attention is currently required from:
                • Alan Donovan
                • David Chase
                • Keith Randall
                • Mateusz Poliwczak
                • t hepudds
                Submit Requirements:
                • requirement is not satisfiedCode-Review
                • requirement is not satisfiedNo-Unresolved-Comments
                • requirement is not satisfiedReview-Enforcement
                • requirement is not satisfiedTryBots-Pass
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: comment
                Gerrit-Project: go
                Gerrit-Branch: master
                Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
                Gerrit-Change-Number: 771160
                Gerrit-PatchSet: 5
                Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
                Gerrit-Reviewer: David Chase <drc...@google.com>
                Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
                Gerrit-Reviewer: Keith Randall <k...@golang.org>
                Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
                Gerrit-CC: Alan Donovan <adon...@google.com>
                Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
                Gerrit-Attention: Keith Randall <k...@golang.org>
                Gerrit-Attention: Mateusz Poliwczak <mpoliw...@gmail.com>
                Gerrit-Attention: David Chase <drc...@google.com>
                Gerrit-Attention: t hepudds <thepud...@gmail.com>
                Gerrit-Attention: Alan Donovan <adon...@google.com>
                Gerrit-Comment-Date: Tue, 28 Apr 2026 23:38:39 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: No
                Comment-In-Reply-To: Mateusz Poliwczak <mpoliw...@gmail.com>
                unsatisfied_requirement
                open
                diffy

                Jake Bailey (Gerrit)

                unread,
                Apr 28, 2026, 9:57:40 PM (7 hours ago) Apr 28
                to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
                Attention needed from Alan Donovan, David Chase, Keith Randall, Mateusz Poliwczak and t hepudds

                Jake Bailey uploaded new patchset

                Jake Bailey uploaded patch set #6 to this change.
                Open in Gerrit

                Related details

                Attention is currently required from:
                • Alan Donovan
                • David Chase
                • Keith Randall
                • Mateusz Poliwczak
                • t hepudds
                Submit Requirements:
                • requirement is not satisfiedCode-Review
                • requirement is not satisfiedNo-Unresolved-Comments
                • requirement is not satisfiedReview-Enforcement
                • requirement is not satisfiedTryBots-Pass
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: newpatchset
                Gerrit-Project: go
                Gerrit-Branch: master
                Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
                Gerrit-Change-Number: 771160
                Gerrit-PatchSet: 6
                unsatisfied_requirement
                open
                diffy

                Jake Bailey (Gerrit)

                unread,
                Apr 28, 2026, 10:00:35 PM (7 hours ago) Apr 28
                to goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Alan Donovan, Mateusz Poliwczak, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
                Attention needed from Alan Donovan, David Chase, Keith Randall, Mateusz Poliwczak and t hepudds

                Jake Bailey added 5 comments

                File src/cmd/compile/internal/escape/call.go
                Line 44, Patchset 4: v := ir.StaticValue(call.Fun)
                Mateusz Poliwczak . unresolved

                If we called `FuncSingleAssignment` here instead of `StaticValue`, shouldn't that work?

                Jake Bailey

                No, StaticValue does more stuff than the simple walker, and making it work basically means reimplementing StaticValue...

                File src/cmd/compile/internal/ir/expr.go
                Line 1018, Patchset 3:// non-nil RHS at the same function level (not inside a nested closure).
                Keith Randall . resolved

                Inside a loop is ok?
                (i.e. this is Static Single Assignment.)

                Jake Bailey

                Inside a loop is fine; really, any assignment is fine since we're not determining a static value, just what the escape analyzer sees.

                Jake Bailey

                Acknowledged

                Line 1020, Patchset 3:// assignments, has any complex assignments (OAS2, OASOP, ORANGE), or
                // is assigned inside a closure.
                Mateusz Poliwczak . unresolved

                Is there any reason behind that, other than reducing the complexity? Just curious.

                Jake Bailey

                Largely it was to limit scope; I don't think the existing StaticValue handled that so what I stuck in this CL didn't either.

                Mateusz Poliwczak

                Hmm, I think it does since it follows `OCLOSURE`?

                I just wonder whether removing the `closureDepth > 0` is just enough to support this.

                Jake Bailey

                Turns out there's other stuff in escape analysis that stops this; it seems like crossing the closure boundary causes Addrtaken. I could safely remove it I think, but it would effectively return later in the stack.

                Line 1049, Patchset 4: switch n.Op() {
                Mateusz Poliwczak . resolved

                I think we need to handle `OSWITCH`, for example:

                ```
                foo := any(func(a *int) {escape = a})
                switch foo := foo.(type) {
                case func(a *int):
                foo = func(a *int) {}
                foo(new(int)) // might not escape
                }
                ```

                I think it might miss the implicit var declaration.

                Jake Bailey

                No, it gets followeed via DoChildren through Any, pretty sure

                Jake Bailey

                Acknowledged

                Line 1084, Patchset 3: closureDepth--
                Keith Randall . resolved

                You could do this with a `defer`, then you don't need the `abort` flag. Just `return Any(n.Func, do)`.

                Jake Bailey

                Done

                Open in Gerrit

                Related details

                Attention is currently required from:
                • Alan Donovan
                • David Chase
                • Keith Randall
                • Mateusz Poliwczak
                • t hepudds
                Submit Requirements:
                • requirement is not satisfiedCode-Review
                • requirement is not satisfiedNo-Unresolved-Comments
                • requirement is not satisfiedReview-Enforcement
                • requirement is not satisfiedTryBots-Pass
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: comment
                Gerrit-Project: go
                Gerrit-Branch: master
                Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
                Gerrit-Change-Number: 771160
                Gerrit-PatchSet: 6
                Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
                Gerrit-Reviewer: David Chase <drc...@google.com>
                Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
                Gerrit-Reviewer: Keith Randall <k...@golang.org>
                Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
                Gerrit-CC: Alan Donovan <adon...@google.com>
                Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
                Gerrit-Attention: Keith Randall <k...@golang.org>
                Gerrit-Attention: Mateusz Poliwczak <mpoliw...@gmail.com>
                Gerrit-Attention: David Chase <drc...@google.com>
                Gerrit-Attention: t hepudds <thepud...@gmail.com>
                Gerrit-Attention: Alan Donovan <adon...@google.com>
                Gerrit-Comment-Date: Wed, 29 Apr 2026 02:00:31 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: No
                unsatisfied_requirement
                open
                diffy

                Jake Bailey (Gerrit)

                unread,
                Apr 28, 2026, 11:47:08 PM (5 hours ago) Apr 28
                to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
                Attention needed from Alan Donovan, David Chase, Keith Randall, Mateusz Poliwczak and t hepudds

                Jake Bailey uploaded new patchset

                Jake Bailey uploaded patch set #7 to this change.
                Following approvals got outdated and were removed:
                Open in Gerrit

                Related details

                Attention is currently required from:
                • Alan Donovan
                • David Chase
                • Keith Randall
                • Mateusz Poliwczak
                • t hepudds
                Submit Requirements:
                • requirement is not satisfiedCode-Review
                • requirement is not satisfiedNo-Unresolved-Comments
                • requirement is not satisfiedReview-Enforcement
                • requirement is not satisfiedTryBots-Pass
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: newpatchset
                Gerrit-Project: go
                Gerrit-Branch: master
                Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
                Gerrit-Change-Number: 771160
                Gerrit-PatchSet: 7
                unsatisfied_requirement
                open
                diffy

                Jake Bailey (Gerrit)

                unread,
                Apr 28, 2026, 11:47:15 PM (5 hours ago) Apr 28
                to goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Alan Donovan, Mateusz Poliwczak, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
                Attention needed from Alan Donovan, David Chase, Keith Randall, Mateusz Poliwczak and t hepudds

                Jake Bailey added 3 comments

                Patchset-level comments
                Jake Bailey . unresolved

                So in general, this CL contains the "native" / minimal version of this change, but to do more, I think I'd really want to have switched over to the ReassignOracle to track these assignments. thepudds had told me that this will break things that aren't tested, though, so I'm not sure exactly how you all want me to do it.

                I certainly prefer the method in my last CL in this stack where I can merge the results from all assinged funcs, rather than special casing a single func.

                Mateusz Poliwczak

                Personally I think we might need a specialized oracle just for this usecase. I have done that for devirtualizer and it seems to serve us well.

                I think that we also have a low-hanging fruit in the escape analysis i.e. to track all possible types of interface variables, that then we can use the same trick as in the CL 771500 to improve escape analysis results. And that also seems like a specialized need (although seems like a re-use of devirtualizer logic, with tiny modifications)

                But i will defer that to @k...@golang.org.

                Jake Bailey

                I think that's right, frankly. I'm going to kill the stack and just turn this CL into one with a new oracle, and actually handle the multi-assignment case. I think that will basically resolve all of the comments.

                Jake Bailey

                I tried and it didn't go incredibly; it added something like 300 lines of code. I sort of think the reassign oracle is the end-all-be-all of this...

                File src/cmd/compile/internal/ir/expr.go
                Line 1032, Patchset 3:
                Mateusz Poliwczak . resolved

                StaticValue skips for non-PAUTO, should we do that also here? See L902 here.

                Jake Bailey

                Done

                Line 1102, Patchset 3: if !ok || as.Y == nil {
                Keith Randall . resolved

                as.Y == nil should return true? We use that for zero-initialization.

                Jake Bailey

                Done

                Open in Gerrit

                Related details

                Attention is currently required from:
                • Alan Donovan
                • David Chase
                • Keith Randall
                • Mateusz Poliwczak
                • t hepudds
                Submit Requirements:
                • requirement is not satisfiedCode-Review
                • requirement is not satisfiedNo-Unresolved-Comments
                • requirement is not satisfiedReview-Enforcement
                • requirement is not satisfiedTryBots-Pass
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: comment
                Gerrit-Project: go
                Gerrit-Branch: master
                Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
                Gerrit-Change-Number: 771160
                Gerrit-PatchSet: 7
                Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
                Gerrit-Reviewer: David Chase <drc...@google.com>
                Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
                Gerrit-Reviewer: Keith Randall <k...@golang.org>
                Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
                Gerrit-CC: Alan Donovan <adon...@google.com>
                Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
                Gerrit-Attention: Keith Randall <k...@golang.org>
                Gerrit-Attention: Mateusz Poliwczak <mpoliw...@gmail.com>
                Gerrit-Attention: David Chase <drc...@google.com>
                Gerrit-Attention: t hepudds <thepud...@gmail.com>
                Gerrit-Attention: Alan Donovan <adon...@google.com>
                Gerrit-Comment-Date: Wed, 29 Apr 2026 03:47:12 +0000
                unsatisfied_requirement
                open
                diffy

                Mateusz Poliwczak (Gerrit)

                unread,
                2:42 AM (3 hours ago) 2:42 AM
                to Jake Bailey, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Alan Donovan, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
                Attention needed from Alan Donovan, David Chase, Jake Bailey, Keith Randall and t hepudds

                Mateusz Poliwczak added 1 comment

                File src/cmd/compile/internal/ir/expr.go
                Line 1049, Patchset 4: switch n.Op() {
                Mateusz Poliwczak . unresolved

                I think we need to handle `OSWITCH`, for example:

                ```
                foo := any(func(a *int) {escape = a})
                switch foo := foo.(type) {
                case func(a *int):
                foo = func(a *int) {}
                foo(new(int)) // might not escape
                }
                ```

                I think it might miss the implicit var declaration.

                Jake Bailey

                No, it gets followeed via DoChildren through Any, pretty sure

                Jake Bailey

                Acknowledged

                Mateusz Poliwczak

                Can we have a testcase for this?

                Open in Gerrit

                Related details

                Attention is currently required from:
                • Alan Donovan
                • David Chase
                • Jake Bailey
                • Keith Randall
                • t hepudds
                Submit Requirements:
                  • requirement is not satisfiedCode-Review
                  • requirement is not satisfiedNo-Unresolved-Comments
                  • requirement is not satisfiedReview-Enforcement
                  • requirement satisfiedTryBots-Pass
                  Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                  Gerrit-MessageType: comment
                  Gerrit-Project: go
                  Gerrit-Branch: master
                  Gerrit-Change-Id: I6b701748f05f62376a46bc811181698d8ef76d47
                  Gerrit-Change-Number: 771160
                  Gerrit-PatchSet: 7
                  Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
                  Gerrit-Reviewer: David Chase <drc...@google.com>
                  Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
                  Gerrit-Reviewer: Keith Randall <k...@golang.org>
                  Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
                  Gerrit-CC: Alan Donovan <adon...@google.com>
                  Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
                  Gerrit-Attention: Jake Bailey <jacob.b...@gmail.com>
                  Gerrit-Attention: Keith Randall <k...@golang.org>
                  Gerrit-Attention: David Chase <drc...@google.com>
                  Gerrit-Attention: t hepudds <thepud...@gmail.com>
                  Gerrit-Attention: Alan Donovan <adon...@google.com>
                  Gerrit-Comment-Date: Wed, 29 Apr 2026 06:42:36 +0000
                  Gerrit-HasComments: Yes
                  Gerrit-Has-Labels: No
                  Comment-In-Reply-To: Jake Bailey <jacob.b...@gmail.com>
                  Comment-In-Reply-To: Mateusz Poliwczak <mpoliw...@gmail.com>
                  unsatisfied_requirement
                  satisfied_requirement
                  open
                  diffy

                  Mateusz Poliwczak (Gerrit)

                  unread,
                  3:01 AM (2 hours ago) 3:01 AM
                  to Jake Bailey, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Alan Donovan, Keith Randall, David Chase, t hepudds, golang-co...@googlegroups.com
                  Attention needed from Alan Donovan, David Chase, Jake Bailey, Keith Randall and t hepudds

                  Mateusz Poliwczak added 1 comment

                  File src/cmd/compile/internal/escape/call.go
                  Line 44, Patchset 4: v := ir.StaticValue(call.Fun)
                  Mateusz Poliwczak . resolved

                  If we called `FuncSingleAssignment` here instead of `StaticValue`, shouldn't that work?

                  Jake Bailey

                  No, StaticValue does more stuff than the simple walker, and making it work basically means reimplementing StaticValue...

                  Mateusz Poliwczak

                  Acknowledged

                  Gerrit-Comment-Date: Wed, 29 Apr 2026 07:01:34 +0000
                  unsatisfied_requirement
                  satisfied_requirement
                  open
                  diffy
                  Reply all
                  Reply to author
                  Forward
                  0 new messages