[go] cmd/compile: optimize abi.Type.TFlag loads

2 views
Skip to first unread message

Jake Bailey (Gerrit)

unread,
Jul 18, 2026, 4:38:05 AMJul 18
to goph...@pubsubhelper.golang.org, Keith Randall, Russ Cox, golang...@luci-project-accounts.iam.gserviceaccount.com, golang-co...@googlegroups.com
Attention needed from Keith Randall and Russ Cox

New activity on the change

Open in Gerrit

Related details

Attention is currently required from:
  • Keith Randall
  • Russ Cox
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: Ic4355441de07b5225702b42fbaadd9e670a3ea68
Gerrit-Change-Number: 802360
Gerrit-PatchSet: 6
Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Russ Cox <r...@golang.org>
Gerrit-Attention: Keith Randall <k...@golang.org>
Gerrit-Attention: Russ Cox <r...@golang.org>
Gerrit-Comment-Date: Sat, 18 Jul 2026 08:37:58 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
unsatisfied_requirement
satisfied_requirement
open
diffy

Jake Bailey (Gerrit)

unread,
Aug 9, 2026, 7:25:57 PM (11 hours ago) Aug 9
to goph...@pubsubhelper.golang.org, Keith Randall, Russ Cox, golang...@luci-project-accounts.iam.gserviceaccount.com, golang-co...@googlegroups.com
Attention needed from Keith Randall and Russ Cox

Jake Bailey voted Auto-Submit+1

Auto-Submit+1
Gerrit-Comment-Date: Sun, 09 Aug 2026 23:25:51 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Jorropo (Gerrit)

unread,
Aug 9, 2026, 8:31:10 PM (9 hours ago) Aug 9
to Jake Bailey, goph...@pubsubhelper.golang.org, Keith Randall, Russ Cox, golang...@luci-project-accounts.iam.gserviceaccount.com, golang-co...@googlegroups.com
Attention needed from Jake Bailey, Keith Randall and Russ Cox

Jorropo added 1 comment

Patchset-level comments
File-level comment, Patchset 6 (Latest):
Jorropo . unresolved

This still ICE when you try to fold TFlag of a type declared in an other package which embeds an anonymous struct embeding a type with methods.

---

I couldn't get my repro to work so I've asked an LLM to do so and it found one:
```
From 465ad4412b559a88b7d5bc28383a525a5f9b46df Mon Sep 17 00:00:00 2001
From: Jorropo <jorro...@gmail.com>
Date: Mon, 10 Aug 2026 02:26:45 +0200
Subject: [PATCH] test: add an other repro of 80450

Change-Id: I871338d9bffcf6b5a264b40751192b8ccab5f923
---
test/fixedbugs/issue80450d.dir/a.go | 15 ++++++++++
test/fixedbugs/issue80450d.dir/b.go | 45 +++++++++++++++++++++++++++++
test/fixedbugs/issue80450d.go | 7 +++++
3 files changed, 67 insertions(+)
create mode 100644 test/fixedbugs/issue80450d.dir/a.go
create mode 100644 test/fixedbugs/issue80450d.dir/b.go
create mode 100644 test/fixedbugs/issue80450d.go

diff --git a/test/fixedbugs/issue80450d.dir/a.go b/test/fixedbugs/issue80450d.dir/a.go
new file mode 100644
index 0000000000..01eb1a01ba
--- /dev/null
+++ b/test/fixedbugs/issue80450d.dir/a.go
@@ -0,0 +1,15 @@
+// Copyright 2026 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 target
+
+type Base struct{}
+
+func (Base) M() {}
+
+// Target is a defined pointer type: ReceiverBaseType(Target) is nil,
+// while its element is an unnamed struct with promoted methods.
+type Target *struct{ Base }
+
+var P Target
diff --git a/test/fixedbugs/issue80450d.dir/b.go b/test/fixedbugs/issue80450d.dir/b.go
new file mode 100644
index 0000000000..5a1810a926
--- /dev/null
+++ b/test/fixedbugs/issue80450d.dir/b.go
@@ -0,0 +1,45 @@
+// Copyright 2026 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 main
+
+import (
+ "unsafe"
+
+ target "./a"
+)
+
+// abiType and ptrType mirror the layout of internal/abi.Type and
+// internal/abi.PtrType, so that the loads below hit the descriptor
+// field offsets the compiler constant-folds (Elem, then TFlag of the
+// element's descriptor).
+type abiType struct {
+ Size_ uintptr
+ PtrBytes uintptr
+ Hash uint32
+ TFlag uint8
+ Align_ uint8
+ FieldAlign_ uint8
+ Kind_ uint8
+ Equal func(unsafe.Pointer, unsafe.Pointer) bool
+ GCData *byte
+ Str int32
+ PtrToThis int32
+}
+
+type ptrType struct {
+ abiType
+ Elem *abiType
+}
+
+type eface struct {
+ typ *ptrType
+ data unsafe.Pointer
+}
+
+func main() {
+ var x any = target.P
+ e := (*eface)(unsafe.Pointer(&x))
+ println(e.typ.Elem.TFlag)
+}
diff --git a/test/fixedbugs/issue80450d.go b/test/fixedbugs/issue80450d.go
new file mode 100644
index 0000000000..c791559df4
--- /dev/null
+++ b/test/fixedbugs/issue80450d.go
@@ -0,0 +1,7 @@
+// compiledir
+
+// Copyright 2026 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 ignored
--
2.55.0
```

It's hard to get the right inlining to trigger it without using `reflect` but I'm not confident the bug is not reachable.

Open in Gerrit

Related details

Attention is currently required from:
  • Jake Bailey
  • Keith Randall
  • Russ Cox
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: Ic4355441de07b5225702b42fbaadd9e670a3ea68
    Gerrit-Change-Number: 802360
    Gerrit-PatchSet: 6
    Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
    Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
    Gerrit-Reviewer: Keith Randall <k...@golang.org>
    Gerrit-Reviewer: Russ Cox <r...@golang.org>
    Gerrit-CC: Jorropo <jorro...@gmail.com>
    Gerrit-Attention: Jake Bailey <jacob.b...@gmail.com>
    Gerrit-Attention: Keith Randall <k...@golang.org>
    Gerrit-Attention: Russ Cox <r...@golang.org>
    Gerrit-Comment-Date: Mon, 10 Aug 2026 00:30:58 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Jorropo (Gerrit)

    unread,
    Aug 9, 2026, 8:34:37 PM (9 hours ago) Aug 9
    to Jake Bailey, goph...@pubsubhelper.golang.org, Keith Randall, Russ Cox, golang...@luci-project-accounts.iam.gserviceaccount.com, golang-co...@googlegroups.com
    Patchset-level comments
    Jorropo

    *it's hard to get the right `reflect` inlining to trigger it without using `unsafe`

    Gerrit-Comment-Date: Mon, 10 Aug 2026 00:34:25 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Jorropo <jorro...@gmail.com>
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Jake Bailey (Gerrit)

    unread,
    12:06 AM (6 hours ago) 12:06 AM
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Jake Bailey, Keith Randall and Russ Cox

    Jake Bailey uploaded new patchset

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

    Related details

    Attention is currently required from:
    • Jake Bailey
    • Keith Randall
    • Russ Cox
    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: Ic4355441de07b5225702b42fbaadd9e670a3ea68
      Gerrit-Change-Number: 802360
      Gerrit-PatchSet: 7
      unsatisfied_requirement
      open
      diffy

      Jake Bailey (Gerrit)

      unread,
      12:08 AM (6 hours ago) 12:08 AM
      to goph...@pubsubhelper.golang.org, Jorropo, Keith Randall, Russ Cox, golang...@luci-project-accounts.iam.gserviceaccount.com, golang-co...@googlegroups.com
      Attention needed from Jorropo, Keith Randall and Russ Cox

      Jake Bailey added 1 comment

      Patchset-level comments
      Jake Bailey

      I can't get it to reproduce without using unsafe or internal/abi itself to poke at things. Nor did letting an LLM churn looking for a repro work either. But, with a repro similar to yours, I did at least come up with a fix.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Jorropo
      • Keith Randall
      • Russ Cox
      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: Ic4355441de07b5225702b42fbaadd9e670a3ea68
        Gerrit-Change-Number: 802360
        Gerrit-PatchSet: 7
        Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
        Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
        Gerrit-Reviewer: Keith Randall <k...@golang.org>
        Gerrit-Reviewer: Russ Cox <r...@golang.org>
        Gerrit-CC: Jorropo <jorro...@gmail.com>
        Gerrit-Attention: Keith Randall <k...@golang.org>
        Gerrit-Attention: Russ Cox <r...@golang.org>
        Gerrit-Attention: Jorropo <jorro...@gmail.com>
        Gerrit-Comment-Date: Mon, 10 Aug 2026 04:08:04 +0000
        unsatisfied_requirement
        satisfied_requirement
        open
        diffy
        Reply all
        Reply to author
        Forward
        0 new messages