Chris Lattner | 55c1058 | 2002-10-03 20:38:41 +0000 | [diff] [blame] | 1 | //===- BottomUpClosure.cpp - Compute bottom-up interprocedural closure ----===// |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 2 | // |
| 3 | // This file implements the BUDataStructures class, which represents the |
| 4 | // Bottom-Up Interprocedural closure of the data structure graph over the |
| 5 | // program. This is useful for applications like pool allocation, but **not** |
Chris Lattner | 55c1058 | 2002-10-03 20:38:41 +0000 | [diff] [blame] | 6 | // applications like alias analysis. |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "llvm/Analysis/DataStructure.h" |
| 11 | #include "llvm/Module.h" |
Chris Lattner | fccd06f | 2002-10-01 22:33:50 +0000 | [diff] [blame] | 12 | #include "Support/Statistic.h" |
Chris Lattner | 6806f56 | 2003-08-01 22:15:03 +0000 | [diff] [blame] | 13 | #include "Support/Debug.h" |
Chris Lattner | 5d5b6d6 | 2003-07-01 16:04:18 +0000 | [diff] [blame] | 14 | #include "DSCallSiteIterator.h" |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 15 | |
Chris Lattner | ae5f603 | 2002-11-17 22:16:28 +0000 | [diff] [blame] | 16 | namespace { |
| 17 | Statistic<> MaxSCC("budatastructure", "Maximum SCC Size in Call Graph"); |
Chris Lattner | d391d70 | 2003-07-02 20:24:42 +0000 | [diff] [blame] | 18 | Statistic<> NumBUInlines("budatastructures", "Number of graphs inlined"); |
Chris Lattner | 6c87461 | 2003-07-02 23:42:48 +0000 | [diff] [blame] | 19 | Statistic<> NumCallEdges("budatastructures", "Number of 'actual' call edges"); |
Chris Lattner | ae5f603 | 2002-11-17 22:16:28 +0000 | [diff] [blame] | 20 | |
| 21 | RegisterAnalysis<BUDataStructures> |
Chris Lattner | 312edd3 | 2003-06-28 22:14:55 +0000 | [diff] [blame] | 22 | X("budatastructure", "Bottom-up Data Structure Analysis"); |
Chris Lattner | ae5f603 | 2002-11-17 22:16:28 +0000 | [diff] [blame] | 23 | } |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 24 | |
Chris Lattner | b106043 | 2002-11-07 05:20:53 +0000 | [diff] [blame] | 25 | using namespace DS; |
Chris Lattner | 55c1058 | 2002-10-03 20:38:41 +0000 | [diff] [blame] | 26 | |
Chris Lattner | aa0b468 | 2002-11-09 21:12:07 +0000 | [diff] [blame] | 27 | // run - Calculate the bottom up data structure graphs for each function in the |
| 28 | // program. |
| 29 | // |
| 30 | bool BUDataStructures::run(Module &M) { |
Chris Lattner | 312edd3 | 2003-06-28 22:14:55 +0000 | [diff] [blame] | 31 | LocalDataStructures &LocalDSA = getAnalysis<LocalDataStructures>(); |
| 32 | GlobalsGraph = new DSGraph(LocalDSA.getGlobalsGraph()); |
Chris Lattner | 20167e3 | 2003-02-03 19:11:38 +0000 | [diff] [blame] | 33 | GlobalsGraph->setPrintAuxCalls(); |
Chris Lattner | aa0b468 | 2002-11-09 21:12:07 +0000 | [diff] [blame] | 34 | |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 35 | Function *MainFunc = M.getMainFunction(); |
| 36 | if (MainFunc) |
| 37 | calculateReachableGraphs(MainFunc); |
| 38 | |
| 39 | // Calculate the graphs for any functions that are unreachable from main... |
Chris Lattner | aa0b468 | 2002-11-09 21:12:07 +0000 | [diff] [blame] | 40 | for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) |
Chris Lattner | 5d5b6d6 | 2003-07-01 16:04:18 +0000 | [diff] [blame] | 41 | if (!I->isExternal() && !DSInfo.count(I)) { |
Chris Lattner | ae5f603 | 2002-11-17 22:16:28 +0000 | [diff] [blame] | 42 | #ifndef NDEBUG |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 43 | if (MainFunc) |
| 44 | std::cerr << "*** Function unreachable from main: " |
| 45 | << I->getName() << "\n"; |
Chris Lattner | ae5f603 | 2002-11-17 22:16:28 +0000 | [diff] [blame] | 46 | #endif |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 47 | calculateReachableGraphs(I); // Calculate all graphs... |
| 48 | } |
Chris Lattner | 6c87461 | 2003-07-02 23:42:48 +0000 | [diff] [blame] | 49 | |
| 50 | NumCallEdges += ActualCallees.size(); |
Chris Lattner | aa0b468 | 2002-11-09 21:12:07 +0000 | [diff] [blame] | 51 | return false; |
| 52 | } |
Chris Lattner | 55c1058 | 2002-10-03 20:38:41 +0000 | [diff] [blame] | 53 | |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 54 | void BUDataStructures::calculateReachableGraphs(Function *F) { |
| 55 | std::vector<Function*> Stack; |
Chris Lattner | 41c04f7 | 2003-02-01 04:52:08 +0000 | [diff] [blame] | 56 | hash_map<Function*, unsigned> ValMap; |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 57 | unsigned NextID = 1; |
| 58 | calculateGraphs(F, Stack, NextID, ValMap); |
| 59 | } |
| 60 | |
| 61 | DSGraph &BUDataStructures::getOrCreateGraph(Function *F) { |
| 62 | // Has the graph already been created? |
| 63 | DSGraph *&Graph = DSInfo[F]; |
| 64 | if (Graph) return *Graph; |
| 65 | |
| 66 | // Copy the local version into DSInfo... |
| 67 | Graph = new DSGraph(getAnalysis<LocalDataStructures>().getDSGraph(*F)); |
| 68 | |
| 69 | Graph->setGlobalsGraph(GlobalsGraph); |
| 70 | Graph->setPrintAuxCalls(); |
| 71 | |
| 72 | // Start with a copy of the original call sites... |
| 73 | Graph->getAuxFunctionCalls() = Graph->getFunctionCalls(); |
| 74 | return *Graph; |
| 75 | } |
| 76 | |
| 77 | unsigned BUDataStructures::calculateGraphs(Function *F, |
| 78 | std::vector<Function*> &Stack, |
| 79 | unsigned &NextID, |
Chris Lattner | 41c04f7 | 2003-02-01 04:52:08 +0000 | [diff] [blame] | 80 | hash_map<Function*, unsigned> &ValMap) { |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 81 | assert(ValMap.find(F) == ValMap.end() && "Shouldn't revisit functions!"); |
| 82 | unsigned Min = NextID++, MyID = Min; |
| 83 | ValMap[F] = Min; |
| 84 | Stack.push_back(F); |
| 85 | |
| 86 | if (F->isExternal()) { // sprintf, fprintf, sscanf, etc... |
| 87 | // No callees! |
| 88 | Stack.pop_back(); |
| 89 | ValMap[F] = ~0; |
| 90 | return Min; |
| 91 | } |
| 92 | |
| 93 | DSGraph &Graph = getOrCreateGraph(F); |
| 94 | |
| 95 | // The edges out of the current node are the call site targets... |
Chris Lattner | 2b4c8df | 2003-06-30 05:27:53 +0000 | [diff] [blame] | 96 | for (DSCallSiteIterator I = DSCallSiteIterator::begin_aux(Graph), |
| 97 | E = DSCallSiteIterator::end_aux(Graph); I != E; ++I) { |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 98 | Function *Callee = *I; |
| 99 | unsigned M; |
| 100 | // Have we visited the destination function yet? |
Chris Lattner | 41c04f7 | 2003-02-01 04:52:08 +0000 | [diff] [blame] | 101 | hash_map<Function*, unsigned>::iterator It = ValMap.find(Callee); |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 102 | if (It == ValMap.end()) // No, visit it now. |
| 103 | M = calculateGraphs(Callee, Stack, NextID, ValMap); |
| 104 | else // Yes, get it's number. |
| 105 | M = It->second; |
| 106 | if (M < Min) Min = M; |
| 107 | } |
| 108 | |
| 109 | assert(ValMap[F] == MyID && "SCC construction assumption wrong!"); |
| 110 | if (Min != MyID) |
| 111 | return Min; // This is part of a larger SCC! |
| 112 | |
| 113 | // If this is a new SCC, process it now. |
| 114 | if (Stack.back() == F) { // Special case the single "SCC" case here. |
| 115 | DEBUG(std::cerr << "Visiting single node SCC #: " << MyID << " fn: " |
| 116 | << F->getName() << "\n"); |
| 117 | Stack.pop_back(); |
Chris Lattner | 0eea618 | 2003-06-30 05:09:58 +0000 | [diff] [blame] | 118 | DSGraph &G = getDSGraph(*F); |
| 119 | DEBUG(std::cerr << " [BU] Calculating graph for: " << F->getName()<< "\n"); |
| 120 | calculateGraph(G); |
| 121 | DEBUG(std::cerr << " [BU] Done inlining: " << F->getName() << " [" |
| 122 | << G.getGraphSize() << "+" << G.getAuxFunctionCalls().size() |
| 123 | << "]\n"); |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 124 | |
Chris Lattner | ae5f603 | 2002-11-17 22:16:28 +0000 | [diff] [blame] | 125 | if (MaxSCC < 1) MaxSCC = 1; |
| 126 | |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 127 | // Should we revisit the graph? |
Chris Lattner | 2b4c8df | 2003-06-30 05:27:53 +0000 | [diff] [blame] | 128 | if (DSCallSiteIterator::begin_aux(G) != DSCallSiteIterator::end_aux(G)) { |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 129 | ValMap.erase(F); |
| 130 | return calculateGraphs(F, Stack, NextID, ValMap); |
| 131 | } else { |
| 132 | ValMap[F] = ~0U; |
| 133 | } |
| 134 | return MyID; |
| 135 | |
| 136 | } else { |
| 137 | // SCCFunctions - Keep track of the functions in the current SCC |
| 138 | // |
Chris Lattner | 41c04f7 | 2003-02-01 04:52:08 +0000 | [diff] [blame] | 139 | hash_set<Function*> SCCFunctions; |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 140 | |
| 141 | Function *NF; |
| 142 | std::vector<Function*>::iterator FirstInSCC = Stack.end(); |
Chris Lattner | 0eea618 | 2003-06-30 05:09:58 +0000 | [diff] [blame] | 143 | DSGraph *SCCGraph = 0; |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 144 | do { |
| 145 | NF = *--FirstInSCC; |
| 146 | ValMap[NF] = ~0U; |
| 147 | SCCFunctions.insert(NF); |
Chris Lattner | 0eea618 | 2003-06-30 05:09:58 +0000 | [diff] [blame] | 148 | |
| 149 | // Figure out which graph is the largest one, in order to speed things up |
| 150 | // a bit in situations where functions in the SCC have widely different |
| 151 | // graph sizes. |
| 152 | DSGraph &NFGraph = getDSGraph(*NF); |
| 153 | if (!SCCGraph || SCCGraph->getGraphSize() < NFGraph.getGraphSize()) |
| 154 | SCCGraph = &NFGraph; |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 155 | } while (NF != F); |
| 156 | |
Chris Lattner | 0eea618 | 2003-06-30 05:09:58 +0000 | [diff] [blame] | 157 | std::cerr << "Calculating graph for SCC #: " << MyID << " of size: " |
| 158 | << SCCFunctions.size() << "\n"; |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 159 | |
Chris Lattner | ae5f603 | 2002-11-17 22:16:28 +0000 | [diff] [blame] | 160 | // Compute the Max SCC Size... |
Chris Lattner | 0eea618 | 2003-06-30 05:09:58 +0000 | [diff] [blame] | 161 | if (MaxSCC < SCCFunctions.size()) |
| 162 | MaxSCC = SCCFunctions.size(); |
Chris Lattner | ae5f603 | 2002-11-17 22:16:28 +0000 | [diff] [blame] | 163 | |
Chris Lattner | 0eea618 | 2003-06-30 05:09:58 +0000 | [diff] [blame] | 164 | // First thing first, collapse all of the DSGraphs into a single graph for |
| 165 | // the entire SCC. We computed the largest graph, so clone all of the other |
| 166 | // (smaller) graphs into it. Discard all of the old graphs. |
| 167 | // |
| 168 | for (hash_set<Function*>::iterator I = SCCFunctions.begin(), |
| 169 | E = SCCFunctions.end(); I != E; ++I) { |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 170 | DSGraph &G = getDSGraph(**I); |
Chris Lattner | 0eea618 | 2003-06-30 05:09:58 +0000 | [diff] [blame] | 171 | if (&G != SCCGraph) { |
| 172 | DSGraph::NodeMapTy NodeMap; |
| 173 | SCCGraph->cloneInto(G, SCCGraph->getScalarMap(), |
| 174 | SCCGraph->getReturnNodes(), NodeMap, 0); |
| 175 | // Update the DSInfo map and delete the old graph... |
| 176 | DSInfo[*I] = SCCGraph; |
| 177 | delete &G; |
| 178 | } |
| 179 | } |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 180 | |
Chris Lattner | 744f939 | 2003-07-02 04:37:48 +0000 | [diff] [blame] | 181 | // Clean up the graph before we start inlining a bunch again... |
| 182 | SCCGraph->removeTriviallyDeadNodes(); |
| 183 | |
Chris Lattner | 0eea618 | 2003-06-30 05:09:58 +0000 | [diff] [blame] | 184 | // Now that we have one big happy family, resolve all of the call sites in |
| 185 | // the graph... |
| 186 | calculateGraph(*SCCGraph); |
| 187 | DEBUG(std::cerr << " [BU] Done inlining SCC [" << SCCGraph->getGraphSize() |
| 188 | << "+" << SCCGraph->getAuxFunctionCalls().size() << "]\n"); |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 189 | |
| 190 | std::cerr << "DONE with SCC #: " << MyID << "\n"; |
| 191 | |
| 192 | // We never have to revisit "SCC" processed functions... |
| 193 | |
| 194 | // Drop the stuff we don't need from the end of the stack |
| 195 | Stack.erase(FirstInSCC, Stack.end()); |
| 196 | return MyID; |
| 197 | } |
| 198 | |
| 199 | return MyID; // == Min |
| 200 | } |
| 201 | |
| 202 | |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 203 | // releaseMemory - If the pass pipeline is done with this pass, we can release |
| 204 | // our memory... here... |
| 205 | // |
| 206 | void BUDataStructures::releaseMemory() { |
Chris Lattner | 0eea618 | 2003-06-30 05:09:58 +0000 | [diff] [blame] | 207 | for (hash_map<Function*, DSGraph*>::iterator I = DSInfo.begin(), |
| 208 | E = DSInfo.end(); I != E; ++I) { |
| 209 | I->second->getReturnNodes().erase(I->first); |
| 210 | if (I->second->getReturnNodes().empty()) |
| 211 | delete I->second; |
| 212 | } |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 213 | |
| 214 | // Empty map so next time memory is released, data structures are not |
| 215 | // re-deleted. |
| 216 | DSInfo.clear(); |
Chris Lattner | aa0b468 | 2002-11-09 21:12:07 +0000 | [diff] [blame] | 217 | delete GlobalsGraph; |
| 218 | GlobalsGraph = 0; |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 219 | } |
| 220 | |
Chris Lattner | 0eea618 | 2003-06-30 05:09:58 +0000 | [diff] [blame] | 221 | void BUDataStructures::calculateGraph(DSGraph &Graph) { |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 222 | // Move our call site list into TempFCs so that inline call sites go into the |
| 223 | // new call site list and doesn't invalidate our iterators! |
| 224 | std::vector<DSCallSite> TempFCs; |
| 225 | std::vector<DSCallSite> &AuxCallsList = Graph.getAuxFunctionCalls(); |
| 226 | TempFCs.swap(AuxCallsList); |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame] | 227 | |
Chris Lattner | 0eea618 | 2003-06-30 05:09:58 +0000 | [diff] [blame] | 228 | DSGraph::ReturnNodesTy &ReturnNodes = Graph.getReturnNodes(); |
| 229 | |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 230 | // Loop over all of the resolvable call sites |
| 231 | unsigned LastCallSiteIdx = ~0U; |
Chris Lattner | 2b4c8df | 2003-06-30 05:27:53 +0000 | [diff] [blame] | 232 | for (DSCallSiteIterator I = DSCallSiteIterator::begin(TempFCs), |
| 233 | E = DSCallSiteIterator::end(TempFCs); I != E; ++I) { |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 234 | // If we skipped over any call sites, they must be unresolvable, copy them |
| 235 | // to the real call site list. |
| 236 | LastCallSiteIdx++; |
| 237 | for (; LastCallSiteIdx < I.getCallSiteIdx(); ++LastCallSiteIdx) |
| 238 | AuxCallsList.push_back(TempFCs[LastCallSiteIdx]); |
| 239 | LastCallSiteIdx = I.getCallSiteIdx(); |
Chris Lattner | a107905 | 2002-11-10 06:52:47 +0000 | [diff] [blame] | 240 | |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 241 | // Resolve the current call... |
| 242 | Function *Callee = *I; |
Chris Lattner | 744f939 | 2003-07-02 04:37:48 +0000 | [diff] [blame] | 243 | DSCallSite CS = I.getCallSite(); |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 244 | |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 245 | if (Callee->isExternal()) { |
| 246 | // Ignore this case, simple varargs functions we cannot stub out! |
Chris Lattner | 0eea618 | 2003-06-30 05:09:58 +0000 | [diff] [blame] | 247 | } else if (ReturnNodes.find(Callee) != ReturnNodes.end()) { |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 248 | // Self recursion... simply link up the formal arguments with the |
| 249 | // actual arguments... |
Chris Lattner | 0eea618 | 2003-06-30 05:09:58 +0000 | [diff] [blame] | 250 | DEBUG(std::cerr << " Self Inlining: " << Callee->getName() << "\n"); |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 251 | |
| 252 | // Handle self recursion by resolving the arguments and return value |
Chris Lattner | 0eea618 | 2003-06-30 05:09:58 +0000 | [diff] [blame] | 253 | Graph.mergeInGraph(CS, *Callee, Graph, 0); |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 254 | |
| 255 | } else { |
Chris Lattner | 808a7ae | 2003-09-20 16:34:13 +0000 | [diff] [blame] | 256 | ActualCallees.insert(std::make_pair(CS.getCallSite().getInstruction(), |
| 257 | Callee)); |
Chris Lattner | 744f939 | 2003-07-02 04:37:48 +0000 | [diff] [blame] | 258 | |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 259 | // Get the data structure graph for the called function. |
| 260 | // |
| 261 | DSGraph &GI = getDSGraph(*Callee); // Graph to inline |
| 262 | |
| 263 | DEBUG(std::cerr << " Inlining graph for " << Callee->getName() |
Chris Lattner | 20167e3 | 2003-02-03 19:11:38 +0000 | [diff] [blame] | 264 | << "[" << GI.getGraphSize() << "+" |
Chris Lattner | 5d5b6d6 | 2003-07-01 16:04:18 +0000 | [diff] [blame] | 265 | << GI.getAuxFunctionCalls().size() << "] into '" |
| 266 | << Graph.getFunctionNames() << "' [" << Graph.getGraphSize() << "+" |
Chris Lattner | 20167e3 | 2003-02-03 19:11:38 +0000 | [diff] [blame] | 267 | << Graph.getAuxFunctionCalls().size() << "]\n"); |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 268 | |
| 269 | // Handle self recursion by resolving the arguments and return value |
Chris Lattner | 5a54063 | 2003-06-30 03:15:25 +0000 | [diff] [blame] | 270 | Graph.mergeInGraph(CS, *Callee, GI, |
Vikram S. Adve | 61ff029 | 2002-11-27 17:41:13 +0000 | [diff] [blame] | 271 | DSGraph::KeepModRefBits | |
| 272 | DSGraph::StripAllocaBit | DSGraph::DontCloneCallNodes); |
Chris Lattner | d391d70 | 2003-07-02 20:24:42 +0000 | [diff] [blame] | 273 | ++NumBUInlines; |
Chris Lattner | ae5f603 | 2002-11-17 22:16:28 +0000 | [diff] [blame] | 274 | |
| 275 | #if 0 |
| 276 | Graph.writeGraphToFile(std::cerr, "bu_" + F.getName() + "_after_" + |
| 277 | Callee->getName()); |
| 278 | #endif |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 279 | } |
| 280 | } |
| 281 | |
| 282 | // Make sure to catch any leftover unresolvable calls... |
| 283 | for (++LastCallSiteIdx; LastCallSiteIdx < TempFCs.size(); ++LastCallSiteIdx) |
| 284 | AuxCallsList.push_back(TempFCs[LastCallSiteIdx]); |
| 285 | |
| 286 | TempFCs.clear(); |
| 287 | |
Vikram S. Adve | 1da1d32 | 2003-07-16 21:42:03 +0000 | [diff] [blame] | 288 | // Re-materialize nodes from the globals graph. |
| 289 | // Do not ignore globals inlined from callees -- they are not up-to-date! |
| 290 | Graph.getInlinedGlobals().clear(); |
| 291 | Graph.updateFromGlobalGraph(); |
| 292 | |
| 293 | // Recompute the Incomplete markers |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 294 | Graph.maskIncompleteMarkers(); |
Chris Lattner | 394471f | 2003-01-23 22:05:33 +0000 | [diff] [blame] | 295 | Graph.markIncompleteNodes(DSGraph::MarkFormalArgs); |
Vikram S. Adve | 1da1d32 | 2003-07-16 21:42:03 +0000 | [diff] [blame] | 296 | |
| 297 | // Delete dead nodes. Treat globals that are unreachable but that can |
| 298 | // reach live nodes as live. |
Chris Lattner | 394471f | 2003-01-23 22:05:33 +0000 | [diff] [blame] | 299 | Graph.removeDeadNodes(DSGraph::KeepUnreachableGlobals); |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 300 | |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 301 | //Graph.writeGraphToFile(std::cerr, "bu_" + F.getName()); |
Chris Lattner | a9c9c02 | 2002-11-11 21:35:13 +0000 | [diff] [blame] | 302 | } |
| 303 | |