diff options
author | Chris Lattner <sabre@nondot.org> | 2003-09-20 16:12:57 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-09-20 16:12:57 +0000 |
commit | 36b877ae7fc1569585f929e49e6baf7f3ddbf57d (patch) | |
tree | 1789f3309eb14e403528c9aff59938ef85389119 /llvm/lib/Analysis/DataStructure | |
parent | 22533bc900bc8cfb1e8a939db0f86c4ef53dd3a2 (diff) | |
download | bcm5719-llvm-36b877ae7fc1569585f929e49e6baf7f3ddbf57d.tar.gz bcm5719-llvm-36b877ae7fc1569585f929e49e6baf7f3ddbf57d.zip |
Make this work better for constants that aren't necessarily in ANY graph, such as null pointers
llvm-svn: 8628
Diffstat (limited to 'llvm/lib/Analysis/DataStructure')
-rw-r--r-- | llvm/lib/Analysis/DataStructure/DataStructureStats.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/DataStructure/DataStructureStats.cpp b/llvm/lib/Analysis/DataStructure/DataStructureStats.cpp index 887eb7f550a..674f689a685 100644 --- a/llvm/lib/Analysis/DataStructure/DataStructureStats.cpp +++ b/llvm/lib/Analysis/DataStructure/DataStructureStats.cpp @@ -33,6 +33,7 @@ namespace { const DSGraph *TDGraph; DSNode *getNodeForValue(Value *V); + bool isNodeForValueCollapsed(Value *V); public: /// Driver functions to compute the Load/Store Dep. Graph per function. bool runOnFunction(Function& F); @@ -90,14 +91,24 @@ void DSGraphStats::countCallees(const Function& F) { DSNode *DSGraphStats::getNodeForValue(Value *V) { const DSGraph *G = TDGraph; - if (isa<GlobalValue>(V)) + if (isa<GlobalValue>(V) || isa<Constant>(V)) G = TDGraph->getGlobalsGraph(); - return G->getNodeForValue(V).getNode(); + const DSGraph::ScalarMapTy &ScalarMap = G->getScalarMap(); + DSGraph::ScalarMapTy::const_iterator I = ScalarMap.find(V); + if (I != ScalarMap.end()) + return I->second.getNode(); + return 0; +} + +bool DSGraphStats::isNodeForValueCollapsed(Value *V) { + if (DSNode *N = getNodeForValue(V)) + return N->isNodeCompletelyFolded(); + return false; } void DSGraphStats::visitLoad(LoadInst &LI) { - if (getNodeForValue(LI.getOperand(0))->isNodeCompletelyFolded()) { + if (isNodeForValueCollapsed(LI.getOperand(0))) { NumUntypedMemAccesses++; } else { NumTypedMemAccesses++; @@ -105,7 +116,7 @@ void DSGraphStats::visitLoad(LoadInst &LI) { } void DSGraphStats::visitStore(StoreInst &SI) { - if (getNodeForValue(SI.getOperand(1))->isNodeCompletelyFolded()) { + if (isNodeForValueCollapsed(SI.getOperand(1))) { NumUntypedMemAccesses++; } else { NumTypedMemAccesses++; |