[PATCH] D24641: Fix NameAnonFunctions pass: for ThinLTO we need to rename global variables as well

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 15 17:24:41 PDT 2016


mehdi_amini created this revision.
mehdi_amini added a reviewer: tejohnson.
mehdi_amini added a subscriber: llvm-commits.
Herald added a subscriber: mehdi_amini.

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.

https://reviews.llvm.org/D24641

Files:
  lib/Transforms/Utils/NameAnonFunctions.cpp
  test/Transforms/NameAnonFunctions/rename.ll

Index: test/Transforms/NameAnonFunctions/rename.ll
===================================================================
--- test/Transforms/NameAnonFunctions/rename.ll
+++ test/Transforms/NameAnonFunctions/rename.ll
@@ -11,6 +11,7 @@
     ret void
 }
 
+; CHECK: @anon.acbd18db4cc2f85cedef654fccc4a4d8.3 = global i8 0
 ; CHECK: define void @anon.acbd18db4cc2f85cedef654fccc4a4d8.0()
 ; CHECK: define void @anon.acbd18db4cc2f85cedef654fccc4a4d8.1()
 ; CHECK: define void @anon.acbd18db4cc2f85cedef654fccc4a4d8.2()
@@ -25,3 +26,5 @@
     ret void
 }
 
+
+ at 3 = global i8 0
Index: lib/Transforms/Utils/NameAnonFunctions.cpp
===================================================================
--- lib/Transforms/Utils/NameAnonFunctions.cpp
+++ lib/Transforms/Utils/NameAnonFunctions.cpp
@@ -67,10 +67,10 @@
   bool Changed = false;
   ModuleHasher ModuleHash(M);
   int count = 0;
-  for (auto &F : M) {
-    if (F.hasName())
+  for (auto &GO : M.global_objects()) {
+    if (GO.hasName())
       continue;
-    F.setName(Twine("anon.") + ModuleHash.get() + "." + Twine(count++));
+    GO.setName(Twine("anon.") + ModuleHash.get() + "." + Twine(count++));
     Changed = true;
   }
   return Changed;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24641.71576.patch
Type: text/x-patch
Size: 1195 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160916/354b26e2/attachment.bin>


More information about the llvm-commits mailing list