forked from OSchip/llvm-project
Fix indeterminism in MI scheduler DAG construction.
Similarly to several recent fixes throughout the code replace std::map use with the MapVector. Add find() method to the MapVector. llvm-svn: 168051
This commit is contained in:
parent
262465c126
commit
e822148c80
|
@ -83,6 +83,18 @@ public:
|
||||||
typename MapType::const_iterator Pos = Map.find(Key);
|
typename MapType::const_iterator Pos = Map.find(Key);
|
||||||
return Pos == Map.end()? 0 : 1;
|
return Pos == Map.end()? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iterator find(const KeyT &Key) {
|
||||||
|
typename MapType::const_iterator Pos = Map.find(Key);
|
||||||
|
return Pos == Map.end()? Vector.end() :
|
||||||
|
(Vector.begin() + Pos->second);
|
||||||
|
}
|
||||||
|
|
||||||
|
const_iterator find(const KeyT &Key) const {
|
||||||
|
typename MapType::const_iterator Pos = Map.find(Key);
|
||||||
|
return Pos == Map.end()? Vector.end() :
|
||||||
|
(Vector.begin() + Pos->second);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/Format.h"
|
#include "llvm/Support/Format.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
#include "llvm/ADT/MapVector.h"
|
||||||
#include "llvm/ADT/SmallSet.h"
|
#include "llvm/ADT/SmallSet.h"
|
||||||
#include "llvm/ADT/SmallPtrSet.h"
|
#include "llvm/ADT/SmallPtrSet.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
@ -685,8 +686,8 @@ void ScheduleDAGInstrs::buildSchedGraph(AliasAnalysis *AA,
|
||||||
// so that they can be given more precise dependencies. We track
|
// so that they can be given more precise dependencies. We track
|
||||||
// separately the known memory locations that may alias and those
|
// separately the known memory locations that may alias and those
|
||||||
// that are known not to alias
|
// that are known not to alias
|
||||||
std::map<const Value *, SUnit *> AliasMemDefs, NonAliasMemDefs;
|
MapVector<const Value *, SUnit *> AliasMemDefs, NonAliasMemDefs;
|
||||||
std::map<const Value *, std::vector<SUnit *> > AliasMemUses, NonAliasMemUses;
|
MapVector<const Value *, std::vector<SUnit *> > AliasMemUses, NonAliasMemUses;
|
||||||
std::set<SUnit*> RejectMemNodes;
|
std::set<SUnit*> RejectMemNodes;
|
||||||
|
|
||||||
// Remove any stale debug info; sometimes BuildSchedGraph is called again
|
// Remove any stale debug info; sometimes BuildSchedGraph is called again
|
||||||
|
@ -765,11 +766,11 @@ void ScheduleDAGInstrs::buildSchedGraph(AliasAnalysis *AA,
|
||||||
if (isGlobalMemoryObject(AA, MI)) {
|
if (isGlobalMemoryObject(AA, MI)) {
|
||||||
// Be conservative with these and add dependencies on all memory
|
// Be conservative with these and add dependencies on all memory
|
||||||
// references, even those that are known to not alias.
|
// references, even those that are known to not alias.
|
||||||
for (std::map<const Value *, SUnit *>::iterator I =
|
for (MapVector<const Value *, SUnit *>::iterator I =
|
||||||
NonAliasMemDefs.begin(), E = NonAliasMemDefs.end(); I != E; ++I) {
|
NonAliasMemDefs.begin(), E = NonAliasMemDefs.end(); I != E; ++I) {
|
||||||
I->second->addPred(SDep(SU, SDep::Barrier));
|
I->second->addPred(SDep(SU, SDep::Barrier));
|
||||||
}
|
}
|
||||||
for (std::map<const Value *, std::vector<SUnit *> >::iterator I =
|
for (MapVector<const Value *, std::vector<SUnit *> >::iterator I =
|
||||||
NonAliasMemUses.begin(), E = NonAliasMemUses.end(); I != E; ++I) {
|
NonAliasMemUses.begin(), E = NonAliasMemUses.end(); I != E; ++I) {
|
||||||
for (unsigned i = 0, e = I->second.size(); i != e; ++i) {
|
for (unsigned i = 0, e = I->second.size(); i != e; ++i) {
|
||||||
SDep Dep(SU, SDep::Barrier);
|
SDep Dep(SU, SDep::Barrier);
|
||||||
|
@ -803,10 +804,10 @@ void ScheduleDAGInstrs::buildSchedGraph(AliasAnalysis *AA,
|
||||||
for (unsigned k = 0, m = PendingLoads.size(); k != m; ++k)
|
for (unsigned k = 0, m = PendingLoads.size(); k != m; ++k)
|
||||||
addChainDependency(AA, MFI, SU, PendingLoads[k], RejectMemNodes,
|
addChainDependency(AA, MFI, SU, PendingLoads[k], RejectMemNodes,
|
||||||
TrueMemOrderLatency);
|
TrueMemOrderLatency);
|
||||||
for (std::map<const Value *, SUnit *>::iterator I = AliasMemDefs.begin(),
|
for (MapVector<const Value *, SUnit *>::iterator I = AliasMemDefs.begin(),
|
||||||
E = AliasMemDefs.end(); I != E; ++I)
|
E = AliasMemDefs.end(); I != E; ++I)
|
||||||
addChainDependency(AA, MFI, SU, I->second, RejectMemNodes);
|
addChainDependency(AA, MFI, SU, I->second, RejectMemNodes);
|
||||||
for (std::map<const Value *, std::vector<SUnit *> >::iterator I =
|
for (MapVector<const Value *, std::vector<SUnit *> >::iterator I =
|
||||||
AliasMemUses.begin(), E = AliasMemUses.end(); I != E; ++I) {
|
AliasMemUses.begin(), E = AliasMemUses.end(); I != E; ++I) {
|
||||||
for (unsigned i = 0, e = I->second.size(); i != e; ++i)
|
for (unsigned i = 0, e = I->second.size(); i != e; ++i)
|
||||||
addChainDependency(AA, MFI, SU, I->second[i], RejectMemNodes,
|
addChainDependency(AA, MFI, SU, I->second[i], RejectMemNodes,
|
||||||
|
@ -823,13 +824,12 @@ void ScheduleDAGInstrs::buildSchedGraph(AliasAnalysis *AA,
|
||||||
// A store to a specific PseudoSourceValue. Add precise dependencies.
|
// A store to a specific PseudoSourceValue. Add precise dependencies.
|
||||||
// Record the def in MemDefs, first adding a dep if there is
|
// Record the def in MemDefs, first adding a dep if there is
|
||||||
// an existing def.
|
// an existing def.
|
||||||
std::map<const Value *, SUnit *>::iterator I =
|
MapVector<const Value *, SUnit *>::iterator I =
|
||||||
((MayAlias) ? AliasMemDefs.find(V) : NonAliasMemDefs.find(V));
|
((MayAlias) ? AliasMemDefs.find(V) : NonAliasMemDefs.find(V));
|
||||||
std::map<const Value *, SUnit *>::iterator IE =
|
MapVector<const Value *, SUnit *>::iterator IE =
|
||||||
((MayAlias) ? AliasMemDefs.end() : NonAliasMemDefs.end());
|
((MayAlias) ? AliasMemDefs.end() : NonAliasMemDefs.end());
|
||||||
if (I != IE) {
|
if (I != IE) {
|
||||||
addChainDependency(AA, MFI, SU, I->second, RejectMemNodes,
|
addChainDependency(AA, MFI, SU, I->second, RejectMemNodes, 0, true);
|
||||||
0, true);
|
|
||||||
I->second = SU;
|
I->second = SU;
|
||||||
} else {
|
} else {
|
||||||
if (MayAlias)
|
if (MayAlias)
|
||||||
|
@ -838,9 +838,9 @@ void ScheduleDAGInstrs::buildSchedGraph(AliasAnalysis *AA,
|
||||||
NonAliasMemDefs[V] = SU;
|
NonAliasMemDefs[V] = SU;
|
||||||
}
|
}
|
||||||
// Handle the uses in MemUses, if there are any.
|
// Handle the uses in MemUses, if there are any.
|
||||||
std::map<const Value *, std::vector<SUnit *> >::iterator J =
|
MapVector<const Value *, std::vector<SUnit *> >::iterator J =
|
||||||
((MayAlias) ? AliasMemUses.find(V) : NonAliasMemUses.find(V));
|
((MayAlias) ? AliasMemUses.find(V) : NonAliasMemUses.find(V));
|
||||||
std::map<const Value *, std::vector<SUnit *> >::iterator JE =
|
MapVector<const Value *, std::vector<SUnit *> >::iterator JE =
|
||||||
((MayAlias) ? AliasMemUses.end() : NonAliasMemUses.end());
|
((MayAlias) ? AliasMemUses.end() : NonAliasMemUses.end());
|
||||||
if (J != JE) {
|
if (J != JE) {
|
||||||
for (unsigned i = 0, e = J->second.size(); i != e; ++i)
|
for (unsigned i = 0, e = J->second.size(); i != e; ++i)
|
||||||
|
@ -885,9 +885,9 @@ void ScheduleDAGInstrs::buildSchedGraph(AliasAnalysis *AA,
|
||||||
if (const Value *V =
|
if (const Value *V =
|
||||||
getUnderlyingObjectForInstr(MI, MFI, MayAlias)) {
|
getUnderlyingObjectForInstr(MI, MFI, MayAlias)) {
|
||||||
// A load from a specific PseudoSourceValue. Add precise dependencies.
|
// A load from a specific PseudoSourceValue. Add precise dependencies.
|
||||||
std::map<const Value *, SUnit *>::iterator I =
|
MapVector<const Value *, SUnit *>::iterator I =
|
||||||
((MayAlias) ? AliasMemDefs.find(V) : NonAliasMemDefs.find(V));
|
((MayAlias) ? AliasMemDefs.find(V) : NonAliasMemDefs.find(V));
|
||||||
std::map<const Value *, SUnit *>::iterator IE =
|
MapVector<const Value *, SUnit *>::iterator IE =
|
||||||
((MayAlias) ? AliasMemDefs.end() : NonAliasMemDefs.end());
|
((MayAlias) ? AliasMemDefs.end() : NonAliasMemDefs.end());
|
||||||
if (I != IE)
|
if (I != IE)
|
||||||
addChainDependency(AA, MFI, SU, I->second, RejectMemNodes, 0, true);
|
addChainDependency(AA, MFI, SU, I->second, RejectMemNodes, 0, true);
|
||||||
|
@ -898,7 +898,7 @@ void ScheduleDAGInstrs::buildSchedGraph(AliasAnalysis *AA,
|
||||||
} else {
|
} else {
|
||||||
// A load with no underlying object. Depend on all
|
// A load with no underlying object. Depend on all
|
||||||
// potentially aliasing stores.
|
// potentially aliasing stores.
|
||||||
for (std::map<const Value *, SUnit *>::iterator I =
|
for (MapVector<const Value *, SUnit *>::iterator I =
|
||||||
AliasMemDefs.begin(), E = AliasMemDefs.end(); I != E; ++I)
|
AliasMemDefs.begin(), E = AliasMemDefs.end(); I != E; ++I)
|
||||||
addChainDependency(AA, MFI, SU, I->second, RejectMemNodes);
|
addChainDependency(AA, MFI, SU, I->second, RejectMemNodes);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue