Lines Matching refs:CB
162 static void createRetBitCast(CallBase &CB, Type *RetTy, CastInst **RetBitCast) { in createRetBitCast() argument
166 SmallVector<User *, 16> UsersToUpdate(CB.users()); in createRetBitCast()
171 if (auto *Invoke = dyn_cast<InvokeInst>(&CB)) in createRetBitCast()
175 InsertBefore = &*std::next(CB.getIterator()); in createRetBitCast()
178 auto *Cast = CastInst::CreateBitOrPointerCast(&CB, RetTy, "", InsertBefore); in createRetBitCast()
184 U->replaceUsesOfWith(&CB, Cast); in createRetBitCast()
282 CallBase &llvm::versionCallSite(CallBase &CB, Value *Callee, in versionCallSite() argument
285 IRBuilder<> Builder(&CB); in versionCallSite()
286 CallBase *OrigInst = &CB; in versionCallSite()
291 if (CB.getCalledOperand()->getType() != Callee->getType()) in versionCallSite()
292 Callee = Builder.CreateBitCast(Callee, CB.getCalledOperand()->getType()); in versionCallSite()
293 auto *Cond = Builder.CreateICmpEQ(CB.getCalledOperand(), Callee); in versionCallSite()
299 SplitBlockAndInsertIfThen(Cond, &CB, false, BranchWeights); in versionCallSite()
338 SplitBlockAndInsertIfThenElse(Cond, &CB, &ThenTerm, &ElseTerm, BranchWeights); in versionCallSite()
382 bool llvm::isLegalToPromote(const CallBase &CB, Function *Callee, in isLegalToPromote() argument
384 assert(!CB.getCalledFunction() && "Only indirect call sites can be promoted"); in isLegalToPromote()
390 Type *CallRetTy = CB.getType(); in isLegalToPromote()
403 unsigned NumArgs = CB.arg_size(); in isLegalToPromote()
419 Type *ActualTy = CB.getArgOperand(I)->getType(); in isLegalToPromote()
431 CB.getAttributes().hasParamAttr(I, Attribute::ByVal)) { in isLegalToPromote()
437 CB.getAttributes().hasParamAttr(I, Attribute::InAlloca)) { in isLegalToPromote()
446 if (CB.paramHasAttr(I, Attribute::StructRet)) { in isLegalToPromote()
456 CallBase &llvm::promoteCall(CallBase &CB, Function *Callee, in promoteCall() argument
458 assert(!CB.getCalledFunction() && "Only indirect call sites can be promoted"); in promoteCall()
462 CB.setCalledOperand(Callee); in promoteCall()
467 CB.setMetadata(LLVMContext::MD_prof, nullptr); in promoteCall()
468 CB.setMetadata(LLVMContext::MD_callees, nullptr); in promoteCall()
472 if (CB.getFunctionType() == Callee->getFunctionType()) in promoteCall()
473 return CB; in promoteCall()
476 Type *CallSiteRetTy = CB.getType(); in promoteCall()
480 CB.mutateFunctionType(Callee->getFunctionType()); in promoteCall()
489 const AttributeList &CallerPAL = CB.getAttributes(); in promoteCall()
495 auto *Arg = CB.getArgOperand(ArgNo); in promoteCall()
499 auto *Cast = CastInst::CreateBitOrPointerCast(Arg, FormalTy, "", &CB); in promoteCall()
500 CB.setArgOperand(ArgNo, Cast); in promoteCall()
523 createRetBitCast(CB, CallSiteRetTy, RetBitCast); in promoteCall()
530 CB.setAttributes(AttributeList::get(Ctx, CallerPAL.getFnAttrs(), in promoteCall()
534 return CB; in promoteCall()
537 CallBase &llvm::promoteCallWithIfThenElse(CallBase &CB, Function *Callee, in promoteCallWithIfThenElse() argument
543 CallBase &NewInst = versionCallSite(CB, Callee, BranchWeights); in promoteCallWithIfThenElse()
549 bool llvm::tryPromoteCall(CallBase &CB) { in tryPromoteCall() argument
550 assert(!CB.getCalledFunction()); in tryPromoteCall()
551 Module *M = CB.getCaller()->getParent(); in tryPromoteCall()
553 Value *Callee = CB.getCalledOperand(); in tryPromoteCall()
600 if (!isLegalToPromote(CB, DirectCallee)) in tryPromoteCall()
604 promoteCall(CB, DirectCallee); in tryPromoteCall()