This patch attempts to add a target-overridable hook for allowing module metadata
to override TargetMachine options, especially during LTO.
The new hook is called TargetMachine::resetTargetDefaultOptions and takes the
llvm::Module so that the module metadata can be read with the API provided
by llvm::Module.
It is not clear that this patch handles LTO correctly at the moment.
This patch relates to D72245 and D72246 and the discussion in
http://lists.llvm.org/pipermail/llvm-dev/2020-January/138151.html
Also needed in EmitAssemblyWithNewPassManager. Maybe it should be moved into CreateTargetMachine which would cover both cases.
I'm not sure if this was already discussed - but is there a reason why this can't be done in Target::createTargetMachine()? Is it not possible to ensure it is called once we have the Module available and pass that in? That would centralize this handling and seems cleaner overall.