[PATCH] D106931: [Attributor] Change function internalization to not replace uses in internalized callers

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 28 09:34:17 PDT 2021


jdoerfert added inline comments.


================
Comment at: llvm/lib/Transforms/IPO/Attributor.cpp:1945
+  Twine InternalizedName = F.getName() + ".internalized";
+  return F.getParent()->getFunction(InternalizedName.str());
+}
----------------
Rather than doing this lookup can we pass in `DenseMap<Function *, Function *> InternalizedFns` and use it to lookup the new copy.
More useful in the future too as it allows to lookup all copies.


================
Comment at: llvm/lib/Transforms/IPO/Attributor.cpp:1958
+    Module &M = *F->getParent();
+    Function *&InternalizedFn = InternalizedFns[F];
+    FunctionType *FnTy = F->getFunctionType();
----------------
Move to use to shorten the lifetime.


================
Comment at: llvm/lib/Transforms/IPO/Attributor.cpp:2000-2002
+        if (!InternalizedFns[CB->getCaller()])
+          return true;
+      return false;
----------------



================
Comment at: llvm/lib/Transforms/IPO/Attributor.cpp:2005
+    F->replaceUsesWithIf(InternalizedFn, IsNotInternalized);
+    InternalizedFn->setDSOLocal(true);
+  }
----------------
Why here? Move this to the actual internalization, no?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106931/new/

https://reviews.llvm.org/D106931



More information about the llvm-commits mailing list