Commit e76b9e89 authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile: remove pointer temporaries in walkcompare

When comparing two T-typed values t1 and t2 using the T_eq function,
we used to generate:

    pl := &t1
    pr := &t2
    return T_eq(pl, pr, unsafe.Sizeof(T{}))

This CL changes it to simply generate:

    return T_eq(&t1, &t2, unsafe.Sizeof(T{}))

Surprisingly, this does not pass toolstash. For some reason, it seems
like SSA wasn't able to SSA-ify the pl and pr variables in all cases.

Change-Id: I111fbb068a1741fa169c9922cb8cdb6e21579aa4
Reviewed-on: https://go-review.googlesource.com/c/go/+/197601
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarKeith Randall <khr@golang.org>
parent ecc2d617
......@@ -3130,20 +3130,10 @@ func walkcompare(n *Node, init *Nodes) *Node {
Fatalf("arguments of comparison must be lvalues - %v %v", cmpl, cmpr)
}
pl := temp(types.NewPtr(t))
al := nod(OAS, pl, nod(OADDR, cmpl, nil))
al = typecheck(al, ctxStmt)
init.Append(al)
pr := temp(types.NewPtr(t))
ar := nod(OAS, pr, nod(OADDR, cmpr, nil))
ar = typecheck(ar, ctxStmt)
init.Append(ar)
fn, needsize := eqfor(t)
call := nod(OCALL, fn, nil)
call.List.Append(pl)
call.List.Append(pr)
call.List.Append(nod(OADDR, cmpl, nil))
call.List.Append(nod(OADDR, cmpr, nil))
if needsize {
call.List.Append(nodintconst(t.Width))
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment