Lines Matching refs:F
330 static unsigned NumRetVals(const Function *F) { in NumRetVals() argument
331 Type *RetTy = F->getReturnType(); in NumRetVals()
345 static Type *getRetComponentType(const Function *F, unsigned Idx) { in getRetComponentType() argument
346 Type *RetTy = F->getReturnType(); in getRetComponentType()
389 const Function *F = RI->getParent()->getParent(); in SurveyUse() local
391 RetOrArg Use = CreateRet(F, RetValNum); in SurveyUse()
396 for (unsigned Ri = 0; Ri < NumRetVals(F); ++Ri) { in SurveyUse()
397 RetOrArg Use = CreateRet(F, Ri); in SurveyUse()
430 const Function *F = CB->getCalledFunction(); in SurveyUse() local
431 if (F) { in SurveyUse()
444 if (ArgNo >= F->getFunctionType()->getNumParams()) in SurveyUse()
453 RetOrArg Use = CreateArg(F, ArgNo); in SurveyUse()
488 void DeadArgumentEliminationPass::SurveyFunction(const Function &F) { in SurveyFunction() argument
491 if (F.getAttributes().hasAttrSomewhere(Attribute::InAlloca) || in SurveyFunction()
492 F.getAttributes().hasAttrSomewhere(Attribute::Preallocated)) { in SurveyFunction()
493 MarkLive(F); in SurveyFunction()
500 if (F.hasFnAttribute(Attribute::Naked)) { in SurveyFunction()
501 MarkLive(F); in SurveyFunction()
505 unsigned RetCount = NumRetVals(&F); in SurveyFunction()
521 for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { in SurveyFunction()
524 != F.getFunctionType()->getReturnType()) { in SurveyFunction()
526 MarkLive(F); in SurveyFunction()
538 LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - " << F.getName() in SurveyFunction()
542 if (!F.hasLocalLinkage() && (!ShouldHackArguments || F.isIntrinsic())) { in SurveyFunction()
543 MarkLive(F); in SurveyFunction()
549 << F.getName() << "\n"); in SurveyFunction()
557 for (const Use &U : F.uses()) { in SurveyFunction()
562 MarkLive(F); in SurveyFunction()
609 LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - " << F.getName() in SurveyFunction()
615 MarkValue(CreateRet(&F, Ri), RetValLiveness[Ri], MaybeLiveRetUses[Ri]); in SurveyFunction()
618 << F.getName() << "\n"); in SurveyFunction()
623 for (Function::const_arg_iterator AI = F.arg_begin(), E = F.arg_end(); in SurveyFunction()
626 if (F.getFunctionType()->isVarArg() || HasMustTailCallers || in SurveyFunction()
647 MarkValue(CreateArg(&F, ArgI), Result, MaybeLiveArgUses); in SurveyFunction()
684 void DeadArgumentEliminationPass::MarkLive(const Function &F) { in MarkLive() argument
686 << F.getName() << "\n"); in MarkLive()
688 LiveFunctions.insert(&F); in MarkLive()
690 for (unsigned ArgI = 0, E = F.arg_size(); ArgI != E; ++ArgI) in MarkLive()
691 PropagateLiveness(CreateArg(&F, ArgI)); in MarkLive()
693 for (unsigned Ri = 0, E = NumRetVals(&F); Ri != E; ++Ri) in MarkLive()
694 PropagateLiveness(CreateRet(&F, Ri)); in MarkLive()
712 return LiveFunctions.count(RA.F) || LiveValues.count(RA); in IsLive()
736 bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) { in RemoveDeadStuffFromFunction() argument
738 if (LiveFunctions.count(F)) in RemoveDeadStuffFromFunction()
743 FunctionType *FTy = F->getFunctionType(); in RemoveDeadStuffFromFunction()
751 const AttributeList &PAL = F->getAttributes(); in RemoveDeadStuffFromFunction()
759 for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; in RemoveDeadStuffFromFunction()
761 RetOrArg Arg = CreateArg(F, ArgI); in RemoveDeadStuffFromFunction()
771 << F->getName() << "\n"); in RemoveDeadStuffFromFunction()
778 unsigned RetCount = NumRetVals(F); in RemoveDeadStuffFromFunction()
808 RetOrArg Ret = CreateRet(F, Ri); in RemoveDeadStuffFromFunction()
810 RetTypes.push_back(getRetComponentType(F, Ri)); in RemoveDeadStuffFromFunction()
816 << Ri << " from " << F->getName() << "\n"); in RemoveDeadStuffFromFunction()
835 NRetTy = Type::getVoidTy(F->getContext()); in RemoveDeadStuffFromFunction()
853 AttributeSet RetAttrs = AttributeSet::get(F->getContext(), RAttrs); in RemoveDeadStuffFromFunction()
857 F->getContext(), Attribute::AllocSize); in RemoveDeadStuffFromFunction()
862 AttributeList::get(F->getContext(), FnAttrs, RetAttrs, ArgAttrVec); in RemoveDeadStuffFromFunction()
872 Function *NF = Function::Create(NFTy, F->getLinkage(), F->getAddressSpace()); in RemoveDeadStuffFromFunction()
873 NF->copyAttributesFrom(F); in RemoveDeadStuffFromFunction()
874 NF->setComdat(F->getComdat()); in RemoveDeadStuffFromFunction()
878 F->getParent()->getFunctionList().insert(F->getIterator(), NF); in RemoveDeadStuffFromFunction()
879 NF->takeName(F); in RemoveDeadStuffFromFunction()
884 while (!F->use_empty()) { in RemoveDeadStuffFromFunction()
885 CallBase &CB = cast<CallBase>(*F->user_back()); in RemoveDeadStuffFromFunction()
894 AttributeSet RetAttrs = AttributeSet::get(F->getContext(), RAttrs); in RemoveDeadStuffFromFunction()
914 F->getContext(), in RemoveDeadStuffFromFunction()
934 F->getContext(), Attribute::AllocSize); in RemoveDeadStuffFromFunction()
937 F->getContext(), FnAttrs, RetAttrs, ArgAttrVec); in RemoveDeadStuffFromFunction()
1013 NF->getBasicBlockList().splice(NF->begin(), F->getBasicBlockList()); in RemoveDeadStuffFromFunction()
1018 for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(), in RemoveDeadStuffFromFunction()
1036 if (F->getReturnType() != NF->getReturnType()) in RemoveDeadStuffFromFunction()
1071 auto *NewRet = ReturnInst::Create(F->getContext(), RetVal, RI); in RemoveDeadStuffFromFunction()
1078 F->getAllMetadata(MDs); in RemoveDeadStuffFromFunction()
1083 F->eraseFromParent(); in RemoveDeadStuffFromFunction()
1098 Function &F = *I++; in run() local
1099 if (F.getFunctionType()->isVarArg()) in run()
1100 Changed |= DeleteDeadVarargs(F); in run()
1108 for (auto &F : M) in run() local
1109 SurveyFunction(F); in run()
1116 Function *F = &*I++; in run() local
1117 Changed |= RemoveDeadStuffFromFunction(F); in run()
1122 for (auto &F : M) in run() local
1123 Changed |= RemoveDeadArgumentsFromCallers(F); in run()