[llvm-commits] [poolalloc] r152168 - in /poolalloc/trunk: include/assistDS/DSNodeEquivs.h lib/AssistDS/DSNodeEquivs.cpp
Matthew Wala
mttjwl at gmail.com
Tue Mar 6 16:08:14 PST 2012
Author: wala1
Date: Tue Mar 6 18:08:13 2012
New Revision: 152168
URL: http://llvm.org/viewvc/llvm-project?rev=152168&view=rev
Log:
Make sure every node is in an equivalence class, and add a function to retrieve
the node for a given value.
Modified:
poolalloc/trunk/include/assistDS/DSNodeEquivs.h
poolalloc/trunk/lib/AssistDS/DSNodeEquivs.cpp
Modified: poolalloc/trunk/include/assistDS/DSNodeEquivs.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/DSNodeEquivs.h?rev=152168&r1=152167&r2=152168&view=diff
==============================================================================
--- poolalloc/trunk/include/assistDS/DSNodeEquivs.h (original)
+++ poolalloc/trunk/include/assistDS/DSNodeEquivs.h Tue Mar 6 18:08:13 2012
@@ -21,7 +21,6 @@
#include "llvm/ADT/EquivalenceClasses.h"
#include <vector>
-#include <set>
namespace llvm {
@@ -34,6 +33,7 @@
void buildDSNodeEquivs(Module &M);
+ void addNodesFromGraph(DSGraph *G);
FunctionList getCallees(CallSite &CS);
void equivNodesThroughCallsite(CallInst *CI);
void equivNodesToGlobals(DSGraph *G);
@@ -53,6 +53,9 @@
// Returns the computed equivalence classes.
const EquivalenceClasses<const DSNode*> &getEquivalenceClasses();
+
+ // Returns the DSNode in the equivalence classes for the specified value.
+ const DSNode *getMemberForValue(const Value *V);
};
}
Modified: poolalloc/trunk/lib/AssistDS/DSNodeEquivs.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/DSNodeEquivs.cpp?rev=152168&r1=152167&r2=152168&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/DSNodeEquivs.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/DSNodeEquivs.cpp Tue Mar 6 18:08:13 2012
@@ -42,9 +42,25 @@
equivNodesThroughCallsite(Call);
}
}
-
- equivNodesToGlobals(TDDS.getDSGraph(F));
+
+ DSGraph *Graph = TDDS.getDSGraph(F);
+
+ // Ensure all nodes from this function's graph are in an equivalence class.
+ addNodesFromGraph(Graph);
+
+ equivNodesToGlobals(Graph);
}
+
+ // Ensure all nodes from the globals graph are in an equivalence class.
+ addNodesFromGraph(TDDS.getGlobalsGraph());
+}
+
+// Add nodes from the given graph into the equivalence classes.
+void DSNodeEquivs::addNodesFromGraph(DSGraph *Graph) {
+ DSGraph::node_iterator NodeIt = Graph->node_begin();
+ DSGraph::node_iterator NodeItEnd = Graph->node_end();
+ for (; NodeIt != NodeItEnd; ++NodeIt)
+ Classes.insert(&*NodeIt);
}
FunctionList DSNodeEquivs::getCallees(CallSite &CS) {
@@ -82,7 +98,8 @@
if (Callees.empty()) {
Instruction *Inst = CS.getInstruction();
Function *Parent = Inst->getParent()->getParent();
- DSNodeHandle &NH = TDDS.getDSGraph(*Parent)->getNodeForValue(CS.getCalledValue());
+ Value *CalledValue = CS.getCalledValue();
+ DSNodeHandle &NH = TDDS.getDSGraph(*Parent)->getNodeForValue(CalledValue);
if (!NH.isNull()) {
DSNode *Node = NH.getNode();
@@ -197,4 +214,23 @@
return Classes;
}
+// Returns the DSNode in the equivalence classes for the specified value.
+// Returns null for a node that was not found.
+const DSNode *DSNodeEquivs::getMemberForValue(const Value *V) {
+ TDDataStructures &TDDS = getAnalysis<TDDataStructures>();
+ DSNodeHandle *NHForV = 0;
+
+ if (isa<GlobalValue>(V)) {
+ NHForV = &TDDS.getGlobalsGraph()->getNodeForValue(V);
+ } else if (isa<Instruction>(V)) {
+ const Function *Parent = cast<Instruction>(V)->getParent()->getParent();
+ NHForV = &TDDS.getDSGraph(*Parent)->getNodeForValue(V);
+ }
+
+ if (NHForV == 0 || NHForV->isNull())
+ return 0;
+ else
+ return NHForV->getNode();
+}
+
}
More information about the llvm-commits
mailing list