Lines Matching defs:CI
238 CallInst *CI = dyn_cast<CallInst>(&I);
242 if (!CI || CI->isTailCall() || isa<DbgInfoIntrinsic>(&I) ||
248 bool IsNoTail = CI->isNoTailCall() ||
249 CI->hasOperandBundlesOtherThan(
253 if (!IsNoTail && CI->doesNotAccessMemory()) {
262 for (auto &Arg : CI->args()) {
274 return OptimizationRemark(DEBUG_TYPE, "tailcall-readnone", CI)
277 CI->setTailCall();
283 if (!IsNoTail && Escaped == UNESCAPED && !Tracker.AllocaUsers.count(CI))
284 DeferredTails.push_back(CI);
314 for (CallInst *CI : DeferredTails) {
315 if (Visited[CI->getParent()] != ESCAPED) {
318 LLVM_DEBUG(dbgs() << "Marked as tail call candidate: " << *CI << "\n");
319 CI->setTailCall();
331 static bool canMoveAboveCall(Instruction *I, CallInst *CI, AliasAnalysis *AA) {
347 if (CI->mayHaveSideEffects()) {
353 if (isModSet(AA->getModRefInfo(CI, MemoryLocation::get(L))) ||
365 return !is_contained(I->operands(), CI);
368 static bool canTransformAccumulatorRecursion(Instruction *I, CallInst *CI) {
382 if ((I->getOperand(0) == CI && I->getOperand(1) == CI) ||
383 (I->getOperand(0) != CI && I->getOperand(1) != CI))
440 void createTailRecurseLoopHeader(CallInst *CI);
444 bool eliminateCall(CallInst *CI);
450 void copyByValueOperandIntoLocalTemp(CallInst *CI, int OpndIdx);
452 void copyLocalTempOfByValueOperandIntoArguments(CallInst *CI, int OpndIdx);
468 // this block. If so, set CI to it.
469 CallInst *CI = nullptr;
472 CI = dyn_cast<CallInst>(BBI);
473 if (CI && CI->getCalledFunction() == &F)
481 assert((!CI->isTailCall() || !CI->isNoTailCall()) &&
483 if (!CI->isTailCall())
491 firstNonDbg(BB->front().getIterator()) == CI &&
492 firstNonDbg(std::next(BB->begin())) == TI && CI->getCalledFunction() &&
493 !TTI->isLoweredToCall(CI->getCalledFunction())) {
496 auto I = CI->arg_begin(), E = CI->arg_end();
504 return CI;
507 void TailRecursionEliminator::createTailRecurseLoopHeader(CallInst *CI) {
513 // If the new branch preserves the debug location of CI, it could result in
514 // misleading stepping, if CI is located in a conditional branch.
593 void TailRecursionEliminator::copyByValueOperandIntoLocalTemp(CallInst *CI,
595 Type *AggTy = CI->getParamByValType(OpndIdx);
600 Align Alignment(CI->getParamAlign(OpndIdx).valueOrOne());
606 CI->getArgOperand(OpndIdx)->getName(), F.getEntryBlock().begin());
608 IRBuilder<> Builder(CI);
613 CI->getArgOperand(OpndIdx),
615 CI->setArgOperand(OpndIdx, NewAlloca);
621 CallInst *CI, int OpndIdx) {
622 Type *AggTy = CI->getParamByValType(OpndIdx);
627 Align Alignment(CI->getParamAlign(OpndIdx).valueOrOne());
629 IRBuilder<> Builder(CI);
635 CI->getArgOperand(OpndIdx),
639 bool TailRecursionEliminator::eliminateCall(CallInst *CI) {
640 ReturnInst *Ret = cast<ReturnInst>(CI->getParent()->getTerminator());
647 BasicBlock::iterator BBI(CI);
649 if (canMoveAboveCall(&*BBI, CI, AA))
656 if (AccPN || !canTransformAccumulatorRecursion(&*BBI, CI))
668 return OptimizationRemark(DEBUG_TYPE, "tailcall-recursion", CI)
675 createTailRecurseLoopHeader(CI);
678 for (unsigned I = 0, E = CI->arg_size(); I != E; ++I) {
679 if (CI->isByValArgument(I))
680 copyByValueOperandIntoLocalTemp(CI, I);
686 for (unsigned I = 0, E = CI->arg_size(); I != E; ++I) {
687 if (CI->isByValArgument(I)) {
688 copyLocalTempOfByValueOperandIntoArguments(CI, I);
697 ArgumentPHIs[I]->addIncoming(CI->getArgOperand(I), BB);
706 AccRecInstr->setOperand(AccRecInstr->getOperand(0) != CI, AccPN);
711 if (Ret->getReturnValue() == CI || AccRecInstr) {
735 NewBI->setDebugLoc(CI->getDebugLoc());
738 CI->eraseFromParent(); // Remove call.
832 CallInst *CI = findTRECandidate(&BB);
834 if (!CI)
850 eliminateCall(CI);
853 CallInst *CI = findTRECandidate(&BB);
855 if (CI)
856 return eliminateCall(CI);