From 8cad423d94fd7e30d84742311c454016f36e3ee3 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Wed, 8 Aug 2007 21:39:39 +0000 Subject: [PATCH] Change the None and NonLocal markers in memdep to be const. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40946 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../llvm/Analysis/MemoryDependenceAnalysis.h | 12 +++---- lib/Analysis/MemoryDependenceAnalysis.cpp | 32 +++++++++---------- .../Scalar/DeadStoreElimination.cpp | 6 ++-- lib/Transforms/Scalar/GVN.cpp | 6 ++-- .../Scalar/RedundantLoadElimination.cpp | 4 +-- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/include/llvm/Analysis/MemoryDependenceAnalysis.h b/include/llvm/Analysis/MemoryDependenceAnalysis.h index 28e0454faee..2abb6e62db9 100644 --- a/include/llvm/Analysis/MemoryDependenceAnalysis.h +++ b/include/llvm/Analysis/MemoryDependenceAnalysis.h @@ -32,23 +32,23 @@ class Instruction; class MemoryDependenceAnalysis : public FunctionPass { private: - typedef DenseMap > + typedef DenseMap > depMapType; depMapType depGraphLocal; - typedef DenseMap > reverseDepMapType; reverseDepMapType reverseDep; - Instruction* getCallSiteDependency(CallSite C, Instruction* start, + const Instruction* getCallSiteDependency(CallSite C, Instruction* start, BasicBlock* block); void nonLocalHelper(Instruction* query, BasicBlock* block, DenseMap& resp); public: - static Instruction* NonLocal; - static Instruction* None; + static const Instruction* NonLocal; + static const Instruction* None; static char ID; // Class identification, replacement for typeinfo MemoryDependenceAnalysis() : FunctionPass((intptr_t)&ID) {} @@ -70,7 +70,7 @@ class MemoryDependenceAnalysis : public FunctionPass { /// getDependency - Return the instruction on which a memory operation /// depends, starting with start. - Instruction* getDependency(Instruction* query, Instruction* start = 0, + const Instruction* getDependency(Instruction* query, Instruction* start = 0, BasicBlock* block = 0); void getNonLocalDependency(Instruction* query, diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp index d13b97d01de..43fa647fd84 100644 --- a/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -26,8 +26,8 @@ using namespace llvm; char MemoryDependenceAnalysis::ID = 0; -Instruction* MemoryDependenceAnalysis::NonLocal = (Instruction*)-3; -Instruction* MemoryDependenceAnalysis::None = (Instruction*)-4; +const Instruction* MemoryDependenceAnalysis::NonLocal = (Instruction*)-3; +const Instruction* MemoryDependenceAnalysis::None = (Instruction*)-4; // Register this pass... static RegisterPass X("memdep", @@ -42,7 +42,7 @@ void MemoryDependenceAnalysis::getAnalysisUsage(AnalysisUsage &AU) const { } // Find the dependency of a CallSite -Instruction* MemoryDependenceAnalysis::getCallSiteDependency(CallSite C, Instruction* start, +const Instruction* MemoryDependenceAnalysis::getCallSiteDependency(CallSite C, Instruction* start, BasicBlock* block) { AliasAnalysis& AA = getAnalysis(); @@ -132,9 +132,9 @@ void MemoryDependenceAnalysis::nonLocalHelper(Instruction* query, if (BB != block) { visited.insert(BB); - Instruction* localDep = getDependency(query, 0, BB); + const Instruction* localDep = getDependency(query, 0, BB); if (localDep != NonLocal) { - resp.insert(std::make_pair(BB, localDep)); + resp.insert(std::make_pair(BB, const_cast(localDep))); stack.pop_back(); continue; @@ -142,9 +142,9 @@ void MemoryDependenceAnalysis::nonLocalHelper(Instruction* query, } else if (BB == block && stack.size() > 1) { visited.insert(BB); - Instruction* localDep = getDependency(query, 0, BB); + const Instruction* localDep = getDependency(query, 0, BB); if (localDep != query) - resp.insert(std::make_pair(BB, localDep)); + resp.insert(std::make_pair(BB, const_cast(localDep))); stack.pop_back(); @@ -164,9 +164,9 @@ void MemoryDependenceAnalysis::nonLocalHelper(Instruction* query, if (inserted) continue; else if (!inserted && !predOnStack) { - resp.insert(std::make_pair(BB, None)); + resp.insert(std::make_pair(BB, const_cast(None))); } else if (!inserted && predOnStack){ - resp.insert(std::make_pair(BB, NonLocal)); + resp.insert(std::make_pair(BB, const_cast(NonLocal))); } stack.pop_back(); @@ -175,9 +175,9 @@ void MemoryDependenceAnalysis::nonLocalHelper(Instruction* query, void MemoryDependenceAnalysis::getNonLocalDependency(Instruction* query, DenseMap& resp) { - Instruction* localDep = getDependency(query); + const Instruction* localDep = getDependency(query); if (localDep != NonLocal) { - resp.insert(std::make_pair(query->getParent(), localDep)); + resp.insert(std::make_pair(query->getParent(), const_cast(localDep))); return; } @@ -187,20 +187,20 @@ void MemoryDependenceAnalysis::getNonLocalDependency(Instruction* query, /// getDependency - Return the instruction on which a memory operation /// depends. The local paramter indicates if the query should only /// evaluate dependencies within the same basic block. -Instruction* MemoryDependenceAnalysis::getDependency(Instruction* query, +const Instruction* MemoryDependenceAnalysis::getDependency(Instruction* query, Instruction* start, BasicBlock* block) { // Start looking for dependencies with the queried inst BasicBlock::iterator QI = query; // Check for a cached result - std::pair cachedResult = depGraphLocal[query]; + std::pair cachedResult = depGraphLocal[query]; // If we have a _confirmed_ cached entry, return it if (cachedResult.second) return cachedResult.first; else if (cachedResult.first && cachedResult.first != NonLocal) // If we have an unconfirmed cached entry, we can start our search from there - QI = cachedResult.first; + QI = const_cast(cachedResult.first); if (start) QI = start; @@ -342,7 +342,7 @@ Instruction* MemoryDependenceAnalysis::getDependency(Instruction* query, /// updating the dependence of instructions that previously depended on it. void MemoryDependenceAnalysis::removeInstruction(Instruction* rem) { // Figure out the new dep for things that currently depend on rem - Instruction* newDep = NonLocal; + const Instruction* newDep = NonLocal; depMapType::iterator depGraphEntry = depGraphLocal.find(rem); // We assume here that it's not in the reverse map if it's not in @@ -352,7 +352,7 @@ void MemoryDependenceAnalysis::removeInstruction(Instruction* rem) { if (depGraphEntry->second.first != NonLocal && depGraphEntry->second.second) { // If we have dep info for rem, set them to it - BasicBlock::iterator RI = depGraphEntry->second.first; + BasicBlock::iterator RI = const_cast(depGraphEntry->second.first); RI++; newDep = RI; } else if (depGraphEntry->second.first == NonLocal && diff --git a/lib/Transforms/Scalar/DeadStoreElimination.cpp b/lib/Transforms/Scalar/DeadStoreElimination.cpp index 283fcbc97a1..8cdccc6827f 100644 --- a/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -121,14 +121,14 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) { // ... to a pointer that has been stored to before... if (last) { - Instruction* dep = MD.getDependency(BBI); + Instruction* dep = const_cast(MD.getDependency(BBI)); // ... and no other memory dependencies are between them.... while (dep != MemoryDependenceAnalysis::None && dep != MemoryDependenceAnalysis::NonLocal && isa(dep)) { if (dep != last) { - dep = MD.getDependency(BBI, dep); + dep = const_cast(MD.getDependency(BBI, dep)); continue; } @@ -154,7 +154,7 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) { if (FreeInst* F = dyn_cast(BBI)) { if (!deletedStore) MadeChange |= handleFreeWithNonTrivialDependency(F, - MD.getDependency(F), + const_cast(MD.getDependency(F)), possiblyDead); // No known stores after the free last = 0; diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index edd11e8e493..b8b58bd0036 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/lib/Transforms/Scalar/GVN.cpp @@ -803,7 +803,7 @@ bool GVN::processNonLocalLoad(LoadInst* L, return false; } else if (I->second == MemoryDependenceAnalysis::NonLocal) { continue; - }else if (StoreInst* S = dyn_cast(I->second)) { + } else if (StoreInst* S = dyn_cast(I->second)) { if (S->getPointerOperand() == L->getPointerOperand()) repl[I->first] = S->getOperand(0); else @@ -856,7 +856,7 @@ bool GVN::processLoad(LoadInst* L, // ... to a pointer that has been loaded from before... MemoryDependenceAnalysis& MD = getAnalysis(); - Instruction* dep = MD.getDependency(L); + Instruction* dep = const_cast(MD.getDependency(L)); if (dep == MemoryDependenceAnalysis::NonLocal && L->getParent() != &L->getParent()->getParent()->getEntryBlock()) processNonLocalLoad(L, toErase); @@ -895,7 +895,7 @@ bool GVN::processLoad(LoadInst* L, break; } else { - dep = MD.getDependency(L, dep); + dep = const_cast(MD.getDependency(L, dep)); } } diff --git a/lib/Transforms/Scalar/RedundantLoadElimination.cpp b/lib/Transforms/Scalar/RedundantLoadElimination.cpp index 3b719df4f6e..2dace31e300 100644 --- a/lib/Transforms/Scalar/RedundantLoadElimination.cpp +++ b/lib/Transforms/Scalar/RedundantLoadElimination.cpp @@ -80,7 +80,7 @@ bool RLE::runOnBasicBlock(BasicBlock &BB) { LoadInst*& last = lastLoad[pointer]; // ... to a pointer that has been loaded from before... - Instruction* dep = MD.getDependency(BBI); + Instruction* dep = const_cast(MD.getDependency(BBI)); bool deletedLoad = false; while (dep != MemoryDependenceAnalysis::None && @@ -120,7 +120,7 @@ bool RLE::runOnBasicBlock(BasicBlock &BB) { break; } else { - dep = MD.getDependency(BBI, dep); + dep = const_cast(MD.getDependency(BBI, dep)); } } -- 2.34.1