aboutsummaryrefslogtreecommitdiffstats
path: root/prog/clone.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-01-20 23:55:25 +0100
committerDmitry Vyukov <dvyukov@google.com>2017-01-20 23:55:25 +0100
commita7e4a49fae26bf52b4b8f26aeebc50d947dc1abc (patch)
tree03ccdac553f003b5b389587ebb5a74d4b8091865 /prog/clone.go
parenta8632569bf8339f5fa468f99493d4d825db2cb12 (diff)
all: spot optimizations
A bunch of spot optmizations after cpu/memory profiling: 1. Optimize hot-path coverage comparison in fuzzer. 2. Don't allocate and copy serialized program, serialize directly into shmem. 3. Reduce allocations during parsing of output shmem (encoding/binary sucks). 4. Don't allocate and copy coverage arrays, refer directly to the shmem region (we are not going to mutate them). 5. Don't validate programs outside of tests, validation allocates tons of memory. 6. Replace the choose primitive with simpler switches. Choose allocates fullload of memory (for int, func, and everything the func refers). 7. Other minor optimizations.
Diffstat (limited to 'prog/clone.go')
-rw-r--r--prog/clone.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/prog/clone.go b/prog/clone.go
index 69a54cd4e..6a6837148 100644
--- a/prog/clone.go
+++ b/prog/clone.go
@@ -44,7 +44,9 @@ func (arg *Arg) clone(c *Call, newargs map[*Arg]*Arg) *Arg {
for _, arg2 := range arg.Inner {
arg1.Inner = append(arg1.Inner, arg2.clone(c, newargs))
}
- arg1.Uses = nil // filled when we clone the referent
- newargs[arg] = arg1
+ if len(arg1.Uses) != 0 {
+ arg1.Uses = nil // filled when we clone the referent
+ newargs[arg] = arg1
+ }
return arg1
}