Run verifyRemoved from removeInstruction when -debug is specified.

This shows the root problem behind PR3141.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60216 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2008-11-28 21:45:17 +00:00
parent 8b589fa135
commit 0e575f428c

View File

@ -14,6 +14,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define DEBUG_TYPE "memdep"
#include "llvm/Analysis/MemoryDependenceAnalysis.h" #include "llvm/Analysis/MemoryDependenceAnalysis.h"
#include "llvm/Constants.h" #include "llvm/Constants.h"
#include "llvm/Instructions.h" #include "llvm/Instructions.h"
@ -21,11 +22,10 @@
#include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Support/CFG.h" #include "llvm/Support/CFG.h"
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Target/TargetData.h" #include "llvm/Target/TargetData.h"
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
#define DEBUG_TYPE "memdep"
using namespace llvm; using namespace llvm;
// Control the calculation of non-local dependencies by only examining the // Control the calculation of non-local dependencies by only examining the
@ -46,35 +46,37 @@ Instruction* const MemoryDependenceAnalysis::Dirty = (Instruction*)-5;
// Register this pass... // Register this pass...
static RegisterPass<MemoryDependenceAnalysis> X("memdep", static RegisterPass<MemoryDependenceAnalysis> X("memdep",
"Memory Dependence Analysis", false, true); "Memory Dependence Analysis", false, true);
/// verifyRemoved - Verify that the specified instruction does not occur
/// in our internal data structures.
void MemoryDependenceAnalysis::verifyRemoved(Instruction *D) const { void MemoryDependenceAnalysis::verifyRemoved(Instruction *D) const {
for (depMapType::const_iterator I = depGraphLocal.begin(), for (depMapType::const_iterator I = depGraphLocal.begin(),
E = depGraphLocal.end(); I != E; ++I) { E = depGraphLocal.end(); I != E; ++I) {
assert(I->first != D); assert(I->first != D && "Inst occurs in data structures");
assert(I->second.first != D); assert(I->second.first != D && "Inst occurs in data structures");
} }
for (nonLocalDepMapType::const_iterator I = depGraphNonLocal.begin(), for (nonLocalDepMapType::const_iterator I = depGraphNonLocal.begin(),
E = depGraphNonLocal.end(); I != E; ++I) { E = depGraphNonLocal.end(); I != E; ++I) {
assert(I->first != D); assert(I->first != D && "Inst occurs in data structures");
for (DenseMap<BasicBlock*, Value*>::iterator II = I->second.begin(), for (DenseMap<BasicBlock*, Value*>::iterator II = I->second.begin(),
EE = I->second.end(); II != EE; ++II) EE = I->second.end(); II != EE; ++II)
assert(II->second != D); assert(II->second != D && "Inst occurs in data structures");
} }
for (reverseDepMapType::const_iterator I = reverseDep.begin(), for (reverseDepMapType::const_iterator I = reverseDep.begin(),
E = reverseDep.end(); I != E; ++I) E = reverseDep.end(); I != E; ++I)
for (SmallPtrSet<Instruction*, 4>::const_iterator II = I->second.begin(), for (SmallPtrSet<Instruction*, 4>::const_iterator II = I->second.begin(),
EE = I->second.end(); II != EE; ++II) EE = I->second.end(); II != EE; ++II)
assert(*II != D); assert(*II != D && "Inst occurs in data structures");
for (reverseDepMapType::const_iterator I = reverseDepNonLocal.begin(), for (reverseDepMapType::const_iterator I = reverseDepNonLocal.begin(),
E = reverseDepNonLocal.end(); E = reverseDepNonLocal.end();
I != E; ++I) I != E; ++I)
for (SmallPtrSet<Instruction*, 4>::const_iterator II = I->second.begin(), for (SmallPtrSet<Instruction*, 4>::const_iterator II = I->second.begin(),
EE = I->second.end(); II != EE; ++II) EE = I->second.end(); II != EE; ++II)
assert(*II != D); assert(*II != D && "Inst occurs in data structures");
} }
/// getAnalysisUsage - Does not modify anything. It uses Alias Analysis. /// getAnalysisUsage - Does not modify anything. It uses Alias Analysis.
@ -88,7 +90,7 @@ void MemoryDependenceAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
/// getCallSiteDependency - Private helper for finding the local dependencies /// getCallSiteDependency - Private helper for finding the local dependencies
/// of a call site. /// of a call site.
Instruction* MemoryDependenceAnalysis::getCallSiteDependency(CallSite C, Instruction* MemoryDependenceAnalysis::getCallSiteDependency(CallSite C,
Instruction* start, Instruction* start,
BasicBlock* block) { BasicBlock* block) {
std::pair<Instruction*, bool>& cachedResult = std::pair<Instruction*, bool>& cachedResult =
@ -586,4 +588,6 @@ void MemoryDependenceAnalysis::removeInstruction(Instruction* rem) {
depGraphNonLocal.erase(I); depGraphNonLocal.erase(I);
getAnalysis<AliasAnalysis>().deleteValue(rem); getAnalysis<AliasAnalysis>().deleteValue(rem);
DEBUG(verifyRemoved(rem));
} }