[llvm] [MergeFunctions] keep the symbol of a function an alias points at on COFF (PR #222024)
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 14 10:55:07 PDT 2026
================
@@ -864,6 +864,43 @@ static bool canCreateAliasFor(Function *F) {
return true;
}
+/// Returns true if an alias that is visible to other objects points at \p F.
+static bool hasNonLocalAlias(const Function *F) {
+ for (const GlobalAlias &GA : F->getParent()->aliases())
+ if (!GA.hasLocalLinkage() && GA.getAliaseeObject() == F)
+ return true;
+ return false;
+}
+
+/// COFF names the fallback symbol of a local alias target after unrelated
+/// contents of the object, so two objects defining the alias disagree
+/// (LNK1227).
+static bool needsStableSymbolForAlias(const Function *F) {
+ return F->getParent()->getTargetTriple().isOSBinFormatCOFF();
+}
+
+/// Names \p F after its structural hash, so that every object merging this body
+/// agrees, and folds the copies with a COMDAT. Returns false if it could not.
+static bool giveStableSymbolForAlias(Function *F) {
----------------
compnerd wrote:
This feels a bit out of place - `give` isn't something that you see around LLVM and it feels pretty invasive as it mutates `F` pretty heavily. I think that this should be something more like `ConvertToMergedFunction` or something.
https://github.com/llvm/llvm-project/pull/222024
More information about the llvm-commits
mailing list