go/analysis/passes/asmdecl: Correct identify writeResult instructions
This CL ensure all occurrences of writeResult instructions are identified,
not just those at the beginning of the line without indentation.
This CL also fixes this and changed testcases to match other ABIInternal
test.
Change-Id: I1ce6ea22a227902819dc4e0caafa4bace79c15fe
Reviewed-on: https://go-review.googlesource.com/c/tools/+/620056
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/go/analysis/passes/asmdecl/asmdecl.go b/go/analysis/passes/asmdecl/asmdecl.go
index 92671ca..b622dfd 100644
--- a/go/analysis/passes/asmdecl/asmdecl.go
+++ b/go/analysis/passes/asmdecl/asmdecl.go
@@ -354,7 +354,7 @@
if abi == "ABIInternal" && !haveRetArg {
for _, ins := range archDef.writeResult {
- if strings.HasPrefix(line, ins) {
+ if strings.Contains(line, ins) {
haveRetArg = true
break
}
diff --git a/go/analysis/passes/asmdecl/testdata/src/a/asm.go b/go/analysis/passes/asmdecl/testdata/src/a/asm.go
index 7569d19..077201d 100644
--- a/go/analysis/passes/asmdecl/testdata/src/a/asm.go
+++ b/go/analysis/passes/asmdecl/testdata/src/a/asm.go
@@ -30,7 +30,6 @@
func returnbyte(x int) byte
func returnnamed(x byte) (r1 int, r2 int16, r3 string, r4 byte)
func returnintmissing() int
-func returnsyscall()
func leaf(x, y int) int
func noprof(x int)
@@ -55,5 +54,6 @@
func returnABIInternal() int
func returnmissingABIInternal() int
+func returnsyscallABIInternal() int
func retjmp() int
diff --git a/go/analysis/passes/asmdecl/testdata/src/a/asm1.s b/go/analysis/passes/asmdecl/testdata/src/a/asm1.s
index 9f17a03..ff951c7 100644
--- a/go/analysis/passes/asmdecl/testdata/src/a/asm1.s
+++ b/go/analysis/passes/asmdecl/testdata/src/a/asm1.s
@@ -354,7 +354,7 @@
RET // want `RET without writing to result register`
// issue 69352
-TEXT ·returnsyscall<ABIInternal>(SB),0,$0-0
+TEXT ·returnsyscallABIInternal<ABIInternal>(SB), NOSPLIT, $0
MOVQ $123, CX
SYSCALL
RET
diff --git a/go/analysis/passes/asmdecl/testdata/src/a/asm11.s b/go/analysis/passes/asmdecl/testdata/src/a/asm11.s
index 3e3f5a3..7086713 100644
--- a/go/analysis/passes/asmdecl/testdata/src/a/asm11.s
+++ b/go/analysis/passes/asmdecl/testdata/src/a/asm11.s
@@ -13,7 +13,7 @@
RET // want `RET without writing to result register`
// issue 69352
-TEXT ·returnsyscall<ABIInternal>(SB),0,$0-0
+TEXT ·returnsyscallABIInternal<ABIInternal>(SB), NOSPLIT, $0
MOV $123, X20
ECALL
RET
diff --git a/go/analysis/passes/asmdecl/testdata/src/a/asm7.s b/go/analysis/passes/asmdecl/testdata/src/a/asm7.s
index 28bca66..db00bda 100644
--- a/go/analysis/passes/asmdecl/testdata/src/a/asm7.s
+++ b/go/analysis/passes/asmdecl/testdata/src/a/asm7.s
@@ -200,7 +200,7 @@
RET // want `RET without writing to result register`
// issue 69352
-TEXT ·returnsyscall<ABIInternal>(SB),0,$0-0
+TEXT ·returnsyscallABIInternal<ABIInternal>(SB), NOSPLIT, $0
MOVD $123, R10
SYSCALL
RET