Hi,
This patch refactors the code used in llc such that all the users of the addPassesToEmitFile API have access to a homogeneous way of handling start/stop-after/before options right out of the box.
Previously each user would have needed to duplicate this logic and set up its own options.
Note:
I am not super happy about the error reporting. I would have preferred this to be handled by the caller of the getPassXXX methods. However, since I wanted to have the start/stop-after/before options working out-of-the-box, that's not possible. Indeed that would mean that every user of the getPassXXX API would need to have code to unbox/treat the error case. Thus, I settle for a direct reporting. Given this is more of a developer capability, I thought it would be good enough.
Moreover, the current patch loses the prefix "llc: " or "stop-after" in the error message. I initially thought about passing an additional prefix to the error message (with a default "LLVM: "), but again I thought given the usage of that stuff, this was not worth the effort/complexity.
What do people think?
Cheers,
-Quentin