We set the Location size to beforeOrAfter if the Location value is not
guaranteed loop invariant. But in some cases, we need to reset the
location size if the location size is precise after phi tranlation of
location value. This will improve MemorySSA analysis results.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/include/llvm/Analysis/MemorySSA.h | ||
---|---|---|
1255 | The logic here looks somewhat convoluted -- isn't this equivalent to doing the translation first and then doing the invariance check afterwards (dropping the size adjustment before phi translation entirely)? |
llvm/include/llvm/Analysis/MemorySSA.h | ||
---|---|---|
1255 | Only if the phi translator gets a value different from the original one, line 1271 would be executed. if drop the size adjustment before phi translation entirely, in the case that Location.Ptr is not guaranteed loop invariant and can not be phi translated, the location size of Location.Ptr would not be adjusted to beforeOrAfterPointer. I hope I understood your question correctly and answered it clearly. :) |
llvm/include/llvm/Analysis/MemorySSA.h | ||
---|---|---|
1255 | Maybe it's easier to explain with code, this is what I had in mind: void fillInCurrentPair() { CurrentPair.first = *DefIterator; CurrentPair.second = Location; if (WalkingPhi && Location.Ptr) { PHITransAddr Translator( const_cast<Value *>(Location.Ptr), OriginalAccess->getBlock()->getModule()->getDataLayout(), nullptr); if (!Translator.PHITranslateValue(OriginalAccess->getBlock(), DefIterator.getPhiArgBlock(), DT, true)) CurrentPair.second = CurrentPair.second.getWithNewPtr(Translator.getAddr()); // Mark size as unknown, if the location is not guaranteed to be // loop-invariant for any possible loop in the function. Setting the size // to unknown guarantees that any memory accesses that access locations // after the pointer are considered as clobbers, which is important to // catch loop carried dependences. if (!IsGuaranteedLoopInvariant(CurrentPair.second.Ptr)) CurrentPair.second = Location.getWithNewSize(LocationSize::beforeOrAfterPointer()); } } |
The logic here looks somewhat convoluted -- isn't this equivalent to doing the translation first and then doing the invariance check afterwards (dropping the size adjustment before phi translation entirely)?