Lines Matching refs:F

128 bool DeadArgumentEliminationPass::deleteDeadVarargs(Function &F) {  in deleteDeadVarargs()  argument
129 assert(F.getFunctionType()->isVarArg() && "Function isn't varargs!"); in deleteDeadVarargs()
130 if (F.isDeclaration() || !F.hasLocalLinkage()) in deleteDeadVarargs()
134 if (F.hasAddressTaken()) in deleteDeadVarargs()
140 if (F.hasFnAttribute(Attribute::Naked)) { in deleteDeadVarargs()
146 for (BasicBlock &BB : F) { in deleteDeadVarargs()
165 FunctionType *FTy = F.getFunctionType(); in deleteDeadVarargs()
172 Function *NF = Function::Create(NFTy, F.getLinkage(), F.getAddressSpace()); in deleteDeadVarargs()
173 NF->copyAttributesFrom(&F); in deleteDeadVarargs()
174 NF->setComdat(F.getComdat()); in deleteDeadVarargs()
175 F.getParent()->getFunctionList().insert(F.getIterator(), NF); in deleteDeadVarargs()
176 NF->takeName(&F); in deleteDeadVarargs()
177 NF->IsNewDbgInfoFormat = F.IsNewDbgInfoFormat; in deleteDeadVarargs()
183 for (User *U : llvm::make_early_inc_range(F.users())) { in deleteDeadVarargs()
197 PAL = AttributeList::get(F.getContext(), PAL.getFnAttrs(), in deleteDeadVarargs()
232 NF->splice(NF->begin(), &F); in deleteDeadVarargs()
237 for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(), in deleteDeadVarargs()
247 F.getAllMetadata(MDs); in deleteDeadVarargs()
252 F.replaceAllUsesWith(NF); in deleteDeadVarargs()
257 F.eraseFromParent(); in deleteDeadVarargs()
263 bool DeadArgumentEliminationPass::removeDeadArgumentsFromCallers(Function &F) { in removeDeadArgumentsFromCallers() argument
275 if (!F.hasExactDefinition()) in removeDeadArgumentsFromCallers()
282 if ((F.hasLocalLinkage() && !LiveFunctions.count(&F)) && in removeDeadArgumentsFromCallers()
283 !F.getFunctionType()->isVarArg()) in removeDeadArgumentsFromCallers()
289 if (F.hasFnAttribute(Attribute::Naked)) in removeDeadArgumentsFromCallers()
292 if (F.use_empty()) in removeDeadArgumentsFromCallers()
300 for (Argument &Arg : F.args()) { in removeDeadArgumentsFromCallers()
308 F.removeParamAttrs(Arg.getArgNo(), UBImplyingAttributes); in removeDeadArgumentsFromCallers()
315 for (Use &U : F.uses()) { in removeDeadArgumentsFromCallers()
318 CB->getFunctionType() != F.getFunctionType()) in removeDeadArgumentsFromCallers()
340 static unsigned numRetVals(const Function *F) { in numRetVals() argument
341 Type *RetTy = F->getReturnType(); in numRetVals()
354 static Type *getRetComponentType(const Function *F, unsigned Idx) { in getRetComponentType() argument
355 Type *RetTy = F->getReturnType(); in getRetComponentType()
396 const Function *F = RI->getParent()->getParent(); in surveyUse() local
398 RetOrArg Use = createRet(F, RetValNum); in surveyUse()
404 for (unsigned Ri = 0; Ri < numRetVals(F); ++Ri) { in surveyUse()
405 RetOrArg Use = createRet(F, Ri); in surveyUse()
438 const Function *F = CB->getCalledFunction(); in surveyUse() local
439 if (F) { in surveyUse()
452 if (ArgNo >= F->getFunctionType()->getNumParams()) in surveyUse()
461 RetOrArg Use = createArg(F, ArgNo); in surveyUse()
495 void DeadArgumentEliminationPass::surveyFunction(const Function &F) { in surveyFunction() argument
498 if (F.getAttributes().hasAttrSomewhere(Attribute::InAlloca) || in surveyFunction()
499 F.getAttributes().hasAttrSomewhere(Attribute::Preallocated)) { in surveyFunction()
500 markLive(F); in surveyFunction()
507 if (F.hasFnAttribute(Attribute::Naked)) { in surveyFunction()
508 markLive(F); in surveyFunction()
512 unsigned RetCount = numRetVals(&F); in surveyFunction()
527 for (const BasicBlock &BB : F) { in surveyFunction()
536 markLive(F); in surveyFunction()
543 LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - " << F.getName() in surveyFunction()
547 if (!F.hasLocalLinkage() && (!ShouldHackArguments || F.isIntrinsic())) { in surveyFunction()
548 markLive(F); in surveyFunction()
554 << F.getName() << "\n"); in surveyFunction()
562 for (const Use &U : F.uses()) { in surveyFunction()
567 CB->getFunctionType() != F.getFunctionType()) { in surveyFunction()
568 markLive(F); in surveyFunction()
615 LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - " << F.getName() in surveyFunction()
621 markValue(createRet(&F, Ri), RetValLiveness[Ri], MaybeLiveRetUses[Ri]); in surveyFunction()
624 << F.getName() << "\n"); in surveyFunction()
629 for (Function::const_arg_iterator AI = F.arg_begin(), E = F.arg_end(); in surveyFunction()
632 if (F.getFunctionType()->isVarArg() || HasMustTailCallers || in surveyFunction()
653 markValue(createArg(&F, ArgI), Result, MaybeLiveArgUses); in surveyFunction()
687 void DeadArgumentEliminationPass::markLive(const Function &F) { in markLive() argument
689 << F.getName() << "\n"); in markLive()
691 LiveFunctions.insert(&F); in markLive()
693 for (unsigned ArgI = 0, E = F.arg_size(); ArgI != E; ++ArgI) in markLive()
694 propagateLiveness(createArg(&F, ArgI)); in markLive()
696 for (unsigned Ri = 0, E = numRetVals(&F); Ri != E; ++Ri) in markLive()
697 propagateLiveness(createRet(&F, Ri)); in markLive()
714 return LiveFunctions.count(RA.F) || LiveValues.count(RA); in isLive()
737 bool DeadArgumentEliminationPass::removeDeadStuffFromFunction(Function *F) { in removeDeadStuffFromFunction() argument
739 if (LiveFunctions.count(F)) in removeDeadStuffFromFunction()
744 FunctionType *FTy = F->getFunctionType(); in removeDeadStuffFromFunction()
752 const AttributeList &PAL = F->getAttributes(); in removeDeadStuffFromFunction()
760 for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; in removeDeadStuffFromFunction()
762 RetOrArg Arg = createArg(F, ArgI); in removeDeadStuffFromFunction()
772 << F->getName() << "\n"); in removeDeadStuffFromFunction()
779 unsigned RetCount = numRetVals(F); in removeDeadStuffFromFunction()
809 RetOrArg Ret = createRet(F, Ri); in removeDeadStuffFromFunction()
811 RetTypes.push_back(getRetComponentType(F, Ri)); in removeDeadStuffFromFunction()
817 << Ri << " from " << F->getName() << "\n"); in removeDeadStuffFromFunction()
836 NRetTy = Type::getVoidTy(F->getContext()); in removeDeadStuffFromFunction()
842 AttrBuilder RAttrs(F->getContext(), PAL.getRetAttrs()); in removeDeadStuffFromFunction()
854 AttributeSet RetAttrs = AttributeSet::get(F->getContext(), RAttrs); in removeDeadStuffFromFunction()
858 PAL.getFnAttrs().removeAttribute(F->getContext(), Attribute::AllocSize); in removeDeadStuffFromFunction()
863 AttributeList::get(F->getContext(), FnAttrs, RetAttrs, ArgAttrVec); in removeDeadStuffFromFunction()
873 Function *NF = Function::Create(NFTy, F->getLinkage(), F->getAddressSpace()); in removeDeadStuffFromFunction()
874 NF->copyAttributesFrom(F); in removeDeadStuffFromFunction()
875 NF->setComdat(F->getComdat()); in removeDeadStuffFromFunction()
879 F->getParent()->getFunctionList().insert(F->getIterator(), NF); in removeDeadStuffFromFunction()
880 NF->takeName(F); in removeDeadStuffFromFunction()
881 NF->IsNewDbgInfoFormat = F->IsNewDbgInfoFormat; in removeDeadStuffFromFunction()
886 while (!F->use_empty()) { in removeDeadStuffFromFunction()
887 CallBase &CB = cast<CallBase>(*F->user_back()); in removeDeadStuffFromFunction()
894 AttrBuilder RAttrs(F->getContext(), CallPAL.getRetAttrs()); in removeDeadStuffFromFunction()
896 AttributeSet RetAttrs = AttributeSet::get(F->getContext(), RAttrs); in removeDeadStuffFromFunction()
916 F->getContext(), AttrBuilder(F->getContext(), Attrs) in removeDeadStuffFromFunction()
936 F->getContext(), Attribute::AllocSize); in removeDeadStuffFromFunction()
939 AttributeList::get(F->getContext(), FnAttrs, RetAttrs, ArgAttrVec); in removeDeadStuffFromFunction()
1015 NF->splice(NF->begin(), F); in removeDeadStuffFromFunction()
1020 for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(), in removeDeadStuffFromFunction()
1038 if (F->getReturnType() != NF->getReturnType()) in removeDeadStuffFromFunction()
1073 auto *NewRet = ReturnInst::Create(F->getContext(), RetVal, RI); in removeDeadStuffFromFunction()
1080 F->getAllMetadata(MDs); in removeDeadStuffFromFunction()
1095 F->eraseFromParent(); in removeDeadStuffFromFunction()
1107 for (const auto *F : NewLiveFuncs) in propagateVirtMustcallLiveness() local
1108 for (const auto *U : F->users()) in propagateVirtMustcallLiveness()
1115 for (const auto *F : Temp) in propagateVirtMustcallLiveness() local
1116 markLive(*F); in propagateVirtMustcallLiveness()
1129 for (Function &F : llvm::make_early_inc_range(M)) in run()
1130 if (F.getFunctionType()->isVarArg()) in run()
1131 Changed |= deleteDeadVarargs(F); in run()
1137 for (auto &F : M) in run() local
1138 surveyFunction(F); in run()
1145 for (Function &F : llvm::make_early_inc_range(M)) in run()
1146 Changed |= removeDeadStuffFromFunction(&F); in run()
1150 for (auto &F : M) in run() local
1151 Changed |= removeDeadArgumentsFromCallers(F); in run()