[llvm-commits] [poolalloc] r131166 - /poolalloc/trunk/lib/AssistDS/TypeChecks.cpp

Arushi Aggarwal aggarwa4 at illinois.edu
Tue May 10 15:51:43 PDT 2011


Author: aggarwa4
Date: Tue May 10 17:51:43 2011
New Revision: 131166

URL: http://llvm.org/viewvc/llvm-project?rev=131166&view=rev
Log:
Only instrument stores, if that location is used in an
type unsafe manner.

Only initialize type information for globals used in a 
type unsafe manner.

Modified:
    poolalloc/trunk/lib/AssistDS/TypeChecks.cpp

Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=131166&r1=131165&r2=131166&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Tue May 10 17:51:43 2011
@@ -516,6 +516,11 @@
 bool TypeChecks::visitGlobal(Module &M, GlobalVariable &GV, 
                              Constant *C, Instruction &I, unsigned offset) {
 
+  if(EnableTypeSafeOpt) {
+    if(TS->isTypeSafe(&GV, I.getParent()->getParent())) {
+      return false;
+    }
+  }
   if(ConstantArray *CA = dyn_cast<ConstantArray>(C)) {
     const Type * ElementType = CA->getType()->getElementType();
     unsigned int t = TD->getTypeStoreSize(ElementType);
@@ -786,6 +791,11 @@
 
 // Insert runtime checks before all store instructions.
 bool TypeChecks::visitStoreInst(Module &M, StoreInst &SI) {
+  if(EnableTypeSafeOpt) {
+    if(TS->isTypeSafe(SI.getOperand(1), SI.getParent()->getParent())) {
+      return false;
+    }
+  }
   // Cast the pointer operand to i8* for the runtime function.
   CastInst *BCI = BitCastInst::CreatePointerCast(SI.getPointerOperand(), VoidPtrTy, "", &SI);
 
@@ -805,6 +815,11 @@
 
 // Insert runtime checks before copying store instructions.
 bool TypeChecks::visitCopyingStoreInst(Module &M, StoreInst &SI, Value *SS) {
+  if(EnableTypeSafeOpt) {
+    if(TS->isTypeSafe(SI.getOperand(1), SI.getParent()->getParent())) {
+      return false;
+    }
+  }
   // Cast the pointer operand to i8* for the runtime function.
   CastInst *BCI_Dest = BitCastInst::CreatePointerCast(SI.getPointerOperand(), VoidPtrTy, "", &SI);
   CastInst *BCI_Src = BitCastInst::CreatePointerCast(SS, VoidPtrTy, "", &SI);





More information about the llvm-commits mailing list