+ DSGraph& CalleeGraph = getDSGraph(*I->second);
+ assert(&CalleeGraph != &Graph && "TD need not inline graph into self!");
+
+ // if this callee graph is already done at this site, skip this callee
+ if (GraphsSeen.find(&CalleeGraph) != GraphsSeen.end())
+ continue;
+ GraphsSeen.insert(&CalleeGraph);
+
+ // Get the root nodes for cloning the reachable subgraph into each callee:
+ // -- all global nodes that appear in both the caller and the callee
+ // -- return value at this call site, if any
+ // -- actual arguments passed at this call site
+ // -- callee node at this call site, if this is an indirect call (this may
+ // not be needed for merging, but allows us to create CS and therefore
+ // simplify the merging below).
+ hash_set<const DSNode*> RootNodeSet;
+ for (DSGraph::ScalarMapTy::const_iterator
+ SI = CalleeGraph.getScalarMap().begin(),
+ SE = CalleeGraph.getScalarMap().end(); SI != SE; ++SI)
+ if (GlobalValue* GV = dyn_cast<GlobalValue>(SI->first)) {
+ DSGraph::ScalarMapTy::const_iterator GI=Graph.getScalarMap().find(GV);
+ if (GI != Graph.getScalarMap().end())
+ RootNodeSet.insert(GI->second.getNode());
+ }
+
+ if (const DSNode* RetNode = FunctionCalls[i].getRetVal().getNode())
+ RootNodeSet.insert(RetNode);