1
2
3
4
5 package walk
6
7 import (
8 "cmd/compile/internal/base"
9 "cmd/compile/internal/ir"
10 "cmd/compile/internal/types"
11 "cmd/internal/src"
12 )
13
14 func instrument(fn *ir.Func) {
15 if fn.Pragma&ir.Norace != 0 || (fn.Linksym() != nil && fn.Linksym().ABIWrapper()) {
16 return
17 }
18
19 if !base.Flag.Race || !base.Compiling(base.NoRacePkgs) {
20 fn.SetInstrumentBody(true)
21 }
22
23 if base.Flag.Race {
24 lno := base.Pos
25 base.Pos = src.NoXPos
26 var init ir.Nodes
27 fn.Enter.Prepend(mkcallstmt("racefuncenter", mkcall("getcallerpc", types.Types[types.TUINTPTR], &init)))
28 if len(init) != 0 {
29 base.Fatalf("race walk: unexpected init for getcallerpc")
30 }
31 fn.Exit.Append(mkcallstmt("racefuncexit"))
32 base.Pos = lno
33 }
34 }
35
View as plain text