[llvm] [llvm][CFI] Do not canonicalize COFF functions in a comdat (PR #139962)

via llvm-commits llvm-commits at lists.llvm.org
Fri May 16 13:34:02 PDT 2025


================
@@ -1715,8 +1715,18 @@ void LowerTypeTestsModule::buildBitSetsFromFunctionsNative(
           F->getValueType(), 0, F->getLinkage(), "", CombinedGlobalElemPtr, &M);
       FAlias->setVisibility(F->getVisibility());
       FAlias->takeName(F);
-      if (FAlias->hasName())
+      if (FAlias->hasName()) {
         F->setName(FAlias->getName() + ".cfi");
+        // For COFF we should also rename the comdat if this function also
+        // happens to be the key function. Even if the comdat name changes, this
+        // should still be fine since comdat and symbol resolution happens
+        // before LTO, so all symbols which would prevail have been selected.
+        if (F->hasComdat() && ObjectFormat == Triple::COFF &&
+            F->getComdat()->getName() == FAlias->getName()) {
+          Comdat *NewComdat = M.getOrInsertComdat(F->getName());
+          F->setComdat(NewComdat);
----------------
PiJoules wrote:

Yeah I believe we do need to update those also.

https://github.com/llvm/llvm-project/pull/139962


More information about the llvm-commits mailing list