[LLVMdev] SU aliasing
Sergei Larin
slarin at codeaurora.org
Wed Nov 9 16:17:07 PST 2011
Sorry if it is described somewhere, but is there any hidden danger in doing
the following during DAG lowering:
The problem is that at some point I seem to get stale data from
(MMOa->getValue()) which produces bogus alias result.
...and it seems that there should be a more elegant way to implement the
function...
Thanks.
bool SUsDoNotAliasEachOther (SUnit *SU1, SUnit *SU2, AliasAnalysis *AA) {
if (!SU1 || !SU2) return false;
if (SU1->isInstr() || SU2->isInstr()) return false;
SDNode *SDN1 = SU1->getNode();
SDNode *SDN2 = SU2->getNode();
if (!SDN1 || !SDN2) return false;
if (SDN1->isMachineOpcode() && SDN2->isMachineOpcode()) {
MachineMemOperand *MMOa = NULL;
MachineMemOperand *MMOb = NULL;
const MachineSDNode *MNb = dyn_cast<MachineSDNode>(SDN2);
const MachineSDNode *MNa = dyn_cast<MachineSDNode>(SDN1);
// Check that they are LD/ST
if (MNa) MMOa = !MNa->memoperands_empty() ?
(*MNa->memoperands_begin()) : NULL;
if (MNb) MMOb = !MNb->memoperands_empty() ?
(*MNb->memoperands_begin()) : NULL;
if (MMOa && MMOa->getValue() && MMOb && MMOb->getValue()) {
if (!AA->alias (MMOa->getValue(), MMOa->getSize(),
MMOb->getValue(), MMOb->getSize())) {
return true;
}
}
}
return false;
}
Sergei
More information about the llvm-dev
mailing list