Home | History | Annotate | Download | only in Utils

Lines Matching refs:Function

1 //===- CloneFunction.cpp - Clone a function into another function ---------===//
11 // low-level function cloner. This is used by the CloneFunction and function
12 // inliner to do the dirty work of copying the body of a function around.
23 #include "llvm/IR/Function.h"
39 const Twine &NameSuffix, Function *F,
76 void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
85 for (Function::const_arg_iterator I = OldFunc->arg_begin(),
92 for (Function::const_arg_iterator I = OldFunc->arg_begin(),
111 // Loop over all of the basic blocks in the function, cloning them as
115 for (Function::const_iterator BI = OldFunc->begin(), BE = OldFunc->end();
125 // It is only legal to clone a function if a block address within that
126 // function is never referenced outside of the function. Given that, we
127 // want to map block addresses from the old function to block addresses in
130 // cloning a function.)
132 Constant *OldBBAddr = BlockAddress::get(const_cast<Function*>(OldFunc),
142 // Loop over all of the instructions in the function, fixing up operand
144 for (Function::iterator BB = cast<BasicBlock>(VMap[OldFunc->begin()]),
153 /// CloneFunction - Return a copy of the specified function, but without
154 /// embedding the function into another module. Also, any references specified
156 /// original one. If any of the arguments to the function are in the VMap,
157 /// the arguments are deleted from the resultant function. The VMap is
159 /// the function from their old to new values.
161 Function *llvm::CloneFunction(const Function *F, ValueToValueMapTy &VMap,
166 // The user might be deleting arguments to the function by specifying them in
169 for (Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end();
174 // Create a new function type...
178 // Create the new function...
179 Function *NewF = Function::Create(FTy, F->getLinkage(), F->getName());
182 Function::arg_iterator DestI = NewF->arg_begin();
183 for (Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end();
201 Function *NewFunc;
202 const Function *OldFunc;
209 PruningFunctionCloner(Function *newFunc, const Function *oldFunc,
241 // It is only legal to clone a function if a block address within that
242 // function is never referenced outside of the function. Given that, we
243 // want to map block addresses from the old function to block addresses in
246 // cloning a function.)
251 Constant *OldBBAddr = BlockAddress::get(const_cast<Function*>(OldFunc),
276 // function, map it back into the new function.
360 /// example) a function call with constant arguments is inlined, and those
364 void llvm::CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc,
375 for (Function::const_arg_iterator II = OldFunc->arg_begin(),
392 function. If the block was
394 // insert it into the new function in the right order. If not, ignore it.
396 // Defer PHI resolution until rest of function is resolved.
398 for (Function::const_iterator BI = OldFunc->begin(), BE = OldFunc->end();
404 // Add the new block to the new function.
421 // Defer PHI resolution until rest of function is resolved, PHI resolution
503 // remapped into the new function, simplifying the PHINode and performing any
513 // Now that the inlined function body has been fully constructed, go through
517 Function::iterator Begin = cast<BasicBlock>(VMap[&OldFunc->getEntryBlock()]);
518 Function::iterator I = Begin;
549 // We know all single-entry PHI nodes in the inlined function have been
565 // Make a final pass over the basic blocks from theh old function to gather
568 for (Function::iterator I = cast<BasicBlock>(VMap[&OldFunc->getEntryBlock()]),