[go] cmd/internal/obj/riscv: add support for compressed instructions

14 views
Skip to first unread message

Joel Sing (Gerrit)

unread,
Aug 28, 2023, 11:43:37 AM8/28/23
to Mark Ryan, M Zhuo, Cherry Mui, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Attention is currently required from: Cherry Mui, M Zhuo, Mark Ryan.

Joel Sing would like Mark Ryan, M Zhuo and Cherry Mui to review this change.

View Change

cmd/internal/obj/riscv: add support for compressed instructions

Implement validation and encoding for Compressed Immediate (CI)
instructions, adding support for the compressed NOP instruction
(CNOP).

Reduce the PC quantum to two bytes, reduce the minimum instruction
length to two bytes and use CNOP in runtime.goexit, where the NOPs
need to match the length of the PC quantum.

Note that this moves the baseline for the riscv64 port to rv64gc.

Change-Id: I4329a8fbfcb4de636aadaeadabb826bc22698640
---
M src/cmd/asm/internal/asm/testdata/riscv64.s
M src/cmd/internal/obj/riscv/obj.go
M src/cmd/internal/sys/arch.go
M src/internal/goarch/goarch_riscv64.go
M src/runtime/asm_riscv64.s
5 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/src/cmd/asm/internal/asm/testdata/riscv64.s b/src/cmd/asm/internal/asm/testdata/riscv64.s
index 9899ec9..e80aad9 100644
--- a/src/cmd/asm/internal/asm/testdata/riscv64.s
+++ b/src/cmd/asm/internal/asm/testdata/riscv64.s
@@ -294,6 +294,9 @@
// 12.6: Double-Precision Floating-Point Classify Instruction
FCLASSD F0, X5 // d31200e2

+ // 16.5: Compressed - Integer Computational Instructions
+ CNOP // 0100
+
// Privileged ISA

// 3.2.1: Environment Call and Breakpoint
diff --git a/src/cmd/internal/obj/riscv/obj.go b/src/cmd/internal/obj/riscv/obj.go
index 776c3a8..1fc27ca 100644
--- a/src/cmd/internal/obj/riscv/obj.go
+++ b/src/cmd/internal/obj/riscv/obj.go
@@ -1062,6 +1062,15 @@
}
}

+func validateCI(ctxt *obj.Link, ins *instruction) {
+ if ins.as == ACNOP && (ins.rd != REG_X0 || ins.rs1 != REG_X0 || ins.imm != 0) {
+ ctxt.Diag("%v: must use X0 register and have a zero immediate", ins.as)
+ }
+ wantIntReg(ctxt, ins.as, "rd", ins.rd)
+ wantIntReg(ctxt, ins.as, "rs1", ins.rs1)
+ wantNoneReg(ctxt, ins.as, "rs2", ins.rs2)
+}
+
func validateRIII(ctxt *obj.Link, ins *instruction) {
wantIntReg(ctxt, ins.as, "rd", ins.rd)
wantIntReg(ctxt, ins.as, "rs1", ins.rs1)
@@ -1187,6 +1196,16 @@
return ((imm >> bit) & 1) << pos
}

+// encodeCI encodes a compressed immediate (CI-type) instruction.
+func encodeCI(ins *instruction) uint32 {
+ enc := encode(ins.as)
+ if enc == nil {
+ panic("encodeCI: could not encode instruction")
+ }
+ imm := uint32(ins.imm)
+ return enc.funct3<<12 | ((imm&0x20)>>5)<<12 | regI(ins.rd)<<7 | (imm&0x1f)<<2 | enc.opcode
+}
+
// encodeR encodes an R-type RISC-V instruction.
func encodeR(as obj.As, rs1, rs2, rd, funct3, funct7 uint32) uint32 {
enc := encode(as)
@@ -1430,7 +1449,7 @@
type encoding struct {
encode func(*instruction) uint32 // encode returns the machine code for an instruction
validate func(*obj.Link, *instruction) // validate validates an instruction
- length int // length of encoded instruction; 0 for pseudo-ops, 4 otherwise
+ length int // length of encoded instruction; 0 for pseudo-ops, 2 for compressed instructions, 4 otherwise
}

var (
@@ -1463,6 +1482,9 @@
uEncoding = encoding{encode: encodeU, validate: validateU, length: 4}
jEncoding = encoding{encode: encodeJ, validate: validateJ, length: 4}

+ // Compressed encodings.
+ ciEncoding = encoding{encode: encodeCI, validate: validateCI, length: 2}
+
// rawEncoding encodes a raw instruction byte sequence.
rawEncoding = encoding{encode: encodeRawIns, validate: validateRaw, length: 4}

@@ -1672,6 +1694,9 @@
// 12.7: Double-Precision Floating-Point Classify Instruction
AFCLASSD & obj.AMask: rFIEncoding,

+ // 16.5: Compressed - Integer Computational Instructions
+ ACNOP & obj.AMask: ciEncoding,
+
// Privileged ISA

// 3.2.1: Environment Call and Breakpoint
@@ -2319,6 +2344,9 @@
if ins.imm < 0 || ins.imm > 31 {
p.Ctxt.Diag("%v: shift amount out of range 0 to 31", p)
}
+
+ case ACNOP:
+ ins.rd, ins.rs1 = REG_ZERO, REG_ZERO
}
return inss
}
diff --git a/src/cmd/internal/sys/arch.go b/src/cmd/internal/sys/arch.go
index 2e35284..77ff223 100644
--- a/src/cmd/internal/sys/arch.go
+++ b/src/cmd/internal/sys/arch.go
@@ -234,7 +234,7 @@
ByteOrder: binary.LittleEndian,
PtrSize: 8,
RegSize: 8,
- MinLC: 4,
+ MinLC: 2,
Alignment: 8, // riscv unaligned loads work, but are really slow (trap + simulated by OS)
CanMergeLoads: false,
HasLR: true,
diff --git a/src/internal/goarch/goarch_riscv64.go b/src/internal/goarch/goarch_riscv64.go
index 3b6da1e..468f9a6 100644
--- a/src/internal/goarch/goarch_riscv64.go
+++ b/src/internal/goarch/goarch_riscv64.go
@@ -7,7 +7,7 @@
const (
_ArchFamily = RISCV64
_DefaultPhysPageSize = 4096
- _PCQuantum = 4
+ _PCQuantum = 2
_MinFrameSize = 8
_StackAlign = PtrSize
)
diff --git a/src/runtime/asm_riscv64.s b/src/runtime/asm_riscv64.s
index eb53cbb..7890058 100644
--- a/src/runtime/asm_riscv64.s
+++ b/src/runtime/asm_riscv64.s
@@ -509,10 +509,10 @@
// The top-most function running on a goroutine
// returns to goexit+PCQuantum.
TEXT runtime·goexit(SB),NOSPLIT|NOFRAME|TOPFRAME,$0-0
- MOV ZERO, ZERO // NOP
+ CNOP // 2 byte compressed NOP
JMP runtime·goexit1(SB) // does not return
// traceback from goexit1 must hit code range of goexit
- MOV ZERO, ZERO // NOP
+ CNOP // 2 byte compressed NOP

// func cgocallback(fn, frame unsafe.Pointer, ctxt uintptr)
// See cgocall.go for more details.

To view, visit change 523477. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I4329a8fbfcb4de636aadaeadabb826bc22698640
Gerrit-Change-Number: 523477
Gerrit-PatchSet: 1
Gerrit-Owner: Joel Sing <jo...@sing.id.au>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: M Zhuo <m...@golangcn.org>
Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
Gerrit-Attention: Mark Ryan <mark...@rivosinc.com>
Gerrit-Attention: M Zhuo <m...@golangcn.org>
Gerrit-Attention: Cherry Mui <cher...@google.com>

Joel Sing (Gerrit)

unread,
Jan 3, 2025, 10:39:10 AMJan 3
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Cherry Mui, Joel Sing, Mark Ryan and Meng Zhuo

Joel Sing uploaded new patchset

Joel Sing uploaded patch set #2 to this change.
Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Joel Sing
  • Mark Ryan
  • Meng Zhuo
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Holds
  • 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: I4329a8fbfcb4de636aadaeadabb826bc22698640
Gerrit-Change-Number: 523477
Gerrit-PatchSet: 2
Gerrit-Owner: Joel Sing <jo...@sing.id.au>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
Gerrit-Reviewer: Russ Cox <r...@golang.org>
Gerrit-Attention: Mark Ryan <mark...@rivosinc.com>
Gerrit-Attention: Joel Sing <jo...@sing.id.au>
Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
Gerrit-Attention: Cherry Mui <cher...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Joel Sing (Gerrit)

unread,
Jan 3, 2025, 11:03:48 AMJan 3
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Cherry Mui, Joel Sing, Mark Ryan and Meng Zhuo

Joel Sing uploaded new patchset

Joel Sing uploaded patch set #3 to this change.
Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Joel Sing
  • Mark Ryan
  • Meng Zhuo
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Holds
  • 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: I4329a8fbfcb4de636aadaeadabb826bc22698640
Gerrit-Change-Number: 523477
Gerrit-PatchSet: 3
unsatisfied_requirement
satisfied_requirement
open
diffy

Joel Sing (Gerrit)

unread,
Aug 8, 2025, 12:52:50 PMAug 8
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Cherry Mui, Joel Sing, Mark Ryan and Meng Zhuo

Joel Sing uploaded new patchset

Joel Sing uploaded patch set #4 to this change.
Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Joel Sing
  • Mark Ryan
  • Meng Zhuo
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Holds
  • 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: I4329a8fbfcb4de636aadaeadabb826bc22698640
Gerrit-Change-Number: 523477
Gerrit-PatchSet: 4
unsatisfied_requirement
satisfied_requirement
open
diffy

Joel Sing (Gerrit)

unread,
Aug 8, 2025, 1:03:05 PMAug 8
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Cherry Mui, Joel Sing, Mark Ryan and Meng Zhuo

Joel Sing uploaded new patchset

Joel Sing uploaded patch set #5 to this change.
Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Joel Sing
  • Mark Ryan
  • Meng Zhuo
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Holds
  • 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: I4329a8fbfcb4de636aadaeadabb826bc22698640
Gerrit-Change-Number: 523477
Gerrit-PatchSet: 5
unsatisfied_requirement
satisfied_requirement
open
diffy

Joel Sing (Gerrit)

unread,
Aug 8, 2025, 1:03:57 PMAug 8
to goph...@pubsubhelper.golang.org, Russ Cox, Meng Zhuo, Mark Ryan, Cherry Mui, golang-co...@googlegroups.com
Attention needed from Cherry Mui, Joel Sing, Mark Ryan, Meng Zhuo and Russ Cox

Joel Sing removed a vote from this change

Removed Hold+1 by Russ Cox <r...@golang.org>
Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Joel Sing
  • Mark Ryan
  • Meng Zhuo
  • 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: deleteVote
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I4329a8fbfcb4de636aadaeadabb826bc22698640
    Gerrit-Change-Number: 523477
    Gerrit-PatchSet: 5
    Gerrit-Owner: Joel Sing <jo...@sing.id.au>
    Gerrit-Reviewer: Cherry Mui <cher...@google.com>
    Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
    Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
    Gerrit-Reviewer: Russ Cox <r...@golang.org>
    Gerrit-Attention: Mark Ryan <mark...@rivosinc.com>
    Gerrit-Attention: Joel Sing <jo...@sing.id.au>
    Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
    Gerrit-Attention: Russ Cox <r...@golang.org>
    Gerrit-Attention: Cherry Mui <cher...@google.com>
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Joel Sing (Gerrit)

    unread,
    Aug 8, 2025, 1:04:09 PMAug 8
    to goph...@pubsubhelper.golang.org, Russ Cox, Meng Zhuo, Mark Ryan, Cherry Mui, golang-co...@googlegroups.com
    Attention needed from Cherry Mui, Mark Ryan, Meng Zhuo and Russ Cox

    Joel Sing voted and added 1 comment

    Votes added by Joel Sing

    Commit-Queue+1

    1 comment

    Patchset-level comments
    File-level comment, Patchset 1:
    Russ Cox . resolved

    This would require compressed instruction support in the riscv port, so we need an accepted proposal for that.

    Joel Sing

    Proposal has been accepted, removing hold.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Cherry Mui
    • Mark Ryan
    • Meng Zhuo
    • 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: I4329a8fbfcb4de636aadaeadabb826bc22698640
    Gerrit-Change-Number: 523477
    Gerrit-PatchSet: 5
    Gerrit-Owner: Joel Sing <jo...@sing.id.au>
    Gerrit-Reviewer: Cherry Mui <cher...@google.com>
    Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
    Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
    Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
    Gerrit-Reviewer: Russ Cox <r...@golang.org>
    Gerrit-Attention: Mark Ryan <mark...@rivosinc.com>
    Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
    Gerrit-Attention: Russ Cox <r...@golang.org>
    Gerrit-Attention: Cherry Mui <cher...@google.com>
    Gerrit-Comment-Date: Fri, 08 Aug 2025 17:04:01 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Russ Cox <r...@golang.org>
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Joel Sing (Gerrit)

    unread,
    Aug 18, 2025, 11:10:38 AMAug 18
    to goph...@pubsubhelper.golang.org, Go LUCI, Russ Cox, Meng Zhuo, Mark Ryan, Cherry Mui, golang-co...@googlegroups.com
    Attention needed from Cherry Mui, Mark Ryan, Meng Zhuo and Russ Cox

    Joel Sing voted Commit-Queue+1

    Commit-Queue+1
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Cherry Mui
    • Mark Ryan
    • Meng Zhuo
    • 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: I4329a8fbfcb4de636aadaeadabb826bc22698640
    Gerrit-Change-Number: 523477
    Gerrit-PatchSet: 6
    Gerrit-Owner: Joel Sing <jo...@sing.id.au>
    Gerrit-Reviewer: Cherry Mui <cher...@google.com>
    Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
    Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
    Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
    Gerrit-Reviewer: Russ Cox <r...@golang.org>
    Gerrit-Attention: Mark Ryan <mark...@rivosinc.com>
    Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
    Gerrit-Attention: Russ Cox <r...@golang.org>
    Gerrit-Attention: Cherry Mui <cher...@google.com>
    Gerrit-Comment-Date: Mon, 18 Aug 2025 15:10:29 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Cherry Mui (Gerrit)

    unread,
    Aug 18, 2025, 12:03:30 PMAug 18
    to Joel Sing, goph...@pubsubhelper.golang.org, Go LUCI, Russ Cox, Meng Zhuo, Mark Ryan, golang-co...@googlegroups.com
    Attention needed from Joel Sing, Mark Ryan, Meng Zhuo and Russ Cox

    Cherry Mui added 2 comments

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

    As mentioned on the issue, we probably want to have a command-line debugging flag to switch on/off compressed instructions.

    File src/runtime/asm_riscv64.s
    Line 531, Patchset 6 (Latest): CNOP // 2 byte compressed NOP
    Cherry Mui . unresolved

    Could the assembler just emit CNOP for `MOV ZERO, ZERO`? This way, we can have it controlled by a command-line flag in the assembler, and the runtime code doesn't need to change.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Joel Sing
    • Mark Ryan
    • Meng Zhuo
    • 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: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I4329a8fbfcb4de636aadaeadabb826bc22698640
        Gerrit-Change-Number: 523477
        Gerrit-PatchSet: 6
        Gerrit-Owner: Joel Sing <jo...@sing.id.au>
        Gerrit-Reviewer: Cherry Mui <cher...@google.com>
        Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
        Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
        Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
        Gerrit-Reviewer: Russ Cox <r...@golang.org>
        Gerrit-Attention: Mark Ryan <mark...@rivosinc.com>
        Gerrit-Attention: Joel Sing <jo...@sing.id.au>
        Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
        Gerrit-Attention: Russ Cox <r...@golang.org>
        Gerrit-Comment-Date: Mon, 18 Aug 2025 16:03:24 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        unsatisfied_requirement
        open
        diffy

        Joel Sing (Gerrit)

        unread,
        Aug 21, 2025, 9:37:28 AMAug 21
        to goph...@pubsubhelper.golang.org, Go LUCI, Russ Cox, Meng Zhuo, Mark Ryan, Cherry Mui, golang-co...@googlegroups.com
        Attention needed from Cherry Mui, Mark Ryan, Meng Zhuo and Russ Cox

        Joel Sing added 1 comment

        File src/runtime/asm_riscv64.s
        Line 531, Patchset 6 (Latest): CNOP // 2 byte compressed NOP
        Cherry Mui . unresolved

        Could the assembler just emit CNOP for `MOV ZERO, ZERO`? This way, we can have it controlled by a command-line flag in the assembler, and the runtime code doesn't need to change.

        Joel Sing

        I don't believe so - I'll double check (it's been 2+ years since I originally did this work), but as far as I recall the size of the NOPs here have to be exactly the same as the PC quantum. If this is correct we cannot flip between a CNOP (2 bytes) and regular ADDI based noop (4 bytes) without also changing the PC quantum... but let me confirm.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Cherry Mui
        • Mark Ryan
        • Meng Zhuo
        • 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: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I4329a8fbfcb4de636aadaeadabb826bc22698640
        Gerrit-Change-Number: 523477
        Gerrit-PatchSet: 6
        Gerrit-Owner: Joel Sing <jo...@sing.id.au>
        Gerrit-Reviewer: Cherry Mui <cher...@google.com>
        Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
        Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
        Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
        Gerrit-Reviewer: Russ Cox <r...@golang.org>
        Gerrit-Attention: Mark Ryan <mark...@rivosinc.com>
        Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
        Gerrit-Attention: Russ Cox <r...@golang.org>
        Gerrit-Attention: Cherry Mui <cher...@google.com>
        Gerrit-Comment-Date: Thu, 21 Aug 2025 13:37:20 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Cherry Mui <cher...@google.com>
        unsatisfied_requirement
        open
        diffy

        Joel Sing (Gerrit)

        unread,
        Aug 21, 2025, 10:09:58 AMAug 21
        to goph...@pubsubhelper.golang.org, Go LUCI, Russ Cox, Meng Zhuo, Mark Ryan, Cherry Mui, golang-co...@googlegroups.com
        Attention needed from Cherry Mui, Mark Ryan, Meng Zhuo and Russ Cox

        Joel Sing voted and added 2 comments

        Votes added by Joel Sing

        Commit-Queue+1

        2 comments

        Patchset-level comments
        Cherry Mui . unresolved

        As mentioned on the issue, we probably want to have a command-line debugging flag to switch on/off compressed instructions.

        Joel Sing

        This certainly makes sense to disable the compression pass that will be added to the assembler to emit compressed instructions that replace regular instructions. I think CNOPs have to always be available though.

        File src/runtime/asm_riscv64.s
        Line 531, Patchset 6: CNOP // 2 byte compressed NOP
        Cherry Mui . unresolved

        Could the assembler just emit CNOP for `MOV ZERO, ZERO`? This way, we can have it controlled by a command-line flag in the assembler, and the runtime code doesn't need to change.

        Joel Sing

        I don't believe so - I'll double check (it's been 2+ years since I originally did this work), but as far as I recall the size of the NOPs here have to be exactly the same as the PC quantum. If this is correct we cannot flip between a CNOP (2 bytes) and regular ADDI based noop (4 bytes) without also changing the PC quantum... but let me confirm.

        Joel Sing

        ```
        $ ./all.bash
        Building Go cmd/dist using /usr/local/go. (go1.24.6 openbsd/riscv64)
        Building Go toolchain1 using /usr/local/go.
        Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
        Building Go toolchain2 using go_bootstrap and Go toolchain1.
        SIGILL: illegal instruction
        PC=0x8a922 m=0 sigcode=4
        instruction bytes: 0x0 0x0 0x6f 0x20 0x40 0x6e 0x13 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x73 0x0
        ```

        As expected, we end up in the middle of the 4 byte instruction which is then SIGILL:

        ```
        000000000008a920 <runtime.goexit.abi0>:
        8a920: 00000013 nop
        8a924: 6e40206f j 0x8d008 <runtime.goexit1.abi0>
        8a928: 00000013 nop
        8a92c: 0000 <unknown>
        8a92e: 0000 <unknown>
        ```
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Cherry Mui
        • Mark Ryan
        • Meng Zhuo
        • 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: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I4329a8fbfcb4de636aadaeadabb826bc22698640
        Gerrit-Change-Number: 523477
        Gerrit-PatchSet: 7
        Gerrit-Owner: Joel Sing <jo...@sing.id.au>
        Gerrit-Reviewer: Cherry Mui <cher...@google.com>
        Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
        Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
        Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
        Gerrit-Reviewer: Russ Cox <r...@golang.org>
        Gerrit-Attention: Mark Ryan <mark...@rivosinc.com>
        Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
        Gerrit-Attention: Russ Cox <r...@golang.org>
        Gerrit-Attention: Cherry Mui <cher...@google.com>
        Gerrit-Comment-Date: Thu, 21 Aug 2025 14:09:50 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        Comment-In-Reply-To: Joel Sing <jo...@sing.id.au>
        Comment-In-Reply-To: Cherry Mui <cher...@google.com>
        unsatisfied_requirement
        open
        diffy

        Joel Sing (Gerrit)

        unread,
        Oct 20, 2025, 12:40:22 AMOct 20
        to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
        Attention needed from Cherry Mui, Mark Ryan, Meng Zhuo and Russ Cox

        Joel Sing uploaded new patchset

        Joel Sing 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:
        • Cherry Mui
        • Mark Ryan
        • Meng Zhuo
        • 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: I4329a8fbfcb4de636aadaeadabb826bc22698640
        Gerrit-Change-Number: 523477
        Gerrit-PatchSet: 8
        Gerrit-Owner: Joel Sing <jo...@sing.id.au>
        Gerrit-Reviewer: Cherry Mui <cher...@google.com>
        Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
        Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
        Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
        Gerrit-Reviewer: Russ Cox <r...@golang.org>
        Gerrit-Attention: Russ Cox <r...@golang.org>
        Gerrit-Attention: Cherry Mui <cher...@google.com>
        Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
        Gerrit-Attention: Mark Ryan <mark...@rivosinc.com>
        unsatisfied_requirement
        open
        diffy

        Joel Sing (Gerrit)

        unread,
        Oct 20, 2025, 12:44:04 AMOct 20
        to goph...@pubsubhelper.golang.org, Go LUCI, Meng Zhuo, Mark Ryan, Cherry Mui, golang-co...@googlegroups.com
        Attention needed from Cherry Mui, Mark Ryan and Meng Zhuo

        Joel Sing voted Commit-Queue+1

        Commit-Queue+1
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Cherry Mui
        • Mark Ryan
        • Meng Zhuo
        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: I4329a8fbfcb4de636aadaeadabb826bc22698640
        Gerrit-Change-Number: 523477
        Gerrit-PatchSet: 8
        Gerrit-Owner: Joel Sing <jo...@sing.id.au>
        Gerrit-Reviewer: Cherry Mui <cher...@google.com>
        Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
        Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
        Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
        Gerrit-Attention: Cherry Mui <cher...@google.com>
        Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
        Gerrit-Attention: Mark Ryan <mark...@rivosinc.com>
        Gerrit-Comment-Date: Mon, 20 Oct 2025 04:43:58 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes
        unsatisfied_requirement
        open
        diffy

        Joel Sing (Gerrit)

        unread,
        Oct 20, 2025, 12:45:53 AMOct 20
        to goph...@pubsubhelper.golang.org, Go LUCI, Meng Zhuo, Mark Ryan, Cherry Mui, golang-co...@googlegroups.com
        Attention needed from Cherry Mui, Mark Ryan and Meng Zhuo

        Joel Sing removed a vote from this change

        Removed Commit-Queue+1 by Joel Sing <jo...@sing.id.au>
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Cherry Mui
        • Mark Ryan
        • Meng Zhuo
        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: deleteVote
        unsatisfied_requirement
        open
        diffy

        Joel Sing (Gerrit)

        unread,
        Oct 20, 2025, 12:46:06 AMOct 20
        to goph...@pubsubhelper.golang.org, Go LUCI, Meng Zhuo, Mark Ryan, Cherry Mui, golang-co...@googlegroups.com
        Attention needed from Cherry Mui, Joel Sing, Mark Ryan and Meng Zhuo

        Joel Sing voted and added 2 comments

        Votes added by Joel Sing

        Commit-Queue+1

        2 comments

        Patchset-level comments
        File-level comment, Patchset 6:
        Cherry Mui . resolved

        As mentioned on the issue, we probably want to have a command-line debugging flag to switch on/off compressed instructions.

        Joel Sing

        This certainly makes sense to disable the compression pass that will be added to the assembler to emit compressed instructions that replace regular instructions. I think CNOPs have to always be available though.

        Joel Sing

        This is included in the next change (as `-d=compressinstructions=0`)

        File src/runtime/asm_riscv64.s
        Line 531, Patchset 6: CNOP // 2 byte compressed NOP
        Cherry Mui . resolved

        Could the assembler just emit CNOP for `MOV ZERO, ZERO`? This way, we can have it controlled by a command-line flag in the assembler, and the runtime code doesn't need to change.

        Joel Sing

        I don't believe so - I'll double check (it's been 2+ years since I originally did this work), but as far as I recall the size of the NOPs here have to be exactly the same as the PC quantum. If this is correct we cannot flip between a CNOP (2 bytes) and regular ADDI based noop (4 bytes) without also changing the PC quantum... but let me confirm.

        Joel Sing

        ```
        $ ./all.bash
        Building Go cmd/dist using /usr/local/go. (go1.24.6 openbsd/riscv64)
        Building Go toolchain1 using /usr/local/go.
        Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
        Building Go toolchain2 using go_bootstrap and Go toolchain1.
        SIGILL: illegal instruction
        PC=0x8a922 m=0 sigcode=4
        instruction bytes: 0x0 0x0 0x6f 0x20 0x40 0x6e 0x13 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x73 0x0
        ```

        As expected, we end up in the middle of the 4 byte instruction which is then SIGILL:

        ```
        000000000008a920 <runtime.goexit.abi0>:
        8a920: 00000013 nop
        8a924: 6e40206f j 0x8d008 <runtime.goexit1.abi0>
        8a928: 00000013 nop
        8a92c: 0000 <unknown>
        8a92e: 0000 <unknown>
        ```
        Joel Sing

        Resolving since there is no obvious way to work around this easily, and the effort is not justified.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Cherry Mui
        • Joel Sing
        • Mark Ryan
        • Meng Zhuo
        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: I4329a8fbfcb4de636aadaeadabb826bc22698640
          Gerrit-Change-Number: 523477
          Gerrit-PatchSet: 8
          Gerrit-Owner: Joel Sing <jo...@sing.id.au>
          Gerrit-Reviewer: Cherry Mui <cher...@google.com>
          Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
          Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
          Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
          Gerrit-Attention: Cherry Mui <cher...@google.com>
          Gerrit-Attention: Joel Sing <jo...@sing.id.au>
          Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
          Gerrit-Attention: Mark Ryan <mark...@rivosinc.com>
          Gerrit-Comment-Date: Mon, 20 Oct 2025 04:45:59 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          Comment-In-Reply-To: Cherry Mui <cher...@google.com>
          Comment-In-Reply-To: Joel Sing <jo...@sing.id.au>
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Joel Sing (Gerrit)

          unread,
          Oct 20, 2025, 12:46:35 AMOct 20
          to goph...@pubsubhelper.golang.org, Go LUCI, Meng Zhuo, Mark Ryan, Cherry Mui, golang-co...@googlegroups.com
          Attention needed from Cherry Mui, Joel Sing, Mark Ryan and Meng Zhuo

          Joel Sing removed a vote from this change

          Removed LUCI-TryBot-Result-1 by Go LUCI <golang...@luci-project-accounts.iam.gserviceaccount.com>
          Open in Gerrit

          Related details

          Attention is currently required from:
          • Cherry Mui
          • Joel Sing
          • Mark Ryan
          • Meng Zhuo
          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: deleteVote
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Joel Sing (Gerrit)

          unread,
          Oct 20, 2025, 1:14:03 AMOct 20
          to goph...@pubsubhelper.golang.org, Go LUCI, Meng Zhuo, Mark Ryan, Cherry Mui, golang-co...@googlegroups.com
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Joel Sing (Gerrit)

          unread,
          Oct 20, 2025, 1:14:09 AMOct 20
          to goph...@pubsubhelper.golang.org, Go LUCI, Meng Zhuo, Mark Ryan, Cherry Mui, golang-co...@googlegroups.com
          Attention needed from Cherry Mui, Mark Ryan and Meng Zhuo

          Joel Sing voted Commit-Queue+1

          Commit-Queue+1
          Open in Gerrit

          Related details

          Attention is currently required from:
          • Cherry Mui
          • Mark Ryan
          • Meng Zhuo
          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: I4329a8fbfcb4de636aadaeadabb826bc22698640
          Gerrit-Change-Number: 523477
          Gerrit-PatchSet: 8
          Gerrit-Owner: Joel Sing <jo...@sing.id.au>
          Gerrit-Reviewer: Cherry Mui <cher...@google.com>
          Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
          Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
          Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
          Gerrit-Attention: Cherry Mui <cher...@google.com>
          Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
          Gerrit-Attention: Mark Ryan <mark...@rivosinc.com>
          Gerrit-Comment-Date: Mon, 20 Oct 2025 05:14:00 +0000
          Gerrit-HasComments: No
          Gerrit-Has-Labels: Yes
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Cherry Mui (Gerrit)

          unread,
          Oct 20, 2025, 9:12:05 AMOct 20
          to Joel Sing, goph...@pubsubhelper.golang.org, Go LUCI, Meng Zhuo, Mark Ryan, golang-co...@googlegroups.com
          Attention needed from Joel Sing, Mark Ryan and Meng Zhuo

          Cherry Mui added 1 comment

          File src/runtime/asm_riscv64.s
          Line 629, Patchset 8 (Latest): CNOP // 2 byte compressed NOP
          Cherry Mui . unresolved

          As discussed in the issue, we want to have a flag in the compiler/assembler to control whether to use compressed instructions. If this is the only use in the runtime assembly, probably just leave them.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Joel Sing
          • Mark Ryan
          • Meng Zhuo
          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: I4329a8fbfcb4de636aadaeadabb826bc22698640
            Gerrit-Change-Number: 523477
            Gerrit-PatchSet: 8
            Gerrit-Owner: Joel Sing <jo...@sing.id.au>
            Gerrit-Reviewer: Cherry Mui <cher...@google.com>
            Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
            Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
            Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
            Gerrit-Attention: Joel Sing <jo...@sing.id.au>
            Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
            Gerrit-Attention: Mark Ryan <mark...@rivosinc.com>
            Gerrit-Comment-Date: Mon, 20 Oct 2025 13:12:01 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            unsatisfied_requirement
            satisfied_requirement
            open
            diffy

            Joel Sing (Gerrit)

            unread,
            Oct 20, 2025, 9:23:06 AMOct 20
            to goph...@pubsubhelper.golang.org, Go LUCI, Meng Zhuo, Mark Ryan, Cherry Mui, golang-co...@googlegroups.com
            Attention needed from Cherry Mui, Mark Ryan and Meng Zhuo

            Joel Sing added 1 comment

            File src/runtime/asm_riscv64.s
            Line 629, Patchset 8 (Latest): CNOP // 2 byte compressed NOP
            Cherry Mui . unresolved

            As discussed in the issue, we want to have a flag in the compiler/assembler to control whether to use compressed instructions. If this is the only use in the runtime assembly, probably just leave them.

            Joel Sing

            The previous comment threads explain this in detail - please see:

              https://go-review.googlesource.com/c/go/+/523477/comment/4159da8c_7a60a1df
              https://go-review.googlesource.com/c/go/+/523477/comments/765358be_38dd1e42

            In summary, I do not believe there is an easy way to avoid this usage in the runtime (or at least it would require significant effort) and the debug flag is included in the next CL (https://go-review.googlesource.com/c/go/+/523478/10).

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Cherry Mui
            • Mark Ryan
            • Meng Zhuo
            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: I4329a8fbfcb4de636aadaeadabb826bc22698640
            Gerrit-Change-Number: 523477
            Gerrit-PatchSet: 8
            Gerrit-Owner: Joel Sing <jo...@sing.id.au>
            Gerrit-Reviewer: Cherry Mui <cher...@google.com>
            Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
            Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
            Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
            Gerrit-Attention: Cherry Mui <cher...@google.com>
            Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
            Gerrit-Attention: Mark Ryan <mark...@rivosinc.com>
            Gerrit-Comment-Date: Mon, 20 Oct 2025 13:22:58 +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,
            Oct 24, 2025, 10:48:06 AMOct 24
            to Joel Sing, goph...@pubsubhelper.golang.org, Go LUCI, Meng Zhuo, Mark Ryan, golang-co...@googlegroups.com
            Attention needed from Joel Sing, Mark Ryan and Meng Zhuo

            Cherry Mui voted and added 1 comment

            Votes added by Cherry Mui

            Code-Review+2

            1 comment

            File src/runtime/asm_riscv64.s
            Line 629, Patchset 8 (Latest): CNOP // 2 byte compressed NOP
            Cherry Mui . unresolved

            As discussed in the issue, we want to have a flag in the compiler/assembler to control whether to use compressed instructions. If this is the only use in the runtime assembly, probably just leave them.

            Joel Sing

            The previous comment threads explain this in detail - please see:

              https://go-review.googlesource.com/c/go/+/523477/comment/4159da8c_7a60a1df
              https://go-review.googlesource.com/c/go/+/523477/comments/765358be_38dd1e42

            In summary, I do not believe there is an easy way to avoid this usage in the runtime (or at least it would require significant effort) and the debug flag is included in the next CL (https://go-review.googlesource.com/c/go/+/523478/10).

            Cherry Mui

            Sorry about commenting on it again. And thanks for the explanation. I think I see what the problem is without this change.

            Suppose one wants to run Go on a chip without compressed instruction support (not saying we should support this case, just suppose). The CNOP instructions here are actually not executed, as we manually construct a return address to point to goexit+PCQuantum. So the CNOP won't cause an illegal instruction. However, as PCQuantum is 2, it will be an unaligned address of a non-compressed instruction, so the machine will still fault, right?

            If we want to support this case, one thing we could do is in gostartcall ( https://cs.opensource.google/go/go/+/master:src/runtime/sys_riscv64.go;l=11 ), change buf.lr to be goexit+4 (on entry buf.pc is goexit+PCQuantum as prepared by newproc1). Not sure it is worth the effort.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Joel Sing
            • Mark Ryan
            • Meng Zhuo
            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: I4329a8fbfcb4de636aadaeadabb826bc22698640
            Gerrit-Change-Number: 523477
            Gerrit-PatchSet: 8
            Gerrit-Owner: Joel Sing <jo...@sing.id.au>
            Gerrit-Reviewer: Cherry Mui <cher...@google.com>
            Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
            Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
            Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
            Gerrit-Attention: Joel Sing <jo...@sing.id.au>
            Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
            Gerrit-Attention: Mark Ryan <mark...@rivosinc.com>
            Gerrit-Comment-Date: Fri, 24 Oct 2025 14:48:01 +0000
            Gerrit-HasComments: Yes
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Mark Ryan (Gerrit)

            unread,
            Nov 6, 2025, 7:03:57 AM (5 days ago) Nov 6
            to Joel Sing, goph...@pubsubhelper.golang.org, Cherry Mui, Go LUCI, Meng Zhuo, golang-co...@googlegroups.com
            Attention needed from Joel Sing and Meng Zhuo

            Mark Ryan voted and added 1 comment

            Votes added by Mark Ryan

            Code-Review+2

            1 comment

            Patchset-level comments
            Open in Gerrit

            Related details

            Attention is currently required from:
            • Joel Sing
            • Meng Zhuo
            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: I4329a8fbfcb4de636aadaeadabb826bc22698640
            Gerrit-Change-Number: 523477
            Gerrit-PatchSet: 8
            Gerrit-Owner: Joel Sing <jo...@sing.id.au>
            Gerrit-Reviewer: Cherry Mui <cher...@google.com>
            Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
            Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
            Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
            Gerrit-Attention: Joel Sing <jo...@sing.id.au>
            Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
            Gerrit-Comment-Date: Thu, 06 Nov 2025 12:03:52 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: Yes
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Joel Sing (Gerrit)

            unread,
            Nov 8, 2025, 11:06:32 AM (3 days ago) Nov 8
            to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
            Attention needed from Cherry Mui, Joel Sing, Mark Ryan and Meng Zhuo

            Joel Sing uploaded new patchset

            Joel Sing uploaded patch set #9 to this change.
            Following approvals got outdated and were removed:
            • Code-Review: +2 by Mark Ryan, +2 by Cherry Mui
            • TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
              Open in Gerrit

              Related details

              Attention is currently required from:
              • Cherry Mui
              • Joel Sing
              • Mark Ryan
              • Meng Zhuo
              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: I4329a8fbfcb4de636aadaeadabb826bc22698640
              Gerrit-Change-Number: 523477
              Gerrit-PatchSet: 9
              Gerrit-Owner: Joel Sing <jo...@sing.id.au>
              Gerrit-Reviewer: Cherry Mui <cher...@google.com>
              Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
              Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
              Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
              Gerrit-Attention: Cherry Mui <cher...@google.com>
              Gerrit-Attention: Joel Sing <jo...@sing.id.au>
              Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
              Gerrit-Attention: Mark Ryan <mark...@rivosinc.com>
              unsatisfied_requirement
              open
              diffy

              Joel Sing (Gerrit)

              unread,
              Nov 8, 2025, 11:25:00 AM (3 days ago) Nov 8
              to goph...@pubsubhelper.golang.org, Mark Ryan, Cherry Mui, Go LUCI, Meng Zhuo, golang-co...@googlegroups.com
              Attention needed from Cherry Mui, Mark Ryan and Meng Zhuo

              Joel Sing voted Commit-Queue+1

              Commit-Queue+1
              Open in Gerrit

              Related details

              Attention is currently required from:
              • Cherry Mui
              • Mark Ryan
              • Meng Zhuo
              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: I4329a8fbfcb4de636aadaeadabb826bc22698640
              Gerrit-Change-Number: 523477
              Gerrit-PatchSet: 9
              Gerrit-Owner: Joel Sing <jo...@sing.id.au>
              Gerrit-Reviewer: Cherry Mui <cher...@google.com>
              Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
              Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
              Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
              Gerrit-Attention: Cherry Mui <cher...@google.com>
              Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
              Gerrit-Attention: Mark Ryan <mark...@rivosinc.com>
              Gerrit-Comment-Date: Sat, 08 Nov 2025 16:24:51 +0000
              Gerrit-HasComments: No
              Gerrit-Has-Labels: Yes
              unsatisfied_requirement
              open
              diffy
              Reply all
              Reply to author
              Forward
              0 new messages