go/analysis/passes/asmdecl: permit return jump without writing to results

RET f(SB) is a tail call. It is okay to not write the results,
as it has not returned to the caller at this point.

Change-Id: I670486d02285c3a346cbc93e91be3b9e61ab77bd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/264319
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
Cherry Zhang 2020-10-21 21:44:15 -04:00
parent 2c115999a7
commit 690a3c245f
3 changed files with 8 additions and 1 deletions

View File

@ -308,7 +308,8 @@ Files:
continue
}
if strings.Contains(line, "RET") {
if strings.Contains(line, "RET") && !strings.Contains(line, "(SB)") {
// RET f(SB) is a tail call. It is okay to not write the results.
retLine = append(retLine, lineno)
}

View File

@ -51,3 +51,5 @@ func fvariadic(int, ...int)
func pickStableABI(x int)
func pickInternalABI(x int)
func pickFutureABI(x int)
func retjmp() int

View File

@ -345,3 +345,7 @@ TEXT ·pickInternalABI<ABIInternal>(SB), NOSPLIT, $32
TEXT ·pickFutureABI<ABISomethingNotyetInvented>(SB), NOSPLIT, $32
MOVQ x+0(FP), AX
RET
// return jump
TEXT ·retjmp(SB), NOSPLIT, $0-8
RET retjmp1(SB) // It's okay to not write results if there's a tail call.