[go] cmd/compile: generate single deferreturn block

23 views
Skip to first unread message

Youlin Feng (Gerrit)

unread,
Nov 1, 2025, 8:48:43 AM11/1/25
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Youlin Feng has uploaded the change for review

Commit message

cmd/compile: generate single deferreturn block

For the following code, we used to generate two Ret blocks for fn, one
as the function's normal return, the other as the defer's recovery code
path, both containing a call to runtime.deferreturn.

func fn(n int, f func(int)) {
for i := range n {
defer f(i)
}
}

On AMD64, the Ret blocks look like this:

CALL runtime.deferreturn(SB)
ADDQ $0x18, SP
POPQ BP
RET
CALL runtime.deferreturn(SB)
ADDQ $0x18, SP
POPQ BP
RET

This CL omits the second block, uses the normal return block as well as
the recovery code path, thus reducing at least four instructions.
Change-Id: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c

Change diff

diff --git a/src/cmd/compile/internal/ssa/check.go b/src/cmd/compile/internal/ssa/check.go
index ef06bd9..b1067fd 100644
--- a/src/cmd/compile/internal/ssa/check.go
+++ b/src/cmd/compile/internal/ssa/check.go
@@ -85,8 +85,8 @@
f.Fatalf("if block %s has non-bool control value %s", b, b.Controls[0].LongString())
}
case BlockDefer:
- if len(b.Succs) != 2 {
- f.Fatalf("defer block %s len(Succs)==%d, want 2", b, len(b.Succs))
+ if len(b.Succs) != 2 && len(b.Succs) != 1 {
+ f.Fatalf("defer block %s len(Succs)==%d, want 2 or 1", b, len(b.Succs))
}
if b.NumControls() != 1 {
f.Fatalf("defer block %s has no control value", b)
@@ -94,6 +94,22 @@
if !b.Controls[0].Type.IsMemory() {
f.Fatalf("defer block %s has non-memory control value %s", b, b.Controls[0].LongString())
}
+ var deferReturn bool
+ for _, b := range f.Blocks {
+ if b.Kind != BlockRet || len(b.Preds) == 0 {
+ continue
+ }
+ for _, v := range b.Values {
+ if c, ok := v.Aux.(*AuxCall); ok && c.Fn.String() == "runtime.deferreturn" {
+ deferReturn = true
+ break
+ }
+ }
+ break
+ }
+ if !deferReturn {
+ f.Fatalf("defer block %s has no deferreturn", b)
+ }
case BlockFirst:
if len(b.Succs) != 2 {
f.Fatalf("plain/dead block %s len(Succs)==%d, want 2", b, len(b.Succs))
diff --git a/src/cmd/compile/internal/ssa/func.go b/src/cmd/compile/internal/ssa/func.go
index fc8cb3f..1a14eda 100644
--- a/src/cmd/compile/internal/ssa/func.go
+++ b/src/cmd/compile/internal/ssa/func.go
@@ -46,7 +46,7 @@
NoSplit bool // true if function is marked as nosplit. Used by schedule check pass.
dumpFileSeq uint8 // the sequence numbers of dump file. (%s_%02d__%s.dump", funcname, dumpFileSeq, phaseName)
IsPgoHot bool
- DeferReturn *Block // avoid creating more than one deferreturn if there's multiple calls to deferproc-etc.
+ Defer *Block // avoid creating more than one deferreturn if there's multiple calls to deferproc-etc.

// when register allocation is done, maps value ids to locations
RegAlloc []Location
diff --git a/src/cmd/compile/internal/ssagen/ssa.go b/src/cmd/compile/internal/ssagen/ssa.go
index db2ffb5..0529330 100644
--- a/src/cmd/compile/internal/ssagen/ssa.go
+++ b/src/cmd/compile/internal/ssagen/ssa.go
@@ -562,11 +562,20 @@
s.paramsToHeap()
s.stmtList(fn.Body)

+ var r *ssa.Block
// fallthrough to exit
if s.curBlock != nil {
s.pushLine(fn.Endlineno)
- s.exit()
+ r = s.exit()
s.popLine()
+ } else if s.f.Defer != nil {
+ r = s.f.NewBlock(ssa.BlockPlain) // Share a single deferreturn among all defers
+ s.startBlock(r)
+ s.exit()
+ }
+ if r != nil && len(r.Preds) == 0 && s.f.Defer != nil {
+ s.f.Defer.AddEdgeTo(r) // Add recover edge to exit code. This is a fake edge to keep the block live.
+ s.f.Defer.Likely = ssa.BranchLikely
}

for _, b := range s.f.Blocks {
@@ -4927,15 +4936,7 @@
b.SetControl(call)
bNext := s.f.NewBlock(ssa.BlockPlain)
b.AddEdgeTo(bNext)
- r := s.f.DeferReturn // Share a single deferreturn among all defers
- if r == nil {
- r = s.f.NewBlock(ssa.BlockPlain)
- s.startBlock(r)
- s.exit()
- s.f.DeferReturn = r
- }
- b.AddEdgeTo(r) // Add recover edge to exit code. This is a fake edge to keep the block live.
- b.Likely = ssa.BranchLikely
+ s.f.Defer = b
s.startBlock(bNext)
}

Change information

Files:
  • M src/cmd/compile/internal/ssa/check.go
  • M src/cmd/compile/internal/ssa/func.go
  • M src/cmd/compile/internal/ssagen/ssa.go
Change size: S
Delta: 3 files changed, 30 insertions(+), 13 deletions(-)
Open in Gerrit

Related details

Attention set is empty
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: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
Gerrit-Change-Number: 716980
Gerrit-PatchSet: 1
Gerrit-Owner: Youlin Feng <fengy...@live.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Youlin Feng (Gerrit)

unread,
Nov 1, 2025, 8:50:31 AM11/1/25
to goph...@pubsubhelper.golang.org, Keith Randall, David Chase, golang-co...@googlegroups.com
Attention needed from David Chase and Keith Randall

Youlin Feng voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • David Chase
  • Keith Randall
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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
Gerrit-Change-Number: 716980
Gerrit-PatchSet: 1
Gerrit-Owner: Youlin Feng <fengy...@live.com>
Gerrit-Reviewer: David Chase <drc...@google.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
Gerrit-Attention: Keith Randall <k...@golang.org>
Gerrit-Attention: David Chase <drc...@google.com>
Gerrit-Comment-Date: Sat, 01 Nov 2025 12:50:23 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Youlin Feng (Gerrit)

unread,
Nov 2, 2025, 12:20:17 AM11/2/25
to goph...@pubsubhelper.golang.org, Go LUCI, Keith Randall, David Chase, golang-co...@googlegroups.com
Attention needed from David Chase and Keith Randall

Youlin Feng voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • David Chase
  • Keith Randall
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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
Gerrit-Change-Number: 716980
Gerrit-PatchSet: 3
Gerrit-Owner: Youlin Feng <fengy...@live.com>
Gerrit-Reviewer: David Chase <drc...@google.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
Gerrit-Attention: Keith Randall <k...@golang.org>
Gerrit-Attention: David Chase <drc...@google.com>
Gerrit-Comment-Date: Sun, 02 Nov 2025 04:20:08 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Keith Randall (Gerrit)

unread,
Nov 3, 2025, 1:04:15 PM11/3/25
to Youlin Feng, goph...@pubsubhelper.golang.org, Go LUCI, Keith Randall, David Chase, golang-co...@googlegroups.com
Attention needed from David Chase and Youlin Feng

Keith Randall added 2 comments

File src/cmd/compile/internal/ssa/prove.go
Line 1727, Patchset 3 (Latest): // block that used as the recovery code path. Since the normal return
Keith Randall . unresolved

that is used

Line 1740, Patchset 3 (Latest): p.b.ResetControls()
Keith Randall . unresolved

I'm not sure I understand how this is supposed to work.
The normal return block might have other stuff in it.

For instance, this program:
```
var g int

func fn(n int, f func(int)) {
for i := range n {
defer f(i)
}
	g = 5
}
```
The normal return block has the `g=5` store in it, but we can't have that in the deferreturn path.

Also, if I remember correctly the OpDefer needs to stay around for liveness analysis. (I don't remember what the issue was, so maybe no longer an issue?)

Open in Gerrit

Related details

Attention is currently required from:
  • David Chase
  • Youlin Feng
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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
    Gerrit-Change-Number: 716980
    Gerrit-PatchSet: 3
    Gerrit-Owner: Youlin Feng <fengy...@live.com>
    Gerrit-Reviewer: David Chase <drc...@google.com>
    Gerrit-Reviewer: Keith Randall <k...@golang.org>
    Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
    Gerrit-Attention: David Chase <drc...@google.com>
    Gerrit-Attention: Youlin Feng <fengy...@live.com>
    Gerrit-Comment-Date: Mon, 03 Nov 2025 18:04:08 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Youlin Feng (Gerrit)

    unread,
    Nov 4, 2025, 8:09:58 AM11/4/25
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from David Chase and Youlin Feng

    Youlin Feng uploaded new patchset

    Youlin Feng uploaded patch set #4 to this change.
    Following approvals got outdated and were removed:
    • TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
    Open in Gerrit

    Related details

    Attention is currently required from:
    • David Chase
    • Youlin Feng
    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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
      Gerrit-Change-Number: 716980
      Gerrit-PatchSet: 4
      unsatisfied_requirement
      open
      diffy

      Youlin Feng (Gerrit)

      unread,
      Nov 4, 2025, 8:19:24 AM11/4/25
      to goph...@pubsubhelper.golang.org, Go LUCI, Keith Randall, David Chase, golang-co...@googlegroups.com
      Attention needed from David Chase and Keith Randall

      Youlin Feng voted and added 2 comments

      Votes added by Youlin Feng

      Commit-Queue+1

      2 comments

      File src/cmd/compile/internal/ssa/prove.go
      Line 1727, Patchset 3: // block that used as the recovery code path. Since the normal return
      Keith Randall . resolved

      that is used

      Youlin Feng

      Done

      Line 1740, Patchset 3: p.b.ResetControls()
      Keith Randall . resolved

      I'm not sure I understand how this is supposed to work.
      The normal return block might have other stuff in it.

      For instance, this program:
      ```
      var g int
      func fn(n int, f func(int)) {
      for i := range n {
      defer f(i)
      }
      g = 5
      }
      ```
      The normal return block has the `g=5` store in it, but we can't have that in the deferreturn path.

      Also, if I remember correctly the OpDefer needs to stay around for liveness analysis. (I don't remember what the issue was, so maybe no longer an issue?)

      Youlin Feng

      The final part of a normal return block and the whole deferreturn block both are generated by the `(*state).exit()`, the assembly code in both blocks that start from the instruction that calls `runtime.deferreturn` should be same. The panic recovery will jump back to the instruction that calls `runtime.deferreturn`, so the code in the normal return block that before this instruction may not matter.

      I can find an OpDefer, maybe you mean BlockDefer? I don't known.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • David Chase
      • Keith Randall
      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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
        Gerrit-Change-Number: 716980
        Gerrit-PatchSet: 4
        Gerrit-Owner: Youlin Feng <fengy...@live.com>
        Gerrit-Reviewer: David Chase <drc...@google.com>
        Gerrit-Reviewer: Keith Randall <k...@golang.org>
        Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
        Gerrit-Attention: Keith Randall <k...@golang.org>
        Gerrit-Attention: David Chase <drc...@google.com>
        Gerrit-Comment-Date: Tue, 04 Nov 2025 13:19:16 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        Comment-In-Reply-To: Keith Randall <k...@golang.org>
        unsatisfied_requirement
        satisfied_requirement
        open
        diffy

        Keith Randall (Gerrit)

        unread,
        Nov 4, 2025, 11:02:55 AM11/4/25
        to Youlin Feng, goph...@pubsubhelper.golang.org, Go LUCI, Keith Randall, David Chase, golang-co...@googlegroups.com
        Attention needed from David Chase and Youlin Feng

        Keith Randall added 1 comment

        File src/cmd/compile/internal/ssa/prove.go
        Line 1740, Patchset 3: p.b.ResetControls()
        Keith Randall . unresolved

        I'm not sure I understand how this is supposed to work.
        The normal return block might have other stuff in it.

        For instance, this program:
        ```
        var g int
        func fn(n int, f func(int)) {
        for i := range n {
        defer f(i)
        }
        g = 5
        }
        ```
        The normal return block has the `g=5` store in it, but we can't have that in the deferreturn path.

        Also, if I remember correctly the OpDefer needs to stay around for liveness analysis. (I don't remember what the issue was, so maybe no longer an issue?)

        Youlin Feng

        The final part of a normal return block and the whole deferreturn block both are generated by the `(*state).exit()`, the assembly code in both blocks that start from the instruction that calls `runtime.deferreturn` should be same. The panic recovery will jump back to the instruction that calls `runtime.deferreturn`, so the code in the normal return block that before this instruction may not matter.

        I can find an OpDefer, maybe you mean BlockDefer? I don't known.

        Keith Randall

        Yes, sorry, BlockDefer.
        I think maybe it is just used for https://github.com/golang/go/blob/34fec512ce34fb5926aa38e0ccd0083feed94733/src/cmd/compile/internal/ssagen/ssa.go#L4937 . Maybe you would need to add Func.DeferReturn as a reachable block here: https://github.com/golang/go/blob/34fec512ce34fb5926aa38e0ccd0083feed94733/src/cmd/compile/internal/ssa/deadcode.go#L24 ?
        But then it won't get deadcoded if the defer statement is determined to be unreachable.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • David Chase
        • Youlin Feng
        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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
          Gerrit-Change-Number: 716980
          Gerrit-PatchSet: 4
          Gerrit-Owner: Youlin Feng <fengy...@live.com>
          Gerrit-Reviewer: David Chase <drc...@google.com>
          Gerrit-Reviewer: Keith Randall <k...@golang.org>
          Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
          Gerrit-Attention: David Chase <drc...@google.com>
          Gerrit-Attention: Youlin Feng <fengy...@live.com>
          Gerrit-Comment-Date: Tue, 04 Nov 2025 16:02:46 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Keith Randall <k...@golang.org>
          Comment-In-Reply-To: Youlin Feng <fengy...@live.com>
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Cherry Mui (Gerrit)

          unread,
          Nov 4, 2025, 1:27:11 PM11/4/25
          to Youlin Feng, goph...@pubsubhelper.golang.org, Go LUCI, Keith Randall, David Chase, golang-co...@googlegroups.com
          Attention needed from David Chase and Youlin Feng

          Cherry Mui added 1 comment

          Commit Message
          Line 7, Patchset 4 (Latest):cmd/compile/internal/ssa: remove extra deferreturn block in prove pass
          Cherry Mui . unresolved

          Why prove pass? This doesn't seem to have anything to do with prove. If we want to do this (which I'm not sure), the deadcode pass seems more reasonable.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • David Chase
          • Youlin Feng
          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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
          Gerrit-Change-Number: 716980
          Gerrit-PatchSet: 4
          Gerrit-Owner: Youlin Feng <fengy...@live.com>
          Gerrit-Reviewer: David Chase <drc...@google.com>
          Gerrit-Reviewer: Keith Randall <k...@golang.org>
          Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
          Gerrit-CC: Cherry Mui <cher...@google.com>
          Gerrit-Attention: David Chase <drc...@google.com>
          Gerrit-Attention: Youlin Feng <fengy...@live.com>
          Gerrit-Comment-Date: Tue, 04 Nov 2025 18:27:07 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Youlin Feng (Gerrit)

          unread,
          Nov 5, 2025, 1:26:57 AM11/5/25
          to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
          Attention needed from David Chase and Youlin Feng

          Youlin Feng uploaded new patchset

          Youlin Feng uploaded patch set #5 to this change.
          Following approvals got outdated and were removed:
          • TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI

          Related details

          Attention is currently required from:
          • David Chase
          • Youlin Feng
          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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
            Gerrit-Change-Number: 716980
            Gerrit-PatchSet: 5
            unsatisfied_requirement
            open
            diffy

            Youlin Feng (Gerrit)

            unread,
            Nov 5, 2025, 1:59:55 AM11/5/25
            to goph...@pubsubhelper.golang.org, Cherry Mui, Go LUCI, Keith Randall, David Chase, golang-co...@googlegroups.com
            Attention needed from Cherry Mui, David Chase and Keith Randall

            Youlin Feng voted and added 2 comments

            Votes added by Youlin Feng

            Commit-Queue+1

            2 comments

            Commit Message
            Line 7, Patchset 4:cmd/compile/internal/ssa: remove extra deferreturn block in prove pass
            Cherry Mui . resolved

            Why prove pass? This doesn't seem to have anything to do with prove. If we want to do this (which I'm not sure), the deadcode pass seems more reasonable.

            Youlin Feng

            Yes, I initially tried to do this in the deadcode pass, but it didn't work. In fact, DeferReturn will not be a dead block in most cases, as every BlockDefer maintains an edge to it. What I’m doing in the prove pass is more like proving that the DeferReturn block is useless via a rule: "when there is a live normal return block". This rule cannot be satisfied if the final outcome is a panic or an infinite loop, in which cases the normal return block will be dead. If I remove the DeferReturn block in the deadcode pass using the same rule, and the normal return block is later removed in subsequent passes (for example, the opt pass), a "no deferreturn" runtime error will occur. Thus, moving this logic to the deadcode pass seems to execute it too early—I need to do it a little later, and it seems that the generic deadcode pass may be suitable. I’m not familiar with many of the passes; perhaps there are better alternatives?

            File src/cmd/compile/internal/ssa/prove.go
            Line 1740, Patchset 3: p.b.ResetControls()
            Keith Randall . resolved

            I'm not sure I understand how this is supposed to work.
            The normal return block might have other stuff in it.

            For instance, this program:
            ```
            var g int
            func fn(n int, f func(int)) {
            for i := range n {
            defer f(i)
            }
            g = 5
            }
            ```
            The normal return block has the `g=5` store in it, but we can't have that in the deferreturn path.

            Also, if I remember correctly the OpDefer needs to stay around for liveness analysis. (I don't remember what the issue was, so maybe no longer an issue?)

            Youlin Feng

            The final part of a normal return block and the whole deferreturn block both are generated by the `(*state).exit()`, the assembly code in both blocks that start from the instruction that calls `runtime.deferreturn` should be same. The panic recovery will jump back to the instruction that calls `runtime.deferreturn`, so the code in the normal return block that before this instruction may not matter.

            I can find an OpDefer, maybe you mean BlockDefer? I don't known.

            Keith Randall

            Yes, sorry, BlockDefer.
            I think maybe it is just used for https://github.com/golang/go/blob/34fec512ce34fb5926aa38e0ccd0083feed94733/src/cmd/compile/internal/ssagen/ssa.go#L4937 . Maybe you would need to add Func.DeferReturn as a reachable block here: https://github.com/golang/go/blob/34fec512ce34fb5926aa38e0ccd0083feed94733/src/cmd/compile/internal/ssa/deadcode.go#L24 ?
            But then it won't get deadcoded if the defer statement is determined to be unreachable.

            Youlin Feng

            I tried implementing it in the deadcode pass. How does it look this time?

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Cherry Mui
            • David Chase
            • Keith Randall
            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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
              Gerrit-Change-Number: 716980
              Gerrit-PatchSet: 5
              Gerrit-Owner: Youlin Feng <fengy...@live.com>
              Gerrit-Reviewer: David Chase <drc...@google.com>
              Gerrit-Reviewer: Keith Randall <k...@golang.org>
              Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
              Gerrit-CC: Cherry Mui <cher...@google.com>
              Gerrit-Attention: Keith Randall <k...@golang.org>
              Gerrit-Attention: Cherry Mui <cher...@google.com>
              Gerrit-Attention: David Chase <drc...@google.com>
              Gerrit-Comment-Date: Wed, 05 Nov 2025 06:59:47 +0000
              Gerrit-HasComments: Yes
              Gerrit-Has-Labels: Yes
              Comment-In-Reply-To: Keith Randall <k...@golang.org>
              Comment-In-Reply-To: Cherry Mui <cher...@google.com>
              Comment-In-Reply-To: Youlin Feng <fengy...@live.com>
              unsatisfied_requirement
              satisfied_requirement
              open
              diffy

              Youlin Feng (Gerrit)

              unread,
              Nov 5, 2025, 5:59:30 PM11/5/25
              to goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com
              Attention needed from Cherry Mui, David Chase and Keith Randall

              Youlin Feng voted Commit-Queue+1

              Commit-Queue+1
              Gerrit-Comment-Date: Wed, 05 Nov 2025 22:59:20 +0000
              Gerrit-HasComments: No
              Gerrit-Has-Labels: Yes
              unsatisfied_requirement
              satisfied_requirement
              open
              diffy

              Keith Randall (Gerrit)

              unread,
              Nov 10, 2025, 6:01:31 PM11/10/25
              to Youlin Feng, goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com
              Attention needed from Cherry Mui, David Chase and Youlin Feng

              Keith Randall added 1 comment

              File src/cmd/compile/internal/ssa/deadcode.go
              Line 189, Patchset 5 (Latest): reachable[f.DeferReturn.ID] = false
              Keith Randall . unresolved

              I don't understand how this works. If we mark the deferreturn block as unreachable, then what happens to the BlockDefer blocks?
              What do we mark as the final deferreturn entry point?

              Open in Gerrit

              Related details

              Attention is currently required from:
              • Cherry Mui
              • David Chase
              • Youlin Feng
              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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                Gerrit-Change-Number: 716980
                Gerrit-PatchSet: 5
                Gerrit-Owner: Youlin Feng <fengy...@live.com>
                Gerrit-Reviewer: David Chase <drc...@google.com>
                Gerrit-Reviewer: Keith Randall <k...@golang.org>
                Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                Gerrit-CC: Cherry Mui <cher...@google.com>
                Gerrit-Attention: Cherry Mui <cher...@google.com>
                Gerrit-Attention: David Chase <drc...@google.com>
                Gerrit-Attention: Youlin Feng <fengy...@live.com>
                Gerrit-Comment-Date: Mon, 10 Nov 2025 23:01:26 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: No
                unsatisfied_requirement
                satisfied_requirement
                open
                diffy

                Youlin Feng (Gerrit)

                unread,
                Nov 11, 2025, 5:08:14 AM11/11/25
                to goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com
                Attention needed from Keith Randall

                Youlin Feng added 1 comment

                File src/cmd/compile/internal/ssa/deadcode.go
                Keith Randall . unresolved

                I don't understand how this works. If we mark the deferreturn block as unreachable, then what happens to the BlockDefer blocks?
                What do we mark as the final deferreturn entry point?

                Youlin Feng

                Because we have two BlockRet blocks both containing the `CALL runtime.deferreturn(SB)`, one is the normal return block of the function, the other one is only used as the recovery destination.

                ```
                BlockDefer
                /\
                / \
                / \
                / \
                BlockXXX BlockRet (DeferReturn, the recovery path)
                |
                |
                Blocks
                |
                |
                BlockRet (normal return)
                ```
                The linker picks the first deferreturn call it sees, https://github.com/golang/go/blob/go1.25.4/src/cmd/compile/internal/ssagen/ssa.go#L2296. So, when the DeferReturn block is removed, the `recovery()` can use the `CALL runtime.deferreturn(SB)` in the normal return block as its destination.

                Is this okay? Did I miss something?

                Open in Gerrit

                Related details

                Attention is currently required from:
                • Keith Randall
                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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                Gerrit-Change-Number: 716980
                Gerrit-PatchSet: 5
                Gerrit-Owner: Youlin Feng <fengy...@live.com>
                Gerrit-Reviewer: David Chase <drc...@google.com>
                Gerrit-Reviewer: Keith Randall <k...@golang.org>
                Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                Gerrit-CC: Cherry Mui <cher...@google.com>
                Gerrit-Attention: Keith Randall <k...@golang.org>
                Gerrit-Comment-Date: Tue, 11 Nov 2025 10:08:06 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: No
                Comment-In-Reply-To: Keith Randall <k...@golang.org>
                unsatisfied_requirement
                satisfied_requirement
                open
                diffy

                Keith Randall (Gerrit)

                unread,
                Nov 11, 2025, 12:32:14 PM11/11/25
                to Youlin Feng, goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com
                Attention needed from Youlin Feng

                Keith Randall added 1 comment

                File src/cmd/compile/internal/ssa/deadcode.go
                Keith Randall . unresolved

                I don't understand how this works. If we mark the deferreturn block as unreachable, then what happens to the BlockDefer blocks?
                What do we mark as the final deferreturn entry point?

                Youlin Feng

                Because we have two BlockRet blocks both containing the `CALL runtime.deferreturn(SB)`, one is the normal return block of the function, the other one is only used as the recovery destination.

                ```
                BlockDefer
                /\
                / \
                / \
                / \
                BlockXXX BlockRet (DeferReturn, the recovery path)
                |
                |
                Blocks
                |
                |
                BlockRet (normal return)
                ```
                The linker picks the first deferreturn call it sees, https://github.com/golang/go/blob/go1.25.4/src/cmd/compile/internal/ssagen/ssa.go#L2296. So, when the DeferReturn block is removed, the `recovery()` can use the `CALL runtime.deferreturn(SB)` in the normal return block as its destination.

                Is this okay? Did I miss something?

                Keith Randall

                I worry that a specific deadcode pass still has a reachable return block, so we convert BlockDefer to BlockPlain. But then a subsequent deadcode pass might get rid of the return block we were counting on. Then we end up with no deferreturn call anywhere.
                (We run deadcode 8 times when compiling.)

                Open in Gerrit

                Related details

                Attention is currently required from:
                • Youlin Feng
                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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                Gerrit-Change-Number: 716980
                Gerrit-PatchSet: 5
                Gerrit-Owner: Youlin Feng <fengy...@live.com>
                Gerrit-Reviewer: David Chase <drc...@google.com>
                Gerrit-Reviewer: Keith Randall <k...@golang.org>
                Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                Gerrit-CC: Cherry Mui <cher...@google.com>
                Gerrit-Attention: Youlin Feng <fengy...@live.com>
                Gerrit-Comment-Date: Tue, 11 Nov 2025 17:32:09 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: No
                Comment-In-Reply-To: Keith Randall <k...@golang.org>
                Comment-In-Reply-To: Youlin Feng <fengy...@live.com>
                unsatisfied_requirement
                satisfied_requirement
                open
                diffy

                Youlin Feng (Gerrit)

                unread,
                Nov 12, 2025, 7:31:54 AM11/12/25
                to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
                Attention needed from Youlin Feng

                Youlin Feng uploaded new patchset

                Youlin Feng uploaded patch set #6 to this change.
                Following approvals got outdated and were removed:
                • TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI

                Related details

                Attention is currently required from:
                • Youlin Feng
                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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                  Gerrit-Change-Number: 716980
                  Gerrit-PatchSet: 6
                  unsatisfied_requirement
                  open
                  diffy

                  Youlin Feng (Gerrit)

                  unread,
                  Nov 12, 2025, 7:37:59 AM11/12/25
                  to goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com

                  Youlin Feng voted and added 1 comment

                  Votes added by Youlin Feng

                  Commit-Queue+1

                  1 comment

                  Patchset-level comments
                  File-level comment, Patchset 6 (Latest):
                  Youlin Feng . resolved

                  How about running it in the "late deadcode" pass? This is the last of the eight deadcode passes.

                  Open in Gerrit

                  Related details

                  Attention set is empty
                  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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                  Gerrit-Change-Number: 716980
                  Gerrit-PatchSet: 6
                  Gerrit-Owner: Youlin Feng <fengy...@live.com>
                  Gerrit-Reviewer: David Chase <drc...@google.com>
                  Gerrit-Reviewer: Keith Randall <k...@golang.org>
                  Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                  Gerrit-CC: Cherry Mui <cher...@google.com>
                  Gerrit-Comment-Date: Wed, 12 Nov 2025 12:37:49 +0000
                  Gerrit-HasComments: Yes
                  Gerrit-Has-Labels: Yes
                  unsatisfied_requirement
                  open
                  diffy

                  Youlin Feng (Gerrit)

                  unread,
                  Nov 12, 2025, 8:00:23 AM11/12/25
                  to goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com
                  Attention needed from Keith Randall

                  Youlin Feng added 1 comment

                  File src/cmd/compile/internal/ssa/deadcode.go
                  Keith Randall . unresolved

                  I don't understand how this works. If we mark the deferreturn block as unreachable, then what happens to the BlockDefer blocks?
                  What do we mark as the final deferreturn entry point?

                  Youlin Feng

                  Because we have two BlockRet blocks both containing the `CALL runtime.deferreturn(SB)`, one is the normal return block of the function, the other one is only used as the recovery destination.

                  ```
                  BlockDefer
                  /\
                  / \
                  / \
                  / \
                  BlockXXX BlockRet (DeferReturn, the recovery path)
                  |
                  |
                  Blocks
                  |
                  |
                  BlockRet (normal return)
                  ```
                  The linker picks the first deferreturn call it sees, https://github.com/golang/go/blob/go1.25.4/src/cmd/compile/internal/ssagen/ssa.go#L2296. So, when the DeferReturn block is removed, the `recovery()` can use the `CALL runtime.deferreturn(SB)` in the normal return block as its destination.

                  Is this okay? Did I miss something?

                  Keith Randall

                  I worry that a specific deadcode pass still has a reachable return block, so we convert BlockDefer to BlockPlain. But then a subsequent deadcode pass might get rid of the return block we were counting on. Then we end up with no deferreturn call anywhere.
                  (We run deadcode 8 times when compiling.)

                  Youlin Feng

                  How about running it in the "late deadcode" pass? This is the last of the eight deadcode passes.

                  Open in Gerrit

                  Related details

                  Attention is currently required from:
                  • Keith Randall
                  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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                    Gerrit-Change-Number: 716980
                    Gerrit-PatchSet: 6
                    Gerrit-Owner: Youlin Feng <fengy...@live.com>
                    Gerrit-Reviewer: David Chase <drc...@google.com>
                    Gerrit-Reviewer: Keith Randall <k...@golang.org>
                    Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                    Gerrit-CC: Cherry Mui <cher...@google.com>
                    Gerrit-Attention: Keith Randall <k...@golang.org>
                    Gerrit-Comment-Date: Wed, 12 Nov 2025 13:00:11 +0000
                    unsatisfied_requirement
                    satisfied_requirement
                    open
                    diffy

                    Keith Randall (Gerrit)

                    unread,
                    Nov 12, 2025, 12:24:59 PM11/12/25
                    to Youlin Feng, goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com
                    Attention needed from Youlin Feng

                    Keith Randall added 1 comment

                    File src/cmd/compile/internal/ssa/deadcode.go
                    Keith Randall . unresolved

                    I don't understand how this works. If we mark the deferreturn block as unreachable, then what happens to the BlockDefer blocks?
                    What do we mark as the final deferreturn entry point?

                    Youlin Feng

                    Because we have two BlockRet blocks both containing the `CALL runtime.deferreturn(SB)`, one is the normal return block of the function, the other one is only used as the recovery destination.

                    ```
                    BlockDefer
                    /\
                    / \
                    / \
                    / \
                    BlockXXX BlockRet (DeferReturn, the recovery path)
                    |
                    |
                    Blocks
                    |
                    |
                    BlockRet (normal return)
                    ```
                    The linker picks the first deferreturn call it sees, https://github.com/golang/go/blob/go1.25.4/src/cmd/compile/internal/ssagen/ssa.go#L2296. So, when the DeferReturn block is removed, the `recovery()` can use the `CALL runtime.deferreturn(SB)` in the normal return block as its destination.

                    Is this okay? Did I miss something?

                    Keith Randall

                    I worry that a specific deadcode pass still has a reachable return block, so we convert BlockDefer to BlockPlain. But then a subsequent deadcode pass might get rid of the return block we were counting on. Then we end up with no deferreturn call anywhere.
                    (We run deadcode 8 times when compiling.)

                    Youlin Feng

                    How about running it in the "late deadcode" pass? This is the last of the eight deadcode passes.

                    Keith Randall

                    I don't want to go down that route. The SSA representation shouldn't have implicit constraints like that (in this case, that would be "can't run deadcode anymore after this phase"). We already have one of those (no deadcode after regalloc), I'd rather not add more.

                    You would need to make that dependency explicit somehow.

                    Idea: when a function has defers, have ssagen.(*state).exit use a jump to an existing block if it has run before. This block would be after regular return code has executed (e.g. calling `f` in `return f()`), but would have a deferreturn in it.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Youlin Feng
                    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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                    Gerrit-Change-Number: 716980
                    Gerrit-PatchSet: 6
                    Gerrit-Owner: Youlin Feng <fengy...@live.com>
                    Gerrit-Reviewer: David Chase <drc...@google.com>
                    Gerrit-Reviewer: Keith Randall <k...@golang.org>
                    Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                    Gerrit-CC: Cherry Mui <cher...@google.com>
                    Gerrit-Attention: Youlin Feng <fengy...@live.com>
                    Gerrit-Comment-Date: Wed, 12 Nov 2025 17:24:52 +0000
                    unsatisfied_requirement
                    satisfied_requirement
                    open
                    diffy

                    Youlin Feng (Gerrit)

                    unread,
                    Nov 12, 2025, 10:05:19 PM11/12/25
                    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
                    Attention needed from Youlin Feng

                    Youlin Feng uploaded new patchset

                    Youlin Feng uploaded patch set #7 to this change.
                    Following approvals got outdated and were removed:
                    • TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI

                    Related details

                    Attention is currently required from:
                    • Youlin Feng
                    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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                      Gerrit-Change-Number: 716980
                      Gerrit-PatchSet: 7
                      unsatisfied_requirement
                      open
                      diffy

                      Youlin Feng (Gerrit)

                      unread,
                      Nov 12, 2025, 10:06:42 PM11/12/25
                      to goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com

                      Youlin Feng voted Commit-Queue+1

                      Commit-Queue+1
                      Open in Gerrit

                      Related details

                      Attention set is empty
                      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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                      Gerrit-Change-Number: 716980
                      Gerrit-PatchSet: 7
                      Gerrit-Owner: Youlin Feng <fengy...@live.com>
                      Gerrit-Reviewer: David Chase <drc...@google.com>
                      Gerrit-Reviewer: Keith Randall <k...@golang.org>
                      Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                      Gerrit-CC: Cherry Mui <cher...@google.com>
                      Gerrit-Comment-Date: Thu, 13 Nov 2025 03:06:34 +0000
                      Gerrit-HasComments: No
                      Gerrit-Has-Labels: Yes
                      unsatisfied_requirement
                      open
                      diffy

                      Youlin Feng (Gerrit)

                      unread,
                      Nov 13, 2025, 5:02:46 AM11/13/25
                      to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
                      Attention needed from Youlin Feng

                      Youlin Feng uploaded new patchset

                      Youlin Feng uploaded patch set #8 to this change.
                      Following approvals got outdated and were removed:
                      • TryBots-Pass: LUCI-TryBot-Result-1 by Go LUCI
                      Open in Gerrit

                      Related details

                      Attention is currently required from:
                      • Youlin Feng
                      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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                      Gerrit-Change-Number: 716980
                      Gerrit-PatchSet: 8
                      Gerrit-Owner: Youlin Feng <fengy...@live.com>
                      Gerrit-Reviewer: David Chase <drc...@google.com>
                      Gerrit-Reviewer: Keith Randall <k...@golang.org>
                      Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                      Gerrit-CC: Cherry Mui <cher...@google.com>
                      Gerrit-Attention: Youlin Feng <fengy...@live.com>
                      unsatisfied_requirement
                      open
                      diffy

                      Youlin Feng (Gerrit)

                      unread,
                      Nov 13, 2025, 5:03:36 AM11/13/25
                      to goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com

                      Youlin Feng voted Commit-Queue+1

                      Commit-Queue+1
                      Open in Gerrit

                      Related details

                      Attention set is empty
                      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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                      Gerrit-Change-Number: 716980
                      Gerrit-PatchSet: 8
                      Gerrit-Owner: Youlin Feng <fengy...@live.com>
                      Gerrit-Reviewer: David Chase <drc...@google.com>
                      Gerrit-Reviewer: Keith Randall <k...@golang.org>
                      Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                      Gerrit-CC: Cherry Mui <cher...@google.com>
                      Gerrit-Comment-Date: Thu, 13 Nov 2025 10:03:29 +0000
                      Gerrit-HasComments: No
                      Gerrit-Has-Labels: Yes
                      unsatisfied_requirement
                      open
                      diffy

                      Youlin Feng (Gerrit)

                      unread,
                      Nov 13, 2025, 5:40:24 AM11/13/25
                      to goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com
                      Gerrit-Comment-Date: Thu, 13 Nov 2025 10:40:15 +0000
                      Gerrit-HasComments: No
                      Gerrit-Has-Labels: Yes
                      unsatisfied_requirement
                      open
                      diffy

                      Youlin Feng (Gerrit)

                      unread,
                      Nov 13, 2025, 6:31:49 AM11/13/25
                      to goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com
                      Attention needed from Keith Randall

                      Youlin Feng added 1 comment

                      File src/cmd/compile/internal/ssa/deadcode.go
                      Keith Randall . resolved

                      I don't understand how this works. If we mark the deferreturn block as unreachable, then what happens to the BlockDefer blocks?
                      What do we mark as the final deferreturn entry point?

                      Youlin Feng

                      Because we have two BlockRet blocks both containing the `CALL runtime.deferreturn(SB)`, one is the normal return block of the function, the other one is only used as the recovery destination.

                      ```
                      BlockDefer
                      /\
                      / \
                      / \
                      / \
                      BlockXXX BlockRet (DeferReturn, the recovery path)
                      |
                      |
                      Blocks
                      |
                      |
                      BlockRet (normal return)
                      ```
                      The linker picks the first deferreturn call it sees, https://github.com/golang/go/blob/go1.25.4/src/cmd/compile/internal/ssagen/ssa.go#L2296. So, when the DeferReturn block is removed, the `recovery()` can use the `CALL runtime.deferreturn(SB)` in the normal return block as its destination.

                      Is this okay? Did I miss something?

                      Keith Randall

                      I worry that a specific deadcode pass still has a reachable return block, so we convert BlockDefer to BlockPlain. But then a subsequent deadcode pass might get rid of the return block we were counting on. Then we end up with no deferreturn call anywhere.
                      (We run deadcode 8 times when compiling.)

                      Youlin Feng

                      How about running it in the "late deadcode" pass? This is the last of the eight deadcode passes.

                      Keith Randall

                      I don't want to go down that route. The SSA representation shouldn't have implicit constraints like that (in this case, that would be "can't run deadcode anymore after this phase"). We already have one of those (no deadcode after regalloc), I'd rather not add more.

                      You would need to make that dependency explicit somehow.

                      Idea: when a function has defers, have ssagen.(*state).exit use a jump to an existing block if it has run before. This block would be after regular return code has executed (e.g. calling `f` in `return f()`), but would have a deferreturn in it.

                      Youlin Feng

                      Initially, I tried to do that but failed. However, after a few days of research, it now seems to work properly. PTAL.

                      Open in Gerrit

                      Related details

                      Attention is currently required from:
                      • Keith Randall
                      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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                        Gerrit-Change-Number: 716980
                        Gerrit-PatchSet: 8
                        Gerrit-Owner: Youlin Feng <fengy...@live.com>
                        Gerrit-Reviewer: David Chase <drc...@google.com>
                        Gerrit-Reviewer: Keith Randall <k...@golang.org>
                        Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                        Gerrit-CC: Cherry Mui <cher...@google.com>
                        Gerrit-Attention: Keith Randall <k...@golang.org>
                        Gerrit-Comment-Date: Thu, 13 Nov 2025 11:31:40 +0000
                        unsatisfied_requirement
                        satisfied_requirement
                        open
                        diffy

                        Youlin Feng (Gerrit)

                        unread,
                        Nov 13, 2025, 7:02:32 AM11/13/25
                        to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
                        Attention needed from Keith Randall

                        Youlin Feng uploaded new patchset

                        Youlin Feng uploaded patch set #9 to this change.
                        Following approvals got outdated and were removed:
                        • TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
                        Open in Gerrit

                        Related details

                        Attention is currently required from:
                        • Keith Randall
                        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: newpatchset
                          Gerrit-Project: go
                          Gerrit-Branch: master
                          Gerrit-Change-Id: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                          Gerrit-Change-Number: 716980
                          Gerrit-PatchSet: 9
                          unsatisfied_requirement
                          satisfied_requirement
                          open
                          diffy

                          Youlin Feng (Gerrit)

                          unread,
                          Nov 13, 2025, 7:09:19 AM11/13/25
                          to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
                          Attention needed from Keith Randall

                          Youlin Feng uploaded new patchset

                          Youlin Feng uploaded patch set #10 to this change.
                          Open in Gerrit

                          Related details

                          Attention is currently required from:
                          • Keith Randall
                          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: newpatchset
                          Gerrit-Project: go
                          Gerrit-Branch: master
                          Gerrit-Change-Id: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                          Gerrit-Change-Number: 716980
                          Gerrit-PatchSet: 10
                          unsatisfied_requirement
                          satisfied_requirement
                          open
                          diffy

                          Youlin Feng (Gerrit)

                          unread,
                          Nov 13, 2025, 7:09:58 AM11/13/25
                          to goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com
                          Attention needed from Keith Randall

                          Youlin Feng voted Commit-Queue+1

                          Commit-Queue+1
                          Open in Gerrit

                          Related details

                          Attention is currently required from:
                          • Keith Randall
                          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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                          Gerrit-Change-Number: 716980
                          Gerrit-PatchSet: 10
                          Gerrit-Owner: Youlin Feng <fengy...@live.com>
                          Gerrit-Reviewer: David Chase <drc...@google.com>
                          Gerrit-Reviewer: Keith Randall <k...@golang.org>
                          Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                          Gerrit-CC: Cherry Mui <cher...@google.com>
                          Gerrit-Attention: Keith Randall <k...@golang.org>
                          Gerrit-Comment-Date: Thu, 13 Nov 2025 12:09:51 +0000
                          Gerrit-HasComments: No
                          Gerrit-Has-Labels: Yes
                          unsatisfied_requirement
                          satisfied_requirement
                          open
                          diffy

                          Keith Randall (Gerrit)

                          unread,
                          Nov 14, 2025, 2:03:07 PM11/14/25
                          to Youlin Feng, goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com
                          Attention needed from Youlin Feng

                          Keith Randall added 2 comments

                          File src/cmd/compile/internal/ssagen/ssa.go
                          Line 1960, Patchset 10 (Latest): b := s.exit()
                          Keith Randall . unresolved

                          We set the position of the exit block here. Which would be the deferreturn block, I believe. I don't think we want to do that.
                          Maybe we need some other mechanism for setting the line number for non-defer returns.

                          Line 2318, Patchset 10 (Latest):const shareDeferExits = false
                          Keith Randall . unresolved

                          We're currently not sharing the equivalent exit code for open defers. Shouldn't we do that as well? Or does that indicate that sharing is actually erasing line number information that we want?

                          Consider this program:
                          ```
                          package main

                          import "runtime/debug"

                          func f1(b bool) {
                          defer g()
                          if b {
                          return
                          }
                          return
                          }
                          func f2(b bool) {
                          for range 1 {
                          defer g()
                          }
                          if b {
                          return
                          }
                          return
                          }
                          func g() {
                          debug.PrintStack()
                          }
                          func main() {
                          f1(false)
                          f1(true)
                          f2(false)
                          f2(true)
                          }
                          ```

                          For `f1`, which uses open defers, we get the correct line number for the `return` statement in the stack trace.
                          For `f2`, which uses regular defers, we get the line number of the closing brace.

                          I think I'd rather fix the backtraces to have the correct line number. That fix would require us not to share the deferreturn call, right?

                          I'm still not quite sure I understand what we promise about line numbers. There are I think 3 cases:
                          1) No panics, just normal running of defers when returning. I think we want the line number of the `return` in that case (or closing brace, if we're running off the end of a function with no return values).
                          2) Panics, running the defer. We want the line number where the panic occurred (or the call we were at when some child panicked). I think we do that?
                          3) Panics, a previous defer has recovered, and we're running subsequent defers. Here I think the line number doesn't matter much. Maybe the function closing brace is the right place. Maybe any return is ok? I guess the original panic position would also be ok, if we still knew that.

                          I think #3 is the line number of the deferreturn call that the runtime jumps to.
                          #1 is the line number of the deferreturn call at each return instruction. So I would think we can share #3 with any of the #1 deferreturns, but we can't share two different #1 deferreturns.

                          Just thinking this out loud. Not sure I'm making a whole lot of sense.

                          Open in Gerrit

                          Related details

                          Attention is currently required from:
                          • Youlin Feng
                          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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                            Gerrit-Change-Number: 716980
                            Gerrit-PatchSet: 10
                            Gerrit-Owner: Youlin Feng <fengy...@live.com>
                            Gerrit-Reviewer: David Chase <drc...@google.com>
                            Gerrit-Reviewer: Keith Randall <k...@golang.org>
                            Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                            Gerrit-CC: Cherry Mui <cher...@google.com>
                            Gerrit-Attention: Youlin Feng <fengy...@live.com>
                            Gerrit-Comment-Date: Fri, 14 Nov 2025 19:03:02 +0000
                            Gerrit-HasComments: Yes
                            Gerrit-Has-Labels: No
                            unsatisfied_requirement
                            satisfied_requirement
                            open
                            diffy

                            Youlin Feng (Gerrit)

                            unread,
                            Nov 15, 2025, 5:44:30 AM11/15/25
                            to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
                            Attention needed from Youlin Feng

                            Youlin Feng uploaded new patchset

                            Youlin Feng uploaded patch set #11 to this change.
                            Following approvals got outdated and were removed:
                            • TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI

                            Related details

                            Attention is currently required from:
                            • Youlin Feng
                            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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                              Gerrit-Change-Number: 716980
                              Gerrit-PatchSet: 11
                              unsatisfied_requirement
                              open
                              diffy

                              Youlin Feng (Gerrit)

                              unread,
                              Nov 15, 2025, 5:46:19 AM11/15/25
                              to goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com

                              Youlin Feng voted Commit-Queue+1

                              Commit-Queue+1
                              Open in Gerrit

                              Related details

                              Attention set is empty
                              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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                              Gerrit-Change-Number: 716980
                              Gerrit-PatchSet: 11
                              Gerrit-Owner: Youlin Feng <fengy...@live.com>
                              Gerrit-Reviewer: David Chase <drc...@google.com>
                              Gerrit-Reviewer: Keith Randall <k...@golang.org>
                              Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                              Gerrit-CC: Cherry Mui <cher...@google.com>
                              Gerrit-Comment-Date: Sat, 15 Nov 2025 10:46:12 +0000
                              Gerrit-HasComments: No
                              Gerrit-Has-Labels: Yes
                              unsatisfied_requirement
                              open
                              diffy

                              Youlin Feng (Gerrit)

                              unread,
                              Nov 15, 2025, 7:45:07 AM11/15/25
                              to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
                              Attention needed from Youlin Feng

                              Youlin Feng uploaded new patchset

                              Youlin Feng uploaded patch set #12 to this change.
                              Following approvals got outdated and were removed:
                              • TryBots-Pass: LUCI-TryBot-Result-1 by Go LUCI
                              Open in Gerrit

                              Related details

                              Attention is currently required from:
                              • Youlin Feng
                              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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                              Gerrit-Change-Number: 716980
                              Gerrit-PatchSet: 12
                              Gerrit-Owner: Youlin Feng <fengy...@live.com>
                              Gerrit-Reviewer: David Chase <drc...@google.com>
                              Gerrit-Reviewer: Keith Randall <k...@golang.org>
                              Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                              Gerrit-CC: Cherry Mui <cher...@google.com>
                              Gerrit-Attention: Youlin Feng <fengy...@live.com>
                              unsatisfied_requirement
                              open
                              diffy

                              Youlin Feng (Gerrit)

                              unread,
                              Nov 15, 2025, 7:50:46 AM11/15/25
                              to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
                              Attention needed from Youlin Feng

                              Youlin Feng uploaded new patchset

                              Youlin Feng uploaded patch set #13 to this change.
                              Open in Gerrit

                              Related details

                              Attention is currently required from:
                              • Youlin Feng
                              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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                              Gerrit-Change-Number: 716980
                              Gerrit-PatchSet: 13
                              unsatisfied_requirement
                              open
                              diffy

                              Youlin Feng (Gerrit)

                              unread,
                              Nov 15, 2025, 7:52:13 AM11/15/25
                              to goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com

                              Youlin Feng voted Commit-Queue+1

                              Commit-Queue+1
                              Open in Gerrit

                              Related details

                              Attention set is empty
                              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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                              Gerrit-Change-Number: 716980
                              Gerrit-PatchSet: 13
                              Gerrit-Owner: Youlin Feng <fengy...@live.com>
                              Gerrit-Reviewer: David Chase <drc...@google.com>
                              Gerrit-Reviewer: Keith Randall <k...@golang.org>
                              Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                              Gerrit-CC: Cherry Mui <cher...@google.com>
                              Gerrit-Comment-Date: Sat, 15 Nov 2025 12:52:05 +0000
                              Gerrit-HasComments: No
                              Gerrit-Has-Labels: Yes
                              unsatisfied_requirement
                              open
                              diffy

                              Youlin Feng (Gerrit)

                              unread,
                              Nov 15, 2025, 8:49:16 AM11/15/25
                              to goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com
                              Attention needed from Keith Randall

                              Youlin Feng added 3 comments

                              File src/cmd/compile/internal/ssagen/ssa.go
                              Line 1960, Patchset 10: b := s.exit()
                              Keith Randall . resolved

                              We set the position of the exit block here. Which would be the deferreturn block, I believe. I don't think we want to do that.
                              Maybe we need some other mechanism for setting the line number for non-defer returns.

                              Youlin Feng

                              If we share the deferreturn block only with one normal return, maybe it won't be a problem.

                              Line 2318, Patchset 10:const shareDeferExits = false
                              Keith Randall . resolved
                              Youlin Feng

                              I think I understand what you mean.

                              Line 2355, Patchset 10: s.pushLine(s.curfn.Endlineno)
                              Youlin Feng . unresolved

                              I don't known why we set the line number here. I need to remove it to fix the line number in the stack trace.

                              Open in Gerrit

                              Related details

                              Attention is currently required from:
                              • Keith Randall
                              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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                                Gerrit-Change-Number: 716980
                                Gerrit-PatchSet: 13
                                Gerrit-Owner: Youlin Feng <fengy...@live.com>
                                Gerrit-Reviewer: David Chase <drc...@google.com>
                                Gerrit-Reviewer: Keith Randall <k...@golang.org>
                                Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                                Gerrit-CC: Cherry Mui <cher...@google.com>
                                Gerrit-Attention: Keith Randall <k...@golang.org>
                                Gerrit-Comment-Date: Sat, 15 Nov 2025 13:49:07 +0000
                                Gerrit-HasComments: Yes
                                Gerrit-Has-Labels: No
                                Comment-In-Reply-To: Keith Randall <k...@golang.org>
                                unsatisfied_requirement
                                satisfied_requirement
                                open
                                diffy

                                Keith Randall (Gerrit)

                                unread,
                                Nov 17, 2025, 1:55:44 PM11/17/25
                                to Youlin Feng, goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com
                                Attention needed from Youlin Feng

                                Keith Randall added 1 comment

                                File src/cmd/compile/internal/ssagen/ssa.go
                                Line 2355, Patchset 10: s.pushLine(s.curfn.Endlineno)
                                Youlin Feng . unresolved

                                I don't known why we set the line number here. I need to remove it to fix the line number in the stack trace.

                                Keith Randall

                                That code and comment was added in https://go-review.googlesource.com/c/go/+/650795

                                ./all.bash passes for me if I remove this line and the corresponding popLine. So maybe there's no test that checks this line number currently?

                                Open in Gerrit

                                Related details

                                Attention is currently required from:
                                • Youlin Feng
                                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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                                Gerrit-Change-Number: 716980
                                Gerrit-PatchSet: 13
                                Gerrit-Owner: Youlin Feng <fengy...@live.com>
                                Gerrit-Reviewer: David Chase <drc...@google.com>
                                Gerrit-Reviewer: Keith Randall <k...@golang.org>
                                Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                                Gerrit-CC: Cherry Mui <cher...@google.com>
                                Gerrit-Attention: Youlin Feng <fengy...@live.com>
                                Gerrit-Comment-Date: Mon, 17 Nov 2025 18:55:40 +0000
                                Gerrit-HasComments: Yes
                                Gerrit-Has-Labels: No
                                Comment-In-Reply-To: Youlin Feng <fengy...@live.com>
                                unsatisfied_requirement
                                satisfied_requirement
                                open
                                diffy

                                Youlin Feng (Gerrit)

                                unread,
                                Nov 18, 2025, 8:08:17 AM11/18/25
                                to goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com
                                Attention needed from Keith Randall

                                Youlin Feng added 1 comment

                                File src/cmd/compile/internal/ssagen/ssa.go
                                Line 2355, Patchset 10: s.pushLine(s.curfn.Endlineno)
                                Youlin Feng . unresolved

                                I don't known why we set the line number here. I need to remove it to fix the line number in the stack trace.

                                Keith Randall

                                That code and comment was added in https://go-review.googlesource.com/c/go/+/650795

                                ./all.bash passes for me if I remove this line and the corresponding popLine. So maybe there's no test that checks this line number currently?

                                Youlin Feng

                                It seems so. But how can we make the linker select the deferreturn corresponding to the line number of the function’s closing brace?

                                Open in Gerrit

                                Related details

                                Attention is currently required from:
                                • Keith Randall
                                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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                                Gerrit-Change-Number: 716980
                                Gerrit-PatchSet: 13
                                Gerrit-Owner: Youlin Feng <fengy...@live.com>
                                Gerrit-Reviewer: David Chase <drc...@google.com>
                                Gerrit-Reviewer: Keith Randall <k...@golang.org>
                                Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                                Gerrit-CC: Cherry Mui <cher...@google.com>
                                Gerrit-Attention: Keith Randall <k...@golang.org>
                                Gerrit-Comment-Date: Tue, 18 Nov 2025 13:08:09 +0000
                                Gerrit-HasComments: Yes
                                Gerrit-Has-Labels: No
                                unsatisfied_requirement
                                satisfied_requirement
                                open
                                diffy

                                Keith Randall (Gerrit)

                                unread,
                                Nov 19, 2025, 1:22:09 PM11/19/25
                                to Youlin Feng, goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com
                                Attention needed from Youlin Feng

                                Keith Randall added 1 comment

                                File src/cmd/compile/internal/ssagen/ssa.go
                                Line 2355, Patchset 10: s.pushLine(s.curfn.Endlineno)
                                Youlin Feng . unresolved

                                I don't known why we set the line number here. I need to remove it to fix the line number in the stack trace.

                                Keith Randall

                                That code and comment was added in https://go-review.googlesource.com/c/go/+/650795

                                ./all.bash passes for me if I remove this line and the corresponding popLine. So maybe there's no test that checks this line number currently?

                                Youlin Feng

                                It seems so. But how can we make the linker select the deferreturn corresponding to the line number of the function’s closing brace?

                                Keith Randall

                                I don't know. I'm not sure how much the linker understands line numbers.

                                Open in Gerrit

                                Related details

                                Attention is currently required from:
                                • Youlin Feng
                                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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                                Gerrit-Change-Number: 716980
                                Gerrit-PatchSet: 13
                                Gerrit-Owner: Youlin Feng <fengy...@live.com>
                                Gerrit-Reviewer: David Chase <drc...@google.com>
                                Gerrit-Reviewer: Keith Randall <k...@golang.org>
                                Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                                Gerrit-CC: Cherry Mui <cher...@google.com>
                                Gerrit-Attention: Youlin Feng <fengy...@live.com>
                                Gerrit-Comment-Date: Wed, 19 Nov 2025 18:22:03 +0000
                                unsatisfied_requirement
                                satisfied_requirement
                                open
                                diffy

                                Youlin Feng (Gerrit)

                                unread,
                                Mar 15, 2026, 9:07:20 AM (3 days ago) Mar 15
                                to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
                                Attention needed from Youlin Feng

                                Youlin Feng uploaded new patchset

                                Youlin Feng uploaded patch set #14 to this change.
                                Following approvals got outdated and were removed:
                                • TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
                                Open in Gerrit

                                Related details

                                Attention is currently required from:
                                • Youlin Feng
                                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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                                  Gerrit-Change-Number: 716980
                                  Gerrit-PatchSet: 14
                                  unsatisfied_requirement
                                  open
                                  diffy

                                  Youlin Feng (Gerrit)

                                  unread,
                                  Mar 16, 2026, 9:24:14 AM (2 days ago) Mar 16
                                  to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
                                  Attention needed from Youlin Feng

                                  Youlin Feng uploaded new patchset

                                  Youlin Feng uploaded patch set #15 to this change.
                                  Open in Gerrit

                                  Related details

                                  Attention is currently required from:
                                  • Youlin Feng
                                  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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                                  Gerrit-Change-Number: 716980
                                  Gerrit-PatchSet: 15
                                  unsatisfied_requirement
                                  open
                                  diffy

                                  Youlin Feng (Gerrit)

                                  unread,
                                  Mar 16, 2026, 9:27:51 AM (2 days ago) Mar 16
                                  to goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com
                                  Attention needed from Keith Randall

                                  Youlin Feng voted and added 1 comment

                                  Votes added by Youlin Feng

                                  Commit-Queue+1

                                  1 comment

                                  File src/cmd/compile/internal/ssagen/ssa.go
                                  Line 2355, Patchset 10: s.pushLine(s.curfn.Endlineno)
                                  Youlin Feng . resolved

                                  I don't known why we set the line number here. I need to remove it to fix the line number in the stack trace.

                                  Keith Randall

                                  That code and comment was added in https://go-review.googlesource.com/c/go/+/650795

                                  ./all.bash passes for me if I remove this line and the corresponding popLine. So maybe there's no test that checks this line number currently?

                                  Youlin Feng

                                  It seems so. But how can we make the linker select the deferreturn corresponding to the line number of the function’s closing brace?

                                  Keith Randall

                                  I don't know. I'm not sure how much the linker understands line numbers.

                                  Youlin Feng

                                  I fixed the line number of `CALL runtime.deferreturn(SB)`, so when we print the stack trace in defer, we can get the correct line number if the function returns normally. PTAL.

                                  Open in Gerrit

                                  Related details

                                  Attention is currently required from:
                                  • Keith Randall
                                  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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                                    Gerrit-Change-Number: 716980
                                    Gerrit-PatchSet: 15
                                    Gerrit-Owner: Youlin Feng <fengy...@live.com>
                                    Gerrit-Reviewer: David Chase <drc...@google.com>
                                    Gerrit-Reviewer: Keith Randall <k...@golang.org>
                                    Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                                    Gerrit-CC: Cherry Mui <cher...@google.com>
                                    Gerrit-Attention: Keith Randall <k...@golang.org>
                                    Gerrit-Comment-Date: Mon, 16 Mar 2026 13:27:43 +0000
                                    Gerrit-HasComments: Yes
                                    Gerrit-Has-Labels: Yes
                                    unsatisfied_requirement
                                    satisfied_requirement
                                    open
                                    diffy

                                    Youlin Feng (Gerrit)

                                    unread,
                                    Mar 16, 2026, 6:48:46 PM (2 days ago) Mar 16
                                    to goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com
                                    Attention needed from Keith Randall

                                    Youlin Feng voted Commit-Queue+1

                                    Commit-Queue+1
                                    Open in Gerrit

                                    Related details

                                    Attention is currently required from:
                                    • Keith Randall
                                    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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                                    Gerrit-Change-Number: 716980
                                    Gerrit-PatchSet: 15
                                    Gerrit-Owner: Youlin Feng <fengy...@live.com>
                                    Gerrit-Reviewer: David Chase <drc...@google.com>
                                    Gerrit-Reviewer: Keith Randall <k...@golang.org>
                                    Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                                    Gerrit-CC: Cherry Mui <cher...@google.com>
                                    Gerrit-Attention: Keith Randall <k...@golang.org>
                                    Gerrit-Comment-Date: Mon, 16 Mar 2026 22:48:37 +0000
                                    Gerrit-HasComments: No
                                    Gerrit-Has-Labels: Yes
                                    unsatisfied_requirement
                                    satisfied_requirement
                                    open
                                    diffy

                                    Youlin Feng (Gerrit)

                                    unread,
                                    6:55 AM (7 hours ago) 6:55 AM
                                    to goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com
                                    Attention needed from Keith Randall

                                    Youlin Feng voted Commit-Queue+1

                                    Commit-Queue+1
                                    Open in Gerrit

                                    Related details

                                    Attention is currently required from:
                                    • Keith Randall
                                    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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                                    Gerrit-Change-Number: 716980
                                    Gerrit-PatchSet: 16
                                    Gerrit-Owner: Youlin Feng <fengy...@live.com>
                                    Gerrit-Reviewer: David Chase <drc...@google.com>
                                    Gerrit-Reviewer: Keith Randall <k...@golang.org>
                                    Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                                    Gerrit-CC: Cherry Mui <cher...@google.com>
                                    Gerrit-Attention: Keith Randall <k...@golang.org>
                                    Gerrit-Comment-Date: Wed, 18 Mar 2026 10:54:56 +0000
                                    Gerrit-HasComments: No
                                    Gerrit-Has-Labels: Yes
                                    unsatisfied_requirement
                                    satisfied_requirement
                                    open
                                    diffy

                                    Keith Randall (Gerrit)

                                    unread,
                                    1:50 PM (4 minutes ago) 1:50 PM
                                    to Youlin Feng, goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, David Chase, golang-co...@googlegroups.com
                                    Attention needed from Youlin Feng

                                    Keith Randall added 3 comments

                                    File src/cmd/compile/internal/ssagen/ssa.go
                                    Line 2383, Patchset 16 (Latest): } else if s.peekPos() == s.curfn.Endlineno {
                                    Keith Randall . unresolved

                                    I'd rather pass an argument to `exit` than change what it does based on `peekPos`.
                                    Some kind of enum, representing explicit return, deferreturn, or fall off end, perhaps?

                                    Line 2386, Patchset 16 (Latest): if r == nil {
                                    Keith Randall . unresolved

                                    Can this ever happen? peekPos() == s.curfn.Endlineno would only ever happen for the fall-off-end case, and that call would always happen after the calls from the defer sites, which would have set s.f.DeferReturn?

                                    Line 2390, Patchset 16 (Latest): s.exit()
                                    Keith Randall . unresolved

                                    This recursive call is strange, and confusing. Why organize it this way?

                                    Open in Gerrit

                                    Related details

                                    Attention is currently required from:
                                    • Youlin Feng
                                    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: I3eb39c04b5cbef6cd76a91443086a52f2c3f325c
                                      Gerrit-Change-Number: 716980
                                      Gerrit-PatchSet: 16
                                      Gerrit-Owner: Youlin Feng <fengy...@live.com>
                                      Gerrit-Reviewer: David Chase <drc...@google.com>
                                      Gerrit-Reviewer: Keith Randall <k...@golang.org>
                                      Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
                                      Gerrit-CC: Cherry Mui <cher...@google.com>
                                      Gerrit-Attention: Youlin Feng <fengy...@live.com>
                                      Gerrit-Comment-Date: Wed, 18 Mar 2026 17:50:42 +0000
                                      Gerrit-HasComments: Yes
                                      Gerrit-Has-Labels: No
                                      unsatisfied_requirement
                                      satisfied_requirement
                                      open
                                      diffy
                                      Reply all
                                      Reply to author
                                      Forward
                                      0 new messages