[llvm-commits] [poolalloc] r133520 - in /poolalloc/trunk: include/assistDS/TypeAnalysis.h include/assistDS/TypeChecks.h include/assistDS/TypeChecksCmpOpt.h include/assistDS/TypeChecksOpt.h lib/AssistDS/TypeAnalysis.cpp lib/AssistDS/TypeChecks.cpp lib/AssistDS/TypeChecksCmpOpt.cpp lib/AssistDS/TypeChecksOpt.cpp
Arushi Aggarwal
aggarwa4 at illinois.edu
Tue Jun 21 09:05:07 PDT 2011
Author: aggarwa4
Date: Tue Jun 21 11:05:06 2011
New Revision: 133520
URL: http://llvm.org/viewvc/llvm-project?rev=133520&view=rev
Log:
Move some optimizations to the instrumentation pass
as options.
Delete the rest of the files.
Instrument the use of a load, instead of the load itself
with the check.
Removed:
poolalloc/trunk/include/assistDS/TypeAnalysis.h
poolalloc/trunk/include/assistDS/TypeChecksCmpOpt.h
poolalloc/trunk/lib/AssistDS/TypeAnalysis.cpp
poolalloc/trunk/lib/AssistDS/TypeChecksCmpOpt.cpp
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
Removed: poolalloc/trunk/include/assistDS/TypeAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/TypeAnalysis.h?rev=133519&view=auto
==============================================================================
--- poolalloc/trunk/include/assistDS/TypeAnalysis.h (original)
+++ poolalloc/trunk/include/assistDS/TypeAnalysis.h (removed)
@@ -1,41 +0,0 @@
-//===-- TypeAnalysis.h - Deciphers Types of loads and stores --------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This code defines a pass which clones functions which could potentially be
-// used in indirect function calls.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Instructions.h"
-#include "llvm/Module.h"
-#include "llvm/Pass.h"
-
-namespace llvm {
- //
- // Class: TypeAnalysis
- //
- // Description:
- // Implement an LLVM pass that analyses a file to say what
- // the type of a load/store instruction is.
- //
- class TypeAnalysis : public ModulePass {
- public:
- static char ID;
- TypeAnalysis() : ModulePass(&ID) {}
- virtual bool runOnModule(Module& M);
- virtual void getAnalysisUsage(AnalysisUsage &Info) const;
-
- const Type *getType(LoadInst *);
- const Type *getType(StoreInst *);
- bool isCopyingLoad(LoadInst *);
- bool isCopyingStore(StoreInst *);
- Value *getStoreSource(StoreInst *SI);
- };
-}
-
Modified: poolalloc/trunk/include/assistDS/TypeChecks.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/TypeChecks.h?rev=133520&r1=133519&r2=133520&view=diff
==============================================================================
--- poolalloc/trunk/include/assistDS/TypeChecks.h (original)
+++ poolalloc/trunk/include/assistDS/TypeChecks.h Tue Jun 21 11:05:06 2011
@@ -14,7 +14,6 @@
#ifndef TYPE_CHECKS_H
#define TYPE_CHECKS_H
-#include "assistDS/TypeAnalysis.h"
#include "dsa/AddressTakenAnalysis.h"
#include "llvm/Instructions.h"
@@ -47,7 +46,6 @@
// Analysis from other passes.
TargetData *TD;
- TypeAnalysis *TA;
AddressTakenAnalysis* addrAnalysis;
unsigned int getTypeMarker(const Type*);
@@ -69,7 +67,6 @@
bool visitLoadInst(Module &M, LoadInst &LI);
bool visitStoreInst(Module &M, StoreInst &SI);
- bool visitCopyingStoreInst(Module &M, StoreInst &SI, Value *SS);
bool visitAllocaInst(Module &M, AllocaInst &AI);
bool visitGlobal(Module &M, GlobalVariable &GV,
@@ -97,7 +94,6 @@
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<TargetData>();
- AU.addRequired<TypeAnalysis>();
AU.addRequired<AddressTakenAnalysis>();
}
Removed: poolalloc/trunk/include/assistDS/TypeChecksCmpOpt.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/TypeChecksCmpOpt.h?rev=133519&view=auto
==============================================================================
--- poolalloc/trunk/include/assistDS/TypeChecksCmpOpt.h (original)
+++ poolalloc/trunk/include/assistDS/TypeChecksCmpOpt.h (removed)
@@ -1,46 +0,0 @@
-//=== TypeChecksCmpOpt.h - Remove runtime type checks for ptrs used in cmp ===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This pass removes type checks that are on values used in compares
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef TYPE_CHECKS_CMP_OPT_H
-#define TYPE_CHECKS_CMP_OPT_H
-
-#include "assistDS/TypeAnalysis.h"
-
-#include "llvm/Instructions.h"
-#include "llvm/Pass.h"
-#include "llvm/Target/TargetData.h"
-#include "llvm/Support/CallSite.h"
-
-#include <set>
-
-namespace llvm {
-
-class Type;
-class Value;
-
-class TypeChecksCmpOpt : public ModulePass {
-
-private:
-
- std::set<Instruction *> toDelete;
-
-public:
- static char ID;
- TypeChecksCmpOpt() : ModulePass(&ID) {}
- virtual bool runOnModule(Module &M);
-
-};
-
-} // End llvm namespace
-
-#endif
Modified: poolalloc/trunk/include/assistDS/TypeChecksOpt.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/TypeChecksOpt.h?rev=133520&r1=133519&r2=133520&view=diff
==============================================================================
--- poolalloc/trunk/include/assistDS/TypeChecksOpt.h (original)
+++ poolalloc/trunk/include/assistDS/TypeChecksOpt.h Tue Jun 21 11:05:06 2011
@@ -14,7 +14,6 @@
#ifndef TYPE_CHECKS_OPT_H
#define TYPE_CHECKS_OPT_H
-#include "assistDS/TypeAnalysis.h"
#include "dsa/TypeSafety.h"
#include "dsa/AddressTakenAnalysis.h"
Removed: poolalloc/trunk/lib/AssistDS/TypeAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeAnalysis.cpp?rev=133519&view=auto
==============================================================================
--- poolalloc/trunk/lib/AssistDS/TypeAnalysis.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/TypeAnalysis.cpp (removed)
@@ -1,79 +0,0 @@
-//===-- TypeAnalysis.cpp - Clone Indirectly Called Functions --------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "assistDS/TypeAnalysis.h"
-#include "llvm/Support/FormattedStream.h"
-#include "llvm/Support/Debug.h"
-
-#include <vector>
-
-using namespace llvm;
-
-// Pass ID variable
-char TypeAnalysis::ID = 0;
-
-// Register the Pass
-static RegisterPass<TypeAnalysis>
-X("type-analysis", "Get types for load/stores");
-
-//
-// Method: runOnModule()
-//
-bool
-TypeAnalysis::runOnModule(Module& M) {
- return false;
-}
-
-const Type *
-TypeAnalysis::getType(LoadInst *LI){
- return LI->getType();
-}
-
-const Type *
-TypeAnalysis::getType(StoreInst *SI){
- return SI->getOperand(0)->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;
- }
- }
- }
- // chk if passed through argument, and then stored.
- return false;
-}
-
-
-bool
-TypeAnalysis::isCopyingStore(StoreInst *SI) {
- if(SI->getOperand(0)->getNumUses() == 1) {
- if(isa<LoadInst>(SI->getOperand(0))) {
- return true;
- }
- }
- return false;
-}
-
-Value *
-TypeAnalysis::getStoreSource(StoreInst *SI) {
- if(LoadInst *LI = dyn_cast<LoadInst>(SI->getOperand(0))) {
- return LI->getOperand(0);
- }
- return NULL;
-}
-
-
-void
-TypeAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
- AU.setPreservesAll();
-}
Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=133520&r1=133519&r2=133520&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Tue Jun 21 11:05:06 2011
@@ -44,6 +44,14 @@
cl::desc("DONT Distinguish pointer types"),
cl::Hidden,
cl::init(false));
+ static cl::opt<bool> DisablePtrCmpChecks("no-ptr-cmp-checks",
+ cl::desc("Dont instrument cmp statements"),
+ cl::Hidden,
+ cl::init(false));
+ static cl::opt<bool> TrackAllLoads("track-all-loads",
+ cl::desc("Check at all loads irrespective of use"),
+ cl::Hidden,
+ cl::init(false));
}
static int tagCounter = 0;
@@ -58,8 +66,9 @@
static Constant *trackInitInst;
static Constant *trackUnInitInst;
static Constant *trackStoreInst;
-static Constant *trackLoadInst;
+static Constant *checkTypeInst;
static Constant *copyTypeInfo;
+static Constant *setTypeInfo;
static Constant *RegisterArgv;
static Constant *RegisterEnvp;
static Constant *compareTypeAndNumber;
@@ -105,7 +114,6 @@
bool modified = false; // Flags whether we modified the module.
TD = &getAnalysis<TargetData>();
- TA = &getAnalysis<TypeAnalysis>();
addrAnalysis = &getAnalysis<AddressTakenAnalysis>();
// Create the necessary prototypes
@@ -163,7 +171,7 @@
Int64Ty, /*size*/
VoidPtrTy, /*dest for type tag*/
NULL);
- trackLoadInst = M.getOrInsertFunction("checkType",
+ checkTypeInst = M.getOrInsertFunction("checkType",
VoidTy,
Int8Ty,/*type*/
Int64Ty,/*size*/
@@ -171,6 +179,13 @@
VoidPtrTy,/*ptr*/
Int32Ty,/*tag*/
NULL);
+ setTypeInfo = M.getOrInsertFunction("setTypeInfo",
+ VoidTy,
+ VoidPtrTy,/*dest ptr*/
+ VoidPtrTy,/*metadata*/
+ Int64Ty,/*size*/
+ Int32Ty,/*tag*/
+ NULL);
copyTypeInfo = M.getOrInsertFunction("copyTypeInfo",
VoidTy,
VoidPtrTy,/*dest ptr*/
@@ -310,18 +325,10 @@
for (inst_iterator II = inst_begin(F), IE = inst_end(F); II != IE;++II) {
Instruction &I = *II;
if (StoreInst *SI = dyn_cast<StoreInst>(&I)) {
- if (TA->isCopyingStore(SI)) {
- Value *SS = TA->getStoreSource(SI);
- if (SS != NULL) {
- modified |= visitCopyingStoreInst(M, *SI, SS);
- }
- } else {
+ if(!isa<LoadInst>(SI->getOperand(0)))
modified |= visitStoreInst(M, *SI);
- }
} else if (LoadInst *LI = dyn_cast<LoadInst>(&I)) {
- if (!TA->isCopyingLoad(LI)) {
modified |= visitLoadInst(M, *LI);
- }
} else if (CallInst *CI = dyn_cast<CallInst>(&I)) {
modified |= visitCallInst(M, *CI);
} else if (InvokeInst *II = dyn_cast<InvokeInst>(&I)) {
@@ -590,11 +597,12 @@
NII++;
AllocaInst *Counter = new AllocaInst(Int64Ty, "",&*InsPt);
new StoreInst(NII, Counter, &*InsPt);
- CounterMap[NII] = Counter;
+ errs() << F->getNameStr() <<"\n";
NII++;
AllocaInst *VAMDLoc = new AllocaInst(VoidPtrTy, "", &*InsPt);
new StoreInst(NII, VAMDLoc, &*InsPt);
+ CounterMap[ValueMap[VAListArg]] = Counter;
// Find all va_copy calls
for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) {
for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;I++) {
@@ -625,7 +633,9 @@
if(!VI)
continue;
Constant *One = ConstantInt::get(Int64Ty, 1);
+ VI->getOperand(0)->stripPointerCasts()->dump();
Value *CounterSrc = CounterMap[VI->getOperand(0)->stripPointerCasts()];
+ CounterSrc->dump();
LoadInst *OldValue = new LoadInst(CounterSrc, "count", VI);
Instruction *NewValue = BinaryOperator::Create(BinaryOperator::Add,
OldValue,
@@ -1976,28 +1986,56 @@
Args1.push_back(BCI);
Args1.push_back(getSizeConstant(LI.getType()));
Args1.push_back(BCI_MD);
- CallInst::Create(getTypeTag, Args1.begin(), Args1.end(), "", &LI);
- std::vector<Value *> Args;
- Args.push_back(getTypeMarkerConstant(&LI));
- Args.push_back(getSizeConstant(LI.getType()));
- Args.push_back(BCI_MD);
- Args.push_back(BCI);
- Args.push_back(getTagCounter());
- CallInst::Create(trackLoadInst, Args.begin(), Args.end(), "", &LI);
-
- /*for(Value::use_iterator II = LI.use_begin(); II != LI.use_end(); ++II) {
+ CallInst *getTypeCall = CallInst::Create(getTypeTag, Args1.begin(), Args1.end(), "", &LI);
+ if(TrackAllLoads) {
+ std::vector<Value *> Args;
+ Args.push_back(getTypeMarkerConstant(&LI));
+ Args.push_back(getSizeConstant(LI.getType()));
+ Args.push_back(BCI_MD);
+ Args.push_back(BCI);
+ Args.push_back(getTagCounter());
+ CallInst::Create(checkTypeInst, Args.begin(), Args.end(), "", &LI);
+ }
+ for(Value::use_iterator II = LI.use_begin(); II != LI.use_end(); ++II) {
+ if(DisablePtrCmpChecks) {
+ if(isa<CmpInst>(II)) {
+ if(LI.getType()->isPointerTy())
+ continue;
+ }
+ }
std::vector<Value *> Args;
Args.push_back(getTypeMarkerConstant(&LI));
Args.push_back(getSizeConstant(LI.getType()));
Args.push_back(BCI_MD);
Args.push_back(BCI);
Args.push_back(getTagCounter());
- CallInst::Create(trackLoadInst, Args.begin(), Args.end(), "", cast<Instruction>(II.getUse().getUser()));
- }*/
+ if(StoreInst *SI = dyn_cast<StoreInst>(II)) {
+ // Cast the pointer operand to i8* for the runtime function.
+ CastInst *BCI_Dest = BitCastInst::CreatePointerCast(SI->getPointerOperand(), VoidPtrTy, "", SI);
+
+ std::vector<Value *> Args;
+ Args.push_back(BCI_Dest);
+ Args.push_back(BCI_MD);
+ Args.push_back(getSizeConstant(SI->getOperand(0)->getType()));
+ Args.push_back(getTagCounter());
+ // Create the call to the runtime check and place it before the copying store instruction.
+ CallInst::Create(setTypeInfo, Args.begin(), Args.end(), "", SI);
+ }
+ else if(PHINode *PH = dyn_cast<PHINode>(II)) {
+ BasicBlock *BB = PH->getIncomingBlock(II);
+ CallInst::Create(checkTypeInst, Args.begin(), Args.end(), "", BB->getTerminator());
+ } else {
+ CallInst::Create(checkTypeInst, Args.begin(), Args.end(), "", cast<Instruction>(II.getUse().getUser()));
+ }
+ }
+ if(BCI_MD->getNumUses() == 1) {
+ // No uses needed checks
+ getTypeCall->eraseFromParent();
+ }
+
// Create the call to the runtime check and place it before the load instruction.
- //CallInst::Create(trackLoadInst, Args.begin(), Args.end(), "", &LI);
numLoadChecks++;
return true;
}
@@ -2020,21 +2058,3 @@
return true;
}
-// Insert runtime checks before copying store instructions.
-bool TypeChecks::visitCopyingStoreInst(Module &M, StoreInst &SI, Value *SS) {
- // 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);
-
- std::vector<Value *> Args;
- Args.push_back(BCI_Dest);
- Args.push_back(BCI_Src);
- Args.push_back(getSizeConstant(SI.getOperand(0)->getType()));
- Args.push_back(getTagCounter());
-
- // Create the call to the runtime check and place it before the copying store instruction.
- CallInst::Create(copyTypeInfo, Args.begin(), Args.end(), "", &SI);
- numStoreChecks++;
-
- return true;
-}
Removed: poolalloc/trunk/lib/AssistDS/TypeChecksCmpOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecksCmpOpt.cpp?rev=133519&view=auto
==============================================================================
--- poolalloc/trunk/lib/AssistDS/TypeChecksCmpOpt.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/TypeChecksCmpOpt.cpp (removed)
@@ -1,97 +0,0 @@
-//===---------- TypeChecksOpt.h - Remove safe runtime type checks ---------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This pass removes type checks that are statically proven safe
-//
-//===----------------------------------------------------------------------===//
-
-#include "assistDS/TypeChecksCmpOpt.h"
-#include "llvm/Constants.h"
-#include "llvm/Transforms/Utils/Cloning.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/Module.h"
-#include "llvm/Assembly/Writer.h"
-#include "llvm/Support/Debug.h"
-#include "llvm/Support/InstIterator.h"
-#include "llvm/Support/raw_ostream.h"
-#include "llvm/Intrinsics.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/ADT/Statistic.h"
-
-#include <set>
-#include <vector>
-
-using namespace llvm;
-
-char TypeChecksCmpOpt::ID = 0;
-
-static RegisterPass<TypeChecksCmpOpt>
-TC("typechecks-cmp-opt", "Remove runtime type checks", false, true);
-
-// Pass statistics
-STATISTIC(numSafe, "Number of type checks on loads used in Cmp");
-
-static const Type *VoidTy = 0;
-static const Type *Int8Ty = 0;
-static const Type *Int32Ty = 0;
-static const Type *Int64Ty = 0;
-static const PointerType *VoidPtrTy = 0;
-static Constant *trackLoadInst;
-
-bool TypeChecksCmpOpt::runOnModule(Module &M) {
-
- // Create the necessary prototypes
- VoidTy = IntegerType::getVoidTy(M.getContext());
- Int8Ty = IntegerType::getInt8Ty(M.getContext());
- Int32Ty = IntegerType::getInt32Ty(M.getContext());
- Int64Ty = IntegerType::getInt64Ty(M.getContext());
- VoidPtrTy = PointerType::getUnqual(Int8Ty);
-
- trackLoadInst = M.getOrInsertFunction("trackLoadInst",
- VoidTy,
- VoidPtrTy,/*ptr*/
- Int8Ty,/*type*/
- Int64Ty,/*size*/
- Int32Ty,/*tag*/
- NULL);
- for(Value::use_iterator User = trackLoadInst->use_begin(); User != trackLoadInst->use_end(); ++User) {
- CallInst *CI = dyn_cast<CallInst>(User);
- assert(CI);
- Value *LPtr = CI->getOperand(1)->stripPointerCasts();
- for(Value::use_iterator II = LPtr->use_begin(); II != LPtr->use_end(); ++II) {
- if(LoadInst *LI = dyn_cast<LoadInst>(II)) {
- if(LI->getOperand(0) == LPtr) {
- if(LI->getType()->isPointerTy()) {
- bool allIcmpUse = true;
- for(Value::use_iterator EE = LI->use_begin(); EE != LI->use_end(); ++EE) {
- if(!isa<ICmpInst>(EE)) {
- allIcmpUse = false;
- break;
- }
- }
- if(allIcmpUse) {
- toDelete.insert(CI);
- LI->dump();
- }
- }
- }
- }
- }
- }
-
- numSafe += toDelete.size();
-
- std::set<Instruction*>::iterator II = toDelete.begin();
- for(; II != toDelete.end();) {
- Instruction *I = *II++;
- I->eraseFromParent();
- }
- return (numSafe > 0);
-}
-
Modified: poolalloc/trunk/lib/AssistDS/TypeChecksOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecksOpt.cpp?rev=133520&r1=133519&r2=133520&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/TypeChecksOpt.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/TypeChecksOpt.cpp Tue Jun 21 11:05:06 2011
@@ -49,6 +49,8 @@
static Constant *trackStoreInst;
static Constant *trackLoadInst;
static Constant *copyTypeInfo;
+static Constant *setTypeInfo;
+static Constant *checkTypeInst;
static Constant *MallocFunc;
bool TypeChecksOpt::runOnModule(Module &M) {
@@ -94,6 +96,14 @@
Int64Ty,/*size*/
Int32Ty,/*tag*/
NULL);
+ checkTypeInst = M.getOrInsertFunction("checkType",
+ VoidTy,
+ Int8Ty,/*type*/
+ Int64Ty,/*size*/
+ VoidPtrTy,
+ VoidPtrTy,/*ptr*/
+ Int32Ty,/*tag*/
+ NULL);
trackLoadInst = M.getOrInsertFunction("trackLoadInst",
VoidTy,
VoidPtrTy,/*ptr*/
@@ -108,6 +118,13 @@
Int64Ty,/*size*/
Int32Ty,/*tag*/
NULL);
+ setTypeInfo = M.getOrInsertFunction("setTypeInfo",
+ VoidTy,
+ VoidPtrTy,/*dest ptr*/
+ VoidPtrTy,/*metadata*/
+ Int64Ty,/*size*/
+ Int32Ty,/*tag*/
+ NULL);
trackStringInput = M.getOrInsertFunction("trackStringInput",
VoidTy,
VoidPtrTy,
@@ -128,11 +145,11 @@
}
}
- for(Value::use_iterator User = trackLoadInst->use_begin(); User != trackLoadInst->use_end(); ++User) {
+ for(Value::use_iterator User = checkTypeInst->use_begin(); User != checkTypeInst->use_end(); ++User) {
CallInst *CI = dyn_cast<CallInst>(User);
assert(CI);
- if(TS->isTypeSafe(CI->getOperand(1)->stripPointerCasts(), CI->getParent()->getParent())) {
+ if(TS->isTypeSafe(CI->getOperand(4)->stripPointerCasts(), CI->getParent()->getParent())) {
toDelete.push_back(CI);
}
}
@@ -195,6 +212,19 @@
toDelete.push_back(CI);
}
}
+ for(Value::use_iterator User = setTypeInfo->use_begin(); User != setTypeInfo->use_end(); ++User) {
+ CallInst *CI = dyn_cast<CallInst>(User);
+ assert(CI);
+
+ if(TS->isTypeSafe(CI->getOperand(1)->stripPointerCasts(), CI->getParent()->getParent())) {
+ std::vector<Value*> Args;
+ Args.push_back(CI->getOperand(1));
+ Args.push_back(CI->getOperand(3)); // size
+ Args.push_back(CI->getOperand(4));
+ CallInst::Create(trackInitInst, Args.begin(), Args.end(), "", CI);
+ toDelete.push_back(CI);
+ }
+ }
numSafe += toDelete.size();
More information about the llvm-commits
mailing list