Update optimization passes to use the latest LLVM changes

LLVM had some breaking changes that I didn't notice; on the plus
side this new range-iteration style is much nicer.
rangify the codebase