Allow the ResolveCallSiteModRefInfo method to return a mapping of nodes,
authorChris Lattner <sabre@nondot.org>
Wed, 6 Nov 2002 19:59:33 +0000 (19:59 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 6 Nov 2002 19:59:33 +0000 (19:59 +0000)
implement the mod/ref bit masking

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4578 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/IPModRef.h
lib/Analysis/DataStructure/IPModRef.cpp
lib/Analysis/IPA/IPModRef.cpp

index fb0191e61f518b0f584f071b202f4211a3b41b0e..929b9b18797fb9558d4c9e061f7a2d1c9a9c8391 100644 (file)
 
 #include "llvm/Pass.h"
 #include "Support/BitSetVector.h"
-#include "Support/NonCopyable.h"
 
 class Module;
 class Function;
 class CallInst;
 class DSNode;
 class DSGraph;
+class DSNodeHandle;
 class ModRefInfo;               // Result of IP Mod/Ref for one entity
 class FunctionModRefInfo;       // ModRefInfo for a func and all calls in it
 class IPModRef;                 // Pass that computes IP Mod/Ref info
@@ -125,7 +125,8 @@ class FunctionModRefInfo {
 
   void          computeModRef   (const Function &func);
   void          computeModRef   (const CallInst& callInst);
-  DSGraph *ResolveCallSiteModRefInfo(const CallInst &CI);
+  DSGraph *ResolveCallSiteModRefInfo(const CallInst &CI,
+                                std::map<const DSNode*, DSNodeHandle> &NodeMap);
 
 public:
   /* ctor */    FunctionModRefInfo      (const Function& func,
index 9b33a3c27c8b7c9ea72e33a7cbd318a4afef517c..0f9da42531783c4a4148584f3818def31e521fd0 100644 (file)
@@ -104,17 +104,28 @@ void FunctionModRefInfo::computeModRef(const Function &func)
 //  2. It clears all of the mod/ref bits in the cloned graph
 //  3. It then merges the bottom-up graph(s) for the specified call-site into
 //     the clone (bringing new mod/ref bits).
-//  4. It returns the clone.
+//  4. It returns the clone, and a mapping of nodes from the original TDGraph to
+//     the cloned graph with Mod/Ref info for the callsite.
 //
 // NOTE: Because this clones a dsgraph and returns it, the caller is responsible
 //       for deleting the returned graph!
 //
-DSGraph *FunctionModRefInfo::ResolveCallSiteModRefInfo(const CallInst &CI) {
+DSGraph *FunctionModRefInfo::ResolveCallSiteModRefInfo(const CallInst &CI,
+                               std::map<const DSNode*, DSNodeHandle> &NodeMap) {
+
   // Step #1: Clone the top-down graph...
-  DSGraph *Result = new DSGraph(funcTDGraph);
+  std::map<const DSNode*, DSNode*> RawNodeMap;
+  DSGraph *Result = new DSGraph(funcTDGraph, RawNodeMap);
+
+  // Convert the NodeMap from a map to DSNode* to be a map to DSNodeHandle's
+  NodeMap.insert(RawNodeMap.begin(), RawNodeMap.end());
+
+  // We are now done with the old map... so free it's memory...
+  RawNodeMap.clear();
+
+  // Step #2: Clear Mod/Ref information...
+  Result->maskNodeTypes(~(DSNode::Modified | DSNode::Read));
 
-  //const Function &F = *CI.getParent()->getParent();
-  //DSGraph &TDGraph = IPModRefObj.getAnalysis<TDDataStructures>().getDSGraph(F);
 
   
   return Result;
@@ -133,7 +144,8 @@ FunctionModRefInfo::computeModRef(const CallInst& callInst)
   callSiteModRefInfo[&callInst] = callModRefInfo;
 
   // Get a copy of the graph for the callee with the callee inlined
-  DSGraph* csgp = ResolveCallSiteModRefInfo(callInst);
+  std::map<const DSNode*, DSNodeHandle> NodeMap;
+  DSGraph* csgp = ResolveCallSiteModRefInfo(callInst, NodeMap);
 
   // For all nodes in the graph, extract the mod/ref information
   const std::vector<DSNode*>& csgNodes = csgp->getNodes();
index 9b33a3c27c8b7c9ea72e33a7cbd318a4afef517c..0f9da42531783c4a4148584f3818def31e521fd0 100644 (file)
@@ -104,17 +104,28 @@ void FunctionModRefInfo::computeModRef(const Function &func)
 //  2. It clears all of the mod/ref bits in the cloned graph
 //  3. It then merges the bottom-up graph(s) for the specified call-site into
 //     the clone (bringing new mod/ref bits).
-//  4. It returns the clone.
+//  4. It returns the clone, and a mapping of nodes from the original TDGraph to
+//     the cloned graph with Mod/Ref info for the callsite.
 //
 // NOTE: Because this clones a dsgraph and returns it, the caller is responsible
 //       for deleting the returned graph!
 //
-DSGraph *FunctionModRefInfo::ResolveCallSiteModRefInfo(const CallInst &CI) {
+DSGraph *FunctionModRefInfo::ResolveCallSiteModRefInfo(const CallInst &CI,
+                               std::map<const DSNode*, DSNodeHandle> &NodeMap) {
+
   // Step #1: Clone the top-down graph...
-  DSGraph *Result = new DSGraph(funcTDGraph);
+  std::map<const DSNode*, DSNode*> RawNodeMap;
+  DSGraph *Result = new DSGraph(funcTDGraph, RawNodeMap);
+
+  // Convert the NodeMap from a map to DSNode* to be a map to DSNodeHandle's
+  NodeMap.insert(RawNodeMap.begin(), RawNodeMap.end());
+
+  // We are now done with the old map... so free it's memory...
+  RawNodeMap.clear();
+
+  // Step #2: Clear Mod/Ref information...
+  Result->maskNodeTypes(~(DSNode::Modified | DSNode::Read));
 
-  //const Function &F = *CI.getParent()->getParent();
-  //DSGraph &TDGraph = IPModRefObj.getAnalysis<TDDataStructures>().getDSGraph(F);
 
   
   return Result;
@@ -133,7 +144,8 @@ FunctionModRefInfo::computeModRef(const CallInst& callInst)
   callSiteModRefInfo[&callInst] = callModRefInfo;
 
   // Get a copy of the graph for the callee with the callee inlined
-  DSGraph* csgp = ResolveCallSiteModRefInfo(callInst);
+  std::map<const DSNode*, DSNodeHandle> NodeMap;
+  DSGraph* csgp = ResolveCallSiteModRefInfo(callInst, NodeMap);
 
   // For all nodes in the graph, extract the mod/ref information
   const std::vector<DSNode*>& csgNodes = csgp->getNodes();