mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-16 12:24:03 +00:00
Rename ValueMap to ScalarMap
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4516 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -16,7 +16,7 @@ class DSGraph {
|
|||||||
Function *Func;
|
Function *Func;
|
||||||
std::vector<DSNode*> Nodes;
|
std::vector<DSNode*> Nodes;
|
||||||
DSNodeHandle RetNode; // Node that gets returned...
|
DSNodeHandle RetNode; // Node that gets returned...
|
||||||
std::map<Value*, DSNodeHandle> ValueMap;
|
std::map<Value*, DSNodeHandle> ScalarMap;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// GlobalsGraph -- Reference to the common graph of globally visible objects.
|
// GlobalsGraph -- Reference to the common graph of globally visible objects.
|
||||||
@ -58,11 +58,11 @@ public:
|
|||||||
///
|
///
|
||||||
void addNode(DSNode *N) { Nodes.push_back(N); }
|
void addNode(DSNode *N) { Nodes.push_back(N); }
|
||||||
|
|
||||||
/// getValueMap - Get a map that describes what the nodes the scalars in this
|
/// getScalarMap - Get a map that describes what the nodes the scalars in this
|
||||||
/// function point to...
|
/// function point to...
|
||||||
///
|
///
|
||||||
std::map<Value*, DSNodeHandle> &getValueMap() { return ValueMap; }
|
std::map<Value*, DSNodeHandle> &getScalarMap() { return ScalarMap; }
|
||||||
const std::map<Value*, DSNodeHandle> &getValueMap() const { return ValueMap;}
|
const std::map<Value*, DSNodeHandle> &getScalarMap() const {return ScalarMap;}
|
||||||
|
|
||||||
std::vector<DSCallSite> &getFunctionCalls() {
|
std::vector<DSCallSite> &getFunctionCalls() {
|
||||||
return FunctionCalls;
|
return FunctionCalls;
|
||||||
@ -74,7 +74,7 @@ public:
|
|||||||
/// getNodeForValue - Given a value that is used or defined in the body of the
|
/// getNodeForValue - Given a value that is used or defined in the body of the
|
||||||
/// current function, return the DSNode that it points to.
|
/// current function, return the DSNode that it points to.
|
||||||
///
|
///
|
||||||
DSNodeHandle &getNodeForValue(Value *V) { return ValueMap[V]; }
|
DSNodeHandle &getNodeForValue(Value *V) { return ScalarMap[V]; }
|
||||||
|
|
||||||
const DSNodeHandle &getRetNode() const { return RetNode; }
|
const DSNodeHandle &getRetNode() const { return RetNode; }
|
||||||
DSNodeHandle &getRetNode() { return RetNode; }
|
DSNodeHandle &getRetNode() { return RetNode; }
|
||||||
@ -119,10 +119,10 @@ public:
|
|||||||
void removeDeadNodes(bool KeepAllGlobals = false, bool KeepCalls = true);
|
void removeDeadNodes(bool KeepAllGlobals = false, bool KeepCalls = true);
|
||||||
|
|
||||||
// cloneInto - Clone the specified DSGraph into the current graph, returning
|
// cloneInto - Clone the specified DSGraph into the current graph, returning
|
||||||
// the Return node of the graph. The translated ValueMap for the old function
|
// the Return node of the graph. The translated ScalarMap for the old
|
||||||
// is filled into the OldValMap member.
|
// function is filled into the OldValMap member. If StripScalars
|
||||||
// If StripScalars (StripAllocas) is set to true, Scalar (Alloca) markers
|
// (StripAllocas) is set to true, Scalar (Alloca) markers are removed from the
|
||||||
// are removed from the graph as the graph is being cloned.
|
// graph as the graph is being cloned.
|
||||||
//
|
//
|
||||||
DSNodeHandle cloneInto(const DSGraph &G,
|
DSNodeHandle cloneInto(const DSGraph &G,
|
||||||
std::map<Value*, DSNodeHandle> &OldValMap,
|
std::map<Value*, DSNodeHandle> &OldValMap,
|
||||||
@ -135,8 +135,8 @@ public:
|
|||||||
//
|
//
|
||||||
DSNode* cloneGlobalInto(const DSNode* GNode);
|
DSNode* cloneGlobalInto(const DSNode* GNode);
|
||||||
DSNode* cloneGlobalInto(GlobalValue* GV) {
|
DSNode* cloneGlobalInto(GlobalValue* GV) {
|
||||||
assert(!GV || (((DSGraph*) GlobalsGraph)->ValueMap[GV] != 0));
|
assert(!GV || (((DSGraph*) GlobalsGraph)->ScalarMap[GV] != 0));
|
||||||
return GV? cloneGlobalInto(((DSGraph*) GlobalsGraph)->ValueMap[GV]) : 0;
|
return GV? cloneGlobalInto(((DSGraph*) GlobalsGraph)->ScalarMap[GV]) : 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ class DSGraph {
|
|||||||
Function *Func;
|
Function *Func;
|
||||||
std::vector<DSNode*> Nodes;
|
std::vector<DSNode*> Nodes;
|
||||||
DSNodeHandle RetNode; // Node that gets returned...
|
DSNodeHandle RetNode; // Node that gets returned...
|
||||||
std::map<Value*, DSNodeHandle> ValueMap;
|
std::map<Value*, DSNodeHandle> ScalarMap;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// GlobalsGraph -- Reference to the common graph of globally visible objects.
|
// GlobalsGraph -- Reference to the common graph of globally visible objects.
|
||||||
@ -58,11 +58,11 @@ public:
|
|||||||
///
|
///
|
||||||
void addNode(DSNode *N) { Nodes.push_back(N); }
|
void addNode(DSNode *N) { Nodes.push_back(N); }
|
||||||
|
|
||||||
/// getValueMap - Get a map that describes what the nodes the scalars in this
|
/// getScalarMap - Get a map that describes what the nodes the scalars in this
|
||||||
/// function point to...
|
/// function point to...
|
||||||
///
|
///
|
||||||
std::map<Value*, DSNodeHandle> &getValueMap() { return ValueMap; }
|
std::map<Value*, DSNodeHandle> &getScalarMap() { return ScalarMap; }
|
||||||
const std::map<Value*, DSNodeHandle> &getValueMap() const { return ValueMap;}
|
const std::map<Value*, DSNodeHandle> &getScalarMap() const {return ScalarMap;}
|
||||||
|
|
||||||
std::vector<DSCallSite> &getFunctionCalls() {
|
std::vector<DSCallSite> &getFunctionCalls() {
|
||||||
return FunctionCalls;
|
return FunctionCalls;
|
||||||
@ -74,7 +74,7 @@ public:
|
|||||||
/// getNodeForValue - Given a value that is used or defined in the body of the
|
/// getNodeForValue - Given a value that is used or defined in the body of the
|
||||||
/// current function, return the DSNode that it points to.
|
/// current function, return the DSNode that it points to.
|
||||||
///
|
///
|
||||||
DSNodeHandle &getNodeForValue(Value *V) { return ValueMap[V]; }
|
DSNodeHandle &getNodeForValue(Value *V) { return ScalarMap[V]; }
|
||||||
|
|
||||||
const DSNodeHandle &getRetNode() const { return RetNode; }
|
const DSNodeHandle &getRetNode() const { return RetNode; }
|
||||||
DSNodeHandle &getRetNode() { return RetNode; }
|
DSNodeHandle &getRetNode() { return RetNode; }
|
||||||
@ -119,10 +119,10 @@ public:
|
|||||||
void removeDeadNodes(bool KeepAllGlobals = false, bool KeepCalls = true);
|
void removeDeadNodes(bool KeepAllGlobals = false, bool KeepCalls = true);
|
||||||
|
|
||||||
// cloneInto - Clone the specified DSGraph into the current graph, returning
|
// cloneInto - Clone the specified DSGraph into the current graph, returning
|
||||||
// the Return node of the graph. The translated ValueMap for the old function
|
// the Return node of the graph. The translated ScalarMap for the old
|
||||||
// is filled into the OldValMap member.
|
// function is filled into the OldValMap member. If StripScalars
|
||||||
// If StripScalars (StripAllocas) is set to true, Scalar (Alloca) markers
|
// (StripAllocas) is set to true, Scalar (Alloca) markers are removed from the
|
||||||
// are removed from the graph as the graph is being cloned.
|
// graph as the graph is being cloned.
|
||||||
//
|
//
|
||||||
DSNodeHandle cloneInto(const DSGraph &G,
|
DSNodeHandle cloneInto(const DSGraph &G,
|
||||||
std::map<Value*, DSNodeHandle> &OldValMap,
|
std::map<Value*, DSNodeHandle> &OldValMap,
|
||||||
@ -135,8 +135,8 @@ public:
|
|||||||
//
|
//
|
||||||
DSNode* cloneGlobalInto(const DSNode* GNode);
|
DSNode* cloneGlobalInto(const DSNode* GNode);
|
||||||
DSNode* cloneGlobalInto(GlobalValue* GV) {
|
DSNode* cloneGlobalInto(GlobalValue* GV) {
|
||||||
assert(!GV || (((DSGraph*) GlobalsGraph)->ValueMap[GV] != 0));
|
assert(!GV || (((DSGraph*) GlobalsGraph)->ScalarMap[GV] != 0));
|
||||||
return GV? cloneGlobalInto(((DSGraph*) GlobalsGraph)->ValueMap[GV]) : 0;
|
return GV? cloneGlobalInto(((DSGraph*) GlobalsGraph)->ScalarMap[GV]) : 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ bool BUDataStructures::run(Module &M) {
|
|||||||
// call.
|
// call.
|
||||||
//
|
//
|
||||||
static void ResolveArguments(DSCallSite &Call, Function &F,
|
static void ResolveArguments(DSCallSite &Call, Function &F,
|
||||||
map<Value*, DSNodeHandle> &ValueMap) {
|
map<Value*, DSNodeHandle> &ScalarMap) {
|
||||||
// Resolve all of the function arguments...
|
// Resolve all of the function arguments...
|
||||||
Function::aiterator AI = F.abegin();
|
Function::aiterator AI = F.abegin();
|
||||||
for (unsigned i = 0, e = Call.getNumPtrArgs(); i != e; ++i, ++AI) {
|
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;
|
while (!isPointerType(AI->getType())) ++AI;
|
||||||
|
|
||||||
// Add the link from the argument scalar to the provided value
|
// 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());
|
Graph->getRetNode().mergeWith(Call.getRetVal());
|
||||||
|
|
||||||
// Resolve the arguments in the call to the actual values...
|
// 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
|
// Erase the entry in the callees vector
|
||||||
Callees.erase(Callees.begin()+c--);
|
Callees.erase(Callees.begin()+c--);
|
||||||
|
@ -488,17 +488,17 @@ Function &DSCallSite::getCaller() const {
|
|||||||
|
|
||||||
DSGraph::DSGraph(const DSGraph &G) : Func(G.Func) {
|
DSGraph::DSGraph(const DSGraph &G) : Func(G.Func) {
|
||||||
std::map<const DSNode*, DSNode*> NodeMap;
|
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)
|
DSGraph::DSGraph(const DSGraph &G, std::map<const DSNode*, DSNode*> &NodeMap)
|
||||||
: Func(G.Func) {
|
: Func(G.Func) {
|
||||||
RetNode = cloneInto(G, ValueMap, NodeMap);
|
RetNode = cloneInto(G, ScalarMap, NodeMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
DSGraph::~DSGraph() {
|
DSGraph::~DSGraph() {
|
||||||
FunctionCalls.clear();
|
FunctionCalls.clear();
|
||||||
ValueMap.clear();
|
ScalarMap.clear();
|
||||||
RetNode.setNode(0);
|
RetNode.setNode(0);
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#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
|
// 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
|
// 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
|
// markers are removed from the graph, as the graph is being cloned into a
|
||||||
// calling function's graph.
|
// calling function's graph.
|
||||||
@ -570,18 +570,18 @@ DSNodeHandle DSGraph::cloneInto(const DSGraph &G,
|
|||||||
Nodes[i]->NodeType &= ~StripBits;
|
Nodes[i]->NodeType &= ~StripBits;
|
||||||
|
|
||||||
// Copy the value map... and merge all of the global nodes...
|
// Copy the value map... and merge all of the global nodes...
|
||||||
for (std::map<Value*, DSNodeHandle>::const_iterator I = G.ValueMap.begin(),
|
for (std::map<Value*, DSNodeHandle>::const_iterator I = G.ScalarMap.begin(),
|
||||||
E = G.ValueMap.end(); I != E; ++I) {
|
E = G.ScalarMap.end(); I != E; ++I) {
|
||||||
DSNodeHandle &H = OldValMap[I->first];
|
DSNodeHandle &H = OldValMap[I->first];
|
||||||
H.setNode(OldNodeMap[I->second.getNode()]);
|
H.setNode(OldNodeMap[I->second.getNode()]);
|
||||||
H.setOffset(I->second.getOffset());
|
H.setOffset(I->second.getOffset());
|
||||||
|
|
||||||
if (isa<GlobalValue>(I->first)) { // Is this a global?
|
if (isa<GlobalValue>(I->first)) { // Is this a global?
|
||||||
std::map<Value*, DSNodeHandle>::iterator GVI = ValueMap.find(I->first);
|
std::map<Value*, DSNodeHandle>::iterator GVI = ScalarMap.find(I->first);
|
||||||
if (GVI != ValueMap.end()) { // Is the global value in this fun already?
|
if (GVI != ScalarMap.end()) { // Is the global value in this fn already?
|
||||||
GVI->second.mergeWith(H);
|
GVI->second.mergeWith(H);
|
||||||
} else {
|
} 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 (GNode == 0 || GNode->getGlobals().size() == 0) return 0;
|
||||||
|
|
||||||
// If a clone has already been created for GNode, return it.
|
// 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)
|
if (ValMapEntry != 0)
|
||||||
return ValMapEntry;
|
return ValMapEntry;
|
||||||
|
|
||||||
@ -610,7 +610,7 @@ DSNode *DSGraph::cloneGlobalInto(const DSNode *GNode) {
|
|||||||
ValMapEntry = NewNode; // j=0 case of loop below!
|
ValMapEntry = NewNode; // j=0 case of loop below!
|
||||||
Nodes.push_back(NewNode);
|
Nodes.push_back(NewNode);
|
||||||
for (unsigned j = 1, N = NewNode->getGlobals().size(); j < N; ++j)
|
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.
|
// Rewrite the links in the new node to point into the current graph.
|
||||||
for (unsigned j = 0, e = GNode->getNumLinks(); j != e; ++j)
|
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...
|
// Mark any incoming arguments as incomplete...
|
||||||
if (markFormalArgs && Func)
|
if (markFormalArgs && Func)
|
||||||
for (Function::aiterator I = Func->abegin(), E = Func->aend(); I != E; ++I)
|
for (Function::aiterator I = Func->abegin(), E = Func->aend(); I != E; ++I)
|
||||||
if (isPointerType(I->getType()) && ValueMap.find(I) != ValueMap.end())
|
if (isPointerType(I->getType()) && ScalarMap.find(I) != ScalarMap.end())
|
||||||
markIncompleteNode(ValueMap[I].getNode());
|
markIncompleteNode(ScalarMap[I].getNode());
|
||||||
|
|
||||||
// Mark stuff passed into functions calls as being incomplete...
|
// Mark stuff passed into functions calls as being incomplete...
|
||||||
for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i) {
|
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
|
// 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,
|
static void removeRefsToGlobal(DSNode* N,
|
||||||
std::map<Value*, DSNodeHandle> &ValueMap) {
|
std::map<Value*, DSNodeHandle> &ScalarMap) {
|
||||||
while (!N->getGlobals().empty()) {
|
while (!N->getGlobals().empty()) {
|
||||||
GlobalValue *GV = N->getGlobals().back();
|
GlobalValue *GV = N->getGlobals().back();
|
||||||
N->getGlobals().pop_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 &&
|
if ((N->NodeType & ~DSNode::GlobalNode) == 0 && N->getSize() == 0 &&
|
||||||
N->getReferrers().size() == N->getGlobals().size()) {
|
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.
|
// down to zero.
|
||||||
removeRefsToGlobal(N, ValueMap);
|
removeRefsToGlobal(N, ScalarMap);
|
||||||
assert(N->getReferrers().empty() && "Referrers should all be gone now!");
|
assert(N->getReferrers().empty() && "Referrers should all be gone now!");
|
||||||
return true;
|
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!
|
// This would be a simple iterative loop if function calls were real nodes!
|
||||||
markGlobalsIteration(GlobalNodes, Calls, Alive, FilterCalls);
|
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();
|
std::set<DSNode*>::iterator I = GlobalNodes.begin(), E = GlobalNodes.end();
|
||||||
for( ; I != E; ++I)
|
for( ; I != E; ++I)
|
||||||
if (Alive.count(*I) == 0)
|
if (Alive.count(*I) == 0)
|
||||||
removeRefsToGlobal(*I, G.getValueMap());
|
removeRefsToGlobal(*I, G.getScalarMap());
|
||||||
|
|
||||||
// Delete dead function calls
|
// Delete dead function calls
|
||||||
if (FilterCalls)
|
if (FilterCalls)
|
||||||
@ -927,13 +927,13 @@ void DSGraph::removeDeadNodes(bool KeepAllGlobals, bool KeepCalls) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mark all nodes reachable by scalar nodes as alive...
|
// Mark all nodes reachable by scalar nodes as alive...
|
||||||
for (std::map<Value*, DSNodeHandle>::iterator I = ValueMap.begin(),
|
for (std::map<Value*, DSNodeHandle>::iterator I = ScalarMap.begin(),
|
||||||
E = ValueMap.end(); I != E; ++I)
|
E = ScalarMap.end(); I != E; ++I)
|
||||||
markAlive(I->second.getNode(), Alive);
|
markAlive(I->second.getNode(), Alive);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// Marge all nodes reachable by global nodes, as alive. Isn't this covered by
|
// Marge all nodes reachable by global nodes, as alive. Isn't this covered by
|
||||||
// the ValueMap?
|
// the ScalarMap?
|
||||||
//
|
//
|
||||||
if (KeepAllGlobals)
|
if (KeepAllGlobals)
|
||||||
for (unsigned i = 0, e = Nodes.size(); i != e; ++i)
|
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.
|
// an identical list of globals and return it if it exists.
|
||||||
//
|
//
|
||||||
for (unsigned j = 0, N = OldNode->getGlobals().size(); j != N; ++j)
|
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) {
|
if (NewNode == 0) {
|
||||||
NewNode = PrevNode; // first existing node found
|
NewNode = PrevNode; // first existing node found
|
||||||
if (GlobalsAreFinal && j == 0)
|
if (GlobalsAreFinal && j == 0)
|
||||||
@ -1051,11 +1051,11 @@ DSNode* GlobalDSGraph::cloneNodeInto(DSNode *OldNode,
|
|||||||
else if (NewNode != PrevNode) { // found another, different from prev
|
else if (NewNode != PrevNode) { // found another, different from prev
|
||||||
// update ValMap *before* merging PrevNode into NewNode
|
// update ValMap *before* merging PrevNode into NewNode
|
||||||
for (unsigned k = 0, NK = PrevNode->getGlobals().size(); k < NK; ++k)
|
for (unsigned k = 0, NK = PrevNode->getGlobals().size(); k < NK; ++k)
|
||||||
ValueMap[PrevNode->getGlobals()[k]] = NewNode;
|
ScalarMap[PrevNode->getGlobals()[k]] = NewNode;
|
||||||
NewNode->mergeWith(PrevNode);
|
NewNode->mergeWith(PrevNode);
|
||||||
}
|
}
|
||||||
} else if (NewNode != 0) {
|
} 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.
|
// 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)
|
for (unsigned j = 0, e = NewNode->getNumLinks(); j != e; ++j)
|
||||||
NewNode->setLink(j, 0);
|
NewNode->setLink(j, 0);
|
||||||
for (unsigned j = 0, N = NewNode->getGlobals().size(); j < N; ++j)
|
for (unsigned j = 0, N = NewNode->getGlobals().size(); j < N; ++j)
|
||||||
ValueMap[NewNode->getGlobals()[j]] = NewNode;
|
ScalarMap[NewNode->getGlobals()[j]] = NewNode;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
NewNode->NodeType |= OldNode->NodeType; // Markers may be different!
|
NewNode->NodeType |= OldNode->NodeType; // Markers may be different!
|
||||||
|
@ -60,14 +60,14 @@ namespace {
|
|||||||
DSGraph &G;
|
DSGraph &G;
|
||||||
vector<DSNode*> &Nodes;
|
vector<DSNode*> &Nodes;
|
||||||
DSNodeHandle &RetNode; // Node that gets returned...
|
DSNodeHandle &RetNode; // Node that gets returned...
|
||||||
map<Value*, DSNodeHandle> &ValueMap;
|
map<Value*, DSNodeHandle> &ScalarMap;
|
||||||
vector<DSCallSite> &FunctionCalls;
|
vector<DSCallSite> &FunctionCalls;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GraphBuilder(DSGraph &g, vector<DSNode*> &nodes, DSNodeHandle &retNode,
|
GraphBuilder(DSGraph &g, vector<DSNode*> &nodes, DSNodeHandle &retNode,
|
||||||
map<Value*, DSNodeHandle> &vm,
|
map<Value*, DSNodeHandle> &SM,
|
||||||
vector<DSCallSite> &fc)
|
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...
|
// Create scalar nodes for all pointer arguments...
|
||||||
for (Function::aiterator I = G.getFunction().abegin(),
|
for (Function::aiterator I = G.getFunction().abegin(),
|
||||||
@ -112,7 +112,7 @@ namespace {
|
|||||||
return N;
|
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
|
/// the specified destination. If the Value already points to a node, make
|
||||||
/// sure to merge the two destinations together.
|
/// sure to merge the two destinations together.
|
||||||
///
|
///
|
||||||
@ -135,7 +135,7 @@ namespace {
|
|||||||
// graph.
|
// graph.
|
||||||
DSGraph::DSGraph(Function &F) : Func(&F) {
|
DSGraph::DSGraph(Function &F) : Func(&F) {
|
||||||
// Use the graph builder to construct the local version of the graph
|
// 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();
|
markIncompleteNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ DSNodeHandle GraphBuilder::getValueDest(Value &V) {
|
|||||||
return 0; // Constant doesn't point to anything.
|
return 0; // Constant doesn't point to anything.
|
||||||
}
|
}
|
||||||
|
|
||||||
DSNodeHandle &NH = ValueMap[&V];
|
DSNodeHandle &NH = ScalarMap[&V];
|
||||||
if (NH.getNode())
|
if (NH.getNode())
|
||||||
return NH; // Already have a node? Just return it...
|
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
|
/// specified destination. If the Value already points to a node, make sure to
|
||||||
/// merge the two destinations together.
|
/// merge the two destinations together.
|
||||||
///
|
///
|
||||||
void GraphBuilder::setDestTo(Value &V, const DSNodeHandle &NH) {
|
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?
|
if (AINH.getNode() == 0) // Not pointing to anything yet?
|
||||||
AINH = NH; // Just point directly to NH
|
AINH = NH; // Just point directly to NH
|
||||||
else
|
else
|
||||||
@ -224,7 +224,7 @@ void GraphBuilder::handleAlloc(AllocationInst &AI, DSNode::NodeTy NodeType) {
|
|||||||
void GraphBuilder::visitPHINode(PHINode &PN) {
|
void GraphBuilder::visitPHINode(PHINode &PN) {
|
||||||
if (!isPointerType(PN.getType())) return; // Only pointer PHIs
|
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)
|
for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i)
|
||||||
PNDest.mergeWith(getValueDest(*PN.getIncomingValue(i)));
|
PNDest.mergeWith(getValueDest(*PN.getIncomingValue(i)));
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ struct DOTGraphTraits<const DSGraph*> : public DefaultDOTGraphTraits {
|
|||||||
static void addCustomGraphFeatures(const DSGraph *G,
|
static void addCustomGraphFeatures(const DSGraph *G,
|
||||||
GraphWriter<const DSGraph*> &GW) {
|
GraphWriter<const DSGraph*> &GW) {
|
||||||
// Add scalar nodes to the graph...
|
// 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();
|
for (std::map<Value*, DSNodeHandle>::const_iterator I = VM.begin();
|
||||||
I != VM.end(); ++I)
|
I != VM.end(); ++I)
|
||||||
if (!isa<GlobalValue>(I->first)) {
|
if (!isa<GlobalValue>(I->first)) {
|
||||||
|
@ -84,7 +84,7 @@ void Steens::ResolveFunctionCall(Function *F,
|
|||||||
const DSCallSite &Call,
|
const DSCallSite &Call,
|
||||||
DSNodeHandle &RetVal) {
|
DSNodeHandle &RetVal) {
|
||||||
assert(ResultGraph != 0 && "Result graph not allocated!");
|
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...
|
// Handle the return value of the function...
|
||||||
if (Call.getRetVal().getNode() && RetVal.getNode())
|
if (Call.getRetVal().getNode() && RetVal.getNode())
|
||||||
@ -135,8 +135,9 @@ bool Steens::run(Module &M) {
|
|||||||
RetValMap[I] = RetNode;
|
RetValMap[I] = RetNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Incorporate the inlined Function's ValueMap into the global ValueMap...
|
// Incorporate the inlined Function's ScalarMap into the global
|
||||||
std::map<Value*, DSNodeHandle> &GVM = ResultGraph->getValueMap();
|
// ScalarMap...
|
||||||
|
std::map<Value*, DSNodeHandle> &GVM = ResultGraph->getScalarMap();
|
||||||
|
|
||||||
while (!ValMap.empty()) { // Loop over value map, moving entries over...
|
while (!ValMap.empty()) { // Loop over value map, moving entries over...
|
||||||
const std::pair<Value*, DSNodeHandle> &DSN = *ValMap.begin();
|
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 {
|
AliasAnalysis::Result Steens::alias(const Value *V1, const Value *V2) const {
|
||||||
assert(ResultGraph && "Result grcaph has not yet been computed!");
|
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));
|
std::map<Value*, DSNodeHandle>::iterator I = GVM.find(const_cast<Value*>(V1));
|
||||||
if (I != GVM.end() && I->second.getNode()) {
|
if (I != GVM.end() && I->second.getNode()) {
|
||||||
|
Reference in New Issue
Block a user