Optimization for size


Looking at bugzilla PR11087, I’d like to conditionalise a transformation in ARMIselLowering.cpp based on whether we’re compiling for codesize or performance.

-Os doesn’t actually exist for llc, and I can’t see an obvious place where that condition would be set. Where do we specify if we’re optimizing for codesize or performance?



You can specify a function should be optimized for size with the optsize function attribute. Given a MachineFunction you can check for this using:

bool OptSize = MF.getFunction()->hasFnAttr(Attribute::OptimizeForSize);