mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-20 14:29:27 +00:00
Fix GLIBCXX_DEBUG error owing to dereference of end iterator. There's
no guarantee that an instruction returned by getDependency exists in the maps. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40647 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
054ab94bff
commit
df464195fe
@ -32,9 +32,14 @@ class Instruction;
|
|||||||
|
|
||||||
class MemoryDependenceAnalysis : public FunctionPass {
|
class MemoryDependenceAnalysis : public FunctionPass {
|
||||||
private:
|
private:
|
||||||
|
|
||||||
DenseMap<Instruction*, std::pair<Instruction*, bool> > depGraphLocal;
|
typedef DenseMap<Instruction*, std::pair<Instruction*, bool> >
|
||||||
std::multimap<Instruction*, Instruction*> reverseDep;
|
depMapType;
|
||||||
|
|
||||||
|
depMapType depGraphLocal;
|
||||||
|
|
||||||
|
typedef std::multimap<Instruction*, Instruction*> reverseDepMapType;
|
||||||
|
reverseDepMapType reverseDep;
|
||||||
|
|
||||||
Instruction* getCallSiteDependency(CallSite C, Instruction* start,
|
Instruction* getCallSiteDependency(CallSite C, Instruction* start,
|
||||||
bool local = true);
|
bool local = true);
|
||||||
|
@ -308,33 +308,40 @@ Instruction* MemoryDependenceAnalysis::getDependency(Instruction* query,
|
|||||||
void MemoryDependenceAnalysis::removeInstruction(Instruction* rem) {
|
void MemoryDependenceAnalysis::removeInstruction(Instruction* rem) {
|
||||||
// Figure out the new dep for things that currently depend on rem
|
// Figure out the new dep for things that currently depend on rem
|
||||||
Instruction* newDep = NonLocal;
|
Instruction* newDep = NonLocal;
|
||||||
if (depGraphLocal[rem].first != NonLocal &&
|
|
||||||
depGraphLocal[rem].second) {
|
depMapType::iterator depGraphEntry = depGraphLocal.find(rem);
|
||||||
// If we have dep info for rem, set them to it
|
// We assume here that it's not in the reverse map if it's not in
|
||||||
BasicBlock::iterator RI = depGraphLocal[rem].first;
|
// the dep map. Checking it could be expensive, so don't do it.
|
||||||
RI++;
|
|
||||||
newDep = RI;
|
if (depGraphEntry != depGraphLocal.end()) {
|
||||||
} else if (depGraphLocal[rem].first == NonLocal &&
|
if (depGraphEntry->second.first != NonLocal &&
|
||||||
depGraphLocal[rem].second ) {
|
depGraphEntry->second.second) {
|
||||||
// If we have a confirmed non-local flag, use it
|
// If we have dep info for rem, set them to it
|
||||||
newDep = NonLocal;
|
BasicBlock::iterator RI = depGraphEntry->second.first;
|
||||||
} else {
|
RI++;
|
||||||
// Otherwise, use the immediate successor of rem
|
newDep = RI;
|
||||||
// NOTE: This is because, when getDependence is called, it will first check
|
} else if (depGraphEntry->second.first == NonLocal &&
|
||||||
// the immediate predecessor of what is in the cache.
|
depGraphEntry->second.second ) {
|
||||||
BasicBlock::iterator RI = rem;
|
// If we have a confirmed non-local flag, use it
|
||||||
RI++;
|
newDep = NonLocal;
|
||||||
newDep = RI;
|
} else {
|
||||||
|
// Otherwise, use the immediate successor of rem
|
||||||
|
// NOTE: This is because, when getDependence is called, it will first check
|
||||||
|
// the immediate predecessor of what is in the cache.
|
||||||
|
BasicBlock::iterator RI = rem;
|
||||||
|
RI++;
|
||||||
|
newDep = RI;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::multimap<Instruction*, Instruction*>::iterator I = reverseDep.find(rem);
|
||||||
|
while (I != reverseDep.end() && I->first == rem) {
|
||||||
|
// Insert the new dependencies
|
||||||
|
// Mark it as unconfirmed as long as it is not the non-local flag
|
||||||
|
depGraphLocal[I->second] = std::make_pair(newDep, !newDep);
|
||||||
|
reverseDep.erase(I);
|
||||||
|
I = reverseDep.find(rem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::multimap<Instruction*, Instruction*>::iterator I = reverseDep.find(rem);
|
|
||||||
while (I->first == rem) {
|
|
||||||
// Insert the new dependencies
|
|
||||||
// Mark it as unconfirmed as long as it is not the non-local flag
|
|
||||||
depGraphLocal[I->second] = std::make_pair(newDep, !newDep);
|
|
||||||
reverseDep.erase(I);
|
|
||||||
I = reverseDep.find(rem);
|
|
||||||
}
|
|
||||||
|
|
||||||
getAnalysis<AliasAnalysis>().deleteValue(rem);
|
getAnalysis<AliasAnalysis>().deleteValue(rem);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user