[PATCH] D134161: [MemorySSA] Reset location size if IsGuaranteedLoopInvariant after phi tranlation
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 21 01:43:29 PDT 2022
nikic added inline comments.
================
Comment at: llvm/include/llvm/Analysis/MemorySSA.h:1273
+ CurrentPair.second =
+ CurrentPair.second.getWithNewSize(Location.Size);
+
----------------
StephenFan wrote:
> nikic wrote:
> > 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)?
> 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. :)
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());
}
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134161/new/
https://reviews.llvm.org/D134161
More information about the llvm-commits
mailing list