chapel-lang/chapel — pull request #354 by hildeth (2014-09-09 17:41:53+00:00)
Title: Make narrowWideReferences its own pass...

... and factor the main routine.

Making narrowWideReferences() its own pass was straightforward: It included adding the top-level hooks, and removing its invocation from the tail of insertWideReferences(). Since moveAddressSourcesToTemp() used to be called after the call to narrowWideReferences(), I moved that invocation into narrowWideReferences(), and moved the (static) function into narrowWideReferences.cpp.

While there, it seemed natural to factor the main routine for narrowWideReferences(). I merely chunked up the main blocks of code and pulled them out as (filescope) static functions. I was able to reduce the scope and lifetime of widenMap, defMap and useMap by declaring them inside the main routine and then passing references into those helper functions the need to access them. I left wideRefMap as a filescope variable, for convenience, but reduced its lifetime to one invocation of that pass.