diff options
author | Adrian Prantl <aprantl@apple.com> | 2016-11-11 21:48:09 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2016-11-11 21:48:09 +0000 |
commit | 6cb849e2f0475de39607d4c5a26762e6833400d2 (patch) | |
tree | 6b061d3e70a23ef97ddf42cb41a92a885ccb8644 /llvm/lib/CodeGen/GlobalMerge.cpp | |
parent | 1f2bf2d3e1e45e0f88a4c93bc662724a3b78abf0 (diff) | |
download | bcm5719-llvm-6cb849e2f0475de39607d4c5a26762e6833400d2.tar.gz bcm5719-llvm-6cb849e2f0475de39607d4c5a26762e6833400d2.zip |
Fix a reference-to-temporary introduced in r286607.
llvm-svn: 286640
Diffstat (limited to 'llvm/lib/CodeGen/GlobalMerge.cpp')
-rw-r--r-- | llvm/lib/CodeGen/GlobalMerge.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/GlobalMerge.cpp b/llvm/lib/CodeGen/GlobalMerge.cpp index e0ffd475e64..c3d49c035a4 100644 --- a/llvm/lib/CodeGen/GlobalMerge.cpp +++ b/llvm/lib/CodeGen/GlobalMerge.cpp @@ -425,6 +425,7 @@ 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; @@ -433,7 +434,6 @@ bool GlobalMerge::doMerge(const SmallVectorImpl<GlobalVariable *> &Globals, std::vector<Constant*> Inits; bool HasExternal = false; - GlobalVariable *TheFirstExternal = nullptr; for (j = i; j != -1; j = GlobalSet.find_next(j)) { Type *Ty = Globals[j]->getValueType(); MergedSize += DL.getTypeAllocSize(Ty); @@ -445,7 +445,8 @@ bool GlobalMerge::doMerge(const SmallVectorImpl<GlobalVariable *> &Globals, if (Globals[j]->hasExternalLinkage() && !HasExternal) { HasExternal = true; - TheFirstExternal = Globals[j]; + auto *TheFirstExternal = Globals[j]; + ExternalName = TheFirstExternal->getName(); } } @@ -457,14 +458,15 @@ bool GlobalMerge::doMerge(const SmallVectorImpl<GlobalVariable *> &Globals, StructType *MergedTy = StructType::get(M.getContext(), Tys); Constant *MergedInit = ConstantStruct::get(MergedTy, Inits); - // On Darwin external linkage needs to be preserved, otherwise dsymutil - // cannot preserve the debug info for the merged variables. If they have - // external linkage, use the symbol name of the first variable merged as the - // suffix of global symbol name. This avoids a link-time naming conflict - // for the _MergedGlobals symbols. + // On Darwin external linkage needs to be preserved, otherwise + // dsymutil cannot preserve the debug info for the merged + // variables. If they have external linkage, use the symbol name + // of the first variable merged as the suffix of global symbol + // name. This avoids a link-time naming conflict for the + // _MergedGlobals symbols. Twine MergedName = (IsMachO && HasExternal) - ? "_MergedGlobals_" + TheFirstExternal->getName() + ? "_MergedGlobals_" + ExternalName : "_MergedGlobals"; auto MergedLinkage = IsMachO ? Linkage : GlobalValue::PrivateLinkage; auto *MergedGV = new GlobalVariable( |