[go] cmd/compile: disable inlining for functions using runtime.deferrangefunc

2 views
Skip to first unread message

俊伟左 (Gerrit)

unread,
Dec 23, 2025, 3:12:58 AM (yesterday) Dec 23
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

俊伟左 has uploaded the change for review

Commit message

cmd/compile: disable inlining for functions using runtime.deferrangefunc

The rangefunc rewrite pass implements defer using deferrangefunc and
deferproccat. The loop body is rewritten into a closure, it cannot be inlined
due to defer call. But the outer function may still be inlined in certain
scenarios (e.g., with PGO), leading to the defer executing at the wrong time.
Change-Id: I4649fad5cd1b65891832523522002d9352711123

Change diff

diff --git a/src/cmd/compile/internal/inline/inl.go b/src/cmd/compile/internal/inline/inl.go
index 33f9c32..4fa9cf0 100644
--- a/src/cmd/compile/internal/inline/inl.go
+++ b/src/cmd/compile/internal/inline/inl.go
@@ -516,6 +516,9 @@
break opSwitch
case "panicrangestate":
cheap = true
+ case "deferrangefunc":
+ v.reason = "defer call in range func"
+ return true
}
}
}

Change information

Files:
  • M src/cmd/compile/internal/inline/inl.go
Change size: XS
Delta: 1 file changed, 3 insertions(+), 0 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: I4649fad5cd1b65891832523522002d9352711123
Gerrit-Change-Number: 732140
Gerrit-PatchSet: 1
Gerrit-Owner: 俊伟左 <zuojunw...@bytedance.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

俊伟左 (Gerrit)

unread,
Dec 23, 2025, 3:14:45 AM (yesterday) Dec 23
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

俊伟左 uploaded new patchset

俊伟左 uploaded patch set #2 to this change.
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: newpatchset
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I4649fad5cd1b65891832523522002d9352711123
Gerrit-Change-Number: 732140
Gerrit-PatchSet: 2
Gerrit-Owner: 俊伟左 <zuojunw...@bytedance.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Wayne Zuo (Gerrit)

unread,
Dec 23, 2025, 3:23:09 AM (yesterday) Dec 23
to 俊伟左, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from 俊伟左

Wayne Zuo voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • 俊伟左
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: I4649fad5cd1b65891832523522002d9352711123
Gerrit-Change-Number: 732140
Gerrit-PatchSet: 2
Gerrit-Owner: 俊伟左 <zuojunw...@bytedance.com>
Gerrit-Reviewer: Wayne Zuo <wdvxd...@gmail.com>
Gerrit-Attention: 俊伟左 <zuojunw...@bytedance.com>
Gerrit-Comment-Date: Tue, 23 Dec 2025 08:23:02 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages