[go] cmd/compile: fix ICE when compiling global a, b = f()

5 views
Skip to first unread message

Cuong Manh Le (Gerrit)

unread,
Jul 2, 2024, 6:25:30 AM (yesterday) Jul 2
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Cuong Manh Le has uploaded the change for review

Commit message

cmd/compile: fix ICE when compiling global a, b = f()

CL 327651 rewrites a, b = f() to use temporaries when types are not
identical. That would leave OAS2 node appears in body of init function
for global variables initialization. The staticinit pass is not updated
to handle OAS2 node, causing ICE when compiling global variables.

To fix this, handle OAS2 nodes like other OAS2*, since they mostly
necessitate dynamic execution anyway.

Fixes #68264
Change-Id: I1eff8cc3e47035738a2c70d3169e35ec36ee9242

Change diff

diff --git a/src/cmd/compile/internal/staticinit/sched.go b/src/cmd/compile/internal/staticinit/sched.go
index 7317ed1..bf4bb57 100644
--- a/src/cmd/compile/internal/staticinit/sched.go
+++ b/src/cmd/compile/internal/staticinit/sched.go
@@ -107,7 +107,7 @@
case ir.OAS:
n := n.(*ir.AssignStmt)
lhs, rhs = []ir.Node{n.X}, n.Y
- case ir.OAS2DOTTYPE, ir.OAS2FUNC, ir.OAS2MAPR, ir.OAS2RECV:
+ case ir.OAS2DOTTYPE, ir.OAS2FUNC, ir.OAS2MAPR, ir.OAS2RECV, ir.OAS2:
n := n.(*ir.AssignListStmt)
if len(n.Lhs) < 2 || len(n.Rhs) != 1 {
base.FatalfAt(n.Pos(), "unexpected shape for %v: %v", n.Op(), n)
diff --git a/test/fixedbugs/issue68264.go b/test/fixedbugs/issue68264.go
new file mode 100644
index 0000000..7d67e55
--- /dev/null
+++ b/test/fixedbugs/issue68264.go
@@ -0,0 +1,15 @@
+// compile
+
+// Copyright 2024 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+type nat []int
+
+var a, b nat = y()
+
+func y() (nat, []int) {
+ return nat{0}, nat{1}
+}

Change information

Files:
  • M src/cmd/compile/internal/staticinit/sched.go
  • A test/fixedbugs/issue68264.go
Change size: S
Delta: 2 files changed, 16 insertions(+), 1 deletion(-)
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: I1eff8cc3e47035738a2c70d3169e35ec36ee9242
Gerrit-Change-Number: 596055
Gerrit-PatchSet: 1
Gerrit-Owner: Cuong Manh Le <cuong.m...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Cuong Manh Le (Gerrit)

unread,
Jul 2, 2024, 6:26:08 AM (yesterday) Jul 2
to goph...@pubsubhelper.golang.org, Keith Randall, Cherry Mui, Matthew Dempsky, Than McIntosh, golang-co...@googlegroups.com
Attention needed from Cherry Mui, Keith Randall and Matthew Dempsky

Cuong Manh Le voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Keith Randall
  • Matthew Dempsky
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: I1eff8cc3e47035738a2c70d3169e35ec36ee9242
Gerrit-Change-Number: 596055
Gerrit-PatchSet: 1
Gerrit-Owner: Cuong Manh Le <cuong.m...@gmail.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Cuong Manh Le <cuong.m...@gmail.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Matthew Dempsky <mdem...@google.com>
Gerrit-CC: Than McIntosh <th...@google.com>
Gerrit-Attention: Keith Randall <k...@golang.org>
Gerrit-Attention: Matthew Dempsky <mdem...@google.com>
Gerrit-Attention: Cherry Mui <cher...@google.com>
Gerrit-Comment-Date: Tue, 02 Jul 2024 10:26:01 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Cuong Manh Le (Gerrit)

unread,
Jul 2, 2024, 6:45:01 AM (yesterday) Jul 2
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Cherry Mui, Cuong Manh Le, Keith Randall and Matthew Dempsky

Cuong Manh Le uploaded new patchset

Cuong Manh Le uploaded patch set #2 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:
  • Cherry Mui
  • Cuong Manh Le
  • Keith Randall
  • Matthew Dempsky
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: I1eff8cc3e47035738a2c70d3169e35ec36ee9242
Gerrit-Change-Number: 596055
Gerrit-PatchSet: 2
Gerrit-Owner: Cuong Manh Le <cuong.m...@gmail.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Cuong Manh Le <cuong.m...@gmail.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Matthew Dempsky <mdem...@google.com>
Gerrit-CC: Than McIntosh <th...@google.com>
Gerrit-Attention: Cuong Manh Le <cuong.m...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Cuong Manh Le (Gerrit)

unread,
Jul 2, 2024, 6:45:27 AM (yesterday) Jul 2
to goph...@pubsubhelper.golang.org, Go LUCI, Keith Randall, Cherry Mui, Matthew Dempsky, Than McIntosh, golang-co...@googlegroups.com
Attention needed from Cherry Mui, Keith Randall and Matthew Dempsky

Cuong Manh Le voted

Auto-Submit+1
Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Keith Randall
  • Matthew Dempsky
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: I1eff8cc3e47035738a2c70d3169e35ec36ee9242
Gerrit-Change-Number: 596055
Gerrit-PatchSet: 2
Gerrit-Owner: Cuong Manh Le <cuong.m...@gmail.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Cuong Manh Le <cuong.m...@gmail.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Matthew Dempsky <mdem...@google.com>
Gerrit-CC: Than McIntosh <th...@google.com>
Gerrit-Attention: Keith Randall <k...@golang.org>
Gerrit-Attention: Matthew Dempsky <mdem...@google.com>
Gerrit-Attention: Cherry Mui <cher...@google.com>
Gerrit-Comment-Date: Tue, 02 Jul 2024 10:45:21 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Cherry Mui (Gerrit)

unread,
Jul 2, 2024, 11:04:24 AM (yesterday) Jul 2
to Cuong Manh Le, goph...@pubsubhelper.golang.org, Go LUCI, Keith Randall, Matthew Dempsky, Than McIntosh, golang-co...@googlegroups.com
Attention needed from Cuong Manh Le, Keith Randall and Matthew Dempsky

Cherry Mui added 1 comment

File src/cmd/compile/internal/staticinit/sched.go
Line 110, Patchset 2 (Latest): case ir.OAS2:
return false // rewriting of a, b = f()
Cherry Mui . unresolved

Can we treat OAS2 the same way as OAS2FUNC? Is there any reason we can't do that?

The comment is also confusing as it looks like an OAS2FUNC.

Open in Gerrit

Related details

Attention is currently required from:
  • Cuong Manh Le
  • Keith Randall
  • Matthew Dempsky
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: I1eff8cc3e47035738a2c70d3169e35ec36ee9242
    Gerrit-Change-Number: 596055
    Gerrit-PatchSet: 2
    Gerrit-Owner: Cuong Manh Le <cuong.m...@gmail.com>
    Gerrit-Reviewer: Cherry Mui <cher...@google.com>
    Gerrit-Reviewer: Cuong Manh Le <cuong.m...@gmail.com>
    Gerrit-Reviewer: Keith Randall <k...@golang.org>
    Gerrit-Reviewer: Matthew Dempsky <mdem...@google.com>
    Gerrit-CC: Than McIntosh <th...@google.com>
    Gerrit-Attention: Cuong Manh Le <cuong.m...@gmail.com>
    Gerrit-Attention: Keith Randall <k...@golang.org>
    Gerrit-Attention: Matthew Dempsky <mdem...@google.com>
    Gerrit-Comment-Date: Tue, 02 Jul 2024 15:04:16 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Cuong Manh Le (Gerrit)

    unread,
    Jul 2, 2024, 11:08:25 AM (yesterday) Jul 2
    to goph...@pubsubhelper.golang.org, Go LUCI, Keith Randall, Cherry Mui, Matthew Dempsky, Than McIntosh, golang-co...@googlegroups.com
    Attention needed from Cherry Mui, Keith Randall and Matthew Dempsky

    Cuong Manh Le added 1 comment

    File src/cmd/compile/internal/staticinit/sched.go
    Line 110, Patchset 2 (Latest): case ir.OAS2:
    return false // rewriting of a, b = f()
    Cherry Mui . unresolved

    Can we treat OAS2 the same way as OAS2FUNC? Is there any reason we can't do that?

    The comment is also confusing as it looks like an OAS2FUNC.

    Cuong Manh Le

    Can we treat OAS2 the same way as OAS2FUNC? Is there any reason we can't do that?

    Nope, because the check at L115 is only applied for OAS2* ops, where we have the len(rhs) == 1. For OAS2, we always have len(rhs) > 1.

    The comment is also confusing as it looks like an OAS2FUNC.

    Hmm, to be clear, I mean a, b = f() is rewrittent to:

    tmp1, tmp2, = f()
    a, b = tmp1, tmp2 // The OAS2 is here.

    Maybe we should change it to: "The result of rewriting of a, b = f()"?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Cherry Mui
    • Keith Randall
    • Matthew Dempsky
    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: I1eff8cc3e47035738a2c70d3169e35ec36ee9242
    Gerrit-Change-Number: 596055
    Gerrit-PatchSet: 2
    Gerrit-Owner: Cuong Manh Le <cuong.m...@gmail.com>
    Gerrit-Reviewer: Cherry Mui <cher...@google.com>
    Gerrit-Reviewer: Cuong Manh Le <cuong.m...@gmail.com>
    Gerrit-Reviewer: Keith Randall <k...@golang.org>
    Gerrit-Reviewer: Matthew Dempsky <mdem...@google.com>
    Gerrit-CC: Than McIntosh <th...@google.com>
    Gerrit-Attention: Keith Randall <k...@golang.org>
    Gerrit-Attention: Matthew Dempsky <mdem...@google.com>
    Gerrit-Attention: Cherry Mui <cher...@google.com>
    Gerrit-Comment-Date: Tue, 02 Jul 2024 15:08:17 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Cherry Mui <cher...@google.com>
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Cherry Mui (Gerrit)

    unread,
    Jul 2, 2024, 11:23:19 AM (yesterday) Jul 2
    to Cuong Manh Le, goph...@pubsubhelper.golang.org, Go LUCI, Keith Randall, Matthew Dempsky, Than McIntosh, golang-co...@googlegroups.com
    Attention needed from Cuong Manh Le, Keith Randall and Matthew Dempsky

    Cherry Mui voted and added 1 comment

    Votes added by Cherry Mui

    Code-Review+2

    1 comment

    File src/cmd/compile/internal/staticinit/sched.go
    Line 110, Patchset 2 (Latest): case ir.OAS2:
    return false // rewriting of a, b = f()
    Cherry Mui . unresolved

    Can we treat OAS2 the same way as OAS2FUNC? Is there any reason we can't do that?

    The comment is also confusing as it looks like an OAS2FUNC.

    Cuong Manh Le

    Can we treat OAS2 the same way as OAS2FUNC? Is there any reason we can't do that?

    Nope, because the check at L115 is only applied for OAS2* ops, where we have the len(rhs) == 1. For OAS2, we always have len(rhs) > 1.

    The comment is also confusing as it looks like an OAS2FUNC.

    Hmm, to be clear, I mean a, b = f() is rewrittent to:

    tmp1, tmp2, = f()
    a, b = tmp1, tmp2 // The OAS2 is here.

    Maybe we should change it to: "The result of rewriting of a, b = f()"?

    Cherry Mui

    Okay, thanks.

    For the comment, for completeness, I think we want to be sure that things like
    ```
    var a, b = S{...}, T{...} // static values
    ```
    are actually handled as static. Have they been rewritten to separate OASes at this point? If so mention that in the comments.

    Maybe something like,

    // Usually OAS2 has been rewritten to separate OASes at <reference of the code>.
    // What's left here is "var a, b = tmp1, tmp2" as a result from rewriting
    // "var a, b = f()" that needs type conversion, which is not static.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Cuong Manh Le
    • Keith Randall
    • Matthew Dempsky
    Submit Requirements:
    • requirement 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: I1eff8cc3e47035738a2c70d3169e35ec36ee9242
    Gerrit-Change-Number: 596055
    Gerrit-PatchSet: 2
    Gerrit-Owner: Cuong Manh Le <cuong.m...@gmail.com>
    Gerrit-Reviewer: Cherry Mui <cher...@google.com>
    Gerrit-Reviewer: Cuong Manh Le <cuong.m...@gmail.com>
    Gerrit-Reviewer: Keith Randall <k...@golang.org>
    Gerrit-Reviewer: Matthew Dempsky <mdem...@google.com>
    Gerrit-CC: Than McIntosh <th...@google.com>
    Gerrit-Attention: Cuong Manh Le <cuong.m...@gmail.com>
    Gerrit-Attention: Keith Randall <k...@golang.org>
    Gerrit-Attention: Matthew Dempsky <mdem...@google.com>
    Gerrit-Comment-Date: Tue, 02 Jul 2024 15:23:13 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Cuong Manh Le <cuong.m...@gmail.com>
    Comment-In-Reply-To: Cherry Mui <cher...@google.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Cuong Manh Le (Gerrit)

    unread,
    Jul 2, 2024, 11:49:02 AM (yesterday) Jul 2
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Cuong Manh Le, Keith Randall and Matthew Dempsky

    Cuong Manh Le uploaded new patchset

    Cuong Manh Le uploaded patch set #3 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:
    • Cuong Manh Le
    • Keith Randall
    • Matthew Dempsky
    Submit Requirements:
      • requirement 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: I1eff8cc3e47035738a2c70d3169e35ec36ee9242
      Gerrit-Change-Number: 596055
      Gerrit-PatchSet: 3
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Cuong Manh Le (Gerrit)

      unread,
      Jul 2, 2024, 11:49:51 AM (yesterday) Jul 2
      to goph...@pubsubhelper.golang.org, Cherry Mui, Go LUCI, Keith Randall, Matthew Dempsky, Than McIntosh, golang-co...@googlegroups.com
      Attention needed from Keith Randall and Matthew Dempsky

      Cuong Manh Le voted and added 1 comment

      Votes added by Cuong Manh Le

      Auto-Submit+1
      Commit-Queue+1

      1 comment

      File src/cmd/compile/internal/staticinit/sched.go
      Line 110, Patchset 2: case ir.OAS2:

      return false // rewriting of a, b = f()
      Cherry Mui . resolved

      Can we treat OAS2 the same way as OAS2FUNC? Is there any reason we can't do that?

      The comment is also confusing as it looks like an OAS2FUNC.

      Cuong Manh Le

      Can we treat OAS2 the same way as OAS2FUNC? Is there any reason we can't do that?

      Nope, because the check at L115 is only applied for OAS2* ops, where we have the len(rhs) == 1. For OAS2, we always have len(rhs) > 1.

      The comment is also confusing as it looks like an OAS2FUNC.

      Hmm, to be clear, I mean a, b = f() is rewrittent to:

      tmp1, tmp2, = f()
      a, b = tmp1, tmp2 // The OAS2 is here.

      Maybe we should change it to: "The result of rewriting of a, b = f()"?

      Cherry Mui

      Okay, thanks.

      For the comment, for completeness, I think we want to be sure that things like
      ```
      var a, b = S{...}, T{...} // static values
      ```
      are actually handled as static. Have they been rewritten to separate OASes at this point? If so mention that in the comments.

      Maybe something like,

      // Usually OAS2 has been rewritten to separate OASes at <reference of the code>.
      // What's left here is "var a, b = tmp1, tmp2" as a result from rewriting
      // "var a, b = f()" that needs type conversion, which is not static.

      Cuong Manh Le

      are actually handled as static. Have they been rewritten to separate OASes at this point? If so mention that in the comments.

      Yes, they are emitted as separated OASes by types2.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Keith Randall
      • Matthew Dempsky
      Submit Requirements:
      • requirement 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: I1eff8cc3e47035738a2c70d3169e35ec36ee9242
      Gerrit-Change-Number: 596055
      Gerrit-PatchSet: 3
      Gerrit-Owner: Cuong Manh Le <cuong.m...@gmail.com>
      Gerrit-Reviewer: Cherry Mui <cher...@google.com>
      Gerrit-Reviewer: Cuong Manh Le <cuong.m...@gmail.com>
      Gerrit-Reviewer: Keith Randall <k...@golang.org>
      Gerrit-Reviewer: Matthew Dempsky <mdem...@google.com>
      Gerrit-CC: Than McIntosh <th...@google.com>
      Gerrit-Attention: Keith Randall <k...@golang.org>
      Gerrit-Attention: Matthew Dempsky <mdem...@google.com>
      Gerrit-Comment-Date: Tue, 02 Jul 2024 15:49:44 +0000
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Than McIntosh (Gerrit)

      unread,
      Jul 2, 2024, 12:53:43 PM (yesterday) Jul 2
      to Cuong Manh Le, goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, Matthew Dempsky, Than McIntosh, golang-co...@googlegroups.com
      Attention needed from Cuong Manh Le, Keith Randall and Matthew Dempsky

      Than McIntosh added 1 comment

      File src/cmd/compile/internal/staticinit/sched.go
      Line 123, Patchset 2: s.seenMutation = mayModifyPkgVar(rhs)
      Than McIntosh . unresolved

      Returning early means we won't invoke mayModifyPkgVar on any of the RHS expressions -- is this OK do you think?

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Cuong Manh Le
      • Keith Randall
      • Matthew Dempsky
      Submit Requirements:
      • requirement 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: I1eff8cc3e47035738a2c70d3169e35ec36ee9242
      Gerrit-Change-Number: 596055
      Gerrit-PatchSet: 3
      Gerrit-Owner: Cuong Manh Le <cuong.m...@gmail.com>
      Gerrit-Reviewer: Cherry Mui <cher...@google.com>
      Gerrit-Reviewer: Cuong Manh Le <cuong.m...@gmail.com>
      Gerrit-Reviewer: Keith Randall <k...@golang.org>
      Gerrit-Reviewer: Matthew Dempsky <mdem...@google.com>
      Gerrit-CC: Than McIntosh <th...@google.com>
      Gerrit-Attention: Cuong Manh Le <cuong.m...@gmail.com>
      Gerrit-Attention: Keith Randall <k...@golang.org>
      Gerrit-Attention: Matthew Dempsky <mdem...@google.com>
      Gerrit-Comment-Date: Tue, 02 Jul 2024 16:53:37 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Cherry Mui (Gerrit)

      unread,
      10:40 AM (11 hours ago) 10:40 AM
      to Cuong Manh Le, goph...@pubsubhelper.golang.org, Go LUCI, Keith Randall, Than McIntosh, golang-co...@googlegroups.com
      Attention needed from Cuong Manh Le, Keith Randall and Matthew Dempsky

      Cherry Mui voted and added 1 comment

      Votes added by Cherry Mui

      Code-Review+2

      1 comment

      File src/cmd/compile/internal/staticinit/sched.go
      Line 110, Patchset 2: case ir.OAS2:
      return false // rewriting of a, b = f()
      Cherry Mui . unresolved

      Can we treat OAS2 the same way as OAS2FUNC? Is there any reason we can't do that?

      The comment is also confusing as it looks like an OAS2FUNC.

      Cuong Manh Le

      Can we treat OAS2 the same way as OAS2FUNC? Is there any reason we can't do that?

      Nope, because the check at L115 is only applied for OAS2* ops, where we have the len(rhs) == 1. For OAS2, we always have len(rhs) > 1.

      The comment is also confusing as it looks like an OAS2FUNC.

      Hmm, to be clear, I mean a, b = f() is rewrittent to:

      tmp1, tmp2, = f()
      a, b = tmp1, tmp2 // The OAS2 is here.

      Maybe we should change it to: "The result of rewriting of a, b = f()"?

      Cherry Mui

      Okay, thanks.

      For the comment, for completeness, I think we want to be sure that things like
      ```
      var a, b = S{...}, T{...} // static values
      ```
      are actually handled as static. Have they been rewritten to separate OASes at this point? If so mention that in the comments.

      Maybe something like,

      // Usually OAS2 has been rewritten to separate OASes at <reference of the code>.
      // What's left here is "var a, b = tmp1, tmp2" as a result from rewriting
      // "var a, b = f()" that needs type conversion, which is not static.

      Cuong Manh Le

      are actually handled as static. Have they been rewritten to separate OASes at this point? If so mention that in the comments.

      Yes, they are emitted as separated OASes by types2.

      Cherry Mui

      Another question is, why "var a, b = tmp1, tmp2" is not rewritten to two separate OASes? Could we do that instead?

      Gerrit-Comment-Date: Wed, 03 Jul 2024 14:40:33 +0000
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Cuong Manh Le (Gerrit)

      unread,
      11:41 AM (10 hours ago) 11:41 AM
      to goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, Than McIntosh, golang-co...@googlegroups.com
      Attention needed from Cherry Mui, Keith Randall, Matthew Dempsky and Than McIntosh

      Cuong Manh Le added 2 comments

      File src/cmd/compile/internal/staticinit/sched.go
      Cuong Manh Le

      Because technically, there's no reason to rewrite the assignment like that.

      types2 does the rewritting to ensure variables are initialized in the correct order. That's why there's no OAS2 during staticinit before.

      Line 123, Patchset 2: s.seenMutation = mayModifyPkgVar(rhs)
      Than McIntosh . unresolved

      Returning early means we won't invoke mayModifyPkgVar on any of the RHS expressions -- is this OK do you think?

      Cuong Manh Le

      Yes, because the only OAS2 nodes that could be existed at this time is the result of rewritting `a, b = f()` by us. All user codes that contains OAS2 are rewritten by types2 to ensure global variables are initialized in the correct order.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Cherry Mui
      • Keith Randall
      • Matthew Dempsky
      • Than McIntosh
      Submit Requirements:
      • requirement 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: I1eff8cc3e47035738a2c70d3169e35ec36ee9242
      Gerrit-Change-Number: 596055
      Gerrit-PatchSet: 3
      Gerrit-Owner: Cuong Manh Le <cuong.m...@gmail.com>
      Gerrit-Reviewer: Cherry Mui <cher...@google.com>
      Gerrit-Reviewer: Cuong Manh Le <cuong.m...@gmail.com>
      Gerrit-Reviewer: Keith Randall <k...@golang.org>
      Gerrit-Reviewer: Matthew Dempsky <mdem...@google.com>
      Gerrit-CC: Than McIntosh <th...@google.com>
      Gerrit-Attention: Than McIntosh <th...@google.com>
      Gerrit-Attention: Keith Randall <k...@golang.org>
      Gerrit-Attention: Matthew Dempsky <mdem...@google.com>
      Gerrit-Attention: Cherry Mui <cher...@google.com>
      Gerrit-Comment-Date: Wed, 03 Jul 2024 15:41:08 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Cuong Manh Le <cuong.m...@gmail.com>
      Comment-In-Reply-To: Than McIntosh <th...@google.com>
      Comment-In-Reply-To: Cherry Mui <cher...@google.com>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Cherry Mui (Gerrit)

      unread,
      12:31 PM (9 hours ago) 12:31 PM
      to Cuong Manh Le, goph...@pubsubhelper.golang.org, Go LUCI, Keith Randall, Than McIntosh, golang-co...@googlegroups.com
      Attention needed from Cuong Manh Le, Keith Randall and Than McIntosh

      Cherry Mui added 1 comment

      File src/cmd/compile/internal/staticinit/sched.go
      Cherry Mui

      I'm not sure we want to rely on the fact that OAS2 means "a, b = f()". When other part, seemingly unrelated code changes, this property may change, and it is hard to enforce this. (E.g. what if later we rewrite another OAS2XXX to OAS2, or stop rewriting some static OAS2?) This may be okay for now, but I'd hope we have a fix that is closer to where the rewrite occurs.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Cuong Manh Le
      • Keith Randall
      • Than McIntosh
      Submit Requirements:
      • requirement 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: I1eff8cc3e47035738a2c70d3169e35ec36ee9242
      Gerrit-Change-Number: 596055
      Gerrit-PatchSet: 3
      Gerrit-Owner: Cuong Manh Le <cuong.m...@gmail.com>
      Gerrit-Reviewer: Cherry Mui <cher...@google.com>
      Gerrit-Reviewer: Cuong Manh Le <cuong.m...@gmail.com>
      Gerrit-Reviewer: Keith Randall <k...@golang.org>
      Gerrit-CC: Than McIntosh <th...@google.com>
      Gerrit-Attention: Cuong Manh Le <cuong.m...@gmail.com>
      Gerrit-Attention: Than McIntosh <th...@google.com>
      Gerrit-Attention: Keith Randall <k...@golang.org>
      Gerrit-Comment-Date: Wed, 03 Jul 2024 16:31:00 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Cuong Manh Le <cuong.m...@gmail.com>
      Comment-In-Reply-To: Cherry Mui <cher...@google.com>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Cuong Manh Le (Gerrit)

      unread,
      12:36 PM (9 hours ago) 12:36 PM
      to goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, Than McIntosh, golang-co...@googlegroups.com
      Attention needed from Cherry Mui, Keith Randall and Than McIntosh

      Cuong Manh Le added 1 comment

      File src/cmd/compile/internal/staticinit/sched.go
      Cuong Manh Le

      I think this works for any OAS2XX, not only OAS2UFUNC `a, b = f()`. Any static OAS2 nodes are rewritten by types2 to separated OAS nodes, to ensure the initialization order. Any OAS2 nodes after types2 finished the init order are meaningless for the staticinit.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Cherry Mui
      • Keith Randall
      • Than McIntosh
      Submit Requirements:
      • requirement 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: I1eff8cc3e47035738a2c70d3169e35ec36ee9242
      Gerrit-Change-Number: 596055
      Gerrit-PatchSet: 3
      Gerrit-Owner: Cuong Manh Le <cuong.m...@gmail.com>
      Gerrit-Reviewer: Cherry Mui <cher...@google.com>
      Gerrit-Reviewer: Cuong Manh Le <cuong.m...@gmail.com>
      Gerrit-Reviewer: Keith Randall <k...@golang.org>
      Gerrit-CC: Than McIntosh <th...@google.com>
      Gerrit-Attention: Than McIntosh <th...@google.com>
      Gerrit-Attention: Keith Randall <k...@golang.org>
      Gerrit-Attention: Cherry Mui <cher...@google.com>
      Gerrit-Comment-Date: Wed, 03 Jul 2024 16:35:54 +0000
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Cherry Mui (Gerrit)

      unread,
      12:40 PM (9 hours ago) 12:40 PM
      to Cuong Manh Le, goph...@pubsubhelper.golang.org, Go LUCI, Keith Randall, Than McIntosh, golang-co...@googlegroups.com
      Attention needed from Cuong Manh Le, Keith Randall and Than McIntosh

      Cherry Mui added 1 comment

      File src/cmd/compile/internal/staticinit/sched.go
      Cherry Mui

      Okay. Would it be hard to check the RHS of OAS2 is indeed not static? Or, since it is only temporaries for now, we can return false if the RHS are temporaries, otherwise panic, so we know we won't miss anything.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Cuong Manh Le
      • Keith Randall
      • Than McIntosh
      Submit Requirements:
      • requirement 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: I1eff8cc3e47035738a2c70d3169e35ec36ee9242
      Gerrit-Change-Number: 596055
      Gerrit-PatchSet: 3
      Gerrit-Owner: Cuong Manh Le <cuong.m...@gmail.com>
      Gerrit-Reviewer: Cherry Mui <cher...@google.com>
      Gerrit-Reviewer: Cuong Manh Le <cuong.m...@gmail.com>
      Gerrit-Reviewer: Keith Randall <k...@golang.org>
      Gerrit-CC: Than McIntosh <th...@google.com>
      Gerrit-Attention: Cuong Manh Le <cuong.m...@gmail.com>
      Gerrit-Attention: Than McIntosh <th...@google.com>
      Gerrit-Attention: Keith Randall <k...@golang.org>
      Gerrit-Comment-Date: Wed, 03 Jul 2024 16:40:29 +0000
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Cuong Manh Le (Gerrit)

      unread,
      1:10 PM (8 hours ago) 1:10 PM
      to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
      Attention needed from Cuong Manh Le, Keith Randall and Than McIntosh

      Cuong Manh Le uploaded new patchset

      Cuong Manh Le uploaded patch set #4 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:
      • Cuong Manh Le
      • Keith Randall
      • Than McIntosh
      Submit Requirements:
        • requirement 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: I1eff8cc3e47035738a2c70d3169e35ec36ee9242
        Gerrit-Change-Number: 596055
        Gerrit-PatchSet: 4
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Cuong Manh Le (Gerrit)

        unread,
        1:10 PM (8 hours ago) 1:10 PM
        to goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, Than McIntosh, golang-co...@googlegroups.com
        Attention needed from Keith Randall and Than McIntosh

        Cuong Manh Le voted and added 1 comment

        Votes added by Cuong Manh Le

        Auto-Submit+1
        Commit-Queue+1

        1 comment

        File src/cmd/compile/internal/staticinit/sched.go
        Line 110, Patchset 2: case ir.OAS2:
        return false // rewriting of a, b = f()
        Cherry Mui . resolved
        Cuong Manh Le

        Latest patch adds the check.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Keith Randall
        • Than McIntosh
        Submit Requirements:
        • requirement 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: I1eff8cc3e47035738a2c70d3169e35ec36ee9242
        Gerrit-Change-Number: 596055
        Gerrit-PatchSet: 4
        Gerrit-Owner: Cuong Manh Le <cuong.m...@gmail.com>
        Gerrit-Reviewer: Cherry Mui <cher...@google.com>
        Gerrit-Reviewer: Cuong Manh Le <cuong.m...@gmail.com>
        Gerrit-Reviewer: Keith Randall <k...@golang.org>
        Gerrit-CC: Than McIntosh <th...@google.com>
        Gerrit-Attention: Than McIntosh <th...@google.com>
        Gerrit-Attention: Keith Randall <k...@golang.org>
        Gerrit-Comment-Date: Wed, 03 Jul 2024 17:10:45 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Cherry Mui (Gerrit)

        unread,
        2:45 PM (7 hours ago) 2:45 PM
        to Cuong Manh Le, goph...@pubsubhelper.golang.org, Go LUCI, Keith Randall, Than McIntosh, golang-co...@googlegroups.com
        Attention needed from Cuong Manh Le, Keith Randall and Than McIntosh

        Cherry Mui voted and added 1 comment

        Votes added by Cherry Mui

        Code-Review+2

        1 comment

        File src/cmd/compile/internal/staticinit/sched.go
        Cherry Mui

        Thanks. LGTM.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Cuong Manh Le
        • Keith Randall
        • Than McIntosh
        Submit Requirements:
          • requirement 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: I1eff8cc3e47035738a2c70d3169e35ec36ee9242
          Gerrit-Change-Number: 596055
          Gerrit-PatchSet: 4
          Gerrit-Owner: Cuong Manh Le <cuong.m...@gmail.com>
          Gerrit-Reviewer: Cherry Mui <cher...@google.com>
          Gerrit-Reviewer: Cuong Manh Le <cuong.m...@gmail.com>
          Gerrit-Reviewer: Keith Randall <k...@golang.org>
          Gerrit-CC: Than McIntosh <th...@google.com>
          Gerrit-Attention: Cuong Manh Le <cuong.m...@gmail.com>
          Gerrit-Attention: Than McIntosh <th...@google.com>
          Gerrit-Attention: Keith Randall <k...@golang.org>
          Gerrit-Comment-Date: Wed, 03 Jul 2024 18:45:45 +0000
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy
          Reply all
          Reply to author
          Forward
          0 new messages