Lines Matching refs:CI

105     bool EliminateRecursiveTailCall(CallInst *CI, ReturnInst *Ret,
119 bool CanMoveAboveCall(Instruction *I, CallInst *CI);
120 Value *CanTransformAccumulatorRecursion(Instruction *I, CallInst *CI);
299 CallInst *CI = dyn_cast<CallInst>(&I);
300 if (!CI || CI->isTailCall())
303 if (CI->doesNotAccessMemory()) {
312 for (auto &Arg : CI->arg_operands()) {
323 F.getContext(), "tailcallelim", F, CI->getDebugLoc(),
325 CI->setTailCall();
331 if (Escaped == UNESCAPED && !Tracker.AllocaUsers.count(CI)) {
332 DeferredTails.push_back(CI);
365 for (CallInst *CI : DeferredTails) {
366 if (Visited[CI->getParent()] != ESCAPED) {
370 CI->getDebugLoc(),
372 CI->setTailCall();
440 bool TailCallElim::CanMoveAboveCall(Instruction *I, CallInst *CI) {
448 if (CI->mayHaveSideEffects()) {
453 if (CI->mayWriteToMemory() ||
466 if (I->getOperand(i) == CI)
478 static bool isDynamicConstant(Value *V, CallInst *CI, ReturnInst *RI) {
486 Function *F = CI->getParent()->getParent();
493 if (CI->getArgOperand(ArgNo) == Arg)
513 static Value *getCommonReturnValue(ReturnInst *IgnoreRI, CallInst *CI) {
514 Function *F = CI->getParent()->getParent();
526 if (!isDynamicConstant(RetOp, CI, RI))
541 CallInst *CI) {
547 if ((I->getOperand(0) == CI && I->getOperand(1) == CI) ||
548 (I->getOperand(0) != CI && I->getOperand(1) != CI))
558 return getCommonReturnValue(cast<ReturnInst>(I->user_back()), CI);
577 // this block. If so, set CI to it.
578 CallInst *CI = nullptr;
581 CI = dyn_cast<CallInst>(BBI);
582 if (CI && CI->getCalledFunction() == F)
592 if (CI->isTailCall() && CannotTailCallElimCallsMarkedTail)
600 FirstNonDbg(BB->front()) == CI &&
602 CI->getCalledFunction() &&
603 !TTI->isLoweredToCall(CI->getCalledFunction())) {
606 CallSite::arg_iterator I = CallSite(CI).arg_begin(),
607 E = CallSite(CI).arg_end();
616 return CI;
619 bool TailCallElim::EliminateRecursiveTailCall(CallInst *CI, ReturnInst *Ret,
641 BasicBlock::iterator BBI = CI;
643 if (CanMoveAboveCall(BBI, CI)) continue;
650 CanTransformAccumulatorRecursion(BBI, CI))) {
663 if (Ret->getNumOperands() == 1 && Ret->getReturnValue() != CI &&
666 !getCommonReturnValue(nullptr, CI)) {
670 if (!isDynamicConstant(Ret->getReturnValue(), CI, Ret))
674 AccumulatorRecursionEliminationInitVal = getCommonReturnValue(Ret, CI);
682 emitOptimizationRemark(F->getContext(), "tailcallelim", *F, CI->getDebugLoc(),
696 TailCallsAreMarkedTail = CI->isTailCall();
726 if (TailCallsAreMarkedTail && !CI->isTailCall())
732 for (unsigned i = 0, e = CI->getNumArgOperands(); i != e; ++i)
733 ArgumentPHIs[i]->addIncoming(CI->getArgOperand(i), BB);
771 AccRecInstr->setOperand(AccRecInstr->getOperand(0) != CI, AccPN);
790 NewBI->setDebugLoc(CI->getDebugLoc());
793 BB->getInstList().erase(CI); // Remove call.
821 if (CallInst *CI = FindTRECandidate(BI, CannotTailCallElimCallsMarkedTail)){
824 EliminateRecursiveTailCall(CI, FoldReturnIntoUncondBranch(Ret, BB, Pred),
840 CallInst *CI = FindTRECandidate(Ret, CannotTailCallElimCallsMarkedTail);
841 if (!CI)
844 return EliminateRecursiveTailCall(CI, Ret, OldEntry, TailCallsAreMarkedTail,