[llvm] r286644 - Simplify code and address review comments (NFC)

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 11 14:09:25 PST 2016


Author: adrian
Date: Fri Nov 11 16:09:25 2016
New Revision: 286644

URL: http://llvm.org/viewvc/llvm-project?rev=286644&view=rev
Log:
Simplify code and address review comments (NFC)

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=286644&r1=286643&r2=286644&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalMerge.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalMerge.cpp Fri Nov 11 16:09:25 2016
@@ -425,7 +425,6 @@ 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;
@@ -434,6 +433,7 @@ bool GlobalMerge::doMerge(const SmallVec
     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 SmallVec
 
       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 SmallVec
     // _MergedGlobals symbols.
     Twine MergedName =
         (IsMachO && HasExternal)
-            ? "_MergedGlobals_" + ExternalName
+            ? "_MergedGlobals_" + FirstExternalName
             : "_MergedGlobals";
     auto MergedLinkage = IsMachO ? Linkage : GlobalValue::PrivateLinkage;
     auto *MergedGV = new GlobalVariable(




More information about the llvm-commits mailing list