<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div>This seems to break our bot:<div><span class="Apple-style-span" style="font-family: Times; "><pre style="font-family: 'Courier New', courier, monotype, monospace; "><span class="stderr" style="font-family: 'Courier New', courier, monotype, monospace; color: red; ">/home/jabbey/tmp/buildbot/sandbox/clang-x86_64-ubuntu/clang-x86_64-ubuntu/llvm/Debug+Asserts/lib/libLLVMAnalysis.a(MemoryBuiltins.o): In function `llvm::ObjectSizeOffsetEvaluator::visitCallSite(llvm::CallSite)':
/home/jabbey/tmp/buildbot/sandbox/clang-x86_64-ubuntu/clang-x86_64-ubuntu/llvm/lib/Analysis/MemoryBuiltins.cpp:627: undefined reference to `llvm::EmitStrLen(llvm::Value*, llvm::IRBuilder<true, llvm::ConstantFolder, llvm::IRBuilderDefaultInserter<true> >&, llvm::TargetData const*, llvm::TargetLibraryInfo const*)'
/home/jabbey/tmp/buildbot/sandbox/clang-x86_64-ubuntu/clang-x86_64-ubuntu/llvm/lib/Analysis/MemoryBuiltins.cpp:631: undefined reference to `llvm::EmitStrNLen(llvm::Value*, llvm::Value*, llvm::IRBuilder<true, llvm::ConstantFolder, llvm::IRBuilderDefaultInserter<true> >&, llvm::TargetData const*, llvm::TargetLibraryInfo const*)'
collect2: ld returned 1 exit status
make[2]: *** [/home/jabbey/tmp/buildbot/sandbox/clang-x86_64-ubuntu/clang-x86_64-ubuntu/llvm/Debug+Asserts/bin/llvm-link] Error 1
</span><span class="stdout" style="font-family: 'Courier New', courier, monotype, monospace; color: black; ">make[2]: Leaving directory `/home/jabbey/tmp/buildbot/sandbox/clang-x86_64-ubuntu/clang-x86_64-ubuntu/llvm/tools/llvm-link'
</span><span class="stderr" style="font-family: 'Courier New', courier, monotype, monospace; color: red; ">make[1]: *** [llvm-link/.makeall] Error 2
make[1]: *** Waiting for unfinished jobs....</span></pre></span><div><br></div><div>Thanks,</div><div>Manman</div><div><br></div><div><div>On Jul 25, 2012, at 10:29 AM, Nuno Lopes wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Author: nlopes<br>Date: Wed Jul 25 12:29:22 2012<br>New Revision: 160742<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=160742&view=rev">http://llvm.org/viewvc/llvm-project?rev=160742&view=rev</a><br>Log:<br>MemoryBuiltins: add support to determine the size of strdup'ed non-constant strings<br><br>Added:<br> llvm/trunk/test/Instrumentation/BoundsChecking/strings.ll<br>Modified:<br> llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h<br> llvm/trunk/lib/Analysis/MemoryBuiltins.cpp<br> llvm/trunk/lib/Transforms/Instrumentation/BoundsChecking.cpp<br><br>Modified: llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h?rev=160742&r1=160741&r2=160742&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h?rev=160742&r1=160741&r2=160742&view=diff</a><br>==============================================================================<br>--- llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h (original)<br>+++ llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h Wed Jul 25 12:29:22 2012<br>@@ -201,6 +201,7 @@<br> typedef SmallPtrSet<const Value*, 8> PtrSetTy;<br><br> const TargetData *TD;<br>+ const TargetLibraryInfo *TLI;<br> LLVMContext &Context;<br> BuilderTy Builder;<br> ObjectSizeOffsetVisitor Visitor;<br>@@ -215,7 +216,8 @@<br> SizeOffsetEvalType compute_(Value *V);<br><br> public:<br>- ObjectSizeOffsetEvaluator(const TargetData *TD, LLVMContext &Context);<br>+ ObjectSizeOffsetEvaluator(const TargetData *TD, const TargetLibraryInfo *TLI,<br>+ LLVMContext &Context);<br> SizeOffsetEvalType compute(Value *V);<br><br> bool knownSize(SizeOffsetEvalType SizeOffset) {<br><br>Modified: llvm/trunk/lib/Analysis/MemoryBuiltins.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryBuiltins.cpp?rev=160742&r1=160741&r2=160742&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryBuiltins.cpp?rev=160742&r1=160741&r2=160742&view=diff</a><br>==============================================================================<br>--- llvm/trunk/lib/Analysis/MemoryBuiltins.cpp (original)<br>+++ llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Wed Jul 25 12:29:22 2012<br>@@ -26,6 +26,7 @@<br> #include "llvm/Support/MathExtras.h"<br> #include "llvm/Support/raw_ostream.h"<br> #include "llvm/Target/TargetData.h"<br>+#include "llvm/Transforms/Utils/BuildLibCalls.h"<br> #include "llvm/Transforms/Utils/Local.h"<br> using namespace llvm;<br><br>@@ -448,11 +449,9 @@<br> return std::make_pair(Size, Zero);<br><br> // TODO: handle more standard functions (+ wchar cousins):<br>- // - strdup / strndup<br> // - strcpy / strncpy<br> // - strcat / strncat<br> // - memcpy / memmove<br>- // - strcat / strncat<br> // - memset<br> }<br><br>@@ -524,8 +523,9 @@<br><br><br> ObjectSizeOffsetEvaluator::ObjectSizeOffsetEvaluator(const TargetData *TD,<br>+ const TargetLibraryInfo *TLI,<br> LLVMContext &Context)<br>-: TD(TD), Context(Context), Builder(Context, TargetFolder(TD)),<br>+: TD(TD), TLI(TLI), Context(Context), Builder(Context, TargetFolder(TD)),<br> Visitor(TD, Context) {<br> IntTy = TD->getIntPtrType(Context);<br> Zero = ConstantInt::get(IntTy, 0);<br>@@ -619,8 +619,21 @@<br><br> // handle strdup-like functions separately<br> if (FnData->AllocTy == StrDupLike) {<br>- // TODO<br>- return unknown();<br>+ IRBuilder<> StdBuilder(Builder.GetInsertPoint());<br>+ Value *Size;<br>+<br>+ // strdup(str): size = strlen(str)+1<br>+ if (FnData->FstParam < 0)<br>+ Size = EmitStrLen(CS.getArgument(0), StdBuilder, TD, TLI);<br>+ else<br>+ // strndup(str, maxlen): size = strnlen(str, maxlen)+1<br>+ Size = EmitStrNLen(CS.getArgument(0), CS.getArgument(FnData->FstParam),<br>+ StdBuilder, TD, TLI);<br>+ if (!Size)<br>+ return unknown();<br>+ Builder.SetInsertPoint(StdBuilder.GetInsertPoint());<br>+ Size = Builder.CreateNUWAdd(Size, ConstantInt::get(IntTy, 1));<br>+ return std::make_pair(Size, Zero);<br> }<br><br> Value *FirstArg = CS.getArgument(FnData->FstParam);<br>@@ -634,11 +647,9 @@<br> return std::make_pair(Size, Zero);<br><br> // TODO: handle more standard functions (+ wchar cousins):<br>- // - strdup / strndup<br> // - strcpy / strncpy<br> // - strcat / strncat<br> // - memcpy / memmove<br>- // - strcat / strncat<br> // - memset<br> }<br><br><br>Modified: llvm/trunk/lib/Transforms/Instrumentation/BoundsChecking.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/BoundsChecking.cpp?rev=160742&r1=160741&r2=160742&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/BoundsChecking.cpp?rev=160742&r1=160741&r2=160742&view=diff</a><br>==============================================================================<br>--- llvm/trunk/lib/Transforms/Instrumentation/BoundsChecking.cpp (original)<br>+++ llvm/trunk/lib/Transforms/Instrumentation/BoundsChecking.cpp Wed Jul 25 12:29:22 2012<br>@@ -24,6 +24,7 @@<br> #include "llvm/Support/TargetFolder.h"<br> #include "llvm/Support/raw_ostream.h"<br> #include "llvm/Target/TargetData.h"<br>+#include "llvm/Target/TargetLibraryInfo.h"<br> #include "llvm/Transforms/Instrumentation.h"<br> using namespace llvm;<br><br>@@ -48,6 +49,7 @@<br><br> virtual void getAnalysisUsage(AnalysisUsage &AU) const {<br> AU.addRequired<TargetData>();<br>+ AU.addRequired<TargetLibraryInfo>();<br> }<br><br> private:<br>@@ -166,11 +168,12 @@<br><br> bool BoundsChecking::runOnFunction(Function &F) {<br> TD = &getAnalysis<TargetData>();<br>+ const TargetLibraryInfo *TLI = &getAnalysis<TargetLibraryInfo>();<br><br> TrapBB = 0;<br> BuilderTy TheBuilder(F.getContext(), TargetFolder(TD));<br> Builder = &TheBuilder;<br>- ObjectSizeOffsetEvaluator TheObjSizeEval(TD, F.getContext());<br>+ ObjectSizeOffsetEvaluator TheObjSizeEval(TD, TLI, F.getContext());<br> ObjSizeEval = &TheObjSizeEval;<br><br> // check HANDLE_MEMORY_INST in include/llvm/Instruction.def for memory<br><br>Added: llvm/trunk/test/Instrumentation/BoundsChecking/strings.ll<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/BoundsChecking/strings.ll?rev=160742&view=auto">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/BoundsChecking/strings.ll?rev=160742&view=auto</a><br>==============================================================================<br>--- llvm/trunk/test/Instrumentation/BoundsChecking/strings.ll (added)<br>+++ llvm/trunk/test/Instrumentation/BoundsChecking/strings.ll Wed Jul 25 12:29:22 2012<br>@@ -0,0 +1,31 @@<br>+; RUN: opt < %s -bounds-checking -S | FileCheck %s<br>+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"<br>+<br>+declare noalias i8* @strdup(i8* nocapture) nounwind<br>+declare noalias i8* @strndup(i8* nocapture, i64) nounwind<br>+<br>+; CHECK: @f1<br>+define i8 @f1(i8* nocapture %str, i8** nocapture %esc) nounwind uwtable ssp {<br>+; CHECK: call i64 @strlen(i8* %str)<br>+; CHECK-NEXT: %1 = add nuw i64 {{.*}}, 1<br>+ %call = tail call i8* @strdup(i8* %str) nounwind<br>+ store i8* %call, i8** %esc, align 8<br>+ %arrayidx = getelementptr inbounds i8* %call, i64 3<br>+; CHECK: sub i64 %1, 3<br>+ %1 = load i8* %arrayidx, align 1<br>+ ret i8 %1<br>+; CHECK: call void @llvm.trap<br>+}<br>+<br>+; CHECK: @f2<br>+define i8 @f2(i8* nocapture %str, i8** nocapture %esc, i64 %limit) nounwind uwtable ssp {<br>+; CHECK: call i64 @strnlen(i8* %str, i64 %limit)<br>+; CHECK-NEXT: %1 = add nuw i64 {{.*}}, 1<br>+ %call = tail call i8* @strndup(i8* %str, i64 %limit) nounwind<br>+ store i8* %call, i8** %esc, align 8<br>+ %arrayidx = getelementptr inbounds i8* %call, i64 3<br>+; CHECK: sub i64 %1, 3<br>+ %1 = load i8* %arrayidx, align 1<br>+ ret i8 %1<br>+; CHECK: call void @llvm.trap<br>+}<br><br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br></div></blockquote></div><br></div></body></html>