Lines Matching refs:AI

147                                AllocaInst *AI,  in isOnlyCopiedFromConstantMemory()  argument
150 if (isOnlyCopiedFromConstantMemory(AA, AI, TheCopy, ToDelete)) in isOnlyCopiedFromConstantMemory()
156 static bool isDereferenceableForAllocaSize(const Value *V, const AllocaInst *AI, in isDereferenceableForAllocaSize() argument
158 if (AI->isArrayAllocation()) in isDereferenceableForAllocaSize()
160 uint64_t AllocaSize = DL.getTypeStoreSize(AI->getAllocatedType()); in isDereferenceableForAllocaSize()
163 return isDereferenceableAndAlignedPointer(V, AI->getAlign(), in isDereferenceableForAllocaSize()
168 AllocaInst &AI) { in simplifyAllocaArraySize() argument
170 if (!AI.isArrayAllocation()) { in simplifyAllocaArraySize()
172 if (AI.getArraySize()->getType()->isIntegerTy(32)) in simplifyAllocaArraySize()
176 return IC.replaceOperand(AI, 0, IC.Builder.getInt32(1)); in simplifyAllocaArraySize()
180 if (const ConstantInt *C = dyn_cast<ConstantInt>(AI.getArraySize())) { in simplifyAllocaArraySize()
182 Type *NewTy = ArrayType::get(AI.getAllocatedType(), C->getZExtValue()); in simplifyAllocaArraySize()
183 AllocaInst *New = IC.Builder.CreateAlloca(NewTy, AI.getAddressSpace(), in simplifyAllocaArraySize()
184 nullptr, AI.getName()); in simplifyAllocaArraySize()
185 New->setAlignment(AI.getAlign()); in simplifyAllocaArraySize()
197 Type *IdxTy = IC.getDataLayout().getIntPtrType(AI.getType()); in simplifyAllocaArraySize()
206 return IC.replaceInstUsesWith(AI, GEP); in simplifyAllocaArraySize()
210 if (isa<UndefValue>(AI.getArraySize())) in simplifyAllocaArraySize()
211 return IC.replaceInstUsesWith(AI, Constant::getNullValue(AI.getType())); in simplifyAllocaArraySize()
215 Type *IntPtrTy = IC.getDataLayout().getIntPtrType(AI.getType()); in simplifyAllocaArraySize()
216 if (AI.getArraySize()->getType() != IntPtrTy) { in simplifyAllocaArraySize()
217 Value *V = IC.Builder.CreateIntCast(AI.getArraySize(), IntPtrTy, false); in simplifyAllocaArraySize()
218 return IC.replaceOperand(AI, 0, V); in simplifyAllocaArraySize()
354 Instruction *InstCombinerImpl::visitAllocaInst(AllocaInst &AI) { in visitAllocaInst() argument
355 if (auto *I = simplifyAllocaArraySize(*this, AI)) in visitAllocaInst()
358 if (AI.getAllocatedType()->isSized()) { in visitAllocaInst()
362 if (DL.getTypeAllocSize(AI.getAllocatedType()).getKnownMinSize() == 0) { in visitAllocaInst()
366 if (AI.isArrayAllocation()) in visitAllocaInst()
367 return replaceOperand(AI, 0, in visitAllocaInst()
368 ConstantInt::get(AI.getArraySize()->getType(), 1)); in visitAllocaInst()
371 BasicBlock &EntryBlock = AI.getParent()->getParent()->getEntryBlock(); in visitAllocaInst()
373 if (FirstInst != &AI) { in visitAllocaInst()
381 AI.moveBefore(FirstInst); in visitAllocaInst()
382 return &AI; in visitAllocaInst()
388 const Align MaxAlign = std::max(EntryAI->getAlign(), AI.getAlign()); in visitAllocaInst()
390 if (AI.getType() != EntryAI->getType()) in visitAllocaInst()
391 return new BitCastInst(EntryAI, AI.getType()); in visitAllocaInst()
392 return replaceInstUsesWith(AI, EntryAI); in visitAllocaInst()
404 if (MemTransferInst *Copy = isOnlyCopiedFromConstantMemory(AA, &AI, ToDelete)) { in visitAllocaInst()
406 Align AllocaAlign = AI.getAlign(); in visitAllocaInst()
408 TheSrc, AllocaAlign, DL, &AI, &AC, &DT); in visitAllocaInst()
410 isDereferenceableForAllocaSize(TheSrc, &AI, DL) && in visitAllocaInst()
414 LLVM_DEBUG(dbgs() << "Found alloca equal to global: " << AI << '\n'); in visitAllocaInst()
417 auto *DestTy = PointerType::get(AI.getAllocatedType(), SrcAddrSpace); in visitAllocaInst()
418 if (AI.getType()->getAddressSpace() == SrcAddrSpace) { in visitAllocaInst()
423 Instruction *NewI = replaceInstUsesWith(AI, Cast); in visitAllocaInst()
430 if (PtrReplacer.collectUsers(AI)) { in visitAllocaInst()
435 PtrReplacer.replacePointer(AI, Cast); in visitAllocaInst()
443 return visitAllocSite(AI); in visitAllocaInst()
764 if (AllocaInst *AI = dyn_cast<AllocaInst>(P)) { in isObjectSizeLessThanOrEq() local
765 if (!AI->getAllocatedType()->isSized()) in isObjectSizeLessThanOrEq()
768 ConstantInt *CS = dyn_cast<ConstantInt>(AI->getArraySize()); in isObjectSizeLessThanOrEq()
772 uint64_t TypeSize = DL.getTypeAllocSize(AI->getAllocatedType()); in isObjectSizeLessThanOrEq()