-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile/internal/walk: unreachable branch generated for select cases #50823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Milestone
Comments
Change https://golang.org/cl/380894 mentions this issue: |
CC @randall77 and @cherrymui maybe? |
With my patch, the result for the example in #50823 (comment) is: "".F STEXT size=165 args=0x10 locals=0x70 funcid=0x0 align=0x0 0x0000 00000 (issue50823.go:3) TEXT "".F(SB), ABIInternal, $112-16 0x0000 00000 (issue50823.go:3) CMPQ SP, 16(R14) 0x0004 00004 (issue50823.go:3) PCDATA $0, $-2 0x0004 00004 (issue50823.go:3) JLS 131 0x0006 00006 (issue50823.go:3) PCDATA $0, $-1 0x0006 00006 (issue50823.go:3) SUBQ $112, SP 0x000a 00010 (issue50823.go:3) MOVQ BP, 104(SP) 0x000f 00015 (issue50823.go:3) LEAQ 104(SP), BP 0x0014 00020 (issue50823.go:3) FUNCDATA $0, gclocals·dc9b0298814590ca3ffc3a889546fc8b(SB) 0x0014 00020 (issue50823.go:3) FUNCDATA $1, gclocals·955e25ebd21d9d330257196a49a276e5(SB) 0x0014 00020 (issue50823.go:3) FUNCDATA $2, "".F.stkobj(SB) 0x0014 00020 (issue50823.go:3) FUNCDATA $5, "".F.arginfo1(SB) 0x0014 00020 (issue50823.go:3) FUNCDATA $6, "".F.argliveinfo(SB) 0x0014 00020 (issue50823.go:3) PCDATA $3, $1 0x0014 00020 (issue50823.go:4) MOVUPS X15, ""..autotmp_9+72(SP) 0x001a 00026 (issue50823.go:4) MOVUPS X15, ""..autotmp_9+88(SP) 0x0020 00032 (issue50823.go:5) MOVQ AX, ""..autotmp_9+88(SP) 0x0025 00037 (issue50823.go:5) LEAQ ""..autotmp_6+56(SP), DX 0x002a 00042 (issue50823.go:5) MOVQ DX, ""..autotmp_9+96(SP) 0x002f 00047 (issue50823.go:7) MOVQ BX, ""..autotmp_9+72(SP) 0x0034 00052 (issue50823.go:7) LEAQ ""..autotmp_8+48(SP), DX 0x0039 00057 (issue50823.go:7) MOVQ DX, ""..autotmp_9+80(SP) 0x003e 00062 (issue50823.go:4) LEAQ ""..autotmp_9+72(SP), AX 0x0043 00067 (issue50823.go:4) LEAQ ""..autotmp_10+64(SP), BX 0x0048 00072 (issue50823.go:4) XORL CX, CX 0x004a 00074 (issue50823.go:4) XORL DI, DI 0x004c 00076 (issue50823.go:4) MOVL $2, SI 0x0051 00081 (issue50823.go:4) MOVL $1, R8 0x0057 00087 (issue50823.go:4) PCDATA $1, $1 0x0057 00087 (issue50823.go:4) CALL runtime.selectgo(SB) 0x005c 00092 (issue50823.go:4) NOP 0x0060 00096 (issue50823.go:7) TESTQ AX, AX 0x0063 00099 (issue50823.go:7) JNE 116 0x0065 00101 (issue50823.go:7) MOVQ ""..autotmp_8+48(SP), AX 0x006a 00106 (issue50823.go:8) MOVQ 104(SP), BP 0x006f 00111 (issue50823.go:8) ADDQ $112, SP 0x0073 00115 (issue50823.go:8) RET 0x0074 00116 (issue50823.go:5) MOVQ ""..autotmp_6+56(SP), AX 0x0079 00121 (issue50823.go:6) MOVQ 104(SP), BP 0x007e 00126 (issue50823.go:6) ADDQ $112, SP 0x0082 00130 (issue50823.go:6) RET 0x0083 00131 (issue50823.go:6) NOP 0x0083 00131 (issue50823.go:3) PCDATA $1, $-1 0x0083 00131 (issue50823.go:3) PCDATA $0, $-2 0x0083 00131 (issue50823.go:3) MOVQ AX, 8(SP) 0x0088 00136 (issue50823.go:3) MOVQ BX, 16(SP) 0x008d 00141 (issue50823.go:3) CALL runtime.morestack_noctxt(SB) 0x0092 00146 (issue50823.go:3) MOVQ 8(SP), AX 0x0097 00151 (issue50823.go:3) MOVQ 16(SP), BX 0x009c 00156 (issue50823.go:3) PCDATA $0, $-1 0x009c 00156 (issue50823.go:3) NOP 0x00a0 00160 (issue50823.go:3) JMP 0 We only need one comparation for two cases. |
Change https://go.dev/cl/385516 mentions this issue: |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
demo.go:
Then I run "go tool compile -S demo.go" and got:
What did you expect to see?
There is one CMP or TEST instruction after call runtime.selectgo, because we can distinguish two branch by comparing once.
What did you see instead?
Thers is an unreachable branch after call runtime.selectgo, it's "0x006f JNE 144", 144 is the instruction between ret and morestack check. The instruction "CMPQ AX, $1" and "JNE 144" should not been generated or it should jmp to a panic call.
The text was updated successfully, but these errors were encountered: