diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/README.txt | 22 | ||||
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | 4 |
2 files changed, 22 insertions, 4 deletions
diff --git a/llvm/lib/Target/README.txt b/llvm/lib/Target/README.txt index d13ea736a10..5cc4fe027a8 100644 --- a/llvm/lib/Target/README.txt +++ b/llvm/lib/Target/README.txt @@ -2009,6 +2009,28 @@ entry: //===---------------------------------------------------------------------===// +This code can be seen in viterbi: + + %64 = call noalias i8* @malloc(i64 %62) nounwind +... + %67 = call i64 @llvm.objectsize.i64(i8* %64, i1 false) nounwind + %68 = call i8* @__memset_chk(i8* %64, i32 0, i64 %62, i64 %67) nounwind + +llvm.objectsize.i64 should be taught about malloc/calloc, allowing it to +fold to %62. This is a security win (overflows of malloc will get caught) +and also a performance win by exposing more memsets to the optimizer. + +This occurs several times in viterbi. + +Note that this would change the semantics of @llvm.objectsize which by its +current definition always folds to a constant. We also should make sure that +we remove checking in code like + + char *p = malloc(strlen(s)+1); + __strcpy_chk(p, s, __builtin_objectsize(p, 0)); + +//===---------------------------------------------------------------------===// + This code (from Benchmarks/Dhrystone/dry.c): define i32 @Func1(i32, i32) nounwind readnone optsize ssp { diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index ecd2243c35d..bd451ebcac9 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -304,10 +304,6 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { if (Value *NElems = getMallocArraySize(MI, TD, true)) if (ConstantInt *NElements = dyn_cast<ConstantInt>(NElems)) Size = NElements->getZExtValue() * TD->getTypeAllocSize(MallocType); - - // If there is no offset we can just return the size passed to malloc. - if (Offset == 0) - return ReplaceInstUsesWith(CI, MI->getArgOperand(0)); } // Do not return "I don't know" here. Later optimization passes could |