forked from OSchip/llvm-project
Fix an obscure read-after-free bug that Duncan found.
llvm-svn: 46738
This commit is contained in:
parent
6c037da51c
commit
1de5997119
|
@ -463,15 +463,17 @@ void MemoryDependenceAnalysis::removeInstruction(Instruction* rem) {
|
||||||
reverseDep[depGraphLocal[rem].first].erase(rem);
|
reverseDep[depGraphLocal[rem].first].erase(rem);
|
||||||
|
|
||||||
if (depGraphEntry->second.first != NonLocal &&
|
if (depGraphEntry->second.first != NonLocal &&
|
||||||
|
depGraphEntry->second.first != None &&
|
||||||
depGraphEntry->second.second) {
|
depGraphEntry->second.second) {
|
||||||
// If we have dep info for rem, set them to it
|
// If we have dep info for rem, set them to it
|
||||||
BasicBlock::iterator RI = depGraphEntry->second.first;
|
BasicBlock::iterator RI = depGraphEntry->second.first;
|
||||||
RI++;
|
RI++;
|
||||||
newDep = RI;
|
newDep = RI;
|
||||||
} else if (depGraphEntry->second.first == NonLocal &&
|
} else if ( (depGraphEntry->second.first == NonLocal ||
|
||||||
|
depGraphEntry->second.first == None ) &&
|
||||||
depGraphEntry->second.second ) {
|
depGraphEntry->second.second ) {
|
||||||
// If we have a confirmed non-local flag, use it
|
// If we have a confirmed non-local flag, use it
|
||||||
newDep = NonLocal;
|
newDep = depGraphEntry->second.first;
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, use the immediate successor of rem
|
// Otherwise, use the immediate successor of rem
|
||||||
// NOTE: This is because, when getDependence is called, it will first
|
// NOTE: This is because, when getDependence is called, it will first
|
||||||
|
@ -480,14 +482,22 @@ void MemoryDependenceAnalysis::removeInstruction(Instruction* rem) {
|
||||||
RI++;
|
RI++;
|
||||||
newDep = RI;
|
newDep = RI;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
SmallPtrSet<Instruction*, 4>& set = reverseDep[rem];
|
// Otherwise, use the immediate successor of rem
|
||||||
for (SmallPtrSet<Instruction*, 4>::iterator I = set.begin(), E = set.end();
|
// NOTE: This is because, when getDependence is called, it will first
|
||||||
I != E; ++I) {
|
// check the immediate predecessor of what is in the cache.
|
||||||
// Insert the new dependencies
|
BasicBlock::iterator RI = rem;
|
||||||
// Mark it as unconfirmed as long as it is not the non-local flag
|
RI++;
|
||||||
depGraphLocal[*I] = std::make_pair(newDep, !newDep);
|
newDep = RI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SmallPtrSet<Instruction*, 4>& set = reverseDep[rem];
|
||||||
|
for (SmallPtrSet<Instruction*, 4>::iterator I = set.begin(), E = set.end();
|
||||||
|
I != E; ++I) {
|
||||||
|
// Insert the new dependencies
|
||||||
|
// Mark it as unconfirmed as long as it is not the non-local flag
|
||||||
|
depGraphLocal[*I] = std::make_pair(newDep, (newDep == NonLocal ||
|
||||||
|
newDep == None));
|
||||||
}
|
}
|
||||||
|
|
||||||
depGraphLocal.erase(rem);
|
depGraphLocal.erase(rem);
|
||||||
|
|
Loading…
Reference in New Issue