[llvm-commits] [poolalloc] r132713 - in /poolalloc/trunk: include/assistDS/TypeChecks.h lib/AssistDS/TypeChecks.cpp
Arushi Aggarwal
aggarwa4 at illinois.edu
Tue Jun 7 09:20:00 PDT 2011
Author: aggarwa4
Date: Tue Jun 7 11:20:00 2011
New Revision: 132713
URL: http://llvm.org/viewvc/llvm-project?rev=132713&view=rev
Log:
Clean up by adding some utility functions.
Modified:
poolalloc/trunk/include/assistDS/TypeChecks.h
poolalloc/trunk/lib/AssistDS/TypeChecks.cpp
Modified: poolalloc/trunk/include/assistDS/TypeChecks.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/TypeChecks.h?rev=132713&r1=132712&r2=132713&view=diff
==============================================================================
--- poolalloc/trunk/include/assistDS/TypeChecks.h (original)
+++ poolalloc/trunk/include/assistDS/TypeChecks.h Tue Jun 7 11:20:00 2011
@@ -46,45 +46,57 @@
TypeAnalysis *TA;
dsa::TypeSafety<TDDataStructures> *TS;
AddressTakenAnalysis* addrAnalysis;
-
-public:
- static char ID;
- TypeChecks() : ModulePass(&ID) {}
- virtual bool runOnModule(Module &M);
- virtual void print(raw_ostream &OS, const Module *M) const;
-
- virtual void getAnalysisUsage(AnalysisUsage &AU) const {
- AU.addRequired<TargetData>();
- AU.addRequired<TypeAnalysis>();
- AU.addRequired<AddressTakenAnalysis>();
- }
-
+
+ unsigned int getTypeMarker(const Type*);
+ unsigned int getTypeMarker(Value*);
+ Constant *getTypeMarkerConstant(Value * V);
+ Constant *getTypeMarkerConstant(const Type* T);
+ unsigned int getSize(const Type*);
+
bool initShadow(Module &M);
void addTypeMap(Module &M) ;
+
+ bool visitMain(Module &M, Function &F);
+
bool visitCallInst(Module &M, CallInst &CI);
bool visitInvokeInst(Module &M, InvokeInst &CI);
bool visitCallSite(Module &M, CallSite CS);
bool visitIndirectCallSite(Module &M, Instruction *I);
+
+ bool visitLoadInst(Module &M, LoadInst &LI);
+ bool visitStoreInst(Module &M, StoreInst &SI);
+ bool visitCopyingStoreInst(Module &M, StoreInst &SI, Value *SS);
+ bool visitAllocaInst(Module &M, AllocaInst &AI);
+
+ bool visitGlobal(Module &M, GlobalVariable &GV,
+ Constant *C, Instruction &I, unsigned offset);
+
bool visitInternalByValFunction(Module &M, Function &F);
bool visitExternalByValFunction(Module &M, Function &F);
bool visitByValFunction(Module &M, Function &F);
- bool visitMain(Module &M, Function &F);
+
+ bool visitAddressTakenFunction(Module &M, Function &F);
+
+
bool visitVarArgFunction(Module &M, Function &F);
- bool visitAddressTakenFunction(Module &M, Function &F);
bool visitVAListFunction(Module &M, Function &F);
+ void visitVAListCall(Function *F);
bool visitInternalVarArgFunction(Module &M, Function &F);
- bool visitLoadInst(Module &M, LoadInst &LI);
- bool visitStoreInst(Module &M, StoreInst &SI);
- bool visitAllocaInst(Module &M, AllocaInst &AI);
- bool visitGlobal(Module &M, GlobalVariable &GV,
- Constant *C, Instruction &I, unsigned offset);
- bool visitCopyingStoreInst(Module &M, StoreInst &SI, Value *SS);
+
bool visitInputFunctionValue(Module &M, Value *V, Instruction *CI);
- void visitVAListCall(Function *F);
- unsigned int getTypeMarker(const Type*);
- unsigned int getTypeMarker(Value*);
- unsigned int getSize(const Type*);
+public:
+ static char ID;
+ TypeChecks() : ModulePass(&ID) {}
+ virtual bool runOnModule(Module &M);
+ virtual void print(raw_ostream &OS, const Module *M) const;
+
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.addRequired<TargetData>();
+ AU.addRequired<TypeAnalysis>();
+ AU.addRequired<AddressTakenAnalysis>();
+ }
+
// Return the map containing all of the types used in the module.
const std::map<const Type *, unsigned int> &getTypes() const {
return UsedTypes;
Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=132713&r1=132712&r2=132713&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Tue Jun 7 11:20:00 2011
@@ -87,6 +87,14 @@
return ConstantInt::get(Int32Ty, tagCounter++);
}
+Constant *TypeChecks::getTypeMarkerConstant(Value * V) {
+ return ConstantInt::get(Int8Ty, getTypeMarker(V));
+}
+
+Constant *TypeChecks::getTypeMarkerConstant(const Type *T) {
+ return ConstantInt::get(Int8Ty, getTypeMarker(T));
+}
+
bool TypeChecks::runOnModule(Module &M) {
bool modified = false; // Flags whether we modified the module.
@@ -306,7 +314,6 @@
}
}
-
// visit all the uses of the address taken functions and modify if
// visit all the indirect call sites
std::set<Instruction*>::iterator II = IndCalls.begin();
@@ -560,7 +567,7 @@
Instruction *VAMetaData = new LoadInst(VAMDLoc, "", VI);
Args.push_back(VASize);
Args.push_back(OldValue);
- Args.push_back(ConstantInt::get(Int8Ty, getTypeMarker(VI)));
+ Args.push_back(getTypeMarkerConstant(VI));
Args.push_back(VAMetaData);
Args.push_back(getTagCounter());
CallInst::Create(compareTypeAndNumber,
@@ -640,8 +647,7 @@
Idx,
Idx + 1,
"", CI);
- Constant *C = ConstantInt::get(Int8Ty,
- getTypeMarker(CI->getOperand(i)));
+ Constant *C = getTypeMarkerConstant(CI->getOperand(i));
new StoreInst(C, GEP, CI);
}
@@ -795,7 +801,7 @@
Instruction *VAMetaData = new LoadInst(VAMDLoc, "", VI);
Args.push_back(VASize);
Args.push_back(OldValue);
- Args.push_back(ConstantInt::get(Int8Ty, getTypeMarker(VI)));
+ Args.push_back(getTypeMarkerConstant(VI));
Args.push_back(VAMetaData);
Args.push_back(getTagCounter());
CallInst::Create(compareTypeAndNumber,
@@ -878,8 +884,7 @@
Idx,
Idx + 1,
"", CI);
- Constant *C = ConstantInt::get(Int8Ty,
- getTypeMarker(CI->getOperand(i)));
+ Constant *C = getTypeMarkerConstant(CI->getOperand(i));
new StoreInst(C, GEP, CI);
}
@@ -1263,7 +1268,7 @@
std::vector<Value *> Args;
Args.push_back(GEP);
- Args.push_back(ConstantInt::get(Int8Ty, getTypeMarker(CAZ)));
+ Args.push_back(getTypeMarkerConstant(CAZ));
Args.push_back(ConstantInt::get(Int64Ty, getSize(CAZ->getType())));
Args.push_back(getTagCounter());
CallInst::Create(trackGlobal, Args.begin(), Args.end(), "", &I);
@@ -1279,7 +1284,7 @@
std::vector<Value *> Args;
Args.push_back(GEP);
- Args.push_back(ConstantInt::get(Int8Ty, getTypeMarker(C)));
+ Args.push_back(getTypeMarkerConstant(C));
Args.push_back(ConstantInt::get(Int64Ty, getSize(C->getType())));
Args.push_back(getTagCounter());
CallInst::Create(trackGlobal, Args.begin(), Args.end(), "", &I);
@@ -1547,8 +1552,7 @@
Idx,
Idx + 1,
"", I);
- Constant *C = ConstantInt::get(Int8Ty,
- getTypeMarker(I->getOperand(i)));
+ Constant *C = getTypeMarkerConstant(I->getOperand(i));
new StoreInst(C, GEP, I);
}
std::vector<Value *> Args;
@@ -1617,7 +1621,7 @@
std::vector<Value *> Args;
Args.push_back(BCI);
- Args.push_back(ConstantInt::get(Int8Ty, getTypeMarker(PTy->getElementType())));
+ Args.push_back(getTypeMarkerConstant(PTy->getElementType()));
Args.push_back(ConstantInt::get(Int64Ty, getSize(PTy->getElementType())));
Args.push_back(getTagCounter());
@@ -1644,7 +1648,7 @@
std::vector<Value *> Args;
Args.push_back(BCI);
- Args.push_back(ConstantInt::get(Int8Ty, getTypeMarker(&LI)));
+ Args.push_back(getTypeMarkerConstant(&LI));
Args.push_back(ConstantInt::get(Int64Ty, getSize(LI.getType())));
Args.push_back(getTagCounter());
@@ -1661,8 +1665,7 @@
std::vector<Value *> Args;
Args.push_back(BCI);
- Args.push_back(ConstantInt::get(Int8Ty,
- getTypeMarker(SI.getOperand(0)))); // SI.getValueOperand()
+ Args.push_back(getTypeMarkerConstant(SI.getOperand(0))); // SI.getValueOperand()
Args.push_back(ConstantInt::get(Int64Ty, getSize(SI.getOperand(0)->getType())));
Args.push_back(getTagCounter());
More information about the llvm-commits
mailing list