diff options
author | Stuart Hastings <stuart@apple.com> | 2011-06-13 18:48:49 +0000 |
---|---|---|
committer | Stuart Hastings <stuart@apple.com> | 2011-06-13 18:48:49 +0000 |
commit | 7ac8f8f3418c9ee7cb3f27aa9e5033e9b73ef84f (patch) | |
tree | f238f6dcf8994ca679135e870b4b23806fbd9afc /lib/Transforms | |
parent | afa88eaf659a6151624fd11a61d038864339e8e4 (diff) | |
download | external_llvm-7ac8f8f3418c9ee7cb3f27aa9e5033e9b73ef84f.zip external_llvm-7ac8f8f3418c9ee7cb3f27aa9e5033e9b73ef84f.tar.gz external_llvm-7ac8f8f3418c9ee7cb3f27aa9e5033e9b73ef84f.tar.bz2 |
Avoid fusing bitcasts with dynamic allocas if the amount-to-allocate
might overflow. Re-typing the alloca to a larger type (e.g. double)
hoists a shift into the alloca, potentially exposing overflow in the
expression. rdar://problem/9265821
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132926 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineCasts.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCasts.cpp b/lib/Transforms/InstCombine/InstCombineCasts.cpp index 199902a..601d9b4 100644 --- a/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -71,6 +71,11 @@ Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI, // This requires TargetData to get the alloca alignment and size information. if (!TD) return 0; + // Insist that the amount-to-allocate not overflow. + OverflowingBinaryOperator *OBI = + dyn_cast<OverflowingBinaryOperator>(AI.getOperand(0)); + if (OBI && !(OBI->hasNoSignedWrap() || OBI->hasNoUnsignedWrap())) return 0; + const PointerType *PTy = cast<PointerType>(CI.getType()); BuilderTy AllocaBuilder(*Builder); |