mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-01 16:26:29 +00:00
InstCombine: Don't shrink allocas when combining with a bitcast.
When considering folding a bitcast of an alloca into the alloca itself, make sure we don't shrink the amount of memory being allocated, or things rapidly go sideways. rdar://13324424 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176547 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -104,6 +104,12 @@ Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI,
|
||||
uint64_t CastElTySize = TD->getTypeAllocSize(CastElTy);
|
||||
if (CastElTySize == 0 || AllocElTySize == 0) return 0;
|
||||
|
||||
// If the allocation has multiple uses, only promote it if we're not
|
||||
// shrinking the amount of memory being allocated.
|
||||
uint64_t AllocElTyStoreSize = TD->getTypeStoreSize(AllocElTy);
|
||||
uint64_t CastElTyStoreSize = TD->getTypeStoreSize(CastElTy);
|
||||
if (!AI.hasOneUse() && CastElTyStoreSize < AllocElTyStoreSize) return 0;
|
||||
|
||||
// See if we can satisfy the modulus by pulling a scale out of the array
|
||||
// size argument.
|
||||
unsigned ArraySizeScale;
|
||||
|
Reference in New Issue
Block a user