Fix NameAnonFunctions pass: for ThinLTO we need to rename global variables as well

A follow-up patch will rename this pass and the source file accordingly,
but I figured the non-NFC change will be easier to spot in isolation.

Differential Revision: https://reviews.llvm.org/D24641

llvm-svn: 281744
diff --git a/llvm/lib/Transforms/Utils/NameAnonFunctions.cpp b/llvm/lib/Transforms/Utils/NameAnonFunctions.cpp
index 6dc3520..f6dd98d 100644
--- a/llvm/lib/Transforms/Utils/NameAnonFunctions.cpp
+++ b/llvm/lib/Transforms/Utils/NameAnonFunctions.cpp
@@ -67,12 +67,17 @@
   bool Changed = false;
   ModuleHasher ModuleHash(M);
   int count = 0;
-  for (auto &F : M) {
-    if (F.hasName())
-      continue;
-    F.setName(Twine("anon.") + ModuleHash.get() + "." + Twine(count++));
+  auto RenameIfNeed = [&] (GlobalValue &GV) {
+    if (GV.hasName())
+      return;
+    GV.setName(Twine("anon.") + ModuleHash.get() + "." + Twine(count++));
     Changed = true;
-  }
+  };
+  for (auto &GO : M.global_objects())
+    RenameIfNeed(GO);
+  for (auto &GA : M.aliases())
+    RenameIfNeed(GA);
+
   return Changed;
 }