This is fascinating - would you consider having these optimization passes done as loadable modules?
Say something like swiftc -load-sil-pass=myPass.so
This would allow a pass to inspect the Swift code, and potentially extract interesting information out of it, or generate code out of it.
The first scenario would give us enough information to navigate the public API, like reflection, but without having to extend Swift or the Swift libraries.
The second scenario would be to generate some code on demand, that could complement the existing code. C# has a capability to do this: