[PATCH] D44564: [BasicAA] Relax restriction on PHI node handling.

John Brawn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 2 08:19:47 PDT 2018


john.brawn added a comment.

After some tinkering I've come up with the following solution (I have something that seems to work, but it needs cleaning up and testing):

- Add a PhiAnalysis analysis pass which returns a PhiInfo
- PhiInfo::getUnderlyingPhiValues takes a PHINode and returns the set of non-phi values reachable from that phi
- PhiInfo stores a map of PHINode->values which is initially empty, but is incrementally updated whenever getUnderlyingPhiValues is called on a phi we haven't yet calculated
- BasicAA uses PhiAnalysis if it's available
- When it is BasicAAResults::aliasPHI populates V1Srcs from getUnderlyingPhiValues, otherwise it does what it currently does
- MemoryDependenceAnalysis uses PhiAnalysis, which then makes it available to BasicAA
- MemoryDependenceResults::removeInstruction clears the PhiInfo map, to make sure later queries are correct

Doing all this gets me what I want, which is GVN getting correct aliasing information for the phis that it inserts. I've avoided doing this by adding another alias analysis to basically limit how much work I need to do to get this working, and it means whoever does do that in the future can just make the new alias analysis use PhiAnalysis for that part of it. Also there's maybe other parts of the compiler that want this kind of information.

Does this seem reasonable?


Repository:
  rL LLVM

https://reviews.llvm.org/D44564





More information about the llvm-commits mailing list