-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go/analysis/passes/framepointer: support arm64
Add arm64 support to the framepointer vet check. Essentially use the same logic as the amd64 check: in instruction order, look at functions without frames, and fail if the functions write to the frame pointer register before reading it. Stop looking at a function on the first branch instruction. For golang/go#69838 Change-Id: If69be8a6eb5f9275df602c2c2ff644c338deaef2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/635338 Reviewed-by: Cherry Mui <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Carlos Amedee <[email protected]>
- Loading branch information
Showing
2 changed files
with
137 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
go/analysis/passes/framepointer/testdata/src/a/asm_arm64.s
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2024 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
TEXT ·bad1(SB), 0, $0 | ||
MOVD $0, R29 // want `frame pointer is clobbered before saving` | ||
RET | ||
TEXT ·bad2(SB), 0, $0 | ||
MOVD R1, R29 // want `frame pointer is clobbered before saving` | ||
RET | ||
TEXT ·bad3(SB), 0, $0 | ||
MOVD 6(R2), R29 // want `frame pointer is clobbered before saving` | ||
RET | ||
TEXT ·bad4(SB), 0, $0 | ||
LDP 0(R1), (R26, R29) // want `frame pointer is clobbered before saving` | ||
RET | ||
TEXT ·bad5(SB), 0, $0 | ||
AND $0x1, R3, R29 // want `frame pointer is clobbered before saving` | ||
RET | ||
TEXT ·good1(SB), 0, $0 | ||
STPW (R29, R30), -32(RSP) | ||
MOVD $0, R29 // this is ok | ||
LDPW 32(RSP), (R29, R30) | ||
RET | ||
TEXT ·good2(SB), 0, $0 | ||
MOVD R29, R1 | ||
MOVD $0, R29 // this is ok | ||
MOVD R1, R29 | ||
RET | ||
TEXT ·good3(SB), 0, $0 | ||
CMP R1, R2 | ||
BEQ skip | ||
MOVD $0, R29 // this is ok | ||
skip: | ||
RET | ||
TEXT ·good4(SB), 0, $0 | ||
RET | ||
MOVD $0, R29 // this is ok | ||
RET | ||
TEXT ·good5(SB), 0, $8 | ||
MOVD $0, R29 // this is ok | ||
RET |