]> granicus.if.org Git - llvm/commitdiff
Simplify code and address review comments (NFC)
authorAdrian Prantl <aprantl@apple.com>
Fri, 11 Nov 2016 22:09:25 +0000 (22:09 +0000)
committerAdrian Prantl <aprantl@apple.com>
Fri, 11 Nov 2016 22:09:25 +0000 (22:09 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286644 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/GlobalMerge.cpp

index c3d49c035a4601f469db2ec0a6573c322bb02c66..1ea5349399486e0221f150459c04ac457ba4b33b 100644 (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(