function and stack size constants

I'm looking to add a ConstantArray of function and stack sizes to a module in an opt pass, but obviously these values aren't available until code generation. As far as I can tell, the only way to go about this would be to add two new constants, FunctionSize and StackSize, both taking a function as a parameter and then lower these somewhere in the target-specific code. Does this sound reasonable? I'm not sure where to start with the creation of these constants.

Any pointers on adding the constants or an alternative approach would be greatly appreciated.

- Charlie