diff options
author | Chris Lattner <sabre@nondot.org> | 2002-11-03 21:27:48 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-11-03 21:27:48 +0000 |
commit | c875f023d41f60efc79647e9c2dd44ab0c8c03ca (patch) | |
tree | 5718718ddb016611404b49fc1537150a24592b90 /lib/Analysis/DataStructure | |
parent | d18f342af8c716a88917ef2694f798d67109801d (diff) |
Rename ValueMap to ScalarMap
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4516 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure')
-rw-r--r-- | lib/Analysis/DataStructure/BottomUpClosure.cpp | 6 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/DataStructure.cpp | 54 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/Local.cpp | 18 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/Printer.cpp | 2 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/Steensgaard.cpp | 9 |
5 files changed, 45 insertions, 44 deletions
diff --git a/lib/Analysis/DataStructure/BottomUpClosure.cpp b/lib/Analysis/DataStructure/BottomUpClosure.cpp index be5d725b77..a68e9547f1 100644 --- a/lib/Analysis/DataStructure/BottomUpClosure.cpp +++ b/lib/Analysis/DataStructure/BottomUpClosure.cpp @@ -56,7 +56,7 @@ bool BUDataStructures::run(Module &M) { // call. // static void ResolveArguments(DSCallSite &Call, Function &F, - map<Value*, DSNodeHandle> &ValueMap) { + map<Value*, DSNodeHandle> &ScalarMap) { // Resolve all of the function arguments... Function::aiterator AI = F.abegin(); for (unsigned i = 0, e = Call.getNumPtrArgs(); i != e; ++i, ++AI) { @@ -64,7 +64,7 @@ static void ResolveArguments(DSCallSite &Call, Function &F, while (!isPointerType(AI->getType())) ++AI; // Add the link from the argument scalar to the provided value - ValueMap[AI].mergeWith(Call.getPtrArg(i)); + ScalarMap[AI].mergeWith(Call.getPtrArg(i)); } } @@ -118,7 +118,7 @@ DSGraph &BUDataStructures::calculateGraph(Function &F) { Graph->getRetNode().mergeWith(Call.getRetVal()); // Resolve the arguments in the call to the actual values... - ResolveArguments(Call, F, Graph->getValueMap()); + ResolveArguments(Call, F, Graph->getScalarMap()); // Erase the entry in the callees vector Callees.erase(Callees.begin()+c--); diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp index ac65d2ad76..d20d1b42c2 100644 --- a/lib/Analysis/DataStructure/DataStructure.cpp +++ b/lib/Analysis/DataStructure/DataStructure.cpp @@ -488,17 +488,17 @@ Function &DSCallSite::getCaller() const { DSGraph::DSGraph(const DSGraph &G) : Func(G.Func) { std::map<const DSNode*, DSNode*> NodeMap; - RetNode = cloneInto(G, ValueMap, NodeMap); + RetNode = cloneInto(G, ScalarMap, NodeMap); } DSGraph::DSGraph(const DSGraph &G, std::map<const DSNode*, DSNode*> &NodeMap) : Func(G.Func) { - RetNode = cloneInto(G, ValueMap, NodeMap); + RetNode = cloneInto(G, ScalarMap, NodeMap); } DSGraph::~DSGraph() { FunctionCalls.clear(); - ValueMap.clear(); + ScalarMap.clear(); RetNode.setNode(0); #ifndef NDEBUG @@ -536,7 +536,7 @@ void DSNode::remapLinks(std::map<const DSNode*, DSNode*> &OldNodeMap) { // cloneInto - Clone the specified DSGraph into the current graph, returning the -// Return node of the graph. The translated ValueMap for the old function is +// Return node of the graph. The translated ScalarMap for the old function is // filled into the OldValMap member. If StripAllocas is set to true, Alloca // markers are removed from the graph, as the graph is being cloned into a // calling function's graph. @@ -570,18 +570,18 @@ DSNodeHandle DSGraph::cloneInto(const DSGraph &G, Nodes[i]->NodeType &= ~StripBits; // Copy the value map... and merge all of the global nodes... - for (std::map<Value*, DSNodeHandle>::const_iterator I = G.ValueMap.begin(), - E = G.ValueMap.end(); I != E; ++I) { + for (std::map<Value*, DSNodeHandle>::const_iterator I = G.ScalarMap.begin(), + E = G.ScalarMap.end(); I != E; ++I) { DSNodeHandle &H = OldValMap[I->first]; H.setNode(OldNodeMap[I->second.getNode()]); H.setOffset(I->second.getOffset()); if (isa<GlobalValue>(I->first)) { // Is this a global? - std::map<Value*, DSNodeHandle>::iterator GVI = ValueMap.find(I->first); - if (GVI != ValueMap.end()) { // Is the global value in this fun already? + std::map<Value*, DSNodeHandle>::iterator GVI = ScalarMap.find(I->first); + if (GVI != ScalarMap.end()) { // Is the global value in this fn already? GVI->second.mergeWith(H); } else { - ValueMap[I->first] = H; // Add global pointer to this graph + ScalarMap[I->first] = H; // Add global pointer to this graph } } } @@ -601,7 +601,7 @@ DSNode *DSGraph::cloneGlobalInto(const DSNode *GNode) { if (GNode == 0 || GNode->getGlobals().size() == 0) return 0; // If a clone has already been created for GNode, return it. - DSNodeHandle& ValMapEntry = ValueMap[GNode->getGlobals()[0]]; + DSNodeHandle& ValMapEntry = ScalarMap[GNode->getGlobals()[0]]; if (ValMapEntry != 0) return ValMapEntry; @@ -610,7 +610,7 @@ DSNode *DSGraph::cloneGlobalInto(const DSNode *GNode) { ValMapEntry = NewNode; // j=0 case of loop below! Nodes.push_back(NewNode); for (unsigned j = 1, N = NewNode->getGlobals().size(); j < N; ++j) - ValueMap[NewNode->getGlobals()[j]] = NewNode; + ScalarMap[NewNode->getGlobals()[j]] = NewNode; // Rewrite the links in the new node to point into the current graph. for (unsigned j = 0, e = GNode->getNumLinks(); j != e; ++j) @@ -655,8 +655,8 @@ void DSGraph::markIncompleteNodes(bool markFormalArgs) { // Mark any incoming arguments as incomplete... if (markFormalArgs && Func) for (Function::aiterator I = Func->abegin(), E = Func->aend(); I != E; ++I) - if (isPointerType(I->getType()) && ValueMap.find(I) != ValueMap.end()) - markIncompleteNode(ValueMap[I].getNode()); + if (isPointerType(I->getType()) && ScalarMap.find(I) != ScalarMap.end()) + markIncompleteNode(ScalarMap[I].getNode()); // Mark stuff passed into functions calls as being incomplete... for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i) { @@ -681,13 +681,13 @@ void DSGraph::markIncompleteNodes(bool markFormalArgs) { } // removeRefsToGlobal - Helper function that removes globals from the -// ValueMap so that the referrer count will go down to zero. +// ScalarMap so that the referrer count will go down to zero. static void removeRefsToGlobal(DSNode* N, - std::map<Value*, DSNodeHandle> &ValueMap) { + std::map<Value*, DSNodeHandle> &ScalarMap) { while (!N->getGlobals().empty()) { GlobalValue *GV = N->getGlobals().back(); N->getGlobals().pop_back(); - ValueMap.erase(GV); + ScalarMap.erase(GV); } } @@ -705,9 +705,9 @@ bool DSGraph::isNodeDead(DSNode *N) { if ((N->NodeType & ~DSNode::GlobalNode) == 0 && N->getSize() == 0 && N->getReferrers().size() == N->getGlobals().size()) { - // Remove the globals from the ValueMap, so that the referrer count will go + // Remove the globals from the ScalarMap, so that the referrer count will go // down to zero. - removeRefsToGlobal(N, ValueMap); + removeRefsToGlobal(N, ScalarMap); assert(N->getReferrers().empty() && "Referrers should all be gone now!"); return true; } @@ -881,11 +881,11 @@ static void markGlobalsAlive(DSGraph &G, std::set<DSNode*> &Alive, // This would be a simple iterative loop if function calls were real nodes! markGlobalsIteration(GlobalNodes, Calls, Alive, FilterCalls); - // Free up references to dead globals from the ValueMap + // Free up references to dead globals from the ScalarMap std::set<DSNode*>::iterator I = GlobalNodes.begin(), E = GlobalNodes.end(); for( ; I != E; ++I) if (Alive.count(*I) == 0) - removeRefsToGlobal(*I, G.getValueMap()); + removeRefsToGlobal(*I, G.getScalarMap()); // Delete dead function calls if (FilterCalls) @@ -927,13 +927,13 @@ void DSGraph::removeDeadNodes(bool KeepAllGlobals, bool KeepCalls) { } // Mark all nodes reachable by scalar nodes as alive... - for (std::map<Value*, DSNodeHandle>::iterator I = ValueMap.begin(), - E = ValueMap.end(); I != E; ++I) + for (std::map<Value*, DSNodeHandle>::iterator I = ScalarMap.begin(), + E = ScalarMap.end(); I != E; ++I) markAlive(I->second.getNode(), Alive); #if 0 // Marge all nodes reachable by global nodes, as alive. Isn't this covered by - // the ValueMap? + // the ScalarMap? // if (KeepAllGlobals) for (unsigned i = 0, e = Nodes.size(); i != e; ++i) @@ -1039,7 +1039,7 @@ DSNode* GlobalDSGraph::cloneNodeInto(DSNode *OldNode, // an identical list of globals and return it if it exists. // for (unsigned j = 0, N = OldNode->getGlobals().size(); j != N; ++j) - if (DSNode *PrevNode = ValueMap[OldNode->getGlobals()[j]].getNode()) { + if (DSNode *PrevNode = ScalarMap[OldNode->getGlobals()[j]].getNode()) { if (NewNode == 0) { NewNode = PrevNode; // first existing node found if (GlobalsAreFinal && j == 0) @@ -1051,11 +1051,11 @@ DSNode* GlobalDSGraph::cloneNodeInto(DSNode *OldNode, else if (NewNode != PrevNode) { // found another, different from prev // update ValMap *before* merging PrevNode into NewNode for (unsigned k = 0, NK = PrevNode->getGlobals().size(); k < NK; ++k) - ValueMap[PrevNode->getGlobals()[k]] = NewNode; + ScalarMap[PrevNode->getGlobals()[k]] = NewNode; NewNode->mergeWith(PrevNode); } } else if (NewNode != 0) { - ValueMap[OldNode->getGlobals()[j]] = NewNode; // add the merged node + ScalarMap[OldNode->getGlobals()[j]] = NewNode; // add the merged node } // If no existing node was found, clone the node and update the ValMap. @@ -1065,7 +1065,7 @@ DSNode* GlobalDSGraph::cloneNodeInto(DSNode *OldNode, for (unsigned j = 0, e = NewNode->getNumLinks(); j != e; ++j) NewNode->setLink(j, 0); for (unsigned j = 0, N = NewNode->getGlobals().size(); j < N; ++j) - ValueMap[NewNode->getGlobals()[j]] = NewNode; + ScalarMap[NewNode->getGlobals()[j]] = NewNode; } else NewNode->NodeType |= OldNode->NodeType; // Markers may be different! diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp index e45cdcbed8..42847caf6f 100644 --- a/lib/Analysis/DataStructure/Local.cpp +++ b/lib/Analysis/DataStructure/Local.cpp @@ -60,14 +60,14 @@ namespace { DSGraph &G; vector<DSNode*> &Nodes; DSNodeHandle &RetNode; // Node that gets returned... - map<Value*, DSNodeHandle> &ValueMap; + map<Value*, DSNodeHandle> &ScalarMap; vector<DSCallSite> &FunctionCalls; public: GraphBuilder(DSGraph &g, vector<DSNode*> &nodes, DSNodeHandle &retNode, - map<Value*, DSNodeHandle> &vm, + map<Value*, DSNodeHandle> &SM, vector<DSCallSite> &fc) - : G(g), Nodes(nodes), RetNode(retNode), ValueMap(vm), FunctionCalls(fc) { + : G(g), Nodes(nodes), RetNode(retNode), ScalarMap(SM), FunctionCalls(fc) { // Create scalar nodes for all pointer arguments... for (Function::aiterator I = G.getFunction().abegin(), @@ -112,7 +112,7 @@ namespace { return N; } - /// setDestTo - Set the ValueMap entry for the specified value to point to + /// setDestTo - Set the ScalarMap entry for the specified value to point to /// the specified destination. If the Value already points to a node, make /// sure to merge the two destinations together. /// @@ -135,7 +135,7 @@ namespace { // graph. DSGraph::DSGraph(Function &F) : Func(&F) { // Use the graph builder to construct the local version of the graph - GraphBuilder B(*this, Nodes, RetNode, ValueMap, FunctionCalls); + GraphBuilder B(*this, Nodes, RetNode, ScalarMap, FunctionCalls); markIncompleteNodes(); } @@ -155,7 +155,7 @@ DSNodeHandle GraphBuilder::getValueDest(Value &V) { return 0; // Constant doesn't point to anything. } - DSNodeHandle &NH = ValueMap[&V]; + DSNodeHandle &NH = ScalarMap[&V]; if (NH.getNode()) return NH; // Already have a node? Just return it... @@ -194,12 +194,12 @@ DSNodeHandle &GraphBuilder::getLink(const DSNodeHandle &node, unsigned LinkNo) { } -/// setDestTo - Set the ValueMap entry for the specified value to point to the +/// setDestTo - Set the ScalarMap entry for the specified value to point to the /// specified destination. If the Value already points to a node, make sure to /// merge the two destinations together. /// void GraphBuilder::setDestTo(Value &V, const DSNodeHandle &NH) { - DSNodeHandle &AINH = ValueMap[&V]; + DSNodeHandle &AINH = ScalarMap[&V]; if (AINH.getNode() == 0) // Not pointing to anything yet? AINH = NH; // Just point directly to NH else @@ -224,7 +224,7 @@ void GraphBuilder::handleAlloc(AllocationInst &AI, DSNode::NodeTy NodeType) { void GraphBuilder::visitPHINode(PHINode &PN) { if (!isPointerType(PN.getType())) return; // Only pointer PHIs - DSNodeHandle &PNDest = ValueMap[&PN]; + DSNodeHandle &PNDest = ScalarMap[&PN]; for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) PNDest.mergeWith(getValueDest(*PN.getIncomingValue(i))); } diff --git a/lib/Analysis/DataStructure/Printer.cpp b/lib/Analysis/DataStructure/Printer.cpp index 8514d53faf..e683c358e2 100644 --- a/lib/Analysis/DataStructure/Printer.cpp +++ b/lib/Analysis/DataStructure/Printer.cpp @@ -86,7 +86,7 @@ struct DOTGraphTraits<const DSGraph*> : public DefaultDOTGraphTraits { static void addCustomGraphFeatures(const DSGraph *G, GraphWriter<const DSGraph*> &GW) { // Add scalar nodes to the graph... - const std::map<Value*, DSNodeHandle> &VM = G->getValueMap(); + const std::map<Value*, DSNodeHandle> &VM = G->getScalarMap(); for (std::map<Value*, DSNodeHandle>::const_iterator I = VM.begin(); I != VM.end(); ++I) if (!isa<GlobalValue>(I->first)) { diff --git a/lib/Analysis/DataStructure/Steensgaard.cpp b/lib/Analysis/DataStructure/Steensgaard.cpp index f2b6e87a1f..9fb5f57987 100644 --- a/lib/Analysis/DataStructure/Steensgaard.cpp +++ b/lib/Analysis/DataStructure/Steensgaard.cpp @@ -84,7 +84,7 @@ void Steens::ResolveFunctionCall(Function *F, const DSCallSite &Call, DSNodeHandle &RetVal) { assert(ResultGraph != 0 && "Result graph not allocated!"); - std::map<Value*, DSNodeHandle> &ValMap = ResultGraph->getValueMap(); + std::map<Value*, DSNodeHandle> &ValMap = ResultGraph->getScalarMap(); // Handle the return value of the function... if (Call.getRetVal().getNode() && RetVal.getNode()) @@ -135,8 +135,9 @@ bool Steens::run(Module &M) { RetValMap[I] = RetNode; } - // Incorporate the inlined Function's ValueMap into the global ValueMap... - std::map<Value*, DSNodeHandle> &GVM = ResultGraph->getValueMap(); + // Incorporate the inlined Function's ScalarMap into the global + // ScalarMap... + std::map<Value*, DSNodeHandle> &GVM = ResultGraph->getScalarMap(); while (!ValMap.empty()) { // Loop over value map, moving entries over... const std::pair<Value*, DSNodeHandle> &DSN = *ValMap.begin(); @@ -198,7 +199,7 @@ bool Steens::run(Module &M) { AliasAnalysis::Result Steens::alias(const Value *V1, const Value *V2) const { assert(ResultGraph && "Result grcaph has not yet been computed!"); - std::map<Value*, DSNodeHandle> &GVM = ResultGraph->getValueMap(); + std::map<Value*, DSNodeHandle> &GVM = ResultGraph->getScalarMap(); std::map<Value*, DSNodeHandle>::iterator I = GVM.find(const_cast<Value*>(V1)); if (I != GVM.end() && I->second.getNode()) { |