[PATCH] D111660: [FuncSpec] Make sure function is actually the callee before trying to specialize.

duk via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 12 10:37:58 PDT 2021


duck-37 created this revision.
duck-37 added a reviewer: SjoerdMeijer.
Herald added subscribers: snehasish, ormris, hiraditya.
duck-37 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This causes issues if we start allowing functions with their addresses taken to be specialized.
I intend to submit a patch that does this soon, so this is a blocker at the moment.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111660

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
@@ -662,6 +662,10 @@
       if (!isa<CallInst>(U) && !isa<InvokeInst>(U))
         continue;
       auto &CS = *cast<CallBase>(U);
+      if (CS.getCalledFunction() != F) {
+        continue;
+      }
+
       // If the call site has attribute minsize set, that callsite won't be
       // specialized.
       if (CS.hasFnAttr(Attribute::MinSize)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111660.379106.patch
Type: text/x-patch
Size: 586 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211012/ad61f1fe/attachment.bin>


More information about the llvm-commits mailing list