diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2012-07-25 18:49:28 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2012-07-25 18:49:28 +0000 |
commit | 6e699bf38dd862331532bd6f74ec491bdfad5db9 (patch) | |
tree | d775d86c6bf8e200b4b37ebf7e90d113e209cb69 /lib | |
parent | d68e8cda245269c032a692873dc8eb163fa6ef00 (diff) | |
download | external_llvm-6e699bf38dd862331532bd6f74ec491bdfad5db9.zip external_llvm-6e699bf38dd862331532bd6f74ec491bdfad5db9.tar.gz external_llvm-6e699bf38dd862331532bd6f74ec491bdfad5db9.tar.bz2 |
revert r160742: it's breaking CMake build
original commit msg:
MemoryBuiltins: add support to determine the size of strdup'ed non-constant strings
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160751 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/MemoryBuiltins.cpp | 25 | ||||
-rw-r--r-- | lib/Transforms/Instrumentation/BoundsChecking.cpp | 5 |
2 files changed, 8 insertions, 22 deletions
diff --git a/lib/Analysis/MemoryBuiltins.cpp b/lib/Analysis/MemoryBuiltins.cpp index 2141778..4833b52 100644 --- a/lib/Analysis/MemoryBuiltins.cpp +++ b/lib/Analysis/MemoryBuiltins.cpp @@ -26,7 +26,6 @@ #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetData.h" -#include "llvm/Transforms/Utils/BuildLibCalls.h" #include "llvm/Transforms/Utils/Local.h" using namespace llvm; @@ -449,9 +448,11 @@ SizeOffsetType ObjectSizeOffsetVisitor::visitCallSite(CallSite CS) { return std::make_pair(Size, Zero); // TODO: handle more standard functions (+ wchar cousins): + // - strdup / strndup // - strcpy / strncpy // - strcat / strncat // - memcpy / memmove + // - strcat / strncat // - memset } @@ -523,9 +524,8 @@ SizeOffsetType ObjectSizeOffsetVisitor::visitInstruction(Instruction &I) { ObjectSizeOffsetEvaluator::ObjectSizeOffsetEvaluator(const TargetData *TD, - const TargetLibraryInfo *TLI, LLVMContext &Context) -: TD(TD), TLI(TLI), Context(Context), Builder(Context, TargetFolder(TD)), +: TD(TD), Context(Context), Builder(Context, TargetFolder(TD)), Visitor(TD, Context) { IntTy = TD->getIntPtrType(Context); Zero = ConstantInt::get(IntTy, 0); @@ -619,21 +619,8 @@ SizeOffsetEvalType ObjectSizeOffsetEvaluator::visitCallSite(CallSite CS) { // handle strdup-like functions separately if (FnData->AllocTy == StrDupLike) { - IRBuilder<> StdBuilder(Builder.GetInsertPoint()); - Value *Size; - - // strdup(str): size = strlen(str)+1 - if (FnData->FstParam < 0) - Size = EmitStrLen(CS.getArgument(0), StdBuilder, TD, TLI); - else - // strndup(str, maxlen): size = strnlen(str, maxlen)+1 - Size = EmitStrNLen(CS.getArgument(0), CS.getArgument(FnData->FstParam), - StdBuilder, TD, TLI); - if (!Size) - return unknown(); - Builder.SetInsertPoint(StdBuilder.GetInsertPoint()); - Size = Builder.CreateNUWAdd(Size, ConstantInt::get(IntTy, 1)); - return std::make_pair(Size, Zero); + // TODO + return unknown(); } Value *FirstArg = CS.getArgument(FnData->FstParam); @@ -647,9 +634,11 @@ SizeOffsetEvalType ObjectSizeOffsetEvaluator::visitCallSite(CallSite CS) { return std::make_pair(Size, Zero); // TODO: handle more standard functions (+ wchar cousins): + // - strdup / strndup // - strcpy / strncpy // - strcat / strncat // - memcpy / memmove + // - strcat / strncat // - memset } diff --git a/lib/Transforms/Instrumentation/BoundsChecking.cpp b/lib/Transforms/Instrumentation/BoundsChecking.cpp index b209fff..09e0f14 100644 --- a/lib/Transforms/Instrumentation/BoundsChecking.cpp +++ b/lib/Transforms/Instrumentation/BoundsChecking.cpp @@ -24,7 +24,6 @@ #include "llvm/Support/TargetFolder.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetData.h" -#include "llvm/Target/TargetLibraryInfo.h" #include "llvm/Transforms/Instrumentation.h" using namespace llvm; @@ -49,7 +48,6 @@ namespace { virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<TargetData>(); - AU.addRequired<TargetLibraryInfo>(); } private: @@ -168,12 +166,11 @@ bool BoundsChecking::instrument(Value *Ptr, Value *InstVal) { bool BoundsChecking::runOnFunction(Function &F) { TD = &getAnalysis<TargetData>(); - const TargetLibraryInfo *TLI = &getAnalysis<TargetLibraryInfo>(); TrapBB = 0; BuilderTy TheBuilder(F.getContext(), TargetFolder(TD)); Builder = &TheBuilder; - ObjectSizeOffsetEvaluator TheObjSizeEval(TD, TLI, F.getContext()); + ObjectSizeOffsetEvaluator TheObjSizeEval(TD, F.getContext()); ObjSizeEval = &TheObjSizeEval; // check HANDLE_MEMORY_INST in include/llvm/Instruction.def for memory |