Lines Matching refs:G
188 void replaceBy(Function *G) const { in replaceBy()
189 F = G; in replaceBy()
257 void mergeTwoFunctions(Function *F, Function *G);
265 void eraseTail(Function *G);
274 void writeThunk(Function *F, Function *G);
277 void writeAlias(Function *F, Function *G);
281 bool writeThunkOrAlias(Function *F, Function *G);
284 void replaceFunctionInTree(const FunctionNode &FN, Function *G);
535 void MergeFunctions::eraseTail(Function *G) { in eraseTail() argument
537 for (BasicBlock &BB : drop_begin(*G)) { in eraseTail()
681 void MergeFunctions::writeThunk(Function *F, Function *G) { in writeThunk() argument
689 << G->getName() << "()\n"); in writeThunk()
690 GEntryBlock = &G->getEntryBlock(); in writeThunk()
694 << G->getName() << "() {\n"); in writeThunk()
699 NewG = Function::Create(G->getFunctionType(), G->getLinkage(), in writeThunk()
700 G->getAddressSpace(), "", G->getParent()); in writeThunk()
701 NewG->setComdat(G->getComdat()); in writeThunk()
706 Function *H = MergeFunctionsPDI ? G : NewG; in writeThunk()
718 G->getCallingConv() == CallingConv::SwiftTail; in writeThunk()
730 DISubprogram *DIS = G->getSubprogram(); in writeThunk()
741 << G->getName() << "()\n"); in writeThunk()
743 eraseTail(G); in writeThunk()
747 << G->getName() << "()\n"); in writeThunk()
749 NewG->copyAttributesFrom(G); in writeThunk()
750 NewG->takeName(G); in writeThunk()
751 removeUsers(G); in writeThunk()
752 G->replaceAllUsesWith(NewG); in writeThunk()
753 G->eraseFromParent(); in writeThunk()
772 void MergeFunctions::writeAlias(Function *F, Function *G) { in writeAlias() argument
773 Constant *BitcastF = ConstantExpr::getBitCast(F, G->getType()); in writeAlias()
774 PointerType *PtrType = G->getType(); in writeAlias()
775 auto *GA = GlobalAlias::create(G->getValueType(), PtrType->getAddressSpace(), in writeAlias()
776 G->getLinkage(), "", BitcastF, G->getParent()); in writeAlias()
778 F->setAlignment(MaybeAlign(std::max(F->getAlignment(), G->getAlignment()))); in writeAlias()
779 GA->takeName(G); in writeAlias()
780 GA->setVisibility(G->getVisibility()); in writeAlias()
783 removeUsers(G); in writeAlias()
784 G->replaceAllUsesWith(GA); in writeAlias()
785 G->eraseFromParent(); in writeAlias()
793 bool MergeFunctions::writeThunkOrAlias(Function *F, Function *G) { in writeThunkOrAlias() argument
794 if (canCreateAliasFor(G)) { in writeThunkOrAlias()
795 writeAlias(F, G); in writeThunkOrAlias()
799 writeThunk(F, G); in writeThunkOrAlias()
806 void MergeFunctions::mergeTwoFunctions(Function *F, Function *G) { in mergeTwoFunctions() argument
808 assert(G->isInterposable()); in mergeTwoFunctions()
814 (!canCreateAliasFor(F) || !canCreateAliasFor(G))) in mergeTwoFunctions()
825 MaybeAlign MaxAlignment(std::max(G->getAlignment(), NewF->getAlignment())); in mergeTwoFunctions()
827 writeThunkOrAlias(F, G); in mergeTwoFunctions()
837 if (!G->isInterposable() && !MergeFunctionsPDI) { in mergeTwoFunctions()
841 if (G->hasGlobalUnnamedAddr() && !Used.contains(G)) { in mergeTwoFunctions()
844 GlobalNumbers.erase(G); in mergeTwoFunctions()
846 Constant *BitcastF = ConstantExpr::getBitCast(F, G->getType()); in mergeTwoFunctions()
847 removeUsers(G); in mergeTwoFunctions()
848 G->replaceAllUsesWith(BitcastF); in mergeTwoFunctions()
852 replaceDirectCallers(G, F); in mergeTwoFunctions()
859 if (G->isDiscardableIfUnused() && G->use_empty() && !MergeFunctionsPDI) { in mergeTwoFunctions()
860 G->eraseFromParent(); in mergeTwoFunctions()
865 if (writeThunkOrAlias(F, G)) { in mergeTwoFunctions()
873 Function *G) { in replaceFunctionInTree() argument
875 assert(FunctionComparator(F, G, &GlobalNumbers).compare() == 0 && in replaceFunctionInTree()
880 assert(FNodesInTree.count(G) == 0 && "FNodesInTree should not contain G"); in replaceFunctionInTree()
886 FNodesInTree.insert({G, IterToFNInFnTree}); in replaceFunctionInTree()
888 FN.replaceBy(G); in replaceFunctionInTree()
892 static bool isFuncOrderCorrect(const Function *F, const Function *G) { in isFuncOrderCorrect() argument
893 if (F->isInterposable() != G->isInterposable()) { in isFuncOrderCorrect()
898 if (F->hasLocalLinkage() != G->hasLocalLinkage()) { in isFuncOrderCorrect()
906 return F->getName() <= G->getName(); in isFuncOrderCorrect()