Lines Matching refs:CB

163 static void createRetBitCast(CallBase &CB, Type *RetTy, CastInst **RetBitCast) {  in createRetBitCast()  argument
167 SmallVector<User *, 16> UsersToUpdate(CB.users()); in createRetBitCast()
172 if (auto *Invoke = dyn_cast<InvokeInst>(&CB)) in createRetBitCast()
176 InsertBefore = &*std::next(CB.getIterator()); in createRetBitCast()
179 auto *Cast = CastInst::CreateBitOrPointerCast(&CB, RetTy, "", InsertBefore); in createRetBitCast()
185 U->replaceUsesOfWith(&CB, Cast); in createRetBitCast()
283 CallBase &llvm::versionCallSite(CallBase &CB, Value *Callee, in versionCallSite() argument
286 IRBuilder<> Builder(&CB); in versionCallSite()
287 CallBase *OrigInst = &CB; in versionCallSite()
292 if (CB.getCalledOperand()->getType() != Callee->getType()) in versionCallSite()
293 Callee = Builder.CreateBitCast(Callee, CB.getCalledOperand()->getType()); in versionCallSite()
294 auto *Cond = Builder.CreateICmpEQ(CB.getCalledOperand(), Callee); in versionCallSite()
300 SplitBlockAndInsertIfThen(Cond, &CB, false, BranchWeights); in versionCallSite()
339 SplitBlockAndInsertIfThenElse(Cond, &CB, &ThenTerm, &ElseTerm, BranchWeights); in versionCallSite()
383 bool llvm::isLegalToPromote(const CallBase &CB, Function *Callee, in isLegalToPromote() argument
385 assert(!CB.getCalledFunction() && "Only indirect call sites can be promoted"); in isLegalToPromote()
391 Type *CallRetTy = CB.getType(); in isLegalToPromote()
404 unsigned NumArgs = CB.arg_size(); in isLegalToPromote()
422 CB.getAttributes().hasParamAttr(I, Attribute::ByVal)) { in isLegalToPromote()
428 CB.getAttributes().hasParamAttr(I, Attribute::InAlloca)) { in isLegalToPromote()
435 Type *ActualTy = CB.getArgOperand(I)->getType(); in isLegalToPromote()
446 if (CB.isMustTailCall()) { in isLegalToPromote()
459 if (CB.paramHasAttr(I, Attribute::StructRet)) { in isLegalToPromote()
469 CallBase &llvm::promoteCall(CallBase &CB, Function *Callee, in promoteCall() argument
471 assert(!CB.getCalledFunction() && "Only indirect call sites can be promoted"); in promoteCall()
475 CB.setCalledOperand(Callee); in promoteCall()
480 CB.setMetadata(LLVMContext::MD_prof, nullptr); in promoteCall()
481 CB.setMetadata(LLVMContext::MD_callees, nullptr); in promoteCall()
485 if (CB.getFunctionType() == Callee->getFunctionType()) in promoteCall()
486 return CB; in promoteCall()
489 Type *CallSiteRetTy = CB.getType(); in promoteCall()
493 CB.mutateFunctionType(Callee->getFunctionType()); in promoteCall()
502 const AttributeList &CallerPAL = CB.getAttributes(); in promoteCall()
508 auto *Arg = CB.getArgOperand(ArgNo); in promoteCall()
512 auto *Cast = CastInst::CreateBitOrPointerCast(Arg, FormalTy, "", &CB); in promoteCall()
513 CB.setArgOperand(ArgNo, Cast); in promoteCall()
536 createRetBitCast(CB, CallSiteRetTy, RetBitCast); in promoteCall()
543 CB.setAttributes(AttributeList::get(Ctx, CallerPAL.getFnAttrs(), in promoteCall()
547 return CB; in promoteCall()
550 CallBase &llvm::promoteCallWithIfThenElse(CallBase &CB, Function *Callee, in promoteCallWithIfThenElse() argument
556 CallBase &NewInst = versionCallSite(CB, Callee, BranchWeights); in promoteCallWithIfThenElse()
562 bool llvm::tryPromoteCall(CallBase &CB) { in tryPromoteCall() argument
563 assert(!CB.getCalledFunction()); in tryPromoteCall()
564 Module *M = CB.getCaller()->getParent(); in tryPromoteCall()
566 Value *Callee = CB.getCalledOperand(); in tryPromoteCall()
613 if (!isLegalToPromote(CB, DirectCallee)) in tryPromoteCall()
617 promoteCall(CB, DirectCallee); in tryPromoteCall()