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" |
Chris Lattner | 55c1058 | 2002-10-03 20:38:41 +0000 | [diff] [blame] | 11 | #include "llvm/Analysis/DSGraph.h" |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 12 | #include "llvm/Module.h" |
Chris Lattner | fccd06f | 2002-10-01 22:33:50 +0000 | [diff] [blame] | 13 | #include "Support/Statistic.h" |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 14 | using std::map; |
| 15 | |
Chris Lattner | 1e43516 | 2002-07-26 21:12:44 +0000 | [diff] [blame] | 16 | static RegisterAnalysis<BUDataStructures> |
Vikram S. Adve | 355e2ca | 2002-07-30 22:05:22 +0000 | [diff] [blame] | 17 | X("budatastructure", "Bottom-up Data Structure Analysis Closure"); |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 18 | |
Chris Lattner | b106043 | 2002-11-07 05:20:53 +0000 | [diff] [blame] | 19 | using namespace DS; |
Chris Lattner | 55c1058 | 2002-10-03 20:38:41 +0000 | [diff] [blame] | 20 | |
Chris Lattner | aa0b468 | 2002-11-09 21:12:07 +0000 | [diff] [blame] | 21 | // run - Calculate the bottom up data structure graphs for each function in the |
| 22 | // program. |
| 23 | // |
| 24 | bool BUDataStructures::run(Module &M) { |
| 25 | GlobalsGraph = new DSGraph(); |
| 26 | |
| 27 | // Simply calculate the graphs for each function... |
| 28 | for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) |
| 29 | if (!I->isExternal()) |
Chris Lattner | a107905 | 2002-11-10 06:52:47 +0000 | [diff] [blame] | 30 | calculateGraph(*I, 0); |
Chris Lattner | aa0b468 | 2002-11-09 21:12:07 +0000 | [diff] [blame] | 31 | return false; |
| 32 | } |
Chris Lattner | 55c1058 | 2002-10-03 20:38:41 +0000 | [diff] [blame] | 33 | |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 34 | // releaseMemory - If the pass pipeline is done with this pass, we can release |
| 35 | // our memory... here... |
| 36 | // |
| 37 | void BUDataStructures::releaseMemory() { |
Vikram S. Adve | 355e2ca | 2002-07-30 22:05:22 +0000 | [diff] [blame] | 38 | for (map<const Function*, DSGraph*>::iterator I = DSInfo.begin(), |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 39 | E = DSInfo.end(); I != E; ++I) |
| 40 | delete I->second; |
| 41 | |
| 42 | // Empty map so next time memory is released, data structures are not |
| 43 | // re-deleted. |
| 44 | DSInfo.clear(); |
Chris Lattner | aa0b468 | 2002-11-09 21:12:07 +0000 | [diff] [blame] | 45 | delete GlobalsGraph; |
| 46 | GlobalsGraph = 0; |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 47 | } |
| 48 | |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 49 | |
| 50 | // Return true if a graph was inlined |
| 51 | // Can not modify the part of the AuxCallList < FirstResolvableCall. |
| 52 | // |
| 53 | bool BUDataStructures::ResolveFunctionCalls(DSGraph &G, |
| 54 | unsigned &FirstResolvableCall, |
| 55 | std::map<Function*, DSCallSite> &InProcess, |
| 56 | unsigned Indent) { |
| 57 | std::vector<DSCallSite> &FCs = G.getAuxFunctionCalls(); |
| 58 | bool Changed = false; |
| 59 | |
| 60 | // Loop while there are call sites that we can resolve! |
| 61 | while (FirstResolvableCall != FCs.size()) { |
| 62 | DSCallSite Call = FCs[FirstResolvableCall]; |
| 63 | |
| 64 | // If the function list is incomplete... |
| 65 | if (Call.getCallee().getNode()->NodeType & DSNode::Incomplete) { |
| 66 | // If incomplete, we cannot resolve it, so leave it at the beginning of |
| 67 | // the call list with the other unresolvable calls... |
| 68 | ++FirstResolvableCall; |
| 69 | } else { |
| 70 | // Start inlining all of the functions we can... some may not be |
| 71 | // inlinable if they are external... |
| 72 | // |
| 73 | const std::vector<GlobalValue*> &Callees = |
| 74 | Call.getCallee().getNode()->getGlobals(); |
| 75 | |
| 76 | bool hasExternalTarget = false; |
| 77 | |
| 78 | // Loop over the functions, inlining whatever we can... |
| 79 | for (unsigned c = 0, e = Callees.size(); c != e; ++c) { |
| 80 | // Must be a function type, so this cast should succeed unless something |
| 81 | // really wierd is happening. |
| 82 | Function &FI = cast<Function>(*Callees[c]); |
| 83 | |
| 84 | if (FI.getName() == "printf" || FI.getName() == "sscanf" || |
| 85 | FI.getName() == "fprintf" || FI.getName() == "open" || |
| 86 | FI.getName() == "sprintf" || FI.getName() == "fputs") { |
| 87 | // Ignore |
| 88 | } else if (FI.isExternal()) { |
| 89 | // If the function is external, then we cannot resolve this call site! |
| 90 | hasExternalTarget = true; |
| 91 | break; |
| 92 | } else { |
| 93 | std::map<Function*, DSCallSite>::iterator I = |
| 94 | InProcess.lower_bound(&FI); |
| 95 | |
| 96 | if (I != InProcess.end() && I->first == &FI) { // Recursion detected? |
| 97 | // Merge two call sites to eliminate recursion... |
| 98 | Call.mergeWith(I->second); |
| 99 | |
| 100 | DEBUG(std::cerr << std::string(Indent*2, ' ') |
| 101 | << "* Recursion detected for function " << FI.getName()<<"\n"); |
| 102 | } else { |
| 103 | DEBUG(std::cerr << std::string(Indent*2, ' ') |
| 104 | << "Inlining: " << FI.getName() << "\n"); |
| 105 | |
| 106 | // Get the data structure graph for the called function, closing it |
| 107 | // if possible... |
| 108 | // |
| 109 | DSGraph &GI = calculateGraph(FI, Indent+1); // Graph to inline |
| 110 | |
| 111 | DEBUG(std::cerr << std::string(Indent*2, ' ') |
| 112 | << "Got graph for: " << FI.getName() << "[" |
| 113 | << GI.getGraphSize() << "+" |
| 114 | << GI.getAuxFunctionCalls().size() << "] " |
| 115 | << " in: " << G.getFunction().getName() << "[" |
| 116 | << G.getGraphSize() << "+" |
| 117 | << G.getAuxFunctionCalls().size() << "]\n"); |
| 118 | |
| 119 | // Keep track of how many call sites are added by the inlining... |
| 120 | unsigned NumCalls = FCs.size(); |
| 121 | |
| 122 | // Resolve the arguments and return value |
| 123 | G.mergeInGraph(Call, GI, DSGraph::StripAllocaBit | |
| 124 | DSGraph::DontCloneCallNodes); |
| 125 | |
| 126 | // Added a call site? |
| 127 | if (FCs.size() != NumCalls) { |
| 128 | // Otherwise we need to inline the graph. Temporarily add the |
| 129 | // current function to the InProcess map to be able to handle |
| 130 | // recursion successfully. |
| 131 | // |
| 132 | I = InProcess.insert(I, std::make_pair(&FI, Call)); |
| 133 | |
| 134 | // ResolveFunctionCalls - Resolve the function calls that just got |
| 135 | // inlined... |
| 136 | // |
| 137 | Changed |= ResolveFunctionCalls(G, NumCalls, InProcess, Indent+1); |
| 138 | |
| 139 | // Now that we are done processing the inlined graph, remove our |
| 140 | // cycle detector record... |
| 141 | // |
| 142 | //InProcess.erase(I); |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | if (hasExternalTarget) { |
| 149 | // If we cannot resolve this call site... |
| 150 | ++FirstResolvableCall; |
| 151 | } else { |
| 152 | Changed = true; |
| 153 | FCs.erase(FCs.begin()+FirstResolvableCall); |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | return Changed; |
| 159 | } |
| 160 | |
Chris Lattner | a107905 | 2002-11-10 06:52:47 +0000 | [diff] [blame] | 161 | DSGraph &BUDataStructures::calculateGraph(Function &F, unsigned Indent) { |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 162 | // Make sure this graph has not already been calculated, or that we don't get |
| 163 | // into an infinite loop with mutually recursive functions. |
| 164 | // |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 165 | DSGraph *&GraphPtr = DSInfo[&F]; |
| 166 | if (GraphPtr) return *GraphPtr; |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 167 | |
| 168 | // Copy the local version into DSInfo... |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 169 | GraphPtr = new DSGraph(getAnalysis<LocalDataStructures>().getDSGraph(F)); |
| 170 | DSGraph &Graph = *GraphPtr; |
| 171 | |
| 172 | Graph.setGlobalsGraph(GlobalsGraph); |
| 173 | Graph.setPrintAuxCalls(); |
Vikram S. Adve | 355e2ca | 2002-07-30 22:05:22 +0000 | [diff] [blame] | 174 | |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 175 | // Start resolving calls... |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 176 | std::vector<DSCallSite> &FCs = Graph.getAuxFunctionCalls(); |
Chris Lattner | 1a948a8 | 2002-11-08 21:25:24 +0000 | [diff] [blame] | 177 | |
| 178 | // Start with a copy of the original call sites... |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 179 | FCs = Graph.getFunctionCalls(); |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 180 | |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 181 | DEBUG(std::cerr << std::string(Indent*2, ' ') |
Chris Lattner | a107905 | 2002-11-10 06:52:47 +0000 | [diff] [blame] | 182 | << "[BU] Calculating graph for: " << F.getName() << "\n"); |
Vikram S. Adve | 355e2ca | 2002-07-30 22:05:22 +0000 | [diff] [blame] | 183 | |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 184 | bool Changed; |
| 185 | while (1) { |
| 186 | unsigned FirstResolvableCall = 0; |
| 187 | std::map<Function *, DSCallSite> InProcess; |
| 188 | |
| 189 | // Insert a call site for self to handle self recursion... |
| 190 | std::vector<DSNodeHandle> Args; |
| 191 | Args.reserve(F.asize()); |
| 192 | for (Function::aiterator I = F.abegin(), E = F.aend(); I != E; ++I) |
| 193 | if (isPointerType(I->getType())) |
| 194 | Args.push_back(Graph.getNodeForValue(I)); |
| 195 | |
| 196 | InProcess.insert(std::make_pair(&F, |
| 197 | DSCallSite(*(CallInst*)0, Graph.getRetNode(),(DSNode*)0,Args))); |
| 198 | |
| 199 | Changed = ResolveFunctionCalls(Graph, FirstResolvableCall, InProcess, |
| 200 | Indent); |
| 201 | |
| 202 | if (Changed) { |
| 203 | Graph.maskIncompleteMarkers(); |
| 204 | Graph.markIncompleteNodes(); |
| 205 | Graph.removeDeadNodes(); |
| 206 | break; |
| 207 | } else { |
| 208 | break; |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | #if 0 |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 213 | bool Inlined; |
| 214 | do { |
| 215 | Inlined = false; |
Vikram S. Adve | 355e2ca | 2002-07-30 22:05:22 +0000 | [diff] [blame] | 216 | |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 217 | for (unsigned i = 0; i != FCs.size(); ++i) { |
| 218 | // Copy the call, because inlining graphs may invalidate the FCs vector. |
Vikram S. Adve | 42fd169 | 2002-10-20 18:07:37 +0000 | [diff] [blame] | 219 | DSCallSite Call = FCs[i]; |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 220 | |
Chris Lattner | 55c1058 | 2002-10-03 20:38:41 +0000 | [diff] [blame] | 221 | // If the function list is complete... |
Chris Lattner | 0969c50 | 2002-10-21 02:08:03 +0000 | [diff] [blame] | 222 | if ((Call.getCallee().getNode()->NodeType & DSNode::Incomplete)==0) { |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 223 | // Start inlining all of the functions we can... some may not be |
| 224 | // inlinable if they are external... |
| 225 | // |
Chris Lattner | 7836d60 | 2002-10-20 22:11:17 +0000 | [diff] [blame] | 226 | std::vector<GlobalValue*> Callees = |
Chris Lattner | 0969c50 | 2002-10-21 02:08:03 +0000 | [diff] [blame] | 227 | Call.getCallee().getNode()->getGlobals(); |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 228 | |
Chris Lattner | a107905 | 2002-11-10 06:52:47 +0000 | [diff] [blame] | 229 | unsigned OldNumCalls = FCs.size(); |
| 230 | |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 231 | // Loop over the functions, inlining whatever we can... |
Vikram S. Adve | 355e2ca | 2002-07-30 22:05:22 +0000 | [diff] [blame] | 232 | for (unsigned c = 0; c != Callees.size(); ++c) { |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 233 | // Must be a function type, so this cast MUST succeed. |
Vikram S. Adve | 355e2ca | 2002-07-30 22:05:22 +0000 | [diff] [blame] | 234 | Function &FI = cast<Function>(*Callees[c]); |
Chris Lattner | 613692c | 2002-10-17 04:24:08 +0000 | [diff] [blame] | 235 | |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 236 | if (&FI == &F) { |
| 237 | // Self recursion... simply link up the formal arguments with the |
| 238 | // actual arguments... |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 239 | DEBUG(std::cerr << std::string(Indent*2, ' ') |
| 240 | << "[BU] Self Inlining: " << F.getName() << "\n"); |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 241 | |
Chris Lattner | 076c1f9 | 2002-11-07 06:31:54 +0000 | [diff] [blame] | 242 | // Handle self recursion by resolving the arguments and return value |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 243 | Graph.mergeInGraph(Call, Graph, DSGraph::StripAllocaBit); |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 244 | |
Vikram S. Adve | 355e2ca | 2002-07-30 22:05:22 +0000 | [diff] [blame] | 245 | // Erase the entry in the callees vector |
| 246 | Callees.erase(Callees.begin()+c--); |
Chris Lattner | 613692c | 2002-10-17 04:24:08 +0000 | [diff] [blame] | 247 | |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 248 | } else if (!FI.isExternal()) { |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 249 | DEBUG(std::cerr << std::string(Indent*2, ' ') |
| 250 | << "[BU] In " << F.getName() << " inlining: " |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 251 | << FI.getName() << "\n"); |
Vikram S. Adve | c44e9bf | 2002-07-18 16:13:52 +0000 | [diff] [blame] | 252 | |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 253 | // Get the data structure graph for the called function, closing it |
| 254 | // if possible (which is only impossible in the case of mutual |
| 255 | // recursion... |
| 256 | // |
Chris Lattner | a107905 | 2002-11-10 06:52:47 +0000 | [diff] [blame] | 257 | DSGraph &GI = calculateGraph(FI, Indent+1); // Graph to inline |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 258 | |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 259 | DEBUG(std::cerr << std::string(Indent*2, ' ') |
| 260 | << "[BU] Got graph for " << FI.getName() |
Chris Lattner | a107905 | 2002-11-10 06:52:47 +0000 | [diff] [blame] | 261 | << " in: " << F.getName() << "[" << GI.getGraphSize() << "+" |
| 262 | << GI.getAuxFunctionCalls().size() << "]\n"); |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 263 | |
Chris Lattner | 076c1f9 | 2002-11-07 06:31:54 +0000 | [diff] [blame] | 264 | // Handle self recursion by resolving the arguments and return value |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 265 | Graph.mergeInGraph(Call, GI, DSGraph::StripAllocaBit | |
Chris Lattner | 70925b0 | 2002-11-08 22:27:25 +0000 | [diff] [blame] | 266 | DSGraph::DontCloneCallNodes); |
Vikram S. Adve | 355e2ca | 2002-07-30 22:05:22 +0000 | [diff] [blame] | 267 | |
Vikram S. Adve | 355e2ca | 2002-07-30 22:05:22 +0000 | [diff] [blame] | 268 | // Erase the entry in the Callees vector |
| 269 | Callees.erase(Callees.begin()+c--); |
| 270 | |
Chris Lattner | 9eee58d | 2002-07-19 18:11:43 +0000 | [diff] [blame] | 271 | } else if (FI.getName() == "printf" || FI.getName() == "sscanf" || |
| 272 | FI.getName() == "fprintf" || FI.getName() == "open" || |
Chris Lattner | a107905 | 2002-11-10 06:52:47 +0000 | [diff] [blame] | 273 | FI.getName() == "sprintf" || FI.getName() == "fputs") { |
Chris Lattner | 9267329 | 2002-11-02 00:13:20 +0000 | [diff] [blame] | 274 | // FIXME: These special cases (eg printf) should go away when we can |
| 275 | // define functions that take a variable number of arguments. |
Chris Lattner | 9eee58d | 2002-07-19 18:11:43 +0000 | [diff] [blame] | 276 | |
Chris Lattner | 9267329 | 2002-11-02 00:13:20 +0000 | [diff] [blame] | 277 | // FIXME: at the very least, this should update mod/ref info |
Chris Lattner | 9eee58d | 2002-07-19 18:11:43 +0000 | [diff] [blame] | 278 | // Erase the entry in the globals vector |
Vikram S. Adve | 355e2ca | 2002-07-30 22:05:22 +0000 | [diff] [blame] | 279 | Callees.erase(Callees.begin()+c--); |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 280 | } |
| 281 | } |
| 282 | |
Vikram S. Adve | 355e2ca | 2002-07-30 22:05:22 +0000 | [diff] [blame] | 283 | if (Callees.empty()) { // Inlined all of the function calls? |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 284 | // Erase the call if it is resolvable... |
| 285 | FCs.erase(FCs.begin()+i--); // Don't skip a the next call... |
| 286 | Inlined = true; |
Chris Lattner | 0969c50 | 2002-10-21 02:08:03 +0000 | [diff] [blame] | 287 | } else if (Callees.size() != |
| 288 | Call.getCallee().getNode()->getGlobals().size()) { |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 289 | // Was able to inline SOME, but not all of the functions. Construct a |
| 290 | // new global node here. |
| 291 | // |
| 292 | assert(0 && "Unimpl!"); |
| 293 | Inlined = true; |
| 294 | } |
Chris Lattner | a107905 | 2002-11-10 06:52:47 +0000 | [diff] [blame] | 295 | |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 296 | |
| 297 | #if 0 |
Chris Lattner | a107905 | 2002-11-10 06:52:47 +0000 | [diff] [blame] | 298 | // If we just inlined a function that had call nodes, chances are that |
| 299 | // the call nodes are redundant with ones we already have. Eliminate |
| 300 | // those call nodes now. |
| 301 | // |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 302 | if (FCs.size() >= OldNumCalls) |
| 303 | Graph.removeTriviallyDeadNodes(); |
| 304 | #endif |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 305 | } |
Chris Lattner | a107905 | 2002-11-10 06:52:47 +0000 | [diff] [blame] | 306 | |
| 307 | if (FCs.size() > 200) { |
| 308 | std::cerr << "Aborted inlining fn: '" << F.getName() << "'!" |
| 309 | << std::endl; |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 310 | Graph.maskIncompleteMarkers(); |
| 311 | Graph.markIncompleteNodes(); |
| 312 | Graph.removeDeadNodes(); |
| 313 | Graph.writeGraphToFile(std::cerr, "crap."+F.getName()); |
Chris Lattner | a107905 | 2002-11-10 06:52:47 +0000 | [diff] [blame] | 314 | exit(1); |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 315 | return Graph; |
Chris Lattner | a107905 | 2002-11-10 06:52:47 +0000 | [diff] [blame] | 316 | } |
| 317 | |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | // Recompute the Incomplete markers. If there are any function calls left |
| 321 | // now that are complete, we must loop! |
| 322 | if (Inlined) { |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 323 | Graph.maskIncompleteMarkers(); |
| 324 | Graph.markIncompleteNodes(); |
| 325 | Graph.removeDeadNodes(); |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 326 | } |
Chris Lattner | a107905 | 2002-11-10 06:52:47 +0000 | [diff] [blame] | 327 | |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 328 | } while (Inlined && !FCs.empty()); |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 329 | #endif |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 330 | |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 331 | DEBUG(std::cerr << std::string(Indent*2, ' ') |
Chris Lattner | a107905 | 2002-11-10 06:52:47 +0000 | [diff] [blame] | 332 | << "[BU] Done inlining: " << F.getName() << " [" |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 333 | << Graph.getGraphSize() << "+" << Graph.getAuxFunctionCalls().size() |
Chris Lattner | 221c979 | 2002-08-07 21:41:11 +0000 | [diff] [blame] | 334 | << "]\n"); |
Vikram S. Adve | 355e2ca | 2002-07-30 22:05:22 +0000 | [diff] [blame] | 335 | |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 336 | Graph.writeGraphToFile(std::cerr, "bu_" + F.getName()); |
Chris Lattner | a107905 | 2002-11-10 06:52:47 +0000 | [diff] [blame] | 337 | |
Chris Lattner | 8a5db46 | 2002-11-11 00:01:34 +0000 | [diff] [blame^] | 338 | return Graph; |
Chris Lattner | 0d9bab8 | 2002-07-18 00:12:30 +0000 | [diff] [blame] | 339 | } |