Lines Matching refs:CB
166 static void createRetBitCast(CallBase &CB, Type *RetTy, CastInst **RetBitCast) { in createRetBitCast() argument
170 SmallVector<User *, 16> UsersToUpdate(CB.users()); in createRetBitCast()
175 if (auto *Invoke = dyn_cast<InvokeInst>(&CB)) in createRetBitCast()
179 InsertBefore = std::next(CB.getIterator()); in createRetBitCast()
182 auto *Cast = CastInst::CreateBitOrPointerCast(&CB, RetTy, "", InsertBefore); in createRetBitCast()
188 U->replaceUsesOfWith(&CB, Cast); in createRetBitCast()
285 static CallBase &versionCallSiteWithCond(CallBase &CB, Value *Cond, in versionCallSiteWithCond() argument
288 IRBuilder<> Builder(&CB); in versionCallSiteWithCond()
289 CallBase *OrigInst = &CB; in versionCallSiteWithCond()
296 SplitBlockAndInsertIfThen(Cond, &CB, false, BranchWeights); in versionCallSiteWithCond()
335 SplitBlockAndInsertIfThenElse(Cond, &CB, &ThenTerm, &ElseTerm, BranchWeights); in versionCallSiteWithCond()
381 CallBase &llvm::versionCallSite(CallBase &CB, Value *Callee, in versionCallSite() argument
384 IRBuilder<> Builder(&CB); in versionCallSite()
388 if (CB.getCalledOperand()->getType() != Callee->getType()) in versionCallSite()
389 Callee = Builder.CreateBitCast(Callee, CB.getCalledOperand()->getType()); in versionCallSite()
390 auto *Cond = Builder.CreateICmpEQ(CB.getCalledOperand(), Callee); in versionCallSite()
392 return versionCallSiteWithCond(CB, Cond, BranchWeights); in versionCallSite()
395 bool llvm::isLegalToPromote(const CallBase &CB, Function *Callee, in isLegalToPromote() argument
397 assert(!CB.getCalledFunction() && "Only indirect call sites can be promoted"); in isLegalToPromote()
403 Type *CallRetTy = CB.getType(); in isLegalToPromote()
416 unsigned NumArgs = CB.arg_size(); in isLegalToPromote()
434 CB.getAttributes().hasParamAttr(I, Attribute::ByVal)) { in isLegalToPromote()
440 CB.getAttributes().hasParamAttr(I, Attribute::InAlloca)) { in isLegalToPromote()
447 Type *ActualTy = CB.getArgOperand(I)->getType(); in isLegalToPromote()
458 if (CB.isMustTailCall()) { in isLegalToPromote()
471 if (CB.paramHasAttr(I, Attribute::StructRet)) { in isLegalToPromote()
481 CallBase &llvm::promoteCall(CallBase &CB, Function *Callee, in promoteCall() argument
483 assert(!CB.getCalledFunction() && "Only indirect call sites can be promoted"); in promoteCall()
487 CB.setCalledOperand(Callee); in promoteCall()
492 CB.setMetadata(LLVMContext::MD_prof, nullptr); in promoteCall()
493 CB.setMetadata(LLVMContext::MD_callees, nullptr); in promoteCall()
497 if (CB.getFunctionType() == Callee->getFunctionType()) in promoteCall()
498 return CB; in promoteCall()
501 Type *CallSiteRetTy = CB.getType(); in promoteCall()
505 CB.mutateFunctionType(Callee->getFunctionType()); in promoteCall()
514 const AttributeList &CallerPAL = CB.getAttributes(); in promoteCall()
520 auto *Arg = CB.getArgOperand(ArgNo); in promoteCall()
525 CastInst::CreateBitOrPointerCast(Arg, FormalTy, "", CB.getIterator()); in promoteCall()
526 CB.setArgOperand(ArgNo, Cast); in promoteCall()
549 createRetBitCast(CB, CallSiteRetTy, RetBitCast); in promoteCall()
556 CB.setAttributes(AttributeList::get(Ctx, CallerPAL.getFnAttrs(), in promoteCall()
560 return CB; in promoteCall()
563 CallBase &llvm::promoteCallWithIfThenElse(CallBase &CB, Function *Callee, in promoteCallWithIfThenElse() argument
569 CallBase &NewInst = versionCallSite(CB, Callee, BranchWeights); in promoteCallWithIfThenElse()
575 CallBase &llvm::promoteCallWithVTableCmp(CallBase &CB, Instruction *VPtr, in promoteCallWithVTableCmp() argument
580 IRBuilder<> Builder(&CB); in promoteCallWithVTableCmp()
590 CallBase &NewInst = versionCallSiteWithCond(CB, Cond, BranchWeights); in promoteCallWithVTableCmp()
596 bool llvm::tryPromoteCall(CallBase &CB) { in tryPromoteCall() argument
597 assert(!CB.getCalledFunction()); in tryPromoteCall()
598 Module *M = CB.getCaller()->getParent(); in tryPromoteCall()
600 Value *Callee = CB.getCalledOperand(); in tryPromoteCall()
644 if (!isLegalToPromote(CB, DirectCallee)) in tryPromoteCall()
648 promoteCall(CB, DirectCallee); in tryPromoteCall()