summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
index c4e6e3957d0..f2e01b43b76 100644
--- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -757,9 +757,24 @@ bool DevirtModule::trySingleImplDevirt(
// to make it visible to thin LTO objects. We can only get here during the
// ThinLTO export phase.
if (TheFn->hasLocalLinkage()) {
+ std::string NewName = (TheFn->getName() + "$merged").str();
+
+ // Since we are renaming the function, any comdats with the same name must
+ // also be renamed. This is required when targeting COFF, as the comdat name
+ // must match one of the names of the symbols in the comdat.
+ if (Comdat *C = TheFn->getComdat()) {
+ if (C->getName() == TheFn->getName()) {
+ Comdat *NewC = M.getOrInsertComdat(NewName);
+ NewC->setSelectionKind(C->getSelectionKind());
+ for (GlobalObject &GO : M.global_objects())
+ if (GO.getComdat() == C)
+ GO.setComdat(NewC);
+ }
+ }
+
TheFn->setLinkage(GlobalValue::ExternalLinkage);
TheFn->setVisibility(GlobalValue::HiddenVisibility);
- TheFn->setName(TheFn->getName() + "$merged");
+ TheFn->setName(NewName);
}
Res->TheKind = WholeProgramDevirtResolution::SingleImpl;
OpenPOWER on IntegriCloud