blob: cf4563344750238df4e644a34bc60e817b1f724c [file] [log] [blame]
Chris Lattnerca398dc2003-05-29 15:11:31 +00001//===- InlineFunction.cpp - Code to perform function inlining -------------===//
Misha Brukmanfd939082005-04-21 23:48:37 +00002//
John Criswellb576c942003-10-20 19:43:21 +00003// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
Misha Brukmanfd939082005-04-21 23:48:37 +00007//
John Criswellb576c942003-10-20 19:43:21 +00008//===----------------------------------------------------------------------===//
Chris Lattnerca398dc2003-05-29 15:11:31 +00009//
10// This file implements inlining of a function into a call site, resolving
11// parameters and the return value as appropriate.
12//
13// FIXME: This pass should transform alloca instructions in the called function
Chris Lattner5052c912004-02-04 01:41:09 +000014// into alloca/dealloca pairs! Or perhaps it should refuse to inline them!
Chris Lattnerca398dc2003-05-29 15:11:31 +000015//
16//===----------------------------------------------------------------------===//
17
18#include "llvm/Transforms/Utils/Cloning.h"
Chris Lattner3787e762004-10-17 23:21:07 +000019#include "llvm/Constants.h"
Chris Lattner7152c232003-08-24 04:06:56 +000020#include "llvm/DerivedTypes.h"
Chris Lattnerca398dc2003-05-29 15:11:31 +000021#include "llvm/Module.h"
Chris Lattner80a38d22003-08-24 06:59:16 +000022#include "llvm/Instructions.h"
23#include "llvm/Intrinsics.h"
24#include "llvm/Support/CallSite.h"
Chris Lattnerf7703df2004-01-09 06:12:26 +000025using namespace llvm;
Chris Lattnerca398dc2003-05-29 15:11:31 +000026
Chris Lattnerf7703df2004-01-09 06:12:26 +000027bool llvm::InlineFunction(CallInst *CI) { return InlineFunction(CallSite(CI)); }
28bool llvm::InlineFunction(InvokeInst *II) {return InlineFunction(CallSite(II));}
Chris Lattner80a38d22003-08-24 06:59:16 +000029
Chris Lattnerca398dc2003-05-29 15:11:31 +000030// InlineFunction - This function inlines the called function into the basic
31// block of the caller. This returns false if it is not possible to inline this
32// call. The program is still in a well defined state if this occurs though.
33//
Misha Brukmanfd939082005-04-21 23:48:37 +000034// Note that this only does one level of inlining. For example, if the
35// instruction 'call B' is inlined, and 'B' calls 'C', then the call to 'C' now
Chris Lattnerca398dc2003-05-29 15:11:31 +000036// exists in the instruction stream. Similiarly this will inline a recursive
37// function by one level.
38//
Chris Lattnerf7703df2004-01-09 06:12:26 +000039bool llvm::InlineFunction(CallSite CS) {
Chris Lattner80a38d22003-08-24 06:59:16 +000040 Instruction *TheCall = CS.getInstruction();
41 assert(TheCall->getParent() && TheCall->getParent()->getParent() &&
42 "Instruction not in function!");
Chris Lattnerca398dc2003-05-29 15:11:31 +000043
Chris Lattner80a38d22003-08-24 06:59:16 +000044 const Function *CalledFunc = CS.getCalledFunction();
Chris Lattnerca398dc2003-05-29 15:11:31 +000045 if (CalledFunc == 0 || // Can't inline external function or indirect
46 CalledFunc->isExternal() || // call, or call to a vararg function!
47 CalledFunc->getFunctionType()->isVarArg()) return false;
48
Chris Lattner1b491412005-05-06 06:47:52 +000049
50 // If the call to the callee is a non-tail call, we must clear the 'tail'
51 // flags on any calls that we inline.
52 bool MustClearTailCallFlags =
Chris Lattner3799ed82005-05-06 17:13:16 +000053 isa<CallInst>(TheCall) && !cast<CallInst>(TheCall)->isTailCall();
Chris Lattner1b491412005-05-06 06:47:52 +000054
Chris Lattner80a38d22003-08-24 06:59:16 +000055 BasicBlock *OrigBB = TheCall->getParent();
Chris Lattnerca398dc2003-05-29 15:11:31 +000056 Function *Caller = OrigBB->getParent();
57
Chris Lattner5052c912004-02-04 01:41:09 +000058 // Get an iterator to the last basic block in the function, which will have
59 // the new function inlined after it.
60 //
61 Function::iterator LastBlock = &Caller->back();
62
Chris Lattner5e923de2004-02-04 02:51:48 +000063 // Make sure to capture all of the return instructions from the cloned
Chris Lattnerca398dc2003-05-29 15:11:31 +000064 // function.
Chris Lattner5e923de2004-02-04 02:51:48 +000065 std::vector<ReturnInst*> Returns;
66 { // Scope to destroy ValueMap after cloning.
67 // Calculate the vector of arguments to pass into the function cloner...
68 std::map<const Value*, Value*> ValueMap;
Misha Brukmanfd939082005-04-21 23:48:37 +000069 assert(std::distance(CalledFunc->arg_begin(), CalledFunc->arg_end()) ==
Chris Lattner5e923de2004-02-04 02:51:48 +000070 std::distance(CS.arg_begin(), CS.arg_end()) &&
71 "No varargs calls can be inlined!");
Misha Brukmanfd939082005-04-21 23:48:37 +000072
Chris Lattner5e923de2004-02-04 02:51:48 +000073 CallSite::arg_iterator AI = CS.arg_begin();
Chris Lattnere4d5c442005-03-15 04:54:21 +000074 for (Function::const_arg_iterator I = CalledFunc->arg_begin(),
75 E = CalledFunc->arg_end(); I != E; ++I, ++AI)
Chris Lattner5e923de2004-02-04 02:51:48 +000076 ValueMap[I] = *AI;
Misha Brukmanfd939082005-04-21 23:48:37 +000077
78 // Clone the entire body of the callee into the caller.
Chris Lattner5e923de2004-02-04 02:51:48 +000079 CloneFunctionInto(Caller, CalledFunc, ValueMap, Returns, ".i");
Misha Brukmanfd939082005-04-21 23:48:37 +000080 }
Chris Lattnerc1df7e12004-02-04 21:33:42 +000081
Chris Lattner5e923de2004-02-04 02:51:48 +000082 // Remember the first block that is newly cloned over.
83 Function::iterator FirstNewBlock = LastBlock; ++FirstNewBlock;
Chris Lattnerca398dc2003-05-29 15:11:31 +000084
85 // If there are any alloca instructions in the block that used to be the entry
86 // block for the callee, move them to the entry block of the caller. First
87 // calculate which instruction they should be inserted before. We insert the
88 // instructions at the end of the current alloca list.
89 //
Chris Lattner5e923de2004-02-04 02:51:48 +000090 if (isa<AllocaInst>(FirstNewBlock->begin())) {
Chris Lattner80a38d22003-08-24 06:59:16 +000091 BasicBlock::iterator InsertPoint = Caller->begin()->begin();
Chris Lattner5e923de2004-02-04 02:51:48 +000092 for (BasicBlock::iterator I = FirstNewBlock->begin(),
93 E = FirstNewBlock->end(); I != E; )
Chris Lattnerf775f952003-10-14 01:11:07 +000094 if (AllocaInst *AI = dyn_cast<AllocaInst>(I++))
95 if (isa<Constant>(AI->getArraySize())) {
Chris Lattnerc1df7e12004-02-04 21:33:42 +000096 // Scan for the block of allocas that we can move over.
97 while (isa<AllocaInst>(I) &&
98 isa<Constant>(cast<AllocaInst>(I)->getArraySize()))
99 ++I;
100
101 // Transfer all of the allocas over in a block. Using splice means
102 // that they instructions aren't removed from the symbol table, then
103 // reinserted.
104 Caller->front().getInstList().splice(InsertPoint,
105 FirstNewBlock->getInstList(),
106 AI, I);
Chris Lattnerf775f952003-10-14 01:11:07 +0000107 }
Chris Lattner80a38d22003-08-24 06:59:16 +0000108 }
Chris Lattnerca398dc2003-05-29 15:11:31 +0000109
Jeff Cohen00b168892005-07-27 06:12:32 +0000110 // If we are inlining tail call instruction through an invoke or
Chris Lattner1b491412005-05-06 06:47:52 +0000111 if (MustClearTailCallFlags) {
112 for (Function::iterator BB = FirstNewBlock, E = Caller->end();
113 BB != E; ++BB)
114 for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
115 if (CallInst *CI = dyn_cast<CallInst>(I))
116 CI->setTailCall(false);
117 }
118
Chris Lattner5e923de2004-02-04 02:51:48 +0000119 // If we are inlining for an invoke instruction, we must make sure to rewrite
120 // any inlined 'unwind' instructions into branches to the invoke exception
121 // destination, and call instructions into invoke instructions.
122 if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall)) {
Chris Lattneraeb2a1d2004-02-08 21:44:31 +0000123 BasicBlock *InvokeDest = II->getUnwindDest();
Chris Lattner5e923de2004-02-04 02:51:48 +0000124 std::vector<Value*> InvokeDestPHIValues;
125
126 // If there are PHI nodes in the exceptional destination block, we need to
127 // keep track of which values came into them from this invoke, then remove
128 // the entry for this block.
Reid Spencer2da5c3d2004-09-15 17:06:42 +0000129 for (BasicBlock::iterator I = InvokeDest->begin(); isa<PHINode>(I); ++I) {
130 PHINode *PN = cast<PHINode>(I);
Chris Lattner5e923de2004-02-04 02:51:48 +0000131 // Save the value to use for this edge...
132 InvokeDestPHIValues.push_back(PN->getIncomingValueForBlock(OrigBB));
Reid Spencer2da5c3d2004-09-15 17:06:42 +0000133 }
Chris Lattner5e923de2004-02-04 02:51:48 +0000134
135 for (Function::iterator BB = FirstNewBlock, E = Caller->end();
136 BB != E; ++BB) {
Chris Lattner80a38d22003-08-24 06:59:16 +0000137 for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) {
138 // We only need to check for function calls: inlined invoke instructions
139 // require no special handling...
140 if (CallInst *CI = dyn_cast<CallInst>(I)) {
Chris Lattner494b6922004-02-13 16:47:35 +0000141 // Convert this function call into an invoke instruction... if it's
Chris Lattner1b491412005-05-06 06:47:52 +0000142 // not an intrinsic function call (which are known to not unwind).
Chris Lattner494b6922004-02-13 16:47:35 +0000143 if (CI->getCalledFunction() &&
144 CI->getCalledFunction()->getIntrinsicID()) {
145 ++I;
146 } else {
147 // First, split the basic block...
148 BasicBlock *Split = BB->splitBasicBlock(CI, CI->getName()+".noexc");
Misha Brukmanfd939082005-04-21 23:48:37 +0000149
Chris Lattner494b6922004-02-13 16:47:35 +0000150 // Next, create the new invoke instruction, inserting it at the end
151 // of the old basic block.
152 InvokeInst *II =
Misha Brukmanfd939082005-04-21 23:48:37 +0000153 new InvokeInst(CI->getCalledValue(), Split, InvokeDest,
Chris Lattner494b6922004-02-13 16:47:35 +0000154 std::vector<Value*>(CI->op_begin()+1, CI->op_end()),
155 CI->getName(), BB->getTerminator());
Chris Lattnerc154cef2005-05-09 01:04:34 +0000156 II->setCallingConv(CI->getCallingConv());
Chris Lattner80a38d22003-08-24 06:59:16 +0000157
Chris Lattner494b6922004-02-13 16:47:35 +0000158 // Make sure that anything using the call now uses the invoke!
159 CI->replaceAllUsesWith(II);
Misha Brukmanfd939082005-04-21 23:48:37 +0000160
Chris Lattner494b6922004-02-13 16:47:35 +0000161 // Delete the unconditional branch inserted by splitBasicBlock
162 BB->getInstList().pop_back();
163 Split->getInstList().pop_front(); // Delete the original call
Misha Brukmanfd939082005-04-21 23:48:37 +0000164
Chris Lattner494b6922004-02-13 16:47:35 +0000165 // Update any PHI nodes in the exceptional block to indicate that
166 // there is now a new entry in them.
167 unsigned i = 0;
168 for (BasicBlock::iterator I = InvokeDest->begin();
Reid Spencer2da5c3d2004-09-15 17:06:42 +0000169 isa<PHINode>(I); ++I, ++i) {
170 PHINode *PN = cast<PHINode>(I);
Chris Lattner494b6922004-02-13 16:47:35 +0000171 PN->addIncoming(InvokeDestPHIValues[i], BB);
Reid Spencer2da5c3d2004-09-15 17:06:42 +0000172 }
Misha Brukmanfd939082005-04-21 23:48:37 +0000173
Chris Lattner494b6922004-02-13 16:47:35 +0000174 // This basic block is now complete, start scanning the next one.
175 break;
176 }
Chris Lattner80a38d22003-08-24 06:59:16 +0000177 } else {
178 ++I;
179 }
180 }
Chris Lattnerca398dc2003-05-29 15:11:31 +0000181
Chris Lattneree5457c2003-09-08 19:44:26 +0000182 if (UnwindInst *UI = dyn_cast<UnwindInst>(BB->getTerminator())) {
183 // An UnwindInst requires special handling when it gets inlined into an
184 // invoke site. Once this happens, we know that the unwind would cause
185 // a control transfer to the invoke exception destination, so we can
186 // transform it into a direct branch to the exception destination.
Chris Lattnerf8485c62003-11-20 18:25:24 +0000187 new BranchInst(InvokeDest, UI);
Chris Lattneree5457c2003-09-08 19:44:26 +0000188
189 // Delete the unwind instruction!
190 UI->getParent()->getInstList().pop_back();
Chris Lattner198f4502003-10-27 05:33:09 +0000191
192 // Update any PHI nodes in the exceptional block to indicate that
193 // there is now a new entry in them.
194 unsigned i = 0;
195 for (BasicBlock::iterator I = InvokeDest->begin();
Reid Spencer2da5c3d2004-09-15 17:06:42 +0000196 isa<PHINode>(I); ++I, ++i) {
197 PHINode *PN = cast<PHINode>(I);
Chris Lattner198f4502003-10-27 05:33:09 +0000198 PN->addIncoming(InvokeDestPHIValues[i], BB);
Reid Spencer2da5c3d2004-09-15 17:06:42 +0000199 }
Chris Lattneree5457c2003-09-08 19:44:26 +0000200 }
201 }
202
Chris Lattner51d68162003-09-22 21:59:27 +0000203 // Now that everything is happy, we have one final detail. The PHI nodes in
204 // the exception destination block still have entries due to the original
205 // invoke instruction. Eliminate these entries (which might even delete the
206 // PHI node) now.
Chris Lattner5e923de2004-02-04 02:51:48 +0000207 InvokeDest->removePredecessor(II->getParent());
Chris Lattner51d68162003-09-22 21:59:27 +0000208 }
Chris Lattner5e923de2004-02-04 02:51:48 +0000209
Chris Lattner44a68072004-02-04 04:17:06 +0000210 // If we cloned in _exactly one_ basic block, and if that block ends in a
211 // return instruction, we splice the body of the inlined callee directly into
212 // the calling basic block.
213 if (Returns.size() == 1 && std::distance(FirstNewBlock, Caller->end()) == 1) {
214 // Move all of the instructions right before the call.
215 OrigBB->getInstList().splice(TheCall, FirstNewBlock->getInstList(),
216 FirstNewBlock->begin(), FirstNewBlock->end());
217 // Remove the cloned basic block.
218 Caller->getBasicBlockList().pop_back();
Misha Brukmanfd939082005-04-21 23:48:37 +0000219
Chris Lattner44a68072004-02-04 04:17:06 +0000220 // If the call site was an invoke instruction, add a branch to the normal
221 // destination.
222 if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall))
223 new BranchInst(II->getNormalDest(), TheCall);
224
225 // If the return instruction returned a value, replace uses of the call with
226 // uses of the returned value.
227 if (!TheCall->use_empty())
228 TheCall->replaceAllUsesWith(Returns[0]->getReturnValue());
229
230 // Since we are now done with the Call/Invoke, we can delete it.
231 TheCall->getParent()->getInstList().erase(TheCall);
232
233 // Since we are now done with the return instruction, delete it also.
234 Returns[0]->getParent()->getInstList().erase(Returns[0]);
235
236 // We are now done with the inlining.
237 return true;
238 }
239
240 // Otherwise, we have the normal case, of more than one block to inline or
241 // multiple return sites.
242
Chris Lattner5e923de2004-02-04 02:51:48 +0000243 // We want to clone the entire callee function into the hole between the
244 // "starter" and "ender" blocks. How we accomplish this depends on whether
245 // this is an invoke instruction or a call instruction.
246 BasicBlock *AfterCallBB;
247 if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall)) {
Misha Brukmanfd939082005-04-21 23:48:37 +0000248
Chris Lattner5e923de2004-02-04 02:51:48 +0000249 // Add an unconditional branch to make this look like the CallInst case...
250 BranchInst *NewBr = new BranchInst(II->getNormalDest(), TheCall);
Misha Brukmanfd939082005-04-21 23:48:37 +0000251
Chris Lattner5e923de2004-02-04 02:51:48 +0000252 // Split the basic block. This guarantees that no PHI nodes will have to be
253 // updated due to new incoming edges, and make the invoke case more
254 // symmetric to the call case.
255 AfterCallBB = OrigBB->splitBasicBlock(NewBr,
Chris Lattner284d1b82004-12-11 16:59:54 +0000256 CalledFunc->getName()+".exit");
Misha Brukmanfd939082005-04-21 23:48:37 +0000257
Chris Lattner5e923de2004-02-04 02:51:48 +0000258 } else { // It's a call
Chris Lattner44a68072004-02-04 04:17:06 +0000259 // If this is a call instruction, we need to split the basic block that
260 // the call lives in.
Chris Lattner5e923de2004-02-04 02:51:48 +0000261 //
262 AfterCallBB = OrigBB->splitBasicBlock(TheCall,
Chris Lattner284d1b82004-12-11 16:59:54 +0000263 CalledFunc->getName()+".exit");
Chris Lattner5e923de2004-02-04 02:51:48 +0000264 }
265
Chris Lattner44a68072004-02-04 04:17:06 +0000266 // Change the branch that used to go to AfterCallBB to branch to the first
267 // basic block of the inlined function.
268 //
269 TerminatorInst *Br = OrigBB->getTerminator();
Misha Brukmanfd939082005-04-21 23:48:37 +0000270 assert(Br && Br->getOpcode() == Instruction::Br &&
Chris Lattner44a68072004-02-04 04:17:06 +0000271 "splitBasicBlock broken!");
272 Br->setOperand(0, FirstNewBlock);
273
274
275 // Now that the function is correct, make it a little bit nicer. In
276 // particular, move the basic blocks inserted from the end of the function
277 // into the space made by splitting the source basic block.
278 //
279 Caller->getBasicBlockList().splice(AfterCallBB, Caller->getBasicBlockList(),
280 FirstNewBlock, Caller->end());
281
Chris Lattner5e923de2004-02-04 02:51:48 +0000282 // Handle all of the return instructions that we just cloned in, and eliminate
283 // any users of the original call/invoke instruction.
284 if (Returns.size() > 1) {
285 // The PHI node should go at the front of the new basic block to merge all
286 // possible incoming values.
287 //
288 PHINode *PHI = 0;
289 if (!TheCall->use_empty()) {
290 PHI = new PHINode(CalledFunc->getReturnType(),
291 TheCall->getName(), AfterCallBB->begin());
Misha Brukmanfd939082005-04-21 23:48:37 +0000292
Chris Lattner5e923de2004-02-04 02:51:48 +0000293 // Anything that used the result of the function call should now use the
294 // PHI node as their operand.
295 //
296 TheCall->replaceAllUsesWith(PHI);
297 }
Misha Brukmanfd939082005-04-21 23:48:37 +0000298
Chris Lattner5e923de2004-02-04 02:51:48 +0000299 // Loop over all of the return instructions, turning them into unconditional
300 // branches to the merge point now, and adding entries to the PHI node as
301 // appropriate.
302 for (unsigned i = 0, e = Returns.size(); i != e; ++i) {
303 ReturnInst *RI = Returns[i];
Misha Brukmanfd939082005-04-21 23:48:37 +0000304
Chris Lattner5e923de2004-02-04 02:51:48 +0000305 if (PHI) {
306 assert(RI->getReturnValue() && "Ret should have value!");
Misha Brukmanfd939082005-04-21 23:48:37 +0000307 assert(RI->getReturnValue()->getType() == PHI->getType() &&
Chris Lattner5e923de2004-02-04 02:51:48 +0000308 "Ret value not consistent in function!");
309 PHI->addIncoming(RI->getReturnValue(), RI->getParent());
310 }
Misha Brukmanfd939082005-04-21 23:48:37 +0000311
Chris Lattner5e923de2004-02-04 02:51:48 +0000312 // Add a branch to the merge point where the PHI node lives if it exists.
313 new BranchInst(AfterCallBB, RI);
Misha Brukmanfd939082005-04-21 23:48:37 +0000314
Chris Lattner5e923de2004-02-04 02:51:48 +0000315 // Delete the return instruction now
316 RI->getParent()->getInstList().erase(RI);
317 }
Misha Brukmanfd939082005-04-21 23:48:37 +0000318
Chris Lattner5e923de2004-02-04 02:51:48 +0000319 } else if (!Returns.empty()) {
320 // Otherwise, if there is exactly one return value, just replace anything
321 // using the return value of the call with the computed value.
322 if (!TheCall->use_empty())
323 TheCall->replaceAllUsesWith(Returns[0]->getReturnValue());
Misha Brukmanfd939082005-04-21 23:48:37 +0000324
Chris Lattnercd01ae52004-04-16 05:17:59 +0000325 // Splice the code from the return block into the block that it will return
326 // to, which contains the code that was after the call.
327 BasicBlock *ReturnBB = Returns[0]->getParent();
Chris Lattneradfd32f2004-07-20 05:45:24 +0000328 AfterCallBB->getInstList().splice(AfterCallBB->begin(),
329 ReturnBB->getInstList());
Chris Lattnercd01ae52004-04-16 05:17:59 +0000330
Chris Lattneradfd32f2004-07-20 05:45:24 +0000331 // Update PHI nodes that use the ReturnBB to use the AfterCallBB.
332 ReturnBB->replaceAllUsesWith(AfterCallBB);
Misha Brukmanfd939082005-04-21 23:48:37 +0000333
Chris Lattneradfd32f2004-07-20 05:45:24 +0000334 // Delete the return instruction now and empty ReturnBB now.
Chris Lattner3787e762004-10-17 23:21:07 +0000335 Returns[0]->eraseFromParent();
336 ReturnBB->eraseFromParent();
337 } else if (!TheCall->use_empty()) {
338 // No returns, but something is using the return value of the call. Just
339 // nuke the result.
340 TheCall->replaceAllUsesWith(UndefValue::get(TheCall->getType()));
Chris Lattner5e923de2004-02-04 02:51:48 +0000341 }
Misha Brukmanfd939082005-04-21 23:48:37 +0000342
Chris Lattner5e923de2004-02-04 02:51:48 +0000343 // Since we are now done with the Call/Invoke, we can delete it.
Chris Lattner3787e762004-10-17 23:21:07 +0000344 TheCall->eraseFromParent();
Chris Lattnerca398dc2003-05-29 15:11:31 +0000345
Chris Lattner7152c232003-08-24 04:06:56 +0000346 // We should always be able to fold the entry block of the function into the
347 // single predecessor of the block...
Chris Lattnercd01ae52004-04-16 05:17:59 +0000348 assert(cast<BranchInst>(Br)->isUnconditional() && "splitBasicBlock broken!");
Chris Lattner7152c232003-08-24 04:06:56 +0000349 BasicBlock *CalleeEntry = cast<BranchInst>(Br)->getSuccessor(0);
Chris Lattner44a68072004-02-04 04:17:06 +0000350
Chris Lattnercd01ae52004-04-16 05:17:59 +0000351 // Splice the code entry block into calling block, right before the
352 // unconditional branch.
353 OrigBB->getInstList().splice(Br, CalleeEntry->getInstList());
354 CalleeEntry->replaceAllUsesWith(OrigBB); // Update PHI nodes
355
356 // Remove the unconditional branch.
357 OrigBB->getInstList().erase(Br);
358
359 // Now we can remove the CalleeEntry block, which is now empty.
360 Caller->getBasicBlockList().erase(CalleeEntry);
Chris Lattnerca398dc2003-05-29 15:11:31 +0000361 return true;
362}