[PATCH] D127751: [MergeFunctions] Preserve symbols used llvm.used/llvm.compiler.used

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 14 09:58:14 PDT 2022


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/IPO/MergeFunctions.cpp:862
+        if (CompilerUsed.contains(G))
+          appendToCompilerUsed(*G->getParent(), {G});
       } else {
----------------
Amanieu wrote:
> nikic wrote:
> > So does this just leave the old function behind, effectively not doing a merge? I think what you actually want is to go into the alias/thunk code path in this case.
> The writeThunkOrAlias call below will replace the old function with a thunk or alias. Adding the old function back to llvm.used will cause the `G->use_empty()` condition below to fail which prevents the function from being removed from the IR.
I see. In that case I'd suggest to move a condition (on a single combined set) next to `G->hasGlobalUnnamedAddr()`, so we only do `replaceDirectCallers()` replacement. This might replace the function in slightly less cases, but I'd prefer that over the explicit manipulation of the used globals list here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127751



More information about the llvm-commits mailing list