Skip to content

Commit

Permalink
InstCombine: Drop some typed pointer cast handling
Browse files Browse the repository at this point in the history
  • Loading branch information
arsenm committed Jul 31, 2023
1 parent 662efde commit fbeda97
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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;
Expand All @@ -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;
}
}
Expand Down

0 comments on commit fbeda97

Please sign in to comment.