From 3770500f88d9c9007c83a2961d8de3f0c208c7be Mon Sep 17 00:00:00 2001 From: Andrew Lenharth Date: Mon, 19 Jun 2006 15:42:47 +0000 Subject: [PATCH] Fix a bug, don't drop indirect call sites, especially if there is nothing known about them yet, and restore a simple version of a removed function git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28857 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/DataStructure/DataStructure.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp index 4e326545cc5..8acbe8e26b8 100644 --- a/lib/Analysis/DataStructure/DataStructure.cpp +++ b/lib/Analysis/DataStructure/DataStructure.cpp @@ -938,7 +938,10 @@ void DSNode::mergeWith(const DSNodeHandle &NH, unsigned Offset) { // two node handles, since "this" may get merged away at intermediate steps. DSNodeHandle CurNodeH(this, Offset); DSNodeHandle NHCopy(NH); - DSNode::MergeNodes(CurNodeH, NHCopy); + if (CurNodeH.getOffset() >= NHCopy.getOffset()) + DSNode::MergeNodes(CurNodeH, NHCopy); + else + DSNode::MergeNodes(NHCopy, CurNodeH); } @@ -1594,6 +1597,13 @@ void DSGraph::mergeInGraph(const DSCallSite &CS, for (afc_iterator I = Graph.afc_begin(), E = Graph.afc_end(); I!=E; ++I) if (SCCFinder.PathExistsToClonedNode(*I)) AuxCallToCopy.push_back(&*I); + else if (I->isIndirectCall()){ + //If the call node doesn't have any callees, clone it + std::vector< Function *> List; + I->getCalleeNode()->addFullFunctionList(List); + if (!List.size()) + AuxCallToCopy.push_back(&*I); + } const DSScalarMap &GSM = Graph.getScalarMap(); for (DSScalarMap::global_iterator GI = GSM.global_begin(), @@ -2397,3 +2407,19 @@ void DSGraph::computeCalleeCallerMapping(DSCallSite CS, const Function &Callee, computeNodeMapping(CalleeSM[*GI], CallerSM[*GI], NodeMap); } } + +/// updateFromGlobalGraph - This function rematerializes global nodes and +/// nodes reachable from them from the globals graph into the current graph. +/// +void DSGraph::updateFromGlobalGraph() { + TIME_REGION(X, "updateFromGlobalGraph"); + ReachabilityCloner RC(*this, *GlobalsGraph, 0); + + // Clone the non-up-to-date global nodes into this graph. + for (DSScalarMap::global_iterator I = getScalarMap().global_begin(), + E = getScalarMap().global_end(); I != E; ++I) { + DSScalarMap::iterator It = GlobalsGraph->ScalarMap.find(*I); + if (It != GlobalsGraph->ScalarMap.end()) + RC.merge(getNodeForValue(*I), It->second); + } +} -- 2.11.0