aboutsummaryrefslogtreecommitdiffstats
path: root/prog/prog.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-05-05 10:25:45 +0200
committerDmitry Vyukov <dvyukov@google.com>2018-05-05 10:25:45 +0200
commitafe402d20af0d54d4e0baeb9e70e668e2a26f188 (patch)
tree58f79c51ee9c8a48939059a23c47d68751d55701 /prog/prog.go
parent9dfb5efa91fc0f051a1ddc88ace2867bb6b32275 (diff)
prog: make c.Ret optional
No reason to allocate return value if there is no return type. c.Ret == nil is the reasonable indication that this is a "void" call.
Diffstat (limited to 'prog/prog.go')
-rw-r--r--prog/prog.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/prog/prog.go b/prog/prog.go
index ef09d46a9..19f5e319f 100644
--- a/prog/prog.go
+++ b/prog/prog.go
@@ -261,8 +261,10 @@ func MakeResultArg(t Type, r *ResultArg, v uint64) *ResultArg {
}
func MakeReturnArg(t Type) *ResultArg {
- // TODO(dvyukov): we should not create return arg at all if t is nil.
- if t != nil && t.Dir() != DirOut {
+ if t == nil {
+ return nil
+ }
+ if t.Dir() != DirOut {
panic("return arg is not out")
}
return &ResultArg{ArgCommon: ArgCommon{typ: t}}
@@ -491,7 +493,9 @@ func (p *Prog) removeCall(idx int) {
for _, arg := range c.Args {
removeArg(arg)
}
- removeArg(c.Ret)
+ if c.Ret != nil {
+ removeArg(c.Ret)
+ }
copy(p.Calls[idx:], p.Calls[idx+1:])
p.Calls = p.Calls[:len(p.Calls)-1]
}