-/// The LLVM SymbolTable class autorenames globals that conflict in the symbol
-/// table. This is good for all clients except for us. Go through the trouble
-/// to force this back.
-static void forceRenaming(GlobalValue *GV, StringRef Name) {
- // If the global doesn't force its name or if it already has the right name,
- // there is nothing for us to do.
- // Note that any required local to global promotion should already be done,
- // so promoted locals will not skip this handling as their linkage is no
- // longer local.
- if (GV->hasLocalLinkage() || GV->getName() == Name)
- return;
-
- Module *M = GV->getParent();
-
- // If there is a conflict, rename the conflict.
- if (GlobalValue *ConflictGV = M->getNamedValue(Name)) {
- GV->takeName(ConflictGV);
- ConflictGV->setName(Name); // This will cause ConflictGV to get renamed
- assert(ConflictGV->getName() != Name && "forceRenaming didn't work");
- } else {
- GV->setName(Name); // Force the name back
- }
-}
-
-/// copy additional attributes (those not needed to construct a GlobalValue)
-/// from the SrcGV to the DestGV.
-void ModuleLinker::copyGVAttributes(GlobalValue *NewGV,
- const GlobalValue *SrcGV) {
- NewGV->copyAttributesFrom(SrcGV);
- forceRenaming(NewGV, getName(SrcGV));
-}
-