[LegacyPassManager] Remove TargetMachine constructors
This provides a new way to access the TargetMachine through TargetPassConfig, as a dependency.
The patterns replaced here are:
- Passes handling a null TargetMachine call getAnalysisIfAvailable<TargetPassConfig>.
- Passes not handling a null TargetMachine addRequired<TargetPassConfig> and call getAnalysis<TargetPassConfig>.
- MachineFunctionPasses now use MF.getTarget().
- Remove all the TargetMachine constructors. Remove INITIALIZE_TM_PASS.
This fixes a crash when running llc -start-before prologepilog.
PEI needs StackProtector, which gets constructed without a TargetMachine by the pass manager. The StackProtector pass doesn't handle the case where there is no TargetMachine, so it segfaults.
Related to PR30324.