Remove a couple of #includes, move some code from .h file
authorChris Lattner <sabre@nondot.org>
Wed, 6 Nov 2002 18:38:18 +0000 (18:38 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 6 Nov 2002 18:38:18 +0000 (18:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4575 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/DataStructure/IPModRef.cpp
lib/Analysis/IPA/IPModRef.cpp

index e4d0062f38609211853ad69809636d74797d8bf6..22d7caa92fec14e8db5785b2eaccd39c6ba70db2 100644 (file)
@@ -4,22 +4,15 @@
 // 
 //===----------------------------------------------------------------------===//
 
+#include "llvm/Analysis/IPModRef.h"
 #include "llvm/Analysis/DataStructure.h"
 #include "llvm/Analysis/DSGraph.h"
-#include "llvm/Analysis/IPModRef.h"
 #include "llvm/Module.h"
-#include "llvm/Function.h"
 #include "llvm/iOther.h"
-#include "llvm/Pass.h"
 #include "Support/Statistic.h"
 #include "Support/STLExtras.h"
 #include "Support/StringExtras.h"
 
-#include <algorithm>
-#include <utility>
-#include <vector>
-
-
 //----------------------------------------------------------------------------
 // Private constants and data
 //----------------------------------------------------------------------------
@@ -73,6 +66,12 @@ FunctionModRefInfo::~FunctionModRefInfo()
   callSiteModRefInfo.clear();
 }
 
+unsigned FunctionModRefInfo::getNodeId(const Value* value) const {
+  return getNodeId(funcTDGraph.getNodeForValue(const_cast<Value*>(value))
+                   .getNode());
+}
+
+
 
 // Dummy function that will be replaced with one that inlines
 // the callee's BU graph into the caller's TD graph.
@@ -199,6 +198,31 @@ bool IPModRef::run(Module &theModule)
 }
 
 
+FunctionModRefInfo& IPModRef::getFuncInfo(const Function& func,
+                                          bool computeIfMissing)
+{
+  FunctionModRefInfo*& funcInfo = funcToModRefInfoMap[&func];
+  assert (funcInfo != NULL || computeIfMissing);
+  if (funcInfo == NULL && computeIfMissing)
+    { // Create a new FunctionModRefInfo object
+      funcInfo = new FunctionModRefInfo(func,  // inserts into map
+                              getAnalysis<TDDataStructures>().getDSGraph(func),
+                          getAnalysis<LocalDataStructures>().getDSGraph(func));
+      funcInfo->computeModRef(func);            // computes the mod/ref info
+    }
+  return *funcInfo;
+}
+
+// getAnalysisUsage - This pass requires top-down data structure graphs.
+// It modifies nothing.
+// 
+void IPModRef::getAnalysisUsage(AnalysisUsage &AU) const {
+  AU.setPreservesAll();
+  AU.addRequired<LocalDataStructures>();
+  AU.addRequired<TDDataStructures>();
+}
+
+
 void IPModRef::print(std::ostream &O) const
 {
   O << "\n========== Results of Interprocedural Mod/Ref Analysis ==========\n";
index e4d0062f38609211853ad69809636d74797d8bf6..22d7caa92fec14e8db5785b2eaccd39c6ba70db2 100644 (file)
@@ -4,22 +4,15 @@
 // 
 //===----------------------------------------------------------------------===//
 
+#include "llvm/Analysis/IPModRef.h"
 #include "llvm/Analysis/DataStructure.h"
 #include "llvm/Analysis/DSGraph.h"
-#include "llvm/Analysis/IPModRef.h"
 #include "llvm/Module.h"
-#include "llvm/Function.h"
 #include "llvm/iOther.h"
-#include "llvm/Pass.h"
 #include "Support/Statistic.h"
 #include "Support/STLExtras.h"
 #include "Support/StringExtras.h"
 
-#include <algorithm>
-#include <utility>
-#include <vector>
-
-
 //----------------------------------------------------------------------------
 // Private constants and data
 //----------------------------------------------------------------------------
@@ -73,6 +66,12 @@ FunctionModRefInfo::~FunctionModRefInfo()
   callSiteModRefInfo.clear();
 }
 
+unsigned FunctionModRefInfo::getNodeId(const Value* value) const {
+  return getNodeId(funcTDGraph.getNodeForValue(const_cast<Value*>(value))
+                   .getNode());
+}
+
+
 
 // Dummy function that will be replaced with one that inlines
 // the callee's BU graph into the caller's TD graph.
@@ -199,6 +198,31 @@ bool IPModRef::run(Module &theModule)
 }
 
 
+FunctionModRefInfo& IPModRef::getFuncInfo(const Function& func,
+                                          bool computeIfMissing)
+{
+  FunctionModRefInfo*& funcInfo = funcToModRefInfoMap[&func];
+  assert (funcInfo != NULL || computeIfMissing);
+  if (funcInfo == NULL && computeIfMissing)
+    { // Create a new FunctionModRefInfo object
+      funcInfo = new FunctionModRefInfo(func,  // inserts into map
+                              getAnalysis<TDDataStructures>().getDSGraph(func),
+                          getAnalysis<LocalDataStructures>().getDSGraph(func));
+      funcInfo->computeModRef(func);            // computes the mod/ref info
+    }
+  return *funcInfo;
+}
+
+// getAnalysisUsage - This pass requires top-down data structure graphs.
+// It modifies nothing.
+// 
+void IPModRef::getAnalysisUsage(AnalysisUsage &AU) const {
+  AU.setPreservesAll();
+  AU.addRequired<LocalDataStructures>();
+  AU.addRequired<TDDataStructures>();
+}
+
+
 void IPModRef::print(std::ostream &O) const
 {
   O << "\n========== Results of Interprocedural Mod/Ref Analysis ==========\n";