• Josh Bleecher Snyder's avatar
    cmd/compile: evaluate config as needed in rewrite rules · 193510f2
    Josh Bleecher Snyder authored
    Prior to this CL, config was an explicit argument
    to the SSA rewrite rules, and rules that needed
    a Frontend got at it via config.
    An upcoming CL moves Frontend from Config to Func,
    so rules can no longer reach Frontend via Config.
    Passing a Frontend as an argument to the rewrite rules
    causes a 2-3% regression in compile times.
    This CL takes a different approach:
    It treats the variable names "config" and "fe"
    as special and calculates them as needed.
    The "as needed part" is also important to performance:
    If they are calculated eagerly, the nilchecks themselves
    cause a regression.
    
    This introduces a little bit of magic into the rewrite
    generator. However, from the perspective of the rules,
    the config variable was already more or less magic.
    And it makes the upcoming changes much clearer.
    
    Passes toolstash -cmp.
    
    Change-Id: I173f2bcc124cba43d53138bfa3775e21316a9107
    Reviewed-on: https://go-review.googlesource.com/38326
    Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
    Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
    193510f2
rewritegeneric.go 337 KB