Skip to content

[WIP][CFI][LTO] Avoid duplicate symbols on aliased weak function #150072

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vitalybuka
Copy link
Collaborator

Problem is that LowerTypeTests expects that only one
definition will be left by LTO for a symbol.

However, thanks to strong alias, weak non-prevaling
definition can be preserved.

So strong and weak function definition will be renamed to strong .cfi,
making them duplicate.

Fixes #150070.

Created using spr 1.3.6
@llvmbot
Copy link
Member

llvmbot commented Jul 22, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Vitaly Buka (vitalybuka)

Changes

Problem is that LowerTypeTests expects that only one
definition will be left by LTO for a symbol.

However, thanks to strong alias, weak non-prevaling
definition can be preserved.

So strong and weak function definition will be renamed to strong .cfi,
making them duplicate.

Fixes #150070.


Full diff: https://github.com/llvm/llvm-project/pull/150072.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/IPO/LowerTypeTests.cpp (-1)
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
index 486205c8a3848..71f827dd87086 100644
--- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -1135,7 +1135,6 @@ void LowerTypeTestsModule::importFunction(
   } else {
     F->setName(Name + ".cfi");
     maybeReplaceComdat(F, Name);
-    F->setLinkage(GlobalValue::ExternalLinkage);
     FDecl = Function::Create(F->getFunctionType(), GlobalValue::ExternalLinkage,
                              F->getAddressSpace(), Name, &M);
     FDecl->setVisibility(Visibility);

@@ -1135,7 +1135,6 @@ void LowerTypeTestsModule::importFunction(
} else {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pcc I believe even if this works it's wrong fix.

We probably should rather check if LTO have selected this definition as prevailing before renaming it into .cfi (or make it internal linkage it it's not)

WDYT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CFI] duplicate symbols on aliased weak function
2 participants