From 2cac787919393548dcc762f4a37a16fac1f6a3ad Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Fri, 16 Sep 2016 16:56:25 +0000 Subject: 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 --- llvm/lib/Transforms/Utils/NameAnonFunctions.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'llvm/lib/Transforms/Utils/NameAnonFunctions.cpp') 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; } -- cgit v1.2.3