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

Arushi Aggarwal aggarwa4 at illinois.edu
Fri Apr 15 13:14:27 PDT 2011


Author: aggarwa4
Date: Fri Apr 15 15:14:27 2011
New Revision: 129597

URL: http://llvm.org/viewvc/llvm-project?rev=129597&view=rev
Log:
Every global value is a pointer, and any global
with an initializer should have the metadata updated.

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=129597&r1=129596&r2=129597&view=diff
==============================================================================
--- poolalloc/trunk/include/assistDS/TypeChecks.h (original)
+++ poolalloc/trunk/include/assistDS/TypeChecks.h Fri Apr 15 15:14:27 2011
@@ -48,6 +48,7 @@
   bool initShadow(Module &M, Instruction &I);
   bool unmapShadow(Module &M, Instruction &I);
   bool visitLoadInst(Module &M, LoadInst &LI);
+  bool visitGlobal(Module &M, GlobalVariable &GV, Instruction &I);
   bool visitStoreInst(Module &M, StoreInst &SI);
 
   // Return the map containing all of the types used in the module.

Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=129597&r1=129596&r2=129597&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Fri Apr 15 15:14:27 2011
@@ -87,6 +87,16 @@
   inst_iterator MainI = inst_begin(MainF);
   modified |= initShadow(M, *MainI);
 
+  // record all globals
+  for (Module::global_iterator I = M.global_begin(), E = M.global_end();
+       I != E; ++I) {
+    if(!I->getNumUses() == 1)
+      continue;
+    if(!I->hasInitializer())
+      continue;
+    modified |= visitGlobal(M, *I, *MainI);
+  }
+
   for (Module::iterator MI = M.begin(), ME = M.end(); MI != ME; ++MI) {
     IncorporateType(MI->getType());
     Function &F = *MI;
@@ -99,7 +109,6 @@
       for (User::op_iterator OI = I.op_begin(), OE = I.op_end(); OI != OE; ++OI) {
         IncorporateValue(*OI); // Insert instruction operand types.
       }
-
       if (StoreInst *SI = dyn_cast<StoreInst>(&I)) {
         modified |= visitStoreInst(M, *SI);
       } else if (LoadInst *LI = dyn_cast<LoadInst>(&I)) {
@@ -150,6 +159,18 @@
   return true;
 }
 
+bool TypeChecks::visitGlobal(Module &M, GlobalVariable &GV, Instruction &I) {
+  
+  CastInst *BCI = BitCastInst::CreatePointerCast(&GV, VoidPtrTy, "", &I);
+  std::vector<Value *> Args;
+  Args.push_back(BCI);
+  const PointerType *PTy = GV.getType();
+  Args.push_back(ConstantInt::get(Int8Ty, UsedTypes[PTy->getElementType()]));
+  Constant *F = M.getOrInsertFunction("trackStoreInst", VoidTy, VoidPtrTy, Int8Ty, NULL);
+  CallInst::Create(F, Args.begin(), Args.end(), "", &I);
+
+  return true;
+}
 // Insert runtime checks before all load instructions.
 bool TypeChecks::visitLoadInst(Module &M, LoadInst &LI) {
   // Cast the pointer operand to i8* for the runtime function.





More information about the llvm-commits mailing list