]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/cmd/compile/internal/gc/racewalk.go
[dev.ssa] Merge remote-tracking branch 'origin/master' into ssamerge
[gostls13.git] / src / cmd / compile / internal / gc / racewalk.go
index ee4f3baffdf902c9e07753f84116a260c62ce978..e1b3ae68793e70dc4738ac16353bd17c9d8ac71a 100644 (file)
@@ -50,7 +50,7 @@ func ispkgin(pkgs []string) bool {
 }
 
 func instrument(fn *Node) {
-       if ispkgin(omit_pkgs) || fn.Func.Norace {
+       if ispkgin(omit_pkgs) || fn.Func.Pragma&Norace != 0 {
                return
        }
 
@@ -58,7 +58,7 @@ func instrument(fn *Node) {
                instrumentlist(fn.Nbody, nil)
 
                // nothing interesting for race detector in fn->enter
-               instrumentlist(fn.Func.Exit, nil)
+               instrumentslice(fn.Func.Exit.Slice(), nil)
        }
 
        if flag_race != 0 {
@@ -71,18 +71,18 @@ func instrument(fn *Node) {
                nodpc.Type = Types[TUINTPTR]
                nodpc.Xoffset = int64(-Widthptr)
                nd := mkcall("racefuncenter", nil, nil, nodpc)
-               fn.Func.Enter = concat(list1(nd), fn.Func.Enter)
+               fn.Func.Enter.Set(append([]*Node{nd}, fn.Func.Enter.Slice()...))
                nd = mkcall("racefuncexit", nil, nil)
-               fn.Func.Exit = list(fn.Func.Exit, nd)
+               fn.Func.Exit.Append(nd)
        }
 
        if Debug['W'] != 0 {
                s := fmt.Sprintf("after instrument %v", fn.Func.Nname.Sym)
                dumplist(s, fn.Nbody)
                s = fmt.Sprintf("enter %v", fn.Func.Nname.Sym)
-               dumplist(s, fn.Func.Enter)
+               dumpslice(s, fn.Func.Enter.Slice())
                s = fmt.Sprintf("exit %v", fn.Func.Nname.Sym)
-               dumplist(s, fn.Func.Exit)
+               dumpslice(s, fn.Func.Exit.Slice())
        }
 }
 
@@ -100,6 +100,18 @@ func instrumentlist(l *NodeList, init **NodeList) {
        }
 }
 
+func instrumentslice(l []*Node, init **NodeList) {
+       for i := range l {
+               var instr *NodeList
+               instrumentnode(&l[i], &instr, 0, 0)
+               if init == nil {
+                       l[i].Ninit = concat(l[i].Ninit, instr)
+               } else {
+                       *init = concat(*init, instr)
+               }
+       }
+}
+
 // walkexpr and walkstmt combined
 // walks the tree and adds calls to the
 // instrumentation code to top-level (statement) nodes' init