This changes MemorySSA to be constructed in unoptimized form. MemorySSA::ensureOptimized() can be called to optimize all uses (once). This should be done by passes where having optimized uses is beneficial, either because we're going to query all uses anyway, or because we're doing def-use walks.
This should help reduce the compile-time impact of MemorySSA for some use cases (the reason why I started looking into this is D117926), which can avoid optimizing all uses upfront, and instead only optimize those that are actually queried.
Actually, we have an existing use-case for this, which is EarlyCSE. Disabling eager use optimization there gives a significant compile-time improvement: http://llvm-compile-time-tracker.com/compare.php?from=59191057243e34d85b644716ef2811bfea8efd1e&to=1dd3499045716e71bad61ccd70700e734a74d350&stat=instructions This is because EarlyCSE will generally only query clobbers for a subset of all uses.
To be more conservative I haven't included the EarlyCSE change here, but I can add it.
This is not necessarily true due to the cap set by MaxCheckLimit (memssa-check-limit).
Also not true if a MemoryDef was added that invalidated optimizations (OptimizedID will no longer match).