Target Specific LTO Machine Pass


I want to add Target Specific MachineFunctionPass so that it will run during Link Time Optimization.

The pass is currently running in non-LTO compilation (added in addPreEmitPass).

What do I need to do in order to run my pass also during LTO?



When do you want it to run? Machine specific passes are invoked during codegen. It looks like anything you add via addPreEmitPass should get invoked during LTO codegen (via TargetMachine::addPassesToEmitFile which eventually calls that through some other layers). Are you sure it isn’t being invoked during LTO codegen?

It looks like you are correct. Some Target Machine options were not forwarded to the linker correctly.

It caused the pass not to run.

Thank you for the help,