Calls to the getSubtargetImpl on X86 tend to have non trivial execution cost. Usually it's negligible but it becomes noticeable when we try to request subtarget from the frequently executed methods, i.e like optimizeMemoryInst. This change saves subtarget, target lowering and target register info at the beginning of the pass and reuses this values during pass execution.
On one of our internal benchmarks this change reduces time spent in the llc by ~20%.