aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSumant Kowshik <kowshik@uiuc.edu>2003-05-29 22:43:46 +0000
committerSumant Kowshik <kowshik@uiuc.edu>2003-05-29 22:43:46 +0000
commit5e587d7a23cae5225783dd4dd865b9194bb56742 (patch)
treec1718ee42045a5e244ba77c6091bdd3ecae60e40 /include
parenta78220fe2d7fe0a18e21e5d0303597855a811f55 (diff)
downloadexternal_llvm-5e587d7a23cae5225783dd4dd865b9194bb56742.zip
external_llvm-5e587d7a23cae5225783dd4dd865b9194bb56742.tar.gz
external_llvm-5e587d7a23cae5225783dd4dd865b9194bb56742.tar.bz2
Changes to support function pointers
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6421 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Transforms/PoolAllocate.h45
1 files changed, 41 insertions, 4 deletions
diff --git a/include/llvm/Transforms/PoolAllocate.h b/include/llvm/Transforms/PoolAllocate.h
index 8dc973c..bf6e170 100644
--- a/include/llvm/Transforms/PoolAllocate.h
+++ b/include/llvm/Transforms/PoolAllocate.h
@@ -12,9 +12,12 @@
#include "llvm/Pass.h"
#include "Support/hash_set"
+#include "Support/EquivalenceClasses.h"
class BUDataStructures;
+class TDDataStructures;
class DSNode;
class DSGraph;
+class CallInst;
namespace PA {
/// FuncInfo - Represent the pool allocation information for one function in
@@ -33,9 +36,15 @@ namespace PA {
Function *Clone;
/// ArgNodes - The list of DSNodes which have pools passed in as arguments.
- ///
+ ///
std::vector<DSNode*> ArgNodes;
+ /// In order to handle indirect functions, the start and end of the
+ /// arguments that are useful to this function.
+ /// The pool arguments useful to this function are PoolArgFirst to
+ /// PoolArgLast not inclusive.
+ int PoolArgFirst, PoolArgLast;
+
/// PoolDescriptors - The Value* (either an argument or an alloca) which
/// defines the pool descriptor for this DSNode. Pools are mapped one to
/// one with nodes in the DSGraph, so this contains a pointer to the node it
@@ -44,7 +53,8 @@ namespace PA {
/// alloca instruction. This entry contains a pointer to that alloca if the
/// pool is locally allocated or the argument it is passed in through if
/// not.
- ///
+ /// Note: Does not include pool arguments that are passed in because of
+ /// indirect function calls that are not used in the function.
std::map<DSNode*, Value*> PoolDescriptors;
/// NewToOldValueMap - When and if a function needs to be cloned, this map
@@ -60,10 +70,35 @@ namespace PA {
class PoolAllocate : public Pass {
Module *CurModule;
BUDataStructures *BU;
+
+ TDDataStructures *TDDS;
std::map<Function*, PA::FuncInfo> FunctionInfo;
+
+ void buildIndirectFunctionSets(Module &M);
+
+ void FindFunctionPoolArgs(Function &F);
+
+ // Debug function to print the FuncECs
+ void printFuncECs();
+
public:
- Function *PoolInit, *PoolDestroy, *PoolAlloc, *PoolFree;
+ Function *PoolInit, *PoolDestroy, *PoolAlloc, *PoolAllocArray, *PoolFree;
+
+ // Equivalence class where functions that can potentially be called via
+ // the same function pointer are in the same class.
+ EquivalenceClasses<Function *> FuncECs;
+
+ // Map from an Indirect CallInst to the set of Functions that it can point to
+ map<CallInst *, vector<Function *> > CallInstTargets;
+
+ // This maps an equivalence class to the last pool argument number for that
+ // class. This is used because the pool arguments for all functions within
+ // an equivalence class is passed to all the functions in that class.
+ // If an equivalence class does not require pool arguments, it is not
+ // on this map.
+ map<Function *, int> EqClass2LastPoolArg;
+
public:
bool run(Module &M);
@@ -75,7 +110,9 @@ class PoolAllocate : public Pass {
std::map<Function*, PA::FuncInfo>::iterator I = FunctionInfo.find(&F);
return I != FunctionInfo.end() ? &I->second : 0;
}
-
+
+ Module *getCurModule() { return CurModule; }
+
private:
/// AddPoolPrototypes - Add prototypes for the pool functions to the