Skip to content

cmd/compile: -S reports NOP as WORD $0 on mips and mips64 #18238

Closed
@minux

Description

@minux

go tool compile -S reports NOPs in delay slots as "WORD $0",
and what's more, there are extra zero-length NOP pseduo
instructions in the output, which is very confusing.

e.g.

$ GOARCH=mips go tool compile -S $GOROOT/test/helloworld.go
"".main t=1 size=104 args=0x0 locals=0x8
        0x0000 00000 (../test/helloworld.go:11) TEXT    "".main(SB), $8-0
        0x0000 00000 (../test/helloworld.go:11) MOVW    8(g), R1
        0x0004 00004 (../test/helloworld.go:11) SGTU    R29, R1, R1
        0x0008 00008 (../test/helloworld.go:11) BNE     R1, 36
        0x000c 00012 (../test/helloworld.go:11) WORD    $0
        0x0010 00016 (../test/helloworld.go:11) MOVW    R31, R3
        0x0014 00020 (../test/helloworld.go:11) CALL    runtime.morestack_noctxt(SB)
        0x0018 00024 (../test/helloworld.go:11) WORD    $0   // a real NOP in delay slot
        0x001c 00028 (../test/helloworld.go:11) JMP     0
        0x0020 00032 (../test/helloworld.go:11) WORD    $0  // a real NOP in delay slot
        0x0024 00036 (../test/helloworld.go:11) NOP   // a pseudo NOP
        0x0024 00036 (../test/helloworld.go:11) MOVW    R31, -12(R29)
        0x0028 00040 (../test/helloworld.go:11) ADDU    $-12, R29
        0x002c 00044 (../test/helloworld.go:11) FUNCDATA        $0, gclocals·2002e13acf59079a1a5782c918894579(SB)
        0x002c 00044 (../test/helloworld.go:11) FUNCDATA        $1, gclocals·2002e13acf59079a1a5782c918894579(SB)
        0x002c 00044 (../test/helloworld.go:12) PCDATA  $0, $0

I propose that we don't emit pseudo NOP (NOPs that are added by compiler but
discard by cmd/internal/obj) and replace delay slot filling NOPs as "NOP".

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions