diff options
Diffstat (limited to 'llvm/lib/CodeGen/GlobalMerge.cpp')
-rw-r--r-- | llvm/lib/CodeGen/GlobalMerge.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/GlobalMerge.cpp b/llvm/lib/CodeGen/GlobalMerge.cpp index c3d49c035a4..1ea53493994 100644 --- a/llvm/lib/CodeGen/GlobalMerge.cpp +++ b/llvm/lib/CodeGen/GlobalMerge.cpp @@ -425,7 +425,6 @@ bool GlobalMerge::doMerge(const SmallVectorImpl<GlobalVariable *> &Globals, DEBUG(dbgs() << " Trying to merge set, starts with #" << GlobalSet.find_first() << "\n"); - StringRef ExternalName; ssize_t i = GlobalSet.find_first(); while (i != -1) { ssize_t j = 0; @@ -434,6 +433,7 @@ bool GlobalMerge::doMerge(const SmallVectorImpl<GlobalVariable *> &Globals, std::vector<Constant*> Inits; bool HasExternal = false; + StringRef FirstExternalName; for (j = i; j != -1; j = GlobalSet.find_next(j)) { Type *Ty = Globals[j]->getValueType(); MergedSize += DL.getTypeAllocSize(Ty); @@ -445,8 +445,7 @@ bool GlobalMerge::doMerge(const SmallVectorImpl<GlobalVariable *> &Globals, if (Globals[j]->hasExternalLinkage() && !HasExternal) { HasExternal = true; - auto *TheFirstExternal = Globals[j]; - ExternalName = TheFirstExternal->getName(); + FirstExternalName = Globals[j]->getName(); } } @@ -466,7 +465,7 @@ bool GlobalMerge::doMerge(const SmallVectorImpl<GlobalVariable *> &Globals, // _MergedGlobals symbols. Twine MergedName = (IsMachO && HasExternal) - ? "_MergedGlobals_" + ExternalName + ? "_MergedGlobals_" + FirstExternalName : "_MergedGlobals"; auto MergedLinkage = IsMachO ? Linkage : GlobalValue::PrivateLinkage; auto *MergedGV = new GlobalVariable( |