1 //===- Cloning.h - Clone various parts of LLVM programs ---------*- C++ -*-===//
3 // This file defines various functions that are used to clone chunks of LLVM
4 // code for various purposes. This varies from copying whole modules into new
5 // modules, to cloning functions with different arguments, to inlining
6 // functions, to copying basic blocks to support loop unrolling or superblock
9 //===----------------------------------------------------------------------===//
11 #ifndef LLVM_TRANSFORMS_UTIlS_CLONING_H
12 #define LLVM_TRANSFORMS_UTIlS_CLONING_H
22 // Clone OldFunc into NewFunc, transforming the old arguments into references to
23 // ArgMap values. Note that if NewFunc already has basic blocks, the ones
24 // cloned into it will be added to the end of the function. This function fills
25 // in a list of return instructions, and can optionally append the specified
26 // suffix to all values cloned.
28 void CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
29 const std::vector<Value*> &ArgMap,
30 std::vector<ReturnInst*> &Returns,
31 const char *NameSuffix = "");
34 // InlineFunction - This function forcibly inlines the called function into the
35 // basic block of the caller. This returns true if it is not possible to inline
36 // this call. The program is still in a well defined state if this occurs
39 // Note that this only does one level of inlining. For example, if the
40 // instruction 'call B' is inlined, and 'B' calls 'C', then the call to 'C' now
41 // exists in the instruction stream. Similiarly this will inline a recursive
42 // function by one level.
44 bool InlineFunction(CallInst *C);