[PATCH] D46928: implantation example for new AliasAnalysis functions (getAddressesDistance + ModRefSameBuffer)
Atheel Massalha via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 15 20:46:33 PDT 2018
atheel.ma added a comment.
The use is inside a target specific function:
for (MachineMemOperand *MMOa : MIa.memoperands()) {
for (MachineMemOperand *MMOb : MIb.memoperands()) {
// need to handle different bases cases only, otherwise alias will catch
// it.
const Value *Va = MMOa->getValue();
const Value *Vb = MMOb->getValue();
const PseudoSourceValue *Pa = MMOa->getPseudoValue();
const PseudoSourceValue *Pb = MMOb->getPseudoValue();
if (Va && Vb) {
// Ask alias analysis (if there's one available) what's going on if
// we have access to IR values.
assert(!Pa && !Pb && "IR vs pseudo value inconsistency");
uint64_t Sizea = MMOa->getSize();
uint64_t Sizeb = MMOb->getSize();
// vpld has sometimes UnknownSize
if ((!CII->isUsingAllBanks(MIa) && !CII->isUsingAllBanks(MIb)) &&
(MMOa->getSize() == MemoryLocation::UnknownSize ||
MMOb->getSize() == MemoryLocation::UnknownSize)) {
continue;
}
MemoryLocation Loca = MemoryLocation(Va, Sizea, MMOa->getAAInfo());
MemoryLocation Locb = MemoryLocation(Vb, Sizeb, MMOb->getAAInfo());
int64_t ptr1Offset = MMOa->getPointerInfo().Offset;
int64_t ptr2Offset = MMOb->getPointerInfo().Offset;
if (AA->ModRefSameBuffer(Loca, ptr1Offset, Locb, ptr2Offset)) {
Optional<int64_t> dis = AA->getAddressesDistance(Loca,
ptr1Offset, Locb, ptr2Offset);
if ((CII->isUsingAllBanks(MIa) || CII->isUsingAllBanks(MIb))) {
return true;
}
// need to take care with dis<0 *dis%64 => ((*dis%64)+64)%64
if (dis != None && ((*dis > 0 && Sizeb > (*dis % 64)) ||
(*dis < 0 && Sizea > ((*dis % 64) + 64) % 64))) {
return true;
}
}
}
}
}
Repository:
rL LLVM
https://reviews.llvm.org/D46928
More information about the llvm-commits
mailing list