Lines Matching refs:AI

177                                AllocaInst *AI,  in isOnlyCopiedFromConstantMemory()  argument
180 if (isOnlyCopiedFromConstantMemory(AA, AI, TheCopy, ToDelete)) in isOnlyCopiedFromConstantMemory()
186 static bool isDereferenceableForAllocaSize(const Value *V, const AllocaInst *AI, in isDereferenceableForAllocaSize() argument
188 if (AI->isArrayAllocation()) in isDereferenceableForAllocaSize()
190 uint64_t AllocaSize = DL.getTypeStoreSize(AI->getAllocatedType()); in isDereferenceableForAllocaSize()
193 return isDereferenceableAndAlignedPointer(V, AI->getAlign(), in isDereferenceableForAllocaSize()
198 AllocaInst &AI, DominatorTree &DT) { in simplifyAllocaArraySize() argument
200 if (!AI.isArrayAllocation()) { in simplifyAllocaArraySize()
202 if (AI.getArraySize()->getType()->isIntegerTy(32)) in simplifyAllocaArraySize()
206 return IC.replaceOperand(AI, 0, IC.Builder.getInt32(1)); in simplifyAllocaArraySize()
210 if (const ConstantInt *C = dyn_cast<ConstantInt>(AI.getArraySize())) { in simplifyAllocaArraySize()
212 Type *NewTy = ArrayType::get(AI.getAllocatedType(), C->getZExtValue()); in simplifyAllocaArraySize()
213 AllocaInst *New = IC.Builder.CreateAlloca(NewTy, AI.getAddressSpace(), in simplifyAllocaArraySize()
214 nullptr, AI.getName()); in simplifyAllocaArraySize()
215 New->setAlignment(AI.getAlign()); in simplifyAllocaArraySize()
216 New->setUsedWithInAlloca(AI.isUsedWithInAlloca()); in simplifyAllocaArraySize()
218 replaceAllDbgUsesWith(AI, *New, *New, DT); in simplifyAllocaArraySize()
219 return IC.replaceInstUsesWith(AI, New); in simplifyAllocaArraySize()
223 if (isa<UndefValue>(AI.getArraySize())) in simplifyAllocaArraySize()
224 return IC.replaceInstUsesWith(AI, Constant::getNullValue(AI.getType())); in simplifyAllocaArraySize()
229 Type *PtrIdxTy = IC.getDataLayout().getIndexType(AI.getType()); in simplifyAllocaArraySize()
230 if (AI.getArraySize()->getType() != PtrIdxTy) { in simplifyAllocaArraySize()
231 Value *V = IC.Builder.CreateIntCast(AI.getArraySize(), PtrIdxTy, false); in simplifyAllocaArraySize()
232 return IC.replaceOperand(AI, 0, V); in simplifyAllocaArraySize()
462 Instruction *InstCombinerImpl::visitAllocaInst(AllocaInst &AI) { in visitAllocaInst() argument
463 if (auto *I = simplifyAllocaArraySize(*this, AI, DT)) in visitAllocaInst()
466 if (AI.getAllocatedType()->isSized()) { in visitAllocaInst()
470 if (DL.getTypeAllocSize(AI.getAllocatedType()).getKnownMinValue() == 0) { in visitAllocaInst()
474 if (AI.isArrayAllocation()) in visitAllocaInst()
475 return replaceOperand(AI, 0, in visitAllocaInst()
476 ConstantInt::get(AI.getArraySize()->getType(), 1)); in visitAllocaInst()
479 BasicBlock &EntryBlock = AI.getParent()->getParent()->getEntryBlock(); in visitAllocaInst()
481 if (FirstInst != &AI) { in visitAllocaInst()
489 AI.moveBefore(FirstInst); in visitAllocaInst()
490 return &AI; in visitAllocaInst()
496 const Align MaxAlign = std::max(EntryAI->getAlign(), AI.getAlign()); in visitAllocaInst()
498 return replaceInstUsesWith(AI, EntryAI); in visitAllocaInst()
510 if (MemTransferInst *Copy = isOnlyCopiedFromConstantMemory(AA, &AI, ToDelete)) { in visitAllocaInst()
512 Align AllocaAlign = AI.getAlign(); in visitAllocaInst()
514 TheSrc, AllocaAlign, DL, &AI, &AC, &DT); in visitAllocaInst()
516 isDereferenceableForAllocaSize(TheSrc, &AI, DL) && in visitAllocaInst()
520 LLVM_DEBUG(dbgs() << "Found alloca equal to global: " << AI << '\n'); in visitAllocaInst()
523 if (AI.getAddressSpace() == SrcAddrSpace) { in visitAllocaInst()
527 Instruction *NewI = replaceInstUsesWith(AI, TheSrc); in visitAllocaInst()
533 PointerReplacer PtrReplacer(*this, AI, SrcAddrSpace); in visitAllocaInst()
546 return visitAllocSite(AI); in visitAllocaInst()
841 if (AllocaInst *AI = dyn_cast<AllocaInst>(P)) { in isObjectSizeLessThanOrEq() local
842 if (!AI->getAllocatedType()->isSized()) in isObjectSizeLessThanOrEq()
845 ConstantInt *CS = dyn_cast<ConstantInt>(AI->getArraySize()); in isObjectSizeLessThanOrEq()
849 TypeSize TS = DL.getTypeAllocSize(AI->getAllocatedType()); in isObjectSizeLessThanOrEq()