[llvm-commits] [poolalloc] r128684 - in /poolalloc/trunk: include/assistDS/TypeAnalysis.h lib/AssistDS/TypeAnalysis.cpp
Arushi Aggarwal
aggarwa4 at illinois.edu
Thu Mar 31 15:59:37 PDT 2011
Author: aggarwa4
Date: Thu Mar 31 17:59:37 2011
New Revision: 128684
URL: http://llvm.org/viewvc/llvm-project?rev=128684&view=rev
Log:
Add functions to infer if this load/store is only
used to copy values.
Modified:
poolalloc/trunk/include/assistDS/TypeAnalysis.h
poolalloc/trunk/lib/AssistDS/TypeAnalysis.cpp
Modified: poolalloc/trunk/include/assistDS/TypeAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/TypeAnalysis.h?rev=128684&r1=128683&r2=128684&view=diff
==============================================================================
--- poolalloc/trunk/include/assistDS/TypeAnalysis.h (original)
+++ poolalloc/trunk/include/assistDS/TypeAnalysis.h Thu Mar 31 17:59:37 2011
@@ -28,14 +28,17 @@
public:
static char ID;
TypeAnalysis() : ModulePass(&ID) {}
- virtual ~TypeAnalysis();
virtual bool runOnModule(Module& M);
- virtual void getAnalysisUsage(llvm::AnalysisUsage &Info) const;
+ virtual void getAnalysisUsage(AnalysisUsage &Info) const;
const Type *getType(LoadInst *);
const Type *getType(StoreInst *);
const Type *getType(ExtractValueInst *);
const Type *getType(InsertValueInst *);
+ bool isCopyingLoad(LoadInst *);
+ bool isCopyingLoad(ExtractValueInst *);
+ bool isCopyingStore(StoreInst *);
+ bool isCopyingStore(InsertValueInst *);
};
}
Modified: poolalloc/trunk/lib/AssistDS/TypeAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeAnalysis.cpp?rev=128684&r1=128683&r2=128684&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/TypeAnalysis.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/TypeAnalysis.cpp Thu Mar 31 17:59:37 2011
@@ -8,8 +8,6 @@
//===----------------------------------------------------------------------===//
#include "assistDS/TypeAnalysis.h"
-
-
#include <vector>
using namespace llvm;
@@ -45,4 +43,51 @@
TypeAnalysis::getType(ExtractValueInst *I){
return I->getType();
}
+bool
+TypeAnalysis::isCopyingLoad(LoadInst *LI){
+ if(LI->getNumUses() == 1)
+ if(StoreInst *SI = dyn_cast<StoreInst>(LI->use_begin())) {
+ if(SI->getOperand(0) == LI)
+ return true;
+ } else if(InsertValueInst *IV = dyn_cast<InsertValueInst>(LI->use_begin())) {
+ if(IV->getInsertedValueOperand() == LI)
+ return true;
+ }
+ return false;
+}
+bool
+TypeAnalysis::isCopyingLoad(ExtractValueInst * EI) {
+ if(EI->getNumUses() == 1)
+ if(StoreInst *SI = dyn_cast<StoreInst>(EI->use_begin())) {
+ if(SI->getOperand(0) == EI)
+ return true;
+ } else if(InsertValueInst *IV = dyn_cast<InsertValueInst>(EI->use_begin())) {
+ if(IV->getInsertedValueOperand() == EI)
+ return true;
+ }
+ return false;
+}
+bool
+TypeAnalysis::isCopyingStore(StoreInst *SI) {
+ if(SI->getOperand(0)->getNumUses() == 1)
+ if(isa<LoadInst>(SI->getOperand(0)))
+ return true;
+ else if(isa<ExtractValueInst>(SI->getOperand(0)))
+ return true;
+
+ return false;
+}
+bool
+TypeAnalysis::isCopyingStore(InsertValueInst *IVI) {
+ if(IVI->getInsertedValueOperand()->getNumUses() == 1)
+ if(isa<LoadInst>(IVI->getInsertedValueOperand()))
+ return true;
+ else if(isa<ExtractValueInst>(IVI->getInsertedValueOperand()))
+ return true;
+ return false;
+}
+void
+TypeAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
+}
More information about the llvm-commits
mailing list