[PATCH] D107136: [WIP] [FuncSpec] Handle Available Externally Linkage Function
Chuanqi Xu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 30 00:47:10 PDT 2021
ChuanqiXu created this revision.
Herald added subscribers: snehasish, ormris, hiraditya.
ChuanqiXu requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This is the successive patch of D105966 <https://reviews.llvm.org/D105966>. With D105544 <https://reviews.llvm.org/D105544>, D105966 <https://reviews.llvm.org/D105966> and this diff, they construct my prototype of ThinLTO for function specialization.
To make this work for 505.mcf_r, it requires that the function specialization handle the case that the argument is already constant, which would be handled by IPSCCP by the design of function specialization. We could discuss it later.
https://reviews.llvm.org/D107136
Files:
llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
Index: llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
===================================================================
--- llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
+++ llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
@@ -216,6 +216,10 @@
ValueToValueMapTy EmptyMap;
Function *Clone = CloneFunction(F, EmptyMap);
Argument *ClonedArg = Clone->arg_begin() + A.getArgNo();
+ // Functions with AvailableExternallyLinkage would be deleted
+ // in the end.
+ if (Clone->hasAvailableExternallyLinkage())
+ Clone->setLinkage(GlobalValue::InternalLinkage);
// Rewrite calls to the function so that they call the clone instead.
rewriteCallSites(F, Clone, *ClonedArg, C);
@@ -463,7 +467,8 @@
// Determine if we can track the function's arguments. If so, add the
// function to the solver's set of argument-tracked functions.
- if (canTrackArgumentsInterprocedurally(&F)) {
+ if (canTrackArgumentsInterprocedurally(&F) ||
+ F.hasAvailableExternallyLinkage()) {
LLVM_DEBUG(dbgs() << "FnSpecialization: Can track arguments\n");
Solver.addArgumentTrackedFunction(&F);
continue;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107136.362980.patch
Type: text/x-patch
Size: 1204 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210730/1ba9818a/attachment.bin>
More information about the llvm-commits
mailing list