mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 20:23:11 +01:00
Fix PR9955 by only attaching load memory operands to load instructions and
similarly for stores. Now "make check" passes with the MachineVerifier forced on with the VerifyCoalescing option! llvm-svn: 131705
This commit is contained in:
parent
ecdbb58b95
commit
4e8f708cbb
@ -2650,11 +2650,45 @@ SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
|
||||
// instructions that access memory and for ComplexPatterns that match
|
||||
// loads.
|
||||
if (EmitNodeInfo & OPFL_MemRefs) {
|
||||
// Only attach load or store memory operands if the generated
|
||||
// instruction may load or store.
|
||||
const TargetInstrDesc &TID = TM.getInstrInfo()->get(TargetOpc);
|
||||
bool mayLoad = TID.mayLoad();
|
||||
bool mayStore = TID.mayStore();
|
||||
|
||||
unsigned NumMemRefs = 0;
|
||||
for (SmallVector<MachineMemOperand*, 2>::const_iterator I =
|
||||
MatchedMemRefs.begin(), E = MatchedMemRefs.end(); I != E; ++I) {
|
||||
if ((*I)->isLoad()) {
|
||||
if (mayLoad)
|
||||
++NumMemRefs;
|
||||
} else if ((*I)->isStore()) {
|
||||
if (mayStore)
|
||||
++NumMemRefs;
|
||||
} else {
|
||||
++NumMemRefs;
|
||||
}
|
||||
}
|
||||
|
||||
MachineSDNode::mmo_iterator MemRefs =
|
||||
MF->allocateMemRefsArray(MatchedMemRefs.size());
|
||||
std::copy(MatchedMemRefs.begin(), MatchedMemRefs.end(), MemRefs);
|
||||
MF->allocateMemRefsArray(NumMemRefs);
|
||||
|
||||
MachineSDNode::mmo_iterator MemRefsPos = MemRefs;
|
||||
for (SmallVector<MachineMemOperand*, 2>::const_iterator I =
|
||||
MatchedMemRefs.begin(), E = MatchedMemRefs.end(); I != E; ++I) {
|
||||
if ((*I)->isLoad()) {
|
||||
if (mayLoad)
|
||||
*MemRefsPos++ = *I;
|
||||
} else if ((*I)->isStore()) {
|
||||
if (mayStore)
|
||||
*MemRefsPos++ = *I;
|
||||
} else {
|
||||
*MemRefsPos++ = *I;
|
||||
}
|
||||
}
|
||||
|
||||
cast<MachineSDNode>(Res)
|
||||
->setMemRefs(MemRefs, MemRefs + MatchedMemRefs.size());
|
||||
->setMemRefs(MemRefs, MemRefs + NumMemRefs);
|
||||
}
|
||||
|
||||
DEBUG(errs() << " "
|
||||
|
Loading…
Reference in New Issue
Block a user