• Josh Bleecher Snyder's avatar
    cmd/compile: check labels and gotos before building SSA · c03e75e5
    Josh Bleecher Snyder authored
    This CL introduces yet another compiler pass,
    which checks for correct control flow constructs
    prior to converting from AST to SSA form.
    
    It cannot be integrated with walk, since walk rewrites
    switch and select statements on the fly.
    
    To reduce code duplication, this CL also does some
    minor refactoring.
    
    With this pass in place, the AST to SSA converter
    can now stop generating SSA for any known-dead code.
    This minor savings pays for the minor cost of the new pass.
    
    Performance is almost a wash:
    
    name       old time/op     new time/op     delta
    Template       206ms ± 4%      205ms ± 4%   ~     (p=0.108 n=43+43)
    Unicode       84.0ms ± 4%     84.0ms ± 4%   ~     (p=0.979 n=43+43)
    GoTypes        550ms ± 3%      553ms ± 3%   ~     (p=0.065 n=40+41)
    Compiler       2.57s ± 4%      2.58s ± 2%   ~     (p=0.103 n=44+41)
    SSA            3.94s ± 3%      3.93s ± 2%   ~     (p=0.833 n=44+42)
    Flate          126ms ± 6%      125ms ± 4%   ~     (p=0.941 n=43+39)
    GoParser       147ms ± 4%      148ms ± 3%   ~     (p=0.164 n=42+39)
    Reflect        359ms ± 3%      357ms ± 5%   ~     (p=0.241 n=43+44)
    Tar            106ms ± 5%      106ms ± 7%   ~     (p=0.853 n=40+43)
    XML            202ms ± 3%      203ms ± 3%   ~     (p=0.488 n=42+41)
    
    name       old user-ns/op  new user-ns/op  delta
    Template        240M ± 4%       239M ± 4%   ~     (p=0.844 n=42+43)
    Unicode         107M ± 5%       107M ± 4%   ~     (p=0.332 n=40+43)
    GoTypes         735M ± 3%       731M ± 4%   ~     (p=0.141 n=43+44)
    Compiler       3.51G ± 3%      3.52G ± 3%   ~     (p=0.208 n=42+43)
    SSA            5.72G ± 4%      5.72G ± 3%   ~     (p=0.928 n=44+42)
    Flate           151M ± 7%       150M ± 8%   ~     (p=0.662 n=44+43)
    GoParser        181M ± 5%       181M ± 4%   ~     (p=0.379 n=41+44)
    Reflect         447M ± 4%       445M ± 4%   ~     (p=0.344 n=43+43)
    Tar             125M ± 7%       124M ± 6%   ~     (p=0.353 n=43+43)
    XML             248M ± 4%       250M ± 6%   ~     (p=0.158 n=44+44)
    
    name       old alloc/op    new alloc/op    delta
    Template      40.3MB ± 0%     40.2MB ± 0%  -0.27%  (p=0.000 n=10+10)
    Unicode       30.3MB ± 0%     30.2MB ± 0%  -0.10%  (p=0.015 n=10+10)
    GoTypes        114MB ± 0%      114MB ± 0%  -0.06%  (p=0.000 n=7+9)
    Compiler       480MB ± 0%      481MB ± 0%  +0.07%  (p=0.000 n=10+10)
    SSA            864MB ± 0%      862MB ± 0%  -0.25%  (p=0.000 n=9+10)
    Flate         25.9MB ± 0%     25.9MB ± 0%    ~     (p=0.123 n=10+10)
    GoParser      32.1MB ± 0%     32.1MB ± 0%    ~     (p=0.631 n=10+10)
    Reflect       79.9MB ± 0%     79.6MB ± 0%  -0.39%  (p=0.000 n=10+9)
    Tar           27.1MB ± 0%     27.0MB ± 0%  -0.18%  (p=0.003 n=10+10)
    XML           42.6MB ± 0%     42.6MB ± 0%    ~     (p=0.143 n=10+10)
    
    name       old allocs/op   new allocs/op   delta
    Template        401k ± 0%       401k ± 1%    ~     (p=0.353 n=10+10)
    Unicode         322k ± 0%       322k ± 0%    ~     (p=0.739 n=10+10)
    GoTypes        1.18M ± 0%      1.18M ± 0%  +0.25%  (p=0.001 n=7+8)
    Compiler       4.51M ± 0%      4.53M ± 0%  +0.37%  (p=0.000 n=10+10)
    SSA            7.91M ± 0%      7.93M ± 0%  +0.20%  (p=0.000 n=9+10)
    Flate           244k ± 0%       245k ± 0%    ~     (p=0.123 n=10+10)
    GoParser        323k ± 1%       324k ± 1%  +0.40%  (p=0.035 n=10+10)
    Reflect        1.01M ± 0%      1.02M ± 0%  +0.37%  (p=0.000 n=10+9)
    Tar             258k ± 1%       258k ± 1%    ~     (p=0.661 n=10+9)
    XML             403k ± 0%       405k ± 0%  +0.47%  (p=0.004 n=10+10)
    
    Updates #15756
    Updates #19250
    
    Change-Id: I647bfbb745c35630447eb79dfcaa994b490ce942
    Reviewed-on: https://go-review.googlesource.com/38159
    Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
    c03e75e5
Name
Last commit
Last update
..
archive Loading commit data...
bufio Loading commit data...
builtin Loading commit data...
bytes Loading commit data...
cmd Loading commit data...
compress Loading commit data...
container Loading commit data...
context Loading commit data...
crypto Loading commit data...
database/sql Loading commit data...
debug Loading commit data...
encoding Loading commit data...
errors Loading commit data...
expvar Loading commit data...
flag Loading commit data...
fmt Loading commit data...
go Loading commit data...
hash Loading commit data...
html Loading commit data...
image Loading commit data...
index/suffixarray Loading commit data...
internal Loading commit data...
io Loading commit data...
log Loading commit data...
math Loading commit data...
mime Loading commit data...
net Loading commit data...
os Loading commit data...
path Loading commit data...
plugin Loading commit data...
reflect Loading commit data...
regexp Loading commit data...
runtime Loading commit data...
sort Loading commit data...
strconv Loading commit data...
strings Loading commit data...
sync Loading commit data...
syscall Loading commit data...
testing Loading commit data...
text Loading commit data...
time Loading commit data...
unicode Loading commit data...
unsafe Loading commit data...
vendor/golang_org/x Loading commit data...
Make.dist Loading commit data...
all.bash Loading commit data...
all.bat Loading commit data...
all.rc Loading commit data...
androidtest.bash Loading commit data...
bootstrap.bash Loading commit data...
buildall.bash Loading commit data...
clean.bash Loading commit data...
clean.bat Loading commit data...
clean.rc Loading commit data...
cmp.bash Loading commit data...
iostest.bash Loading commit data...
make.bash Loading commit data...
make.bat Loading commit data...
make.rc Loading commit data...
naclmake.bash Loading commit data...
nacltest.bash Loading commit data...
race.bash Loading commit data...
race.bat Loading commit data...
run.bash Loading commit data...
run.bat Loading commit data...
run.rc Loading commit data...