Skip to content

Conversation

@vitalybuka
Copy link
Collaborator

Merged unit contains jump tables, but no
definition target functions. For each function
with canonical jump table it expects, that the
module with definition will rename function into
".cfi" version. However, it does not happend for
aliases. To overcome that we will use .cfi version
of aliasee.

Fixes #150075.

Created using spr 1.3.6
@llvmbot
Copy link
Member

llvmbot commented Jul 23, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Vitaly Buka (vitalybuka)

Changes

Merged unit contains jump tables, but no
definition target functions. For each function
with canonical jump table it expects, that the
module with definition will rename function into
".cfi" version. However, it does not happend for
aliases. To overcome that we will use .cfi version
of aliasee.

Fixes #150075.


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

1 Files Affected:

  • (modified) llvm/lib/Transforms/IPO/LowerTypeTests.cpp (+11)
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
index 486205c8a3848..43f22bcc892ef 100644
--- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -2453,6 +2453,17 @@ bool LowerTypeTestsModule::lower() {
         } else {
           Alias->setName(AliasName);
         }
+
+        if (auto *F = M.getFunction((AliasName + ".cfi").str())) {
+          // Function can be an alias. In such case we need definition of .cfi
+          // of aliasee.
+          if (auto *CfiAleasee = M.getFunction((Aliasee + ".cfi").str())) {
+            F->replaceAllUsesWith(CfiAleasee);
+            F->eraseFromParent();
+          } else {
+            F->setName(Aliasee + ".cfi");
+          }
+        }
       }
     }
   }

@vitalybuka vitalybuka changed the title [CFI] Use .cfi of aleasee if the function is infact a alias [WIP][CFI] Use .cfi of aleasee if the function is infact a alias Jul 23, 2025
@vitalybuka vitalybuka marked this pull request as draft November 10, 2025 18:06
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] missing .cfi symbols when alias override weak function

3 participants