diff options
author | Mehdi Amini <mehdi.amini@apple.com> | 2016-09-16 16:56:25 +0000 |
---|---|---|
committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-09-16 16:56:25 +0000 |
commit | 2cac787919393548dcc762f4a37a16fac1f6a3ad (patch) | |
tree | 486d8ddc1922b26394bc0ed75d1fbf145eac3e7e /llvm/lib/Transforms | |
parent | 10494b268239b2ccd4757920d6307a1be5e7f855 (diff) | |
download | bcm5719-llvm-2cac787919393548dcc762f4a37a16fac1f6a3ad.tar.gz bcm5719-llvm-2cac787919393548dcc762f4a37a16fac1f6a3ad.zip |
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
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Utils/NameAnonFunctions.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/NameAnonFunctions.cpp b/llvm/lib/Transforms/Utils/NameAnonFunctions.cpp index 6dc3520b61a..f6dd98d12ab 100644 --- a/llvm/lib/Transforms/Utils/NameAnonFunctions.cpp +++ b/llvm/lib/Transforms/Utils/NameAnonFunctions.cpp @@ -67,12 +67,17 @@ bool llvm::nameUnamedFunctions(Module &M) { 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; } |