diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-01-06 14:22:52 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-01-06 14:22:52 +0000 |
commit | ae67cc13a99e65b00f5e706514e2ca4e6ea880fd (patch) | |
tree | f40003976ad23bbf8f299f090741ce8c138cfc81 /llvm/lib/Transforms | |
parent | 605f21a6c857260e2a46f09333ef223ad4cdee52 (diff) | |
download | bcm5719-llvm-ae67cc13a99e65b00f5e706514e2ca4e6ea880fd.tar.gz bcm5719-llvm-ae67cc13a99e65b00f5e706514e2ca4e6ea880fd.zip |
InstCombine: Turn _chk functions into the "unsafe" variant if length and max langth are equal.
This happens when we take the (non-constant) length from a malloc.
llvm-svn: 122961
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index 603a01075a5..ecd2243c35d 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -722,6 +722,8 @@ protected: NewInstruction = IC->ReplaceInstUsesWith(*CI, With); } bool isFoldable(unsigned SizeCIOp, unsigned SizeArgOp, bool isString) const { + if (CI->getArgOperand(SizeCIOp) == CI->getArgOperand(SizeArgOp)) + return true; if (ConstantInt *SizeCI = dyn_cast<ConstantInt>(CI->getArgOperand(SizeCIOp))) { if (SizeCI->isAllOnesValue()) |