Lines Matching refs:AI
150 AllocaInst *AI, in isOnlyCopiedFromConstantMemory() argument
153 if (isOnlyCopiedFromConstantMemory(AA, AI, TheCopy, ToDelete)) in isOnlyCopiedFromConstantMemory()
159 static bool isDereferenceableForAllocaSize(const Value *V, const AllocaInst *AI, in isDereferenceableForAllocaSize() argument
161 if (AI->isArrayAllocation()) in isDereferenceableForAllocaSize()
163 uint64_t AllocaSize = DL.getTypeStoreSize(AI->getAllocatedType()); in isDereferenceableForAllocaSize()
166 return isDereferenceableAndAlignedPointer(V, Align(AI->getAlignment()), in isDereferenceableForAllocaSize()
171 AllocaInst &AI) { in simplifyAllocaArraySize() argument
173 if (!AI.isArrayAllocation()) { in simplifyAllocaArraySize()
175 if (AI.getArraySize()->getType()->isIntegerTy(32)) in simplifyAllocaArraySize()
179 return IC.replaceOperand(AI, 0, IC.Builder.getInt32(1)); in simplifyAllocaArraySize()
183 if (const ConstantInt *C = dyn_cast<ConstantInt>(AI.getArraySize())) { in simplifyAllocaArraySize()
185 Type *NewTy = ArrayType::get(AI.getAllocatedType(), C->getZExtValue()); in simplifyAllocaArraySize()
186 AllocaInst *New = IC.Builder.CreateAlloca(NewTy, nullptr, AI.getName()); in simplifyAllocaArraySize()
187 New->setAlignment(AI.getAlign()); in simplifyAllocaArraySize()
199 Type *IdxTy = IC.getDataLayout().getIntPtrType(AI.getType()); in simplifyAllocaArraySize()
207 if (AI.getType()->getPointerAddressSpace() != in simplifyAllocaArraySize()
210 CastInst::CreatePointerBitCastOrAddrSpaceCast(NewI, AI.getType()); in simplifyAllocaArraySize()
216 return IC.replaceInstUsesWith(AI, NewI); in simplifyAllocaArraySize()
220 if (isa<UndefValue>(AI.getArraySize())) in simplifyAllocaArraySize()
221 return IC.replaceInstUsesWith(AI, Constant::getNullValue(AI.getType())); in simplifyAllocaArraySize()
225 Type *IntPtrTy = IC.getDataLayout().getIntPtrType(AI.getType()); in simplifyAllocaArraySize()
226 if (AI.getArraySize()->getType() != IntPtrTy) { in simplifyAllocaArraySize()
227 Value *V = IC.Builder.CreateIntCast(AI.getArraySize(), IntPtrTy, false); in simplifyAllocaArraySize()
228 return IC.replaceOperand(AI, 0, V); in simplifyAllocaArraySize()
365 Instruction *InstCombinerImpl::visitAllocaInst(AllocaInst &AI) { in visitAllocaInst() argument
366 if (auto *I = simplifyAllocaArraySize(*this, AI)) in visitAllocaInst()
369 if (AI.getAllocatedType()->isSized()) { in visitAllocaInst()
373 if (DL.getTypeAllocSize(AI.getAllocatedType()).getKnownMinSize() == 0) { in visitAllocaInst()
377 if (AI.isArrayAllocation()) in visitAllocaInst()
378 return replaceOperand(AI, 0, in visitAllocaInst()
379 ConstantInt::get(AI.getArraySize()->getType(), 1)); in visitAllocaInst()
382 BasicBlock &EntryBlock = AI.getParent()->getParent()->getEntryBlock(); in visitAllocaInst()
384 if (FirstInst != &AI) { in visitAllocaInst()
392 AI.moveBefore(FirstInst); in visitAllocaInst()
393 return &AI; in visitAllocaInst()
399 const Align MaxAlign = std::max(EntryAI->getAlign(), AI.getAlign()); in visitAllocaInst()
401 if (AI.getType() != EntryAI->getType()) in visitAllocaInst()
402 return new BitCastInst(EntryAI, AI.getType()); in visitAllocaInst()
403 return replaceInstUsesWith(AI, EntryAI); in visitAllocaInst()
415 if (MemTransferInst *Copy = isOnlyCopiedFromConstantMemory(AA, &AI, ToDelete)) { in visitAllocaInst()
417 Align AllocaAlign = AI.getAlign(); in visitAllocaInst()
419 TheSrc, AllocaAlign, DL, &AI, &AC, &DT); in visitAllocaInst()
421 isDereferenceableForAllocaSize(TheSrc, &AI, DL) && in visitAllocaInst()
425 LLVM_DEBUG(dbgs() << "Found alloca equal to global: " << AI << '\n'); in visitAllocaInst()
428 auto *DestTy = PointerType::get(AI.getAllocatedType(), SrcAddrSpace); in visitAllocaInst()
429 if (AI.getType()->getAddressSpace() == SrcAddrSpace) { in visitAllocaInst()
434 Instruction *NewI = replaceInstUsesWith(AI, Cast); in visitAllocaInst()
441 if (PtrReplacer.collectUsers(AI)) { in visitAllocaInst()
446 PtrReplacer.replacePointer(AI, Cast); in visitAllocaInst()
454 return visitAllocSite(AI); in visitAllocaInst()
784 if (AllocaInst *AI = dyn_cast<AllocaInst>(P)) { in isObjectSizeLessThanOrEq() local
785 if (!AI->getAllocatedType()->isSized()) in isObjectSizeLessThanOrEq()
788 ConstantInt *CS = dyn_cast<ConstantInt>(AI->getArraySize()); in isObjectSizeLessThanOrEq()
792 uint64_t TypeSize = DL.getTypeAllocSize(AI->getAllocatedType()); in isObjectSizeLessThanOrEq()