Simplify code and address review comments (NFC)

llvm-svn: 286644
This commit is contained in:
Adrian Prantl 2016-11-11 22:09:25 +00:00
parent eb1c2a0dac
commit 622bddb6e0
1 changed files with 3 additions and 4 deletions

View File

@ -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(