diff options
author | Jordan Rupprecht <rupprecht@google.com> | 2022-10-10 11:40:45 -0700 |
---|---|---|
committer | Jordan Rupprecht <rupprecht@google.com> | 2022-10-10 11:40:45 -0700 |
commit | fb27fd5f88b0fc72cc7ffc49f132bda7da9c4d2c (patch) | |
tree | 0f1321c308b844af13570d210ac700118ee3b9c0 /llvm/lib | |
parent | 438e59182b0c2e44c263f5bacc1add0e514354f8 (diff) | |
download | llvm-fb27fd5f88b0fc72cc7ffc49f132bda7da9c4d2c.zip llvm-fb27fd5f88b0fc72cc7ffc49f132bda7da9c4d2c.tar.gz llvm-fb27fd5f88b0fc72cc7ffc49f132bda7da9c4d2c.tar.bz2 |
Revert "[LTO] Make local linkage GlobalValue in non-prevailing COMDAT available_externally"
This reverts commit 4fbe33593c8132fdc48647c06f4d1455bfff1c88. It causes linking errors, with details provided internally. (Hopefully the author/reviewers will be able to upstream the internal repro).
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/LTO/LTO.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/Transforms/IPO/FunctionImport.cpp | 18 |
2 files changed, 6 insertions, 22 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index 0ce8519..10ca98f 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -696,11 +696,11 @@ handleNonPrevailingComdat(GlobalValue &GV, if (!NonPrevailingComdats.count(C)) return; - // Additionally need to drop all global values from the comdat to - // available_externally, to satisfy the COMDAT requirement that all members - // are discarded as a unit. The non-local linkage global values avoid - // duplicate definition linker errors. - GV.setLinkage(GlobalValue::AvailableExternallyLinkage); + // Additionally need to drop externally visible global values from the comdat + // to available_externally, so that there aren't multiply defined linker + // errors. + if (!GV.hasLocalLinkage()) + GV.setLinkage(GlobalValue::AvailableExternallyLinkage); if (auto GO = dyn_cast<GlobalObject>(&GV)) GO->setComdat(nullptr); diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index ca14df7..b589ec7 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -1051,7 +1051,6 @@ bool llvm::convertToDeclaration(GlobalValue &GV) { void llvm::thinLTOFinalizeInModule(Module &TheModule, const GVSummaryMapTy &DefinedGlobals, bool PropagateAttrs) { - DenseSet<Comdat *> NonPrevailingComdats; auto FinalizeInModule = [&](GlobalValue &GV, bool Propagate = false) { // See if the global summary analysis computed a new resolved linkage. const auto &GS = DefinedGlobals.find(GV.getGUID()); @@ -1129,10 +1128,8 @@ void llvm::thinLTOFinalizeInModule(Module &TheModule, // as this is a declaration for the linker, and will be dropped eventually. // It is illegal for comdats to contain declarations. auto *GO = dyn_cast_or_null<GlobalObject>(&GV); - if (GO && GO->isDeclarationForLinker() && GO->hasComdat()) { - NonPrevailingComdats.insert(GO->getComdat()); + if (GO && GO->isDeclarationForLinker() && GO->hasComdat()) GO->setComdat(nullptr); - } }; // Process functions and global now @@ -1142,19 +1139,6 @@ void llvm::thinLTOFinalizeInModule(Module &TheModule, FinalizeInModule(GV); for (auto &GV : TheModule.aliases()) FinalizeInModule(GV); - - // For a non-prevailing comdat, all its members must be available_externally. - // FinalizeInModule has handled non-local-linkage GlobalValues. Here we handle - // local linkage GlobalValues. - if (NonPrevailingComdats.empty()) - return; - for (auto &GO : TheModule.global_objects()) { - if (auto *C = GO.getComdat(); C && NonPrevailingComdats.count(C)) { - GO.setComdat(nullptr); - assert(GO.hasLocalLinkage() && "GO's comdat should have been dropped"); - GO.setLinkage(GlobalValue::AvailableExternallyLinkage); - } - } } /// Run internalization on \p TheModule based on symmary analysis. |