diff options
author | Eric Christopher <echristo@apple.com> | 2010-02-03 00:21:58 +0000 |
---|---|---|
committer | Eric Christopher <echristo@apple.com> | 2010-02-03 00:21:58 +0000 |
commit | d86233c1188429c3d3a36c34b65160a4aef08774 (patch) | |
tree | 5973dc6282101a95a01d7fad576e7dcde1a14933 /llvm/lib/Transforms/Scalar/SimplifyLibCalls.cpp | |
parent | 08d614d92eab71487a1ef7c9f343bae6bfaea081 (diff) | |
download | bcm5719-llvm-d86233c1188429c3d3a36c34b65160a4aef08774.tar.gz bcm5719-llvm-d86233c1188429c3d3a36c34b65160a4aef08774.zip |
Recommit this, looks like it wasn't the cause.
llvm-svn: 95165
Diffstat (limited to 'llvm/lib/Transforms/Scalar/SimplifyLibCalls.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/SimplifyLibCalls.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Scalar/SimplifyLibCalls.cpp index db6ff29200f..4216e8f995c 100644 --- a/llvm/lib/Transforms/Scalar/SimplifyLibCalls.cpp +++ b/llvm/lib/Transforms/Scalar/SimplifyLibCalls.cpp @@ -1213,8 +1213,13 @@ struct StrCpyChkOpt : public LibCallOptimization { if (!SizeCI) return 0; - // We don't have any length information, just lower to a plain strcpy. - if (SizeCI->isAllOnesValue()) + // If a) we don't have any length information, or b) we know this will + // fit then just lower to a plain strcpy. Otherwise we'll keep our + // strcpy_chk call which may fail at runtime if the size is too long. + // TODO: It might be nice to get a maximum length out of the possible + // string lengths for varying. + if (SizeCI->isAllOnesValue() || + SizeCI->getZExtValue() >= GetStringLength(CI->getOperand(2))) return EmitStrCpy(CI->getOperand(1), CI->getOperand(2), B); return 0; |