This includes the following refactoring that is useful for a subsequent patch that adds a new inlining heuristic:
- Factor out the code in instruction visitors that checks if an instruction evaluates to a constant.
- Add a method to accumulate the cost of inlining.
- Make isGEPOffsetConstant (which is called once) into a lambda.
- Move a block of code in visitSwitchInst to a lambda.
Some of these may not make much sense standalone, but are useful for the subsequent patch (to be posted shortly)
Of all of these, this one seems the one that doesn't really make sense on its own. I'd rather this be part of the change where it starts to make sense rather than a seemingly bad code smell being added because of some subsequent change.