This patch adds MemorySSA as an alternative to the AliasSetTracker in LICM.
I'm also using this to list several issues I came across, and get feedback on best ways to address them.
At the end of the day, doing such a replacement may require major rewrites to LICM, this patch
still tries to fit into the pattern that already exists in LICM, that, for promotion in particular,
is not ideal for using MemorySSA.
This patch is intended to add the functionality without enabling it by default.
Work for follow-up patches:
---> Teach all loop passes to preserve MemorySSA
---> Expose alias information for Uses in MemorySSA
- (Current approach needs review) Adding MemorySSA as a loop dependency ------>This patch adds MemorySSA as a dependency to all loop passes. It is added as a required pass that gets invalidated if used in LICM. The ideal scenario is to have all loop passes preserve MemorySSA. ------>MemorySSA is *not* used by default in LICM in this patch. However it is always *built*. ------>Patch updates tests to reflect MemorySSA pass being run/invalidated: test/Other/loop-pm-invalidation.ll test/Other/new-pass-manager.ll test/Other/pass-pipelines.ll ------>Patch does *not* update "unittests/Transforms/Scalar/LoopPassManagerTest.cpp" (fails when LICMwMSSA=true)
- For hoist/sink, it is possible to get "less than perfect" results, due to the fact that we intentionally allow
some imprecision, by using getDefiningAccess instead of getClobberingAccess. MemorySSA has a cap on the number of stores/phis it will walk past when optimizing Uses (memssa-check-limit).
------>(Done - Working as intended) See "BIG NOTE" in LICM.cpp.
- In order to keep the promotion mechanism the same, we use MemorySSA to create some alias sets.
------>(Major refactor needed, will not address in this patch) Changing the promotion mechanism will require some major changes, I'm not sure this is the path to go on now.
------>(Done) We still face a performance penalty if we allow full sets to be created. This time, we cannot rely on the
imprecision approach used for hoist/sink. See the follow up to BIG NOTE in MemorySSAAliasSets.h
Patch has a cap on the number of sets and number of MemorySSA queries that did work (vs used cached info).
------>(TODO added in MemorySSAAliasSets.h) We can avoid calling into AA for uses. From discussions with dberlin, this info is available and could be exposed by MemorySSA. For defs, we still need to query AA.
------>(Done) [refactor] Move LICM:collectChildrenInLoop to Utils and reuse in MemorySSAAliasSets.h to avoid recursion. This is required to avoid blowing up stack (D35609).