blob: 70570baae56a34136eea1f9ee09b57677ed59aeb [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//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// 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//
Chris Lattnerca398dc2003-05-29 15:11:31 +000013//===----------------------------------------------------------------------===//
14
15#include "llvm/Transforms/Utils/Cloning.h"
Chris Lattner3787e762004-10-17 23:21:07 +000016#include "llvm/Constants.h"
Chris Lattner7152c232003-08-24 04:06:56 +000017#include "llvm/DerivedTypes.h"
Owen Anderson0a205a42009-07-05 22:41:43 +000018#include "llvm/LLVMContext.h"
Chris Lattnerca398dc2003-05-29 15:11:31 +000019#include "llvm/Module.h"
Chris Lattner80a38d22003-08-24 06:59:16 +000020#include "llvm/Instructions.h"
Devang Patel517576d2009-04-15 00:17:06 +000021#include "llvm/IntrinsicInst.h"
Chris Lattner80a38d22003-08-24 06:59:16 +000022#include "llvm/Intrinsics.h"
Devang Pateleaf42ab2008-09-23 23:03:40 +000023#include "llvm/Attributes.h"
Chris Lattner468fb1d2006-01-14 20:07:50 +000024#include "llvm/Analysis/CallGraph.h"
Devang Patel517576d2009-04-15 00:17:06 +000025#include "llvm/Analysis/DebugInfo.h"
Chris Lattnerc93adca2008-01-11 06:09:30 +000026#include "llvm/Target/TargetData.h"
Chris Lattner93e985f2007-02-13 02:10:56 +000027#include "llvm/ADT/SmallVector.h"
Devang Patel641ca932008-03-10 18:22:16 +000028#include "llvm/ADT/StringExtras.h"
Chris Lattner80a38d22003-08-24 06:59:16 +000029#include "llvm/Support/CallSite.h"
Chris Lattnerf7703df2004-01-09 06:12:26 +000030using namespace llvm;
Chris Lattnerca398dc2003-05-29 15:11:31 +000031
Chris Lattner1dfdf822007-01-30 23:22:39 +000032bool llvm::InlineFunction(CallInst *CI, CallGraph *CG, const TargetData *TD) {
33 return InlineFunction(CallSite(CI), CG, TD);
Chris Lattner468fb1d2006-01-14 20:07:50 +000034}
Chris Lattner1dfdf822007-01-30 23:22:39 +000035bool llvm::InlineFunction(InvokeInst *II, CallGraph *CG, const TargetData *TD) {
36 return InlineFunction(CallSite(II), CG, TD);
Chris Lattner468fb1d2006-01-14 20:07:50 +000037}
Chris Lattner80a38d22003-08-24 06:59:16 +000038
Chris Lattner135755d2009-08-27 03:51:50 +000039
40/// HandleCallsInBlockInlinedThroughInvoke - When we inline a basic block into
41/// an invoke, we have to check all of all of the calls that can throw into
42/// invokes. This function analyze BB to see if there are any calls, and if so,
43/// it rewrites them to be invokes that jump to InvokeDest and fills in the PHI
44/// nodes in that block with the values specified in InvokeDestPHIValues. If
45/// CallerCGN is specified, this function updates the call graph.
46///
47static void HandleCallsInBlockInlinedThroughInvoke(BasicBlock *BB,
48 BasicBlock *InvokeDest,
49 const SmallVectorImpl<Value*> &InvokeDestPHIValues,
50 CallGraphNode *CallerCGN) {
51 for (BasicBlock::iterator BBI = BB->begin(), E = BB->end(); BBI != E; ) {
52 Instruction *I = BBI++;
53
54 // We only need to check for function calls: inlined invoke
55 // instructions require no special handling.
56 CallInst *CI = dyn_cast<CallInst>(I);
57 if (CI == 0) continue;
58
59 // If this call cannot unwind, don't convert it to an invoke.
60 if (CI->doesNotThrow())
61 continue;
62
63 // Convert this function call into an invoke instruction.
64 // First, split the basic block.
65 BasicBlock *Split = BB->splitBasicBlock(CI, CI->getName()+".noexc");
66
67 // Next, create the new invoke instruction, inserting it at the end
68 // of the old basic block.
69 SmallVector<Value*, 8> InvokeArgs(CI->op_begin()+1, CI->op_end());
70 InvokeInst *II =
71 InvokeInst::Create(CI->getCalledValue(), Split, InvokeDest,
72 InvokeArgs.begin(), InvokeArgs.end(),
73 CI->getName(), BB->getTerminator());
74 II->setCallingConv(CI->getCallingConv());
75 II->setAttributes(CI->getAttributes());
76
77 // Make sure that anything using the call now uses the invoke!
78 CI->replaceAllUsesWith(II);
79
80 // Update the callgraph if present.
81 if (CallerCGN) {
82 // We should be able to do this:
83 // (*CG)[Caller]->replaceCallSite(CI, II);
84 // but that fails if the old call site isn't in the call graph,
85 // which, because of LLVM bug 3601, it sometimes isn't.
86 for (CallGraphNode::iterator NI = CallerCGN->begin(), NE = CallerCGN->end();
87 NI != NE; ++NI) {
88 if (NI->first == CI) {
89 NI->first = II;
90 break;
91 }
92 }
93 }
94
95 // Delete the unconditional branch inserted by splitBasicBlock
96 BB->getInstList().pop_back();
97 Split->getInstList().pop_front(); // Delete the original call
98
99 // Update any PHI nodes in the exceptional block to indicate that
100 // there is now a new entry in them.
101 unsigned i = 0;
102 for (BasicBlock::iterator I = InvokeDest->begin();
103 isa<PHINode>(I); ++I, ++i)
104 cast<PHINode>(I)->addIncoming(InvokeDestPHIValues[i], BB);
105
106 // This basic block is now complete, the caller will continue scanning the
107 // next one.
108 return;
109 }
110}
111
112
Chris Lattnercd4d3392006-01-13 19:05:59 +0000113/// HandleInlinedInvoke - If we inlined an invoke site, we need to convert calls
114/// in the body of the inlined function into invokes and turn unwind
115/// instructions into branches to the invoke unwind dest.
116///
Nick Lewyckydac5c4b2009-02-03 04:34:40 +0000117/// II is the invoke instruction being inlined. FirstNewBlock is the first
Chris Lattnercd4d3392006-01-13 19:05:59 +0000118/// block of the inlined code (the last block is the end of the function),
119/// and InlineCodeInfo is information about the code that got inlined.
120static void HandleInlinedInvoke(InvokeInst *II, BasicBlock *FirstNewBlock,
Devang Patel28c531c2009-03-31 17:36:12 +0000121 ClonedCodeInfo &InlinedCodeInfo,
122 CallGraph *CG) {
Chris Lattnercd4d3392006-01-13 19:05:59 +0000123 BasicBlock *InvokeDest = II->getUnwindDest();
Chris Lattner135755d2009-08-27 03:51:50 +0000124 SmallVector<Value*, 8> InvokeDestPHIValues;
Chris Lattnercd4d3392006-01-13 19:05:59 +0000125
126 // If there are PHI nodes in the unwind 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.
129 BasicBlock *InvokeBlock = II->getParent();
130 for (BasicBlock::iterator I = InvokeDest->begin(); isa<PHINode>(I); ++I) {
131 PHINode *PN = cast<PHINode>(I);
132 // Save the value to use for this edge.
133 InvokeDestPHIValues.push_back(PN->getIncomingValueForBlock(InvokeBlock));
134 }
135
136 Function *Caller = FirstNewBlock->getParent();
Duncan Sandsa7212e52008-09-05 12:37:12 +0000137
Chris Lattnercd4d3392006-01-13 19:05:59 +0000138 // The inlined code is currently at the end of the function, scan from the
139 // start of the inlined code to its end, checking for stuff we need to
Chris Lattner135755d2009-08-27 03:51:50 +0000140 // rewrite. If the code doesn't have calls or unwinds, we know there is
141 // nothing to rewrite.
142 if (!InlinedCodeInfo.ContainsCalls && !InlinedCodeInfo.ContainsUnwinds) {
143 // Now that everything is happy, we have one final detail. The PHI nodes in
144 // the exception destination block still have entries due to the original
145 // invoke instruction. Eliminate these entries (which might even delete the
146 // PHI node) now.
147 InvokeDest->removePredecessor(II->getParent());
148 return;
149 }
150
151 CallGraphNode *CallerCGN = 0;
152 if (CG) CallerCGN = (*CG)[Caller];
153
154 for (Function::iterator BB = FirstNewBlock, E = Caller->end(); BB != E; ++BB){
155 if (InlinedCodeInfo.ContainsCalls)
156 HandleCallsInBlockInlinedThroughInvoke(BB, InvokeDest,
157 InvokeDestPHIValues, CallerCGN);
Duncan Sandsa7212e52008-09-05 12:37:12 +0000158
Chris Lattner135755d2009-08-27 03:51:50 +0000159 if (UnwindInst *UI = dyn_cast<UnwindInst>(BB->getTerminator())) {
160 // An UnwindInst requires special handling when it gets inlined into an
161 // invoke site. Once this happens, we know that the unwind would cause
162 // a control transfer to the invoke exception destination, so we can
163 // transform it into a direct branch to the exception destination.
164 BranchInst::Create(InvokeDest, UI);
Chris Lattnercd4d3392006-01-13 19:05:59 +0000165
Chris Lattner135755d2009-08-27 03:51:50 +0000166 // Delete the unwind instruction!
167 UI->eraseFromParent();
Duncan Sandsa3355ff2007-12-03 20:06:50 +0000168
Chris Lattner135755d2009-08-27 03:51:50 +0000169 // Update any PHI nodes in the exceptional block to indicate that
170 // there is now a new entry in them.
171 unsigned i = 0;
172 for (BasicBlock::iterator I = InvokeDest->begin();
173 isa<PHINode>(I); ++I, ++i) {
174 PHINode *PN = cast<PHINode>(I);
175 PN->addIncoming(InvokeDestPHIValues[i], BB);
Chris Lattnercd4d3392006-01-13 19:05:59 +0000176 }
177 }
178 }
179
180 // Now that everything is happy, we have one final detail. The PHI nodes in
181 // the exception destination block still have entries due to the original
182 // invoke instruction. Eliminate these entries (which might even delete the
183 // PHI node) now.
184 InvokeDest->removePredecessor(II->getParent());
185}
186
Chris Lattnerd85340f2006-07-12 18:29:36 +0000187/// UpdateCallGraphAfterInlining - Once we have cloned code over from a callee
188/// into the caller, update the specified callgraph to reflect the changes we
189/// made. Note that it's possible that not all code was copied over, so only
Duncan Sandsd7b98512008-09-08 11:05:51 +0000190/// some edges of the callgraph may remain.
191static void UpdateCallGraphAfterInlining(CallSite CS,
Chris Lattnerd85340f2006-07-12 18:29:36 +0000192 Function::iterator FirstNewBlock,
Chris Lattner5e665f52007-02-03 00:08:31 +0000193 DenseMap<const Value*, Value*> &ValueMap,
Chris Lattner468fb1d2006-01-14 20:07:50 +0000194 CallGraph &CG) {
Duncan Sandsd7b98512008-09-08 11:05:51 +0000195 const Function *Caller = CS.getInstruction()->getParent()->getParent();
196 const Function *Callee = CS.getCalledFunction();
Chris Lattner468fb1d2006-01-14 20:07:50 +0000197 CallGraphNode *CalleeNode = CG[Callee];
198 CallGraphNode *CallerNode = CG[Caller];
Duncan Sandsa7212e52008-09-05 12:37:12 +0000199
Chris Lattnerd85340f2006-07-12 18:29:36 +0000200 // Since we inlined some uninlined call sites in the callee into the caller,
Chris Lattner468fb1d2006-01-14 20:07:50 +0000201 // add edges from the caller to all of the callees of the callee.
Gabor Greifc478e522009-01-15 18:40:09 +0000202 CallGraphNode::iterator I = CalleeNode->begin(), E = CalleeNode->end();
203
204 // Consider the case where CalleeNode == CallerNode.
Gabor Greif12532982009-01-17 00:09:08 +0000205 CallGraphNode::CalledFunctionsVector CallCache;
Gabor Greifc478e522009-01-15 18:40:09 +0000206 if (CalleeNode == CallerNode) {
207 CallCache.assign(I, E);
208 I = CallCache.begin();
209 E = CallCache.end();
210 }
211
212 for (; I != E; ++I) {
Chris Lattnerd85340f2006-07-12 18:29:36 +0000213 const Instruction *OrigCall = I->first.getInstruction();
Duncan Sandsa7212e52008-09-05 12:37:12 +0000214
Chris Lattner5e665f52007-02-03 00:08:31 +0000215 DenseMap<const Value*, Value*>::iterator VMI = ValueMap.find(OrigCall);
Chris Lattner981418b2006-07-12 21:37:11 +0000216 // Only copy the edge if the call was inlined!
Chris Lattner135755d2009-08-27 03:51:50 +0000217 if (VMI == ValueMap.end() || VMI->second == 0)
218 continue;
219
220 // If the call was inlined, but then constant folded, there is no edge to
221 // add. Check for this case.
222 if (Instruction *NewCall = dyn_cast<Instruction>(VMI->second))
223 CallerNode->addCalledFunction(CallSite::get(NewCall), I->second);
Chris Lattnerd85340f2006-07-12 18:29:36 +0000224 }
Chris Lattner135755d2009-08-27 03:51:50 +0000225
Dale Johannesen39fa3242009-01-13 22:43:37 +0000226 // Update the call graph by deleting the edge from Callee to Caller. We must
227 // do this after the loop above in case Caller and Callee are the same.
228 CallerNode->removeCallEdgeFor(CS);
Chris Lattner468fb1d2006-01-14 20:07:50 +0000229}
230
Devang Patel517576d2009-04-15 00:17:06 +0000231/// findFnRegionEndMarker - This is a utility routine that is used by
232/// InlineFunction. Return llvm.dbg.region.end intrinsic that corresponds
233/// to the llvm.dbg.func.start of the function F. Otherwise return NULL.
Chris Lattner135755d2009-08-27 03:51:50 +0000234///
Devang Patel517576d2009-04-15 00:17:06 +0000235static const DbgRegionEndInst *findFnRegionEndMarker(const Function *F) {
236
Devang Patel82459882009-08-26 05:01:18 +0000237 GlobalVariable *FnStart = NULL;
Devang Patel517576d2009-04-15 00:17:06 +0000238 const DbgRegionEndInst *FnEnd = NULL;
239 for (Function::const_iterator FI = F->begin(), FE =F->end(); FI != FE; ++FI)
240 for (BasicBlock::const_iterator BI = FI->begin(), BE = FI->end(); BI != BE;
241 ++BI) {
242 if (FnStart == NULL) {
243 if (const DbgFuncStartInst *FSI = dyn_cast<DbgFuncStartInst>(BI)) {
Devang Patel82459882009-08-26 05:01:18 +0000244 DISubprogram SP(cast<GlobalVariable>(FSI->getSubprogram()));
Devang Patel517576d2009-04-15 00:17:06 +0000245 assert (SP.isNull() == false && "Invalid llvm.dbg.func.start");
246 if (SP.describes(F))
Devang Patel82459882009-08-26 05:01:18 +0000247 FnStart = SP.getGV();
Devang Patel517576d2009-04-15 00:17:06 +0000248 }
Chris Lattner135755d2009-08-27 03:51:50 +0000249 continue;
Devang Patel517576d2009-04-15 00:17:06 +0000250 }
Chris Lattner135755d2009-08-27 03:51:50 +0000251
252 if (const DbgRegionEndInst *REI = dyn_cast<DbgRegionEndInst>(BI))
253 if (REI->getContext() == FnStart)
254 FnEnd = REI;
Devang Patel517576d2009-04-15 00:17:06 +0000255 }
256 return FnEnd;
257}
Chris Lattnercd4d3392006-01-13 19:05:59 +0000258
Chris Lattnerca398dc2003-05-29 15:11:31 +0000259// InlineFunction - This function inlines the called function into the basic
260// block of the caller. This returns false if it is not possible to inline this
261// call. The program is still in a well defined state if this occurs though.
262//
Misha Brukmanfd939082005-04-21 23:48:37 +0000263// Note that this only does one level of inlining. For example, if the
264// instruction 'call B' is inlined, and 'B' calls 'C', then the call to 'C' now
Chris Lattnerca398dc2003-05-29 15:11:31 +0000265// exists in the instruction stream. Similiarly this will inline a recursive
266// function by one level.
267//
Chris Lattner1dfdf822007-01-30 23:22:39 +0000268bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
Chris Lattner80a38d22003-08-24 06:59:16 +0000269 Instruction *TheCall = CS.getInstruction();
Owen Andersone922c022009-07-22 00:24:57 +0000270 LLVMContext &Context = TheCall->getContext();
Chris Lattner80a38d22003-08-24 06:59:16 +0000271 assert(TheCall->getParent() && TheCall->getParent()->getParent() &&
272 "Instruction not in function!");
Chris Lattnerca398dc2003-05-29 15:11:31 +0000273
Chris Lattner80a38d22003-08-24 06:59:16 +0000274 const Function *CalledFunc = CS.getCalledFunction();
Chris Lattnerca398dc2003-05-29 15:11:31 +0000275 if (CalledFunc == 0 || // Can't inline external function or indirect
Reid Spencer5cbf9852007-01-30 20:08:39 +0000276 CalledFunc->isDeclaration() || // call, or call to a vararg function!
Chris Lattnerca398dc2003-05-29 15:11:31 +0000277 CalledFunc->getFunctionType()->isVarArg()) return false;
278
Chris Lattner1b491412005-05-06 06:47:52 +0000279
Chris Lattneraf9985c2009-02-12 07:06:42 +0000280 // If the call to the callee is not a tail call, we must clear the 'tail'
Chris Lattner1b491412005-05-06 06:47:52 +0000281 // flags on any calls that we inline.
282 bool MustClearTailCallFlags =
Chris Lattneraf9985c2009-02-12 07:06:42 +0000283 !(isa<CallInst>(TheCall) && cast<CallInst>(TheCall)->isTailCall());
Chris Lattner1b491412005-05-06 06:47:52 +0000284
Duncan Sandsf0c33542007-12-19 21:13:37 +0000285 // If the call to the callee cannot throw, set the 'nounwind' flag on any
286 // calls that we inline.
287 bool MarkNoUnwind = CS.doesNotThrow();
288
Chris Lattner80a38d22003-08-24 06:59:16 +0000289 BasicBlock *OrigBB = TheCall->getParent();
Chris Lattnerca398dc2003-05-29 15:11:31 +0000290 Function *Caller = OrigBB->getParent();
291
Gordon Henriksen0e138212007-12-25 03:10:07 +0000292 // GC poses two hazards to inlining, which only occur when the callee has GC:
293 // 1. If the caller has no GC, then the callee's GC must be propagated to the
294 // caller.
295 // 2. If the caller has a differing GC, it is invalid to inline.
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000296 if (CalledFunc->hasGC()) {
297 if (!Caller->hasGC())
298 Caller->setGC(CalledFunc->getGC());
299 else if (CalledFunc->getGC() != Caller->getGC())
Gordon Henriksen0e138212007-12-25 03:10:07 +0000300 return false;
301 }
Duncan Sandsa7212e52008-09-05 12:37:12 +0000302
Chris Lattner5052c912004-02-04 01:41:09 +0000303 // Get an iterator to the last basic block in the function, which will have
304 // the new function inlined after it.
305 //
306 Function::iterator LastBlock = &Caller->back();
307
Chris Lattner5e923de2004-02-04 02:51:48 +0000308 // Make sure to capture all of the return instructions from the cloned
Chris Lattnerca398dc2003-05-29 15:11:31 +0000309 // function.
Chris Lattnerec1bea02009-08-27 04:02:30 +0000310 SmallVector<ReturnInst*, 8> Returns;
Chris Lattnercd4d3392006-01-13 19:05:59 +0000311 ClonedCodeInfo InlinedFunctionInfo;
Dale Johannesen0744f092009-03-04 02:09:48 +0000312 Function::iterator FirstNewBlock;
Duncan Sandsf0c33542007-12-19 21:13:37 +0000313
Chris Lattner5e923de2004-02-04 02:51:48 +0000314 { // Scope to destroy ValueMap after cloning.
Chris Lattner5e665f52007-02-03 00:08:31 +0000315 DenseMap<const Value*, Value*> ValueMap;
Chris Lattner5b5bc302006-05-27 01:28:04 +0000316
Dan Gohman9614fcc2008-06-20 17:11:32 +0000317 assert(CalledFunc->arg_size() == CS.arg_size() &&
Chris Lattner5e923de2004-02-04 02:51:48 +0000318 "No varargs calls can be inlined!");
Duncan Sandsa7212e52008-09-05 12:37:12 +0000319
Chris Lattnerc93adca2008-01-11 06:09:30 +0000320 // Calculate the vector of arguments to pass into the function cloner, which
321 // matches up the formal to the actual argument values.
Chris Lattner5e923de2004-02-04 02:51:48 +0000322 CallSite::arg_iterator AI = CS.arg_begin();
Chris Lattnerc93adca2008-01-11 06:09:30 +0000323 unsigned ArgNo = 0;
Chris Lattnere4d5c442005-03-15 04:54:21 +0000324 for (Function::const_arg_iterator I = CalledFunc->arg_begin(),
Chris Lattnerc93adca2008-01-11 06:09:30 +0000325 E = CalledFunc->arg_end(); I != E; ++I, ++AI, ++ArgNo) {
326 Value *ActualArg = *AI;
Duncan Sandsa7212e52008-09-05 12:37:12 +0000327
Duncan Sandsd82375c2008-01-27 18:12:58 +0000328 // When byval arguments actually inlined, we need to make the copy implied
329 // by them explicit. However, we don't do this if the callee is readonly
330 // or readnone, because the copy would be unneeded: the callee doesn't
331 // modify the struct.
Devang Patel05988662008-09-25 21:00:45 +0000332 if (CalledFunc->paramHasAttr(ArgNo+1, Attribute::ByVal) &&
Duncan Sandsd82375c2008-01-27 18:12:58 +0000333 !CalledFunc->onlyReadsMemory()) {
Chris Lattnerc93adca2008-01-11 06:09:30 +0000334 const Type *AggTy = cast<PointerType>(I->getType())->getElementType();
Owen Anderson1d0be152009-08-13 21:58:54 +0000335 const Type *VoidPtrTy =
336 PointerType::getUnqual(Type::getInt8Ty(Context));
Duncan Sandsa7212e52008-09-05 12:37:12 +0000337
Chris Lattnerc93adca2008-01-11 06:09:30 +0000338 // Create the alloca. If we have TargetData, use nice alignment.
339 unsigned Align = 1;
340 if (TD) Align = TD->getPrefTypeAlignment(AggTy);
Owen Anderson50dead02009-07-15 23:53:25 +0000341 Value *NewAlloca = new AllocaInst(AggTy, 0, Align,
Owen Anderson9adc0ab2009-07-14 23:09:55 +0000342 I->getName(),
343 &*Caller->begin()->begin());
Chris Lattnerc93adca2008-01-11 06:09:30 +0000344 // Emit a memcpy.
Owen Anderson1d0be152009-08-13 21:58:54 +0000345 const Type *Tys[] = { Type::getInt64Ty(Context) };
Chris Lattnerc93adca2008-01-11 06:09:30 +0000346 Function *MemCpyFn = Intrinsic::getDeclaration(Caller->getParent(),
Chris Lattner824b9582008-11-21 16:42:48 +0000347 Intrinsic::memcpy,
348 Tys, 1);
Chris Lattnerc93adca2008-01-11 06:09:30 +0000349 Value *DestCast = new BitCastInst(NewAlloca, VoidPtrTy, "tmp", TheCall);
350 Value *SrcCast = new BitCastInst(*AI, VoidPtrTy, "tmp", TheCall);
Duncan Sandsa7212e52008-09-05 12:37:12 +0000351
Chris Lattnerc93adca2008-01-11 06:09:30 +0000352 Value *Size;
353 if (TD == 0)
Owen Andersonbaf3c402009-07-29 18:55:55 +0000354 Size = ConstantExpr::getSizeOf(AggTy);
Chris Lattnerc93adca2008-01-11 06:09:30 +0000355 else
Owen Anderson1d0be152009-08-13 21:58:54 +0000356 Size = ConstantInt::get(Type::getInt64Ty(Context),
Owen Anderson0a205a42009-07-05 22:41:43 +0000357 TD->getTypeStoreSize(AggTy));
Duncan Sandsa7212e52008-09-05 12:37:12 +0000358
Chris Lattnerc93adca2008-01-11 06:09:30 +0000359 // Always generate a memcpy of alignment 1 here because we don't know
360 // the alignment of the src pointer. Other optimizations can infer
361 // better alignment.
362 Value *CallArgs[] = {
Owen Anderson1d0be152009-08-13 21:58:54 +0000363 DestCast, SrcCast, Size,
364 ConstantInt::get(Type::getInt32Ty(Context), 1)
Chris Lattnerc93adca2008-01-11 06:09:30 +0000365 };
366 CallInst *TheMemCpy =
Gabor Greif051a9502008-04-06 20:25:17 +0000367 CallInst::Create(MemCpyFn, CallArgs, CallArgs+4, "", TheCall);
Duncan Sandsa7212e52008-09-05 12:37:12 +0000368
Chris Lattnerc93adca2008-01-11 06:09:30 +0000369 // If we have a call graph, update it.
370 if (CG) {
371 CallGraphNode *MemCpyCGN = CG->getOrInsertFunction(MemCpyFn);
372 CallGraphNode *CallerNode = (*CG)[Caller];
373 CallerNode->addCalledFunction(TheMemCpy, MemCpyCGN);
374 }
Duncan Sandsa7212e52008-09-05 12:37:12 +0000375
Chris Lattnerc93adca2008-01-11 06:09:30 +0000376 // Uses of the argument in the function should use our new alloca
377 // instead.
378 ActualArg = NewAlloca;
379 }
Duncan Sandsa7212e52008-09-05 12:37:12 +0000380
Chris Lattnerc93adca2008-01-11 06:09:30 +0000381 ValueMap[I] = ActualArg;
382 }
Misha Brukmanfd939082005-04-21 23:48:37 +0000383
Devang Patel517576d2009-04-15 00:17:06 +0000384 // Adjust llvm.dbg.region.end. If the CalledFunc has region end
385 // marker then clone that marker after next stop point at the
386 // call site. The function body cloner does not clone original
387 // region end marker from the CalledFunc. This will ensure that
388 // inlined function's scope ends at the right place.
Chris Lattner135755d2009-08-27 03:51:50 +0000389 if (const DbgRegionEndInst *DREI = findFnRegionEndMarker(CalledFunc)) {
390 for (BasicBlock::iterator BI = TheCall, BE = TheCall->getParent()->end();
391 BI != BE; ++BI) {
Devang Patel517576d2009-04-15 00:17:06 +0000392 if (DbgStopPointInst *DSPI = dyn_cast<DbgStopPointInst>(BI)) {
393 if (DbgRegionEndInst *NewDREI =
Chris Lattner135755d2009-08-27 03:51:50 +0000394 dyn_cast<DbgRegionEndInst>(DREI->clone(Context)))
Devang Patel517576d2009-04-15 00:17:06 +0000395 NewDREI->insertAfter(DSPI);
396 break;
397 }
398 }
399 }
400
Chris Lattner5b5bc302006-05-27 01:28:04 +0000401 // We want the inliner to prune the code as it copies. We would LOVE to
402 // have no dead or constant instructions leftover after inlining occurs
403 // (which can happen, e.g., because an argument was constant), but we'll be
404 // happy with whatever the cloner can do.
405 CloneAndPruneFunctionInto(Caller, CalledFunc, ValueMap, Returns, ".i",
Chris Lattner1dfdf822007-01-30 23:22:39 +0000406 &InlinedFunctionInfo, TD);
Duncan Sandsa7212e52008-09-05 12:37:12 +0000407
Chris Lattnerd85340f2006-07-12 18:29:36 +0000408 // Remember the first block that is newly cloned over.
409 FirstNewBlock = LastBlock; ++FirstNewBlock;
Duncan Sandsa7212e52008-09-05 12:37:12 +0000410
Chris Lattnerd85340f2006-07-12 18:29:36 +0000411 // Update the callgraph if requested.
412 if (CG)
Duncan Sandsd7b98512008-09-08 11:05:51 +0000413 UpdateCallGraphAfterInlining(CS, FirstNewBlock, ValueMap, *CG);
Misha Brukmanfd939082005-04-21 23:48:37 +0000414 }
Duncan Sandsa7212e52008-09-05 12:37:12 +0000415
Chris Lattnerca398dc2003-05-29 15:11:31 +0000416 // If there are any alloca instructions in the block that used to be the entry
417 // block for the callee, move them to the entry block of the caller. First
418 // calculate which instruction they should be inserted before. We insert the
419 // instructions at the end of the current alloca list.
420 //
Chris Lattner21f20552006-01-13 18:16:48 +0000421 {
Chris Lattner80a38d22003-08-24 06:59:16 +0000422 BasicBlock::iterator InsertPoint = Caller->begin()->begin();
Chris Lattner5e923de2004-02-04 02:51:48 +0000423 for (BasicBlock::iterator I = FirstNewBlock->begin(),
Chris Lattner135755d2009-08-27 03:51:50 +0000424 E = FirstNewBlock->end(); I != E; ) {
425 AllocaInst *AI = dyn_cast<AllocaInst>(I++);
426 if (AI == 0) continue;
427
428 // If the alloca is now dead, remove it. This often occurs due to code
429 // specialization.
430 if (AI->use_empty()) {
431 AI->eraseFromParent();
432 continue;
Chris Lattner33bb3c82006-09-13 19:23:57 +0000433 }
Chris Lattner135755d2009-08-27 03:51:50 +0000434
435 if (!isa<Constant>(AI->getArraySize()))
436 continue;
437
438 // Scan for the block of allocas that we can move over, and move them
439 // all at once.
440 while (isa<AllocaInst>(I) &&
441 isa<Constant>(cast<AllocaInst>(I)->getArraySize()))
442 ++I;
443
444 // Transfer all of the allocas over in a block. Using splice means
445 // that the instructions aren't removed from the symbol table, then
446 // reinserted.
447 Caller->getEntryBlock().getInstList().splice(InsertPoint,
448 FirstNewBlock->getInstList(),
449 AI, I);
450 }
Chris Lattner80a38d22003-08-24 06:59:16 +0000451 }
Chris Lattnerca398dc2003-05-29 15:11:31 +0000452
Chris Lattnerbf229f42006-01-13 19:34:14 +0000453 // If the inlined code contained dynamic alloca instructions, wrap the inlined
454 // code with llvm.stacksave/llvm.stackrestore intrinsics.
455 if (InlinedFunctionInfo.ContainsDynamicAllocas) {
456 Module *M = Caller->getParent();
Chris Lattnerbf229f42006-01-13 19:34:14 +0000457 // Get the two intrinsics we care about.
Chris Lattnera121fdd2007-01-07 07:54:34 +0000458 Constant *StackSave, *StackRestore;
Duncan Sands3d292ac2008-04-07 13:43:58 +0000459 StackSave = Intrinsic::getDeclaration(M, Intrinsic::stacksave);
460 StackRestore = Intrinsic::getDeclaration(M, Intrinsic::stackrestore);
Chris Lattnerd85340f2006-07-12 18:29:36 +0000461
462 // If we are preserving the callgraph, add edges to the stacksave/restore
463 // functions for the calls we insert.
Chris Lattner21ba23d2006-07-18 21:48:57 +0000464 CallGraphNode *StackSaveCGN = 0, *StackRestoreCGN = 0, *CallerNode = 0;
Chris Lattnerd85340f2006-07-12 18:29:36 +0000465 if (CG) {
Chris Lattnera121fdd2007-01-07 07:54:34 +0000466 // We know that StackSave/StackRestore are Function*'s, because they are
467 // intrinsics which must have the right types.
468 StackSaveCGN = CG->getOrInsertFunction(cast<Function>(StackSave));
469 StackRestoreCGN = CG->getOrInsertFunction(cast<Function>(StackRestore));
Chris Lattnerd85340f2006-07-12 18:29:36 +0000470 CallerNode = (*CG)[Caller];
471 }
Duncan Sandsa7212e52008-09-05 12:37:12 +0000472
Chris Lattnerbf229f42006-01-13 19:34:14 +0000473 // Insert the llvm.stacksave.
Duncan Sandsa7212e52008-09-05 12:37:12 +0000474 CallInst *SavedPtr = CallInst::Create(StackSave, "savedstack",
Gabor Greif051a9502008-04-06 20:25:17 +0000475 FirstNewBlock->begin());
Chris Lattnerd85340f2006-07-12 18:29:36 +0000476 if (CG) CallerNode->addCalledFunction(SavedPtr, StackSaveCGN);
Duncan Sandsa7212e52008-09-05 12:37:12 +0000477
Chris Lattnerbf229f42006-01-13 19:34:14 +0000478 // Insert a call to llvm.stackrestore before any return instructions in the
479 // inlined function.
Chris Lattnerd85340f2006-07-12 18:29:36 +0000480 for (unsigned i = 0, e = Returns.size(); i != e; ++i) {
Gabor Greif051a9502008-04-06 20:25:17 +0000481 CallInst *CI = CallInst::Create(StackRestore, SavedPtr, "", Returns[i]);
Chris Lattnerd85340f2006-07-12 18:29:36 +0000482 if (CG) CallerNode->addCalledFunction(CI, StackRestoreCGN);
483 }
Chris Lattner468fb1d2006-01-14 20:07:50 +0000484
485 // Count the number of StackRestore calls we insert.
486 unsigned NumStackRestores = Returns.size();
Duncan Sandsa7212e52008-09-05 12:37:12 +0000487
Chris Lattnerbf229f42006-01-13 19:34:14 +0000488 // If we are inlining an invoke instruction, insert restores before each
489 // unwind. These unwinds will be rewritten into branches later.
490 if (InlinedFunctionInfo.ContainsUnwinds && isa<InvokeInst>(TheCall)) {
491 for (Function::iterator BB = FirstNewBlock, E = Caller->end();
492 BB != E; ++BB)
Chris Lattner468fb1d2006-01-14 20:07:50 +0000493 if (UnwindInst *UI = dyn_cast<UnwindInst>(BB->getTerminator())) {
Duncan Sands3d292ac2008-04-07 13:43:58 +0000494 CallInst::Create(StackRestore, SavedPtr, "", UI);
Chris Lattner468fb1d2006-01-14 20:07:50 +0000495 ++NumStackRestores;
496 }
497 }
Chris Lattnerbf229f42006-01-13 19:34:14 +0000498 }
499
Duncan Sandsa7212e52008-09-05 12:37:12 +0000500 // If we are inlining tail call instruction through a call site that isn't
Chris Lattner1fdf4a82006-01-13 19:18:11 +0000501 // marked 'tail', we must remove the tail marker for any calls in the inlined
Duncan Sandsf0c33542007-12-19 21:13:37 +0000502 // code. Also, calls inlined through a 'nounwind' call site should be marked
503 // 'nounwind'.
504 if (InlinedFunctionInfo.ContainsCalls &&
505 (MustClearTailCallFlags || MarkNoUnwind)) {
Chris Lattner1b491412005-05-06 06:47:52 +0000506 for (Function::iterator BB = FirstNewBlock, E = Caller->end();
507 BB != E; ++BB)
508 for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
Duncan Sandsf0c33542007-12-19 21:13:37 +0000509 if (CallInst *CI = dyn_cast<CallInst>(I)) {
510 if (MustClearTailCallFlags)
511 CI->setTailCall(false);
512 if (MarkNoUnwind)
513 CI->setDoesNotThrow();
514 }
Chris Lattner1b491412005-05-06 06:47:52 +0000515 }
516
Duncan Sandsf0c33542007-12-19 21:13:37 +0000517 // If we are inlining through a 'nounwind' call site then any inlined 'unwind'
518 // instructions are unreachable.
519 if (InlinedFunctionInfo.ContainsUnwinds && MarkNoUnwind)
520 for (Function::iterator BB = FirstNewBlock, E = Caller->end();
521 BB != E; ++BB) {
522 TerminatorInst *Term = BB->getTerminator();
523 if (isa<UnwindInst>(Term)) {
Owen Anderson1d0be152009-08-13 21:58:54 +0000524 new UnreachableInst(Context, Term);
Duncan Sandsf0c33542007-12-19 21:13:37 +0000525 BB->getInstList().erase(Term);
526 }
527 }
528
Chris Lattner5e923de2004-02-04 02:51:48 +0000529 // If we are inlining for an invoke instruction, we must make sure to rewrite
530 // any inlined 'unwind' instructions into branches to the invoke exception
531 // destination, and call instructions into invoke instructions.
Chris Lattnercd4d3392006-01-13 19:05:59 +0000532 if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall))
Devang Patel28c531c2009-03-31 17:36:12 +0000533 HandleInlinedInvoke(II, FirstNewBlock, InlinedFunctionInfo, CG);
Chris Lattner5e923de2004-02-04 02:51:48 +0000534
Chris Lattner44a68072004-02-04 04:17:06 +0000535 // If we cloned in _exactly one_ basic block, and if that block ends in a
536 // return instruction, we splice the body of the inlined callee directly into
537 // the calling basic block.
538 if (Returns.size() == 1 && std::distance(FirstNewBlock, Caller->end()) == 1) {
539 // Move all of the instructions right before the call.
540 OrigBB->getInstList().splice(TheCall, FirstNewBlock->getInstList(),
541 FirstNewBlock->begin(), FirstNewBlock->end());
542 // Remove the cloned basic block.
543 Caller->getBasicBlockList().pop_back();
Misha Brukmanfd939082005-04-21 23:48:37 +0000544
Chris Lattner44a68072004-02-04 04:17:06 +0000545 // If the call site was an invoke instruction, add a branch to the normal
546 // destination.
547 if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall))
Gabor Greif051a9502008-04-06 20:25:17 +0000548 BranchInst::Create(II->getNormalDest(), TheCall);
Chris Lattner44a68072004-02-04 04:17:06 +0000549
550 // If the return instruction returned a value, replace uses of the call with
551 // uses of the returned value.
Devang Pateldc00d422008-03-04 21:15:15 +0000552 if (!TheCall->use_empty()) {
553 ReturnInst *R = Returns[0];
Eli Friedman5877ad72009-05-08 00:22:04 +0000554 if (TheCall == R->getReturnValue())
Owen Anderson9e9a0d52009-07-30 23:03:37 +0000555 TheCall->replaceAllUsesWith(UndefValue::get(TheCall->getType()));
Eli Friedman5877ad72009-05-08 00:22:04 +0000556 else
557 TheCall->replaceAllUsesWith(R->getReturnValue());
Devang Pateldc00d422008-03-04 21:15:15 +0000558 }
Chris Lattner44a68072004-02-04 04:17:06 +0000559 // Since we are now done with the Call/Invoke, we can delete it.
Dan Gohman1adec832008-06-21 22:08:46 +0000560 TheCall->eraseFromParent();
Chris Lattner44a68072004-02-04 04:17:06 +0000561
562 // Since we are now done with the return instruction, delete it also.
Dan Gohman1adec832008-06-21 22:08:46 +0000563 Returns[0]->eraseFromParent();
Chris Lattner44a68072004-02-04 04:17:06 +0000564
565 // We are now done with the inlining.
566 return true;
567 }
568
569 // Otherwise, we have the normal case, of more than one block to inline or
570 // multiple return sites.
571
Chris Lattner5e923de2004-02-04 02:51:48 +0000572 // We want to clone the entire callee function into the hole between the
573 // "starter" and "ender" blocks. How we accomplish this depends on whether
574 // this is an invoke instruction or a call instruction.
575 BasicBlock *AfterCallBB;
576 if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall)) {
Misha Brukmanfd939082005-04-21 23:48:37 +0000577
Chris Lattner5e923de2004-02-04 02:51:48 +0000578 // Add an unconditional branch to make this look like the CallInst case...
Gabor Greif051a9502008-04-06 20:25:17 +0000579 BranchInst *NewBr = BranchInst::Create(II->getNormalDest(), TheCall);
Misha Brukmanfd939082005-04-21 23:48:37 +0000580
Chris Lattner5e923de2004-02-04 02:51:48 +0000581 // Split the basic block. This guarantees that no PHI nodes will have to be
582 // updated due to new incoming edges, and make the invoke case more
583 // symmetric to the call case.
584 AfterCallBB = OrigBB->splitBasicBlock(NewBr,
Chris Lattner284d1b82004-12-11 16:59:54 +0000585 CalledFunc->getName()+".exit");
Misha Brukmanfd939082005-04-21 23:48:37 +0000586
Chris Lattner5e923de2004-02-04 02:51:48 +0000587 } else { // It's a call
Chris Lattner44a68072004-02-04 04:17:06 +0000588 // If this is a call instruction, we need to split the basic block that
589 // the call lives in.
Chris Lattner5e923de2004-02-04 02:51:48 +0000590 //
591 AfterCallBB = OrigBB->splitBasicBlock(TheCall,
Chris Lattner284d1b82004-12-11 16:59:54 +0000592 CalledFunc->getName()+".exit");
Chris Lattner5e923de2004-02-04 02:51:48 +0000593 }
594
Chris Lattner44a68072004-02-04 04:17:06 +0000595 // Change the branch that used to go to AfterCallBB to branch to the first
596 // basic block of the inlined function.
597 //
598 TerminatorInst *Br = OrigBB->getTerminator();
Misha Brukmanfd939082005-04-21 23:48:37 +0000599 assert(Br && Br->getOpcode() == Instruction::Br &&
Chris Lattner44a68072004-02-04 04:17:06 +0000600 "splitBasicBlock broken!");
601 Br->setOperand(0, FirstNewBlock);
602
603
604 // Now that the function is correct, make it a little bit nicer. In
605 // particular, move the basic blocks inserted from the end of the function
606 // into the space made by splitting the source basic block.
Chris Lattner44a68072004-02-04 04:17:06 +0000607 Caller->getBasicBlockList().splice(AfterCallBB, Caller->getBasicBlockList(),
608 FirstNewBlock, Caller->end());
609
Chris Lattner5e923de2004-02-04 02:51:48 +0000610 // Handle all of the return instructions that we just cloned in, and eliminate
611 // any users of the original call/invoke instruction.
Devang Patelb8f198a2008-03-10 18:34:00 +0000612 const Type *RTy = CalledFunc->getReturnType();
Dan Gohman2c317502008-06-20 01:03:44 +0000613
Dan Gohmanfc74abf2008-07-23 00:34:11 +0000614 if (Returns.size() > 1) {
Chris Lattner5e923de2004-02-04 02:51:48 +0000615 // The PHI node should go at the front of the new basic block to merge all
616 // possible incoming values.
Dan Gohmanfc74abf2008-07-23 00:34:11 +0000617 PHINode *PHI = 0;
Chris Lattner5e923de2004-02-04 02:51:48 +0000618 if (!TheCall->use_empty()) {
Dan Gohmanfc74abf2008-07-23 00:34:11 +0000619 PHI = PHINode::Create(RTy, TheCall->getName(),
620 AfterCallBB->begin());
621 // Anything that used the result of the function call should now use the
622 // PHI node as their operand.
Duncan Sandsa7212e52008-09-05 12:37:12 +0000623 TheCall->replaceAllUsesWith(PHI);
Chris Lattner5e923de2004-02-04 02:51:48 +0000624 }
Misha Brukmanfd939082005-04-21 23:48:37 +0000625
Gabor Greifc478e522009-01-15 18:40:09 +0000626 // Loop over all of the return instructions adding entries to the PHI node
627 // as appropriate.
Dan Gohmanfc74abf2008-07-23 00:34:11 +0000628 if (PHI) {
629 for (unsigned i = 0, e = Returns.size(); i != e; ++i) {
630 ReturnInst *RI = Returns[i];
631 assert(RI->getReturnValue()->getType() == PHI->getType() &&
632 "Ret value not consistent in function!");
633 PHI->addIncoming(RI->getReturnValue(), RI->getParent());
Devang Patel12a466b2008-03-07 20:06:16 +0000634 }
635 }
636
Gabor Greifde62aea2009-01-16 23:08:50 +0000637 // Add a branch to the merge points and remove return instructions.
Chris Lattner5e923de2004-02-04 02:51:48 +0000638 for (unsigned i = 0, e = Returns.size(); i != e; ++i) {
639 ReturnInst *RI = Returns[i];
Dale Johannesen0744f092009-03-04 02:09:48 +0000640 BranchInst::Create(AfterCallBB, RI);
Devang Patelb8f198a2008-03-10 18:34:00 +0000641 RI->eraseFromParent();
Chris Lattner5e923de2004-02-04 02:51:48 +0000642 }
Devang Patelb8f198a2008-03-10 18:34:00 +0000643 } else if (!Returns.empty()) {
644 // Otherwise, if there is exactly one return value, just replace anything
645 // using the return value of the call with the computed value.
Eli Friedman5877ad72009-05-08 00:22:04 +0000646 if (!TheCall->use_empty()) {
647 if (TheCall == Returns[0]->getReturnValue())
Owen Anderson9e9a0d52009-07-30 23:03:37 +0000648 TheCall->replaceAllUsesWith(UndefValue::get(TheCall->getType()));
Eli Friedman5877ad72009-05-08 00:22:04 +0000649 else
650 TheCall->replaceAllUsesWith(Returns[0]->getReturnValue());
651 }
Duncan Sandsa7212e52008-09-05 12:37:12 +0000652
Devang Patelb8f198a2008-03-10 18:34:00 +0000653 // Splice the code from the return block into the block that it will return
654 // to, which contains the code that was after the call.
655 BasicBlock *ReturnBB = Returns[0]->getParent();
656 AfterCallBB->getInstList().splice(AfterCallBB->begin(),
657 ReturnBB->getInstList());
Duncan Sandsa7212e52008-09-05 12:37:12 +0000658
Devang Patelb8f198a2008-03-10 18:34:00 +0000659 // Update PHI nodes that use the ReturnBB to use the AfterCallBB.
660 ReturnBB->replaceAllUsesWith(AfterCallBB);
Duncan Sandsa7212e52008-09-05 12:37:12 +0000661
Devang Patelb8f198a2008-03-10 18:34:00 +0000662 // Delete the return instruction now and empty ReturnBB now.
663 Returns[0]->eraseFromParent();
664 ReturnBB->eraseFromParent();
Chris Lattner3787e762004-10-17 23:21:07 +0000665 } else if (!TheCall->use_empty()) {
666 // No returns, but something is using the return value of the call. Just
667 // nuke the result.
Owen Anderson9e9a0d52009-07-30 23:03:37 +0000668 TheCall->replaceAllUsesWith(UndefValue::get(TheCall->getType()));
Chris Lattner5e923de2004-02-04 02:51:48 +0000669 }
Misha Brukmanfd939082005-04-21 23:48:37 +0000670
Chris Lattner5e923de2004-02-04 02:51:48 +0000671 // Since we are now done with the Call/Invoke, we can delete it.
Chris Lattner3787e762004-10-17 23:21:07 +0000672 TheCall->eraseFromParent();
Chris Lattnerca398dc2003-05-29 15:11:31 +0000673
Chris Lattner7152c232003-08-24 04:06:56 +0000674 // We should always be able to fold the entry block of the function into the
675 // single predecessor of the block...
Chris Lattnercd01ae52004-04-16 05:17:59 +0000676 assert(cast<BranchInst>(Br)->isUnconditional() && "splitBasicBlock broken!");
Chris Lattner7152c232003-08-24 04:06:56 +0000677 BasicBlock *CalleeEntry = cast<BranchInst>(Br)->getSuccessor(0);
Chris Lattner44a68072004-02-04 04:17:06 +0000678
Chris Lattnercd01ae52004-04-16 05:17:59 +0000679 // Splice the code entry block into calling block, right before the
680 // unconditional branch.
681 OrigBB->getInstList().splice(Br, CalleeEntry->getInstList());
682 CalleeEntry->replaceAllUsesWith(OrigBB); // Update PHI nodes
683
684 // Remove the unconditional branch.
685 OrigBB->getInstList().erase(Br);
686
687 // Now we can remove the CalleeEntry block, which is now empty.
688 Caller->getBasicBlockList().erase(CalleeEntry);
Duncan Sandsa7212e52008-09-05 12:37:12 +0000689
Chris Lattnerca398dc2003-05-29 15:11:31 +0000690 return true;
691}