[llvm-commits] [llvm] r160751 - in /llvm/trunk: include/llvm/Analysis/MemoryBuiltins.h lib/Analysis/MemoryBuiltins.cpp lib/Transforms/Instrumentation/BoundsChecking.cpp test/Instrumentation/BoundsChecking/strings.ll
Nuno Lopes
nunoplopes at sapo.pt
Wed Jul 25 11:49:28 PDT 2012
Author: nlopes
Date: Wed Jul 25 13:49:28 2012
New Revision: 160751
URL: http://llvm.org/viewvc/llvm-project?rev=160751&view=rev
Log:
revert r160742: it's breaking CMake build
original commit msg:
MemoryBuiltins: add support to determine the size of strdup'ed non-constant strings
Removed:
llvm/trunk/test/Instrumentation/BoundsChecking/strings.ll
Modified:
llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h
llvm/trunk/lib/Analysis/MemoryBuiltins.cpp
llvm/trunk/lib/Transforms/Instrumentation/BoundsChecking.cpp
Modified: llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h?rev=160751&r1=160750&r2=160751&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h (original)
+++ llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h Wed Jul 25 13:49:28 2012
@@ -201,7 +201,6 @@
typedef SmallPtrSet<const Value*, 8> PtrSetTy;
const TargetData *TD;
- const TargetLibraryInfo *TLI;
LLVMContext &Context;
BuilderTy Builder;
ObjectSizeOffsetVisitor Visitor;
@@ -216,8 +215,7 @@
SizeOffsetEvalType compute_(Value *V);
public:
- ObjectSizeOffsetEvaluator(const TargetData *TD, const TargetLibraryInfo *TLI,
- LLVMContext &Context);
+ ObjectSizeOffsetEvaluator(const TargetData *TD, LLVMContext &Context);
SizeOffsetEvalType compute(Value *V);
bool knownSize(SizeOffsetEvalType SizeOffset) {
Modified: llvm/trunk/lib/Analysis/MemoryBuiltins.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryBuiltins.cpp?rev=160751&r1=160750&r2=160751&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MemoryBuiltins.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Wed Jul 25 13:49:28 2012
@@ -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 @@
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 @@
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 @@
// 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 @@
return std::make_pair(Size, Zero);
// TODO: handle more standard functions (+ wchar cousins):
+ // - strdup / strndup
// - strcpy / strncpy
// - strcat / strncat
// - memcpy / memmove
+ // - strcat / strncat
// - memset
}
Modified: llvm/trunk/lib/Transforms/Instrumentation/BoundsChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/BoundsChecking.cpp?rev=160751&r1=160750&r2=160751&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/BoundsChecking.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/BoundsChecking.cpp Wed Jul 25 13:49:28 2012
@@ -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 @@
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<TargetData>();
- AU.addRequired<TargetLibraryInfo>();
}
private:
@@ -168,12 +166,11 @@
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
Removed: llvm/trunk/test/Instrumentation/BoundsChecking/strings.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/BoundsChecking/strings.ll?rev=160750&view=auto
==============================================================================
--- llvm/trunk/test/Instrumentation/BoundsChecking/strings.ll (original)
+++ llvm/trunk/test/Instrumentation/BoundsChecking/strings.ll (removed)
@@ -1,31 +0,0 @@
-; RUN: opt < %s -bounds-checking -S | FileCheck %s
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
-
-declare noalias i8* @strdup(i8* nocapture) nounwind
-declare noalias i8* @strndup(i8* nocapture, i64) nounwind
-
-; CHECK: @f1
-define i8 @f1(i8* nocapture %str, i8** nocapture %esc) nounwind uwtable ssp {
-; CHECK: call i64 @strlen(i8* %str)
-; CHECK-NEXT: %1 = add nuw i64 {{.*}}, 1
- %call = tail call i8* @strdup(i8* %str) nounwind
- store i8* %call, i8** %esc, align 8
- %arrayidx = getelementptr inbounds i8* %call, i64 3
-; CHECK: sub i64 %1, 3
- %1 = load i8* %arrayidx, align 1
- ret i8 %1
-; CHECK: call void @llvm.trap
-}
-
-; CHECK: @f2
-define i8 @f2(i8* nocapture %str, i8** nocapture %esc, i64 %limit) nounwind uwtable ssp {
-; CHECK: call i64 @strnlen(i8* %str, i64 %limit)
-; CHECK-NEXT: %1 = add nuw i64 {{.*}}, 1
- %call = tail call i8* @strndup(i8* %str, i64 %limit) nounwind
- store i8* %call, i8** %esc, align 8
- %arrayidx = getelementptr inbounds i8* %call, i64 3
-; CHECK: sub i64 %1, 3
- %1 = load i8* %arrayidx, align 1
- ret i8 %1
-; CHECK: call void @llvm.trap
-}
More information about the llvm-commits
mailing list