summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-04-22 23:07:58 +0000
committerChris Lattner <sabre@nondot.org>2010-04-22 23:07:58 +0000
commit60915146f4d35e12f10dcdaa155596fac79184da (patch)
treeac5782ad8e8a3ff4627855e7f04872b92f66e658 /include
parent9517144f5395ee88f0e5a22afd2ca1905a344e68 (diff)
downloadllvm-60915146f4d35e12f10dcdaa155596fac79184da.tar.gz
llvm-60915146f4d35e12f10dcdaa155596fac79184da.tar.bz2
llvm-60915146f4d35e12f10dcdaa155596fac79184da.tar.xz
refactor the interface to InlineFunction so that most of the in/out
arguments are handled with a new InlineFunctionInfo class. This makes it easier to extend InlineFunction to return more info in the future. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102137 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Transforms/Utils/Cloning.h40
1 files changed, 27 insertions, 13 deletions
diff --git a/include/llvm/Transforms/Utils/Cloning.h b/include/llvm/Transforms/Utils/Cloning.h
index 5f494fb50d..4b6025b6be 100644
--- a/include/llvm/Transforms/Utils/Cloning.h
+++ b/include/llvm/Transforms/Utils/Cloning.h
@@ -19,6 +19,7 @@
#define LLVM_TRANSFORMS_UTILS_CLONING_H
#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Twine.h"
namespace llvm {
@@ -40,7 +41,6 @@ class TargetData;
class Loop;
class LoopInfo;
class AllocaInst;
-template <typename T> class SmallVectorImpl;
/// CloneModule - Return an exact copy of the specified module
///
@@ -158,6 +158,29 @@ void CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc,
const TargetData *TD = 0,
Instruction *TheCall = 0);
+
+/// InlineFunctionInfo - This class captures the data input to the
+/// InlineFunction call, and records the auxiliary results produced by it.
+class InlineFunctionInfo {
+public:
+ explicit InlineFunctionInfo(CallGraph *cg = 0, const TargetData *td = 0)
+ : CG(cg), TD(td) {}
+
+ /// CG - If non-null, InlineFunction will update the callgraph to reflect the
+ /// changes it makes.
+ CallGraph *CG;
+ const TargetData *TD;
+
+ /// StaticAllocas - InlineFunction fills this in with all static allocas that
+ /// get copied into the caller.
+ SmallVector<AllocaInst*, 4> StaticAllocas;
+
+
+ void reset() {
+ StaticAllocas.clear();
+ }
+};
+
/// InlineFunction - This function inlines the called function into the basic
/// block of the caller. This returns false if it is not possible to inline
/// this call. The program is still in a well defined state if this occurs
@@ -168,18 +191,9 @@ void CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc,
/// exists in the instruction stream. Similiarly this will inline a recursive
/// function by one level.
///
-/// If a non-null callgraph pointer is provided, these functions update the
-/// CallGraph to represent the program after inlining.
-///
-/// If StaticAllocas is non-null, InlineFunction populates it with all of the
-/// static allocas that it inlines into the caller.
-///
-bool InlineFunction(CallInst *C, CallGraph *CG = 0, const TargetData *TD = 0,
- SmallVectorImpl<AllocaInst*> *StaticAllocas = 0);
-bool InlineFunction(InvokeInst *II, CallGraph *CG = 0, const TargetData *TD = 0,
- SmallVectorImpl<AllocaInst*> *StaticAllocas = 0);
-bool InlineFunction(CallSite CS, CallGraph *CG = 0, const TargetData *TD = 0,
- SmallVectorImpl<AllocaInst*> *StaticAllocas = 0);
+bool InlineFunction(CallInst *C, InlineFunctionInfo &IFI);
+bool InlineFunction(InvokeInst *II, InlineFunctionInfo &IFI);
+bool InlineFunction(CallSite CS, InlineFunctionInfo &IFI);
} // End llvm namespace