D68298 updated GlobalOpt to use the DomTreeUpdater, but that can cause compile-time regressions for cases where we do not need to compute the DT for most functions. This patch adds some plumbing to only fetch the DT to update, if it was already requested elsewhere in GlobalOpt.
This is mostly a workaround a limitation of the legacy pass manager, which cannot return function analysis only if available for module passes. In the NewPassManager, getCachedResult works as expected.
clang-tidy: warning: invalid case style for member 'GetDT_' [readability-identifier-naming]