Fix whole-ast pass behavior

 - save the reduction map for later
 - don't clobber pass history due to rewriting
 - emit the appropriate metadata on new defs
 - don't rewrite previously rewritten fns