[llvm-commits] [poolalloc] r133754 - in /poolalloc/trunk: include/assistDS/TypeChecks.h include/assistDS/TypeChecksOpt.h lib/AssistDS/TypeChecks.cpp lib/AssistDS/TypeChecksOpt.cpp
Arushi Aggarwal
aggarwa4 at illinois.edu
Thu Jun 23 13:29:21 PDT 2011
Author: aggarwa4
Date: Thu Jun 23 15:29:21 2011
New Revision: 133754
URL: http://llvm.org/viewvc/llvm-project?rev=133754&view=rev
Log:
Fix prototype.
Remove extra includes.
Add a function to remove extra load checks, using
DominatorTree.
Modified:
poolalloc/trunk/include/assistDS/TypeChecks.h
poolalloc/trunk/include/assistDS/TypeChecksOpt.h
poolalloc/trunk/lib/AssistDS/TypeChecks.cpp
poolalloc/trunk/lib/AssistDS/TypeChecksOpt.cpp
Modified: poolalloc/trunk/include/assistDS/TypeChecks.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/TypeChecks.h?rev=133754&r1=133753&r2=133754&view=diff
==============================================================================
--- poolalloc/trunk/include/assistDS/TypeChecks.h (original)
+++ poolalloc/trunk/include/assistDS/TypeChecks.h Thu Jun 23 15:29:21 2011
@@ -21,6 +21,7 @@
#include "llvm/Pass.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Support/CallSite.h"
+#include "llvm/Analysis/Dominators.h"
#include <map>
#include <list>
@@ -53,6 +54,7 @@
bool initShadow(Module &M);
void addTypeMap(Module &M) ;
+ void optimizeChecks(Module &M);
bool visitMain(Module &M, Function &F);
@@ -91,6 +93,7 @@
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<TargetData>();
+ AU.addRequired<DominatorTree>();
AU.addRequired<AddressTakenAnalysis>();
}
Modified: poolalloc/trunk/include/assistDS/TypeChecksOpt.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/TypeChecksOpt.h?rev=133754&r1=133753&r2=133754&view=diff
==============================================================================
--- poolalloc/trunk/include/assistDS/TypeChecksOpt.h (original)
+++ poolalloc/trunk/include/assistDS/TypeChecksOpt.h Thu Jun 23 15:29:21 2011
@@ -15,14 +15,13 @@
#define TYPE_CHECKS_OPT_H
#include "dsa/TypeSafety.h"
-#include "dsa/AddressTakenAnalysis.h"
#include "llvm/Instructions.h"
#include "llvm/Pass.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Support/CallSite.h"
-#include <map>
+#include <list>
namespace llvm {
Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=133754&r1=133753&r2=133754&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Thu Jun 23 15:29:21 2011
@@ -298,7 +298,6 @@
modified |= visitByValFunction(M, *F);
}
-
while(!VAArgFunctions.empty()) {
Function *F = VAArgFunctions.back();
VAArgFunctions.pop_back();
@@ -405,6 +404,7 @@
}
}
+ optimizeChecks(M);
// add a global that contains the mapping from metadata to strings
addTypeMap(M);
@@ -415,6 +415,46 @@
return modified;
}
+void TypeChecks::optimizeChecks(Module &M) {
+ for (Module::iterator MI = M.begin(), ME = M.end(); MI != ME; ++MI) {
+ Function &F = *MI;
+ if(F.isDeclaration())
+ continue;
+ for (Function::iterator B = F.begin(), FE = F.end(); B != FE; ++B) {
+ DominatorTree & DT = getAnalysis<DominatorTree>(F);
+ for (BasicBlock::iterator bi = B->begin(); bi != B->end(); ++bi) {
+ CallInst *CI = dyn_cast<CallInst>(bi);
+ if(!CI)
+ continue;
+ if(CI->getCalledFunction() != checkTypeInst)
+ continue;
+ std::list<Instruction *>toDelete;
+ for(Value::use_iterator User = checkTypeInst->use_begin(); User != checkTypeInst->use_end(); ++User) {
+ CallInst *CI2 = dyn_cast<CallInst>(User);
+ if(CI2 == CI)
+ continue;
+ if(CI2->getParent()->getParent() != &F)
+ continue;
+ if(CI->getOperand(4) != CI2->getOperand(4))
+ continue;
+ if(CI->getOperand(3) != CI2->getOperand(3))
+ continue;
+ if(!DT.dominates(CI, CI2))
+ continue;
+ CI->dump();
+ CI2->dump();
+ toDelete.push_back(CI2);
+ }
+ while(!toDelete.empty()) {
+ Instruction *I = toDelete.back();
+ toDelete.pop_back();
+ I->eraseFromParent();
+ }
+ }
+ }
+ }
+
+}
// add a global that has the metadata -> typeString mapping
void TypeChecks::addTypeMap(Module &M) {
Modified: poolalloc/trunk/lib/AssistDS/TypeChecksOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecksOpt.cpp?rev=133754&r1=133753&r2=133754&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/TypeChecksOpt.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/TypeChecksOpt.cpp Thu Jun 23 15:29:21 2011
@@ -96,7 +96,7 @@
VoidTy,
TypeTagTy,/*type*/
Int64Ty,/*size*/
- VoidPtrTy,
+ TypeTagPtrTy,
VoidPtrTy,/*ptr*/
Int32Ty,/*tag*/
NULL);
More information about the llvm-commits
mailing list