diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp index 5694e7ef79b64..7be077162c15e 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -507,8 +507,6 @@ Instruction *InstCombinerImpl::visitAllocaInst(AllocaInst &AI) { // types. const Align MaxAlign = std::max(EntryAI->getAlign(), AI.getAlign()); EntryAI->setAlignment(MaxAlign); - if (AI.getType() != EntryAI->getType()) - return new BitCastInst(EntryAI, AI.getType()); return replaceInstUsesWith(AI, EntryAI); } } @@ -534,13 +532,11 @@ Instruction *InstCombinerImpl::visitAllocaInst(AllocaInst &AI) { LLVM_DEBUG(dbgs() << "Found alloca equal to global: " << AI << '\n'); LLVM_DEBUG(dbgs() << " memcpy = " << *Copy << '\n'); unsigned SrcAddrSpace = TheSrc->getType()->getPointerAddressSpace(); - auto *DestTy = PointerType::get(AI.getAllocatedType(), SrcAddrSpace); if (AI.getAddressSpace() == SrcAddrSpace) { for (Instruction *Delete : ToDelete) eraseInstFromFunction(*Delete); - Value *Cast = Builder.CreateBitCast(TheSrc, DestTy); - Instruction *NewI = replaceInstUsesWith(AI, Cast); + Instruction *NewI = replaceInstUsesWith(AI, TheSrc); eraseInstFromFunction(*Copy); ++NumGlobalCopies; return NewI; @@ -551,8 +547,7 @@ Instruction *InstCombinerImpl::visitAllocaInst(AllocaInst &AI) { for (Instruction *Delete : ToDelete) eraseInstFromFunction(*Delete); - Value *Cast = Builder.CreateBitCast(TheSrc, DestTy); - PtrReplacer.replacePointer(Cast); + PtrReplacer.replacePointer(TheSrc); ++NumGlobalCopies; } }