[llvm-commits] [poolalloc] r130202 - /poolalloc/trunk/lib/AssistDS/LoadArgs.cpp

Arushi Aggarwal aggarwa4 at illinois.edu
Tue Apr 26 08:48:07 PDT 2011


Author: aggarwa4
Date: Tue Apr 26 10:48:07 2011
New Revision: 130202

URL: http://llvm.org/viewvc/llvm-project?rev=130202&view=rev
Log:
Make sure that there are no stores between the 
load of the value, and the call inst.

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

Modified: poolalloc/trunk/lib/AssistDS/LoadArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/LoadArgs.cpp?rev=130202&r1=130201&r2=130202&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/LoadArgs.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/LoadArgs.cpp Tue Apr 26 10:48:07 2011
@@ -41,8 +41,6 @@
               continue;
             // we are only interested in GEPs
             LoadInst *LI = cast<LoadInst>(I);
-            if(LI->getType()->isPointerTy())
-              continue;
             // If the GEP is not doing structure indexing, dont care.
             for (Value::use_iterator UI = LI->use_begin(),UE = LI->use_end(); UI != UE; ) {
               // check if GEP is used in a Call Inst
@@ -52,6 +50,30 @@
 
               if(CI->hasByValArgument())
                 continue;
+
+              // It should be in the same basic block
+              if(LI->getParent() != CI->getParent())
+                continue;
+
+              // Also check that there is no store after the load.
+              // TODO: Check if the load/store do not alias.
+              BasicBlock::iterator bii = LI->getParent()->begin();
+              Instruction *BII = bii;
+              while(BII != LI) {
+                ++bii;
+                BII = bii;
+              }
+              while(BII != CI) {
+                if(isa<StoreInst>(BII))
+                  break;
+                ++bii;
+                BII = bii;
+              }
+              if(isa<StoreInst>(bii)){
+                continue;
+              }
+
+
               // if the GEP calls a function, that is externally defined,
               // or might be changed, ignore this call site.
               Function *F = CI->getCalledFunction();
@@ -69,18 +91,9 @@
                 if(LI == CI->getOperand(argNum))
                   break;
 
-              unsigned i = 1;
-              Function::arg_iterator II = F->arg_begin();
-              for (; i!= argNum; ++II, ++i) {
-                ;
-              }
               if(F->paramHasAttr(argNum, Attribute::SExt) ||
                  F->paramHasAttr(argNum, Attribute::ZExt)) 
                 continue;
-              if(II->getNumUses() !=1)
-                continue;
-              if(!isa<StoreInst>(II->use_begin()))
-                continue;
               // Construct the new Type
               // Appends the struct Type at the beginning
               std::vector<const Type*>TP;
@@ -93,7 +106,7 @@
               const FunctionType *NewFTy = FunctionType::get(CI->getType(), TP, false);
               Function *NewF;
               numSimplified++;
-              if(numSimplified > 26) //26
+              if(numSimplified > 50) //26
                 return true;
 
               NewF = Function::Create(NewFTy,
@@ -135,7 +148,7 @@
                 Args.push_back(CI->getOperand(j));
               }
               CallInst *CallI = CallInst::Create(NewF,Args.begin(), Args.end(),"", CI);
-              CallI->setCallingConv(CI->getCallingConv());
+              CallI->setCallingConv(CI->getCallingConv()); 
               CI->replaceAllUsesWith(CallI);
               CI->eraseFromParent();
             }





More information about the llvm-commits mailing list