summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Schouten <ed@80386.nl>2009-04-06 13:06:48 +0000
committerEd Schouten <ed@80386.nl>2009-04-06 13:06:48 +0000
commit01aa6ec97a49a2b36863c9d17b302f68c2d2b361 (patch)
tree1a72fd245926444e504de88646bd695fc5a65c76
parent0b08df8c0944cbfd3681ac7bb1d389a2d4362f75 (diff)
downloadbcm5719-llvm-01aa6ec97a49a2b36863c9d17b302f68c2d2b361.tar.gz
bcm5719-llvm-01aa6ec97a49a2b36863c9d17b302f68c2d2b361.zip
Let the strcat optimizer return the pointer to the start of the buffer,
instead of the place where it started to perform the string copy. - PR3661 - Patch by Benjamin Kramer! llvm-svn: 68443
-rw-r--r--llvm/lib/Transforms/Scalar/SimplifyLibCalls.cpp4
-rw-r--r--llvm/test/Transforms/SimplifyLibCalls/StrCat.ll3
2 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Scalar/SimplifyLibCalls.cpp
index b878e4b4790..c84c23340fc 100644
--- a/llvm/lib/Transforms/Scalar/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Scalar/SimplifyLibCalls.cpp
@@ -514,11 +514,11 @@ struct VISIBILITY_HIDDEN StrCatOpt : public LibCallOptimization {
// Now that we have the destination's length, we must index into the
// destination's pointer to get the actual memcpy destination (end of
// the string .. we're concatenating).
- Dst = B.CreateGEP(Dst, DstLen, "endptr");
+ Value *CpyDst = B.CreateGEP(Dst, DstLen, "endptr");
// We have enough information to now generate the memcpy call to do the
// concatenation for us. Make a memcpy to copy the nul byte with align = 1.
- EmitMemCpy(Dst, Src, ConstantInt::get(TD->getIntPtrType(), Len+1), 1, B);
+ EmitMemCpy(CpyDst, Src, ConstantInt::get(TD->getIntPtrType(), Len+1), 1, B);
return Dst;
}
};
diff --git a/llvm/test/Transforms/SimplifyLibCalls/StrCat.ll b/llvm/test/Transforms/SimplifyLibCalls/StrCat.ll
index a6ef6771b46..89ef4ea49a7 100644
--- a/llvm/test/Transforms/SimplifyLibCalls/StrCat.ll
+++ b/llvm/test/Transforms/SimplifyLibCalls/StrCat.ll
@@ -1,6 +1,9 @@
; Test that the StrCatOptimizer works correctly
+; PR3661
; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
; RUN: not grep {call.*strcat}
+; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
+; RUN: grep {puts.*%arg1}
@hello = constant [6 x i8] c"hello\00" ; <[6 x i8]*> [#uses=1]
@null = constant [1 x i8] zeroinitializer ; <[1 x i8]*> [#uses=1]
OpenPOWER on IntegriCloud