[llvm] r286640 - Fix a reference-to-temporary introduced in r286607.
Adrian Prantl via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 11 13:48:10 PST 2016
Author: adrian
Date: Fri Nov 11 15:48:09 2016
New Revision: 286640
URL: http://llvm.org/viewvc/llvm-project?rev=286640&view=rev
Log:
Fix a reference-to-temporary introduced in r286607.
Modified:
llvm/trunk/lib/CodeGen/GlobalMerge.cpp
Modified: llvm/trunk/lib/CodeGen/GlobalMerge.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalMerge.cpp?rev=286640&r1=286639&r2=286640&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalMerge.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalMerge.cpp Fri Nov 11 15:48:09 2016
@@ -425,6 +425,7 @@ bool GlobalMerge::doMerge(const SmallVec
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 SmallVec
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 SmallVec
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 SmallVec
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(
More information about the llvm-commits
mailing list