• Josh Bleecher Snyder's avatar
    [dev.ssa] cmd/compile/ssa: add nilcheckelim pass · 2a846d2b
    Josh Bleecher Snyder authored
    The nilcheckelim pass eliminates unnecessary nil checks.
    The initial implementation removes redundant nil checks.
    See the comments in nilcheck.go for ideas for future
    improvements.
    
    The efficacy of the cse pass has a significant impact
    on this efficacy of this pass.
    
    There are 886 nil checks in the parts of the standard
    library that SSA can currently compile (~20%).
    
    This pass eliminates 75 (~8.5%) of them.
    
    As a data point, with a more aggressive but unsound
    cse pass that treats many more types as identical,
    this pass eliminates 115 (~13%) of the nil checks.
    
    Change-Id: I13e567a39f5f6909fc33434d55c17a7e3884a704
    Reviewed-on: https://go-review.googlesource.com/11430Reviewed-by: 's avatarAlan Donovan <adonovan@google.com>
    2a846d2b
nilcheck.go 1.93 KB