[PATCH] D104102: Function Specialisation, cont'd
Sjoerd Meijer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 11 03:20:26 PDT 2021
SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: fhahn, ChuanqiXu, sanwou01, jaykang10.
Herald added subscribers: ormris, hiraditya, mgorny.
SjoerdMeijer requested review of this revision.
Herald added a project: LLVM.
This is a follow up of D93838 <https://reviews.llvm.org/D93838>:
- moved the .cpp file to the right place,
- fixed the statistics and specialisation counter.
- fixed the strayline.
I haven't removed those functions from `llvm/include/llvm/Transforms/Utils/SCCPSolver.h` because they are still used.
https://reviews.llvm.org/D104102
Files:
llvm/lib/Transforms/IPO/CMakeLists.txt
llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
llvm/lib/Transforms/Scalar/CMakeLists.txt
llvm/lib/Transforms/Scalar/FunctionSpecialization.cpp
Index: llvm/lib/Transforms/Scalar/CMakeLists.txt
===================================================================
--- llvm/lib/Transforms/Scalar/CMakeLists.txt
+++ llvm/lib/Transforms/Scalar/CMakeLists.txt
@@ -13,7 +13,6 @@
EarlyCSE.cpp
FlattenCFGPass.cpp
Float2Int.cpp
- FunctionSpecialization.cpp
GuardWidening.cpp
GVN.cpp
GVNHoist.cpp
Index: llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
===================================================================
--- llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
+++ llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
@@ -120,6 +120,8 @@
LLVM_DEBUG(dbgs() << "FnSpecialization: Replaced constant argument: "
<< Arg.getName() << "\n");
}
+
+ NumFuncSpecialized += FunctionsSpecialized;
return Changed;
}
@@ -141,6 +143,8 @@
}
private:
+ int FunctionsSpecialized = 0;
+
/// This function decides whether to specialize function \p F based on the
/// known constant values its arguments can take on. Specialization is
/// performed on the first interesting argument. Specializations based on
@@ -217,7 +221,7 @@
// Mark all the specialized functions
Specializations.push_back(Clone);
- NumFuncSpecialized++;
+ FunctionsSpecialized++;
}
// TODO: if we want to support specialize specialized functions, and if
@@ -247,7 +251,7 @@
// Otherwise, set the specialization cost to be the cost of all the
// instructions in the function and penalty for specializing more functions.
- unsigned Penalty = (NumFuncSpecialized + 1);
+ unsigned Penalty = FunctionsSpecialized + 1;
return Metrics.NumInsts * InlineConstants::InstrCost * Penalty;
}
@@ -506,7 +510,6 @@
CallSitesToRewrite.push_back(&CS);
}
for (auto *CS : CallSitesToRewrite) {
-
if ((CS->getFunction() == Clone && CS->getArgOperand(ArgNo) == &Arg) ||
CS->getArgOperand(ArgNo) == C) {
CS->setCalledFunction(Clone);
@@ -632,6 +635,5 @@
// Clean up the IR by removing ssa_copy intrinsics.
cleanup(M);
-
return Changed;
}
Index: llvm/lib/Transforms/IPO/CMakeLists.txt
===================================================================
--- llvm/lib/Transforms/IPO/CMakeLists.txt
+++ llvm/lib/Transforms/IPO/CMakeLists.txt
@@ -15,6 +15,7 @@
ForceFunctionAttrs.cpp
FunctionAttrs.cpp
FunctionImport.cpp
+ FunctionSpecialization.cpp
GlobalDCE.cpp
GlobalOpt.cpp
GlobalSplit.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104102.351389.patch
Type: text/x-patch
Size: 2521 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210611/827bb8a2/attachment.bin>
More information about the llvm-commits
mailing list