Add missing newlines to ends of files.
Remove unnecessary trailing blank line.
Space between referent type and "*" pointer mark.
Prefer "nullptr" over "NULL" in modern C++ code.
Avoid looking up the same key in the same map twice.

Previously we were doing one lookup to see if the key was present, and
then a second lookup to access the key's data.  Instead, we can look up
the key just once, save the resulting iterator, and use that iterator twice
without doing a second lookup.
Remove the declaration for a method that is neither defined nor used.

Also remove two header includes that were only needed for this
declaration.  Those two includes were actually grabbing the same header
twice, which is odd.  Now we don't need it at all.
Simplify traversePHIs() API by offering an alternate entry point.

Previously the caller had to declare an unordered set of phi nodes
found so far, and pass that in as a by-reference argument.  But
really, the caller never cares about that set.  It's an implementation
detail that prevents infinite loops when traversePHIs() recursively
calls itself.

The simpler API is an alternate entry point that omits that set of
already-found phi nodes.  This alternate entry point takes care of
declaring that set and calling into the main traversePHIs() logic.
This makes life easier for the caller by letting the caller remain
ignorant of this phi node set, which is really an implementation
detail.  It also means that set will go out of scope sooner, thereby
releasing its memory sooner.
Prefer iteration over ranges rather than old-fashioned "for" loops.

This could be considered a matter of personal taste.  I like the irange()
approach better because it's a higher level of abstraction that more
clearly documents our intent.  Using this style also means we don't have to
compute and stash the ending value ourselves.  Istead, the endinf value is
just passed in as an argument to irange(), and the range itself is
responsible for knowing when to stop.
Declare various things relating to phi traversal as const.

It was already the case that nobody was changing these things, but the
declarations did not previously make that clear.
Whitespace-only: indent traversePHIs() the same as everything else.
More additions of "const" where things were already not being modified.

Also tweak spacing for some casts: I prefer "(Foo *) bar" over "(Foo*)bar".
Use "isa<T>(v)" and "dyn_cast<T>(v)" for LLVM dynamic type checks.

The static "classof" member is really an implementation detail; one is not
supposed to call "T::classof(v)" directly to test whether v has dynamic
type T.  Instead, use "isa<T>(v)" if you just want the Boolean test.  If
you actually want a checked cast, use "dyn_cast<T>(v)".  This will give you
a retyped pointer of the same value if the dynamic check succeeds, or null
if the dynamic check fails.
Avoid two map lookups when inserting a value if not already already there.

Previously we were checking for the value already being present, and then
doing an insertion if it was not already there.  That requires two map
lookups.  Instead, we can always just perform the insertion.  This is not
a multimap, so we won't end up with duplicates.  Furthermore, the insert
method's return value will tell us whether the value was already present
or not.  So this gives us the same overall effect but with just one map
lookup instead of two.
Avoid casting when an equivalent value with the desired type is available.
Make more things const.
Postpone declaring something until we know what value it should have.

This avoids an assignment that would probably be optimized away anyway.  It
also lets us declare this thing const, which previously we could not do.  I
like to be as const'y as practical.
Limit scope of a local variable to just the control structure that uses it.
Eliminate a local variable that only ever has the value "nullptr".
Leave behind comments for a few things that look sketchy to me.

I'll want to discuss these further with Alisa.
Pass std::string by const reference if the caller won't be mutating it.

Passing std::string by non-const copy really only makes sense if the callee
plans to mutate its own private copy of the string.  If the callee won't be
modifying the string at all, then it's faster to pass by const reference.