• Matthew Dempsky's avatar
    cmd/compile: handle unsafe.Pointer(f()) correctly · c65647d6
    Matthew Dempsky authored
    Previously statements like
    
        f(unsafe.Pointer(g()), int(h()))
    
    would be reordered into a sequence of statements like
    
        autotmp_g := g()
        autotmp_h := h()
        f(unsafe.Pointer(autotmp_g), int(autotmp_h))
    
    which can leave g's temporary value on the stack as a uintptr, rather
    than an unsafe.Pointer. Instead, recognize uintptr-to-unsafe.Pointer
    conversions when reordering function calls to instead produce:
    
        autotmp_g := unsafe.Pointer(g())
        autotmp_h := h()
        f(autotmp_g, int(autotmp_h))
    
    Fixes #15329.
    
    Change-Id: I2cdbd89d233d0d5c94791513a9fd5fd958d11ed5
    Reviewed-on: https://go-review.googlesource.com/22273
    Run-TryBot: Matthew Dempsky <mdempsky@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarKeith Randall <khr@golang.org>
    Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
    c65647d6
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...