[llvm-commits] [poolalloc] r132714 - in /poolalloc/trunk: include/assistDS/TypeChecks.h lib/AssistDS/TypeChecks.cpp

Arushi Aggarwal aggarwa4 at illinois.edu
Tue Jun 7 09:30:15 PDT 2011


Author: aggarwa4
Date: Tue Jun  7 11:30:15 2011
New Revision: 132714

URL: http://llvm.org/viewvc/llvm-project?rev=132714&view=rev
Log:
Cleanup by adding utility function.

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=132714&r1=132713&r2=132714&view=diff
==============================================================================
--- poolalloc/trunk/include/assistDS/TypeChecks.h (original)
+++ poolalloc/trunk/include/assistDS/TypeChecks.h Tue Jun  7 11:30:15 2011
@@ -52,6 +52,7 @@
   Constant *getTypeMarkerConstant(Value * V);
   Constant *getTypeMarkerConstant(const Type* T);
   unsigned int getSize(const Type*);
+  Constant* getSizeConstant(const Type*);
   
   bool initShadow(Module &M);
   void addTypeMap(Module &M) ;

Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=132714&r1=132713&r2=132714&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Tue Jun  7 11:30:15 2011
@@ -83,6 +83,10 @@
   return TD->getTypeStoreSize(Ty);
 }
 
+Constant *TypeChecks::getSizeConstant(const Type *Ty) {
+  return (ConstantInt::get(Int64Ty, getSize(Ty)));
+}
+
 static Constant *getTagCounter() {
   return ConstantInt::get(Int32Ty, tagCounter++);
 }
@@ -1116,8 +1120,7 @@
       CastInst *BCI = BitCastInst::CreatePointerCast(I, VoidPtrTy, "", InsertPt);
       std::vector<Value *> Args;
       Args.push_back(BCI);
-      unsigned int size = getSize(I->getType()->getElementType());
-      Args.push_back(ConstantInt::get(Int64Ty, size));
+      Args.push_back(getSizeConstant(I->getType()->getElementType()));
       Args.push_back(getTagCounter());
       CallInst::Create(trackInitInst, Args.begin(), Args.end(), "", InsertPt);
       continue;
@@ -1209,7 +1212,6 @@
 
   if(ConstantArray *CA = dyn_cast<ConstantArray>(C)) {
     const Type * ElementType = CA->getType()->getElementType();
-    unsigned int t = getSize(ElementType);
     // Create the type entry for the first element
     // using recursive creation till we get to the base types
     visitGlobal(M, GV, CA->getOperand(0), I, offset);
@@ -1219,7 +1221,7 @@
     CastInst *BCI = BitCastInst::CreatePointerCast(&GV, VoidPtrTy, "", &I);
     std::vector<Value *> Args;
     Args.push_back(BCI);
-    Args.push_back(ConstantInt::get(Int64Ty, t));
+    Args.push_back(getSizeConstant(ElementType));
     Args.push_back(ConstantInt::get(Int64Ty, CA->getNumOperands()));
     Args.push_back(getTagCounter());
     CallInst::Create(trackArray, Args.begin(), Args.end(), "", &I);
@@ -1241,12 +1243,11 @@
     const Type *Ty = CAZ->getType();
     if(const ArrayType * ATy = dyn_cast<ArrayType>(Ty)) {
       const Type * ElementType = ATy->getElementType();
-      unsigned int size = getSize(ElementType);
       visitGlobal(M, GV, Constant::getNullValue(ElementType), I, offset);
       CastInst *BCI = BitCastInst::CreatePointerCast(&GV, VoidPtrTy, "", &I);
       std::vector<Value *> Args;
       Args.push_back(BCI);
-      Args.push_back(ConstantInt::get(Int64Ty, size));
+      Args.push_back(getSizeConstant(ElementType));
       Args.push_back(ConstantInt::get(Int64Ty, ATy->getNumElements()));
       Args.push_back(getTagCounter());
       CallInst::Create(trackArray, Args.begin(), Args.end(), "", &I);
@@ -1269,7 +1270,7 @@
       std::vector<Value *> Args;
       Args.push_back(GEP);
       Args.push_back(getTypeMarkerConstant(CAZ));
-      Args.push_back(ConstantInt::get(Int64Ty, getSize(CAZ->getType())));
+      Args.push_back(getSizeConstant(CAZ->getType()));
       Args.push_back(getTagCounter());
       CallInst::Create(trackGlobal, Args.begin(), Args.end(), "", &I);
     }
@@ -1285,7 +1286,7 @@
     std::vector<Value *> Args;
     Args.push_back(GEP);
     Args.push_back(getTypeMarkerConstant(C));
-    Args.push_back(ConstantInt::get(Int64Ty, getSize(C->getType())));
+    Args.push_back(getSizeConstant(C->getType()));
     Args.push_back(getTagCounter());
     CallInst::Create(trackGlobal, Args.begin(), Args.end(), "", &I);
   }
@@ -1428,10 +1429,9 @@
       CastInst *BCI = BitCastInst::CreatePointerCast(I->getOperand(1), VoidPtrTy, "", I);
       const PointerType *PTy = cast<PointerType>(I->getOperand(1)->getType());
       const Type * ElementType = PTy->getElementType();
-      unsigned int size = getSize(ElementType);
       std::vector<Value *> Args;
       Args.push_back(BCI);
-      Args.push_back(ConstantInt::get(Int64Ty, size));
+      Args.push_back(getSizeConstant(ElementType));
       Args.push_back(getTagCounter());
       CallInst::Create(trackInitInst, Args.begin(), Args.end(), "", I);
       return true;
@@ -1622,7 +1622,7 @@
   std::vector<Value *> Args;
   Args.push_back(BCI);
   Args.push_back(getTypeMarkerConstant(PTy->getElementType()));
-  Args.push_back(ConstantInt::get(Int64Ty, getSize(PTy->getElementType())));
+  Args.push_back(getSizeConstant(PTy->getElementType()));
   Args.push_back(getTagCounter());
 
   // Create the call to the runtime check and place it before the store instruction.
@@ -1649,7 +1649,7 @@
   std::vector<Value *> Args;
   Args.push_back(BCI);
   Args.push_back(getTypeMarkerConstant(&LI));
-  Args.push_back(ConstantInt::get(Int64Ty, getSize(LI.getType())));
+  Args.push_back(getSizeConstant(LI.getType()));
   Args.push_back(getTagCounter());
 
   // Create the call to the runtime check and place it before the load instruction.
@@ -1666,7 +1666,7 @@
   std::vector<Value *> Args;
   Args.push_back(BCI);
   Args.push_back(getTypeMarkerConstant(SI.getOperand(0))); // SI.getValueOperand()
-  Args.push_back(ConstantInt::get(Int64Ty, getSize(SI.getOperand(0)->getType())));
+  Args.push_back(getSizeConstant(SI.getOperand(0)->getType()));
   Args.push_back(getTagCounter());
 
   // Create the call to the runtime check and place it before the store instruction.
@@ -1685,7 +1685,7 @@
   std::vector<Value *> Args;
   Args.push_back(BCI_Dest);
   Args.push_back(BCI_Src);
-  Args.push_back(ConstantInt::get(Int64Ty, getSize(SI.getOperand(0)->getType())));
+  Args.push_back(getSizeConstant(SI.getOperand(0)->getType()));
   Args.push_back(getTagCounter());
 
   // Create the call to the runtime check and place it before the copying store instruction.





More information about the llvm-commits mailing list