1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-23 04:52:54 +02:00

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
This commit is contained in:
Mehdi Amini 2016-09-16 16:56:25 +00:00
parent 1e516939b9
commit 55d44fcce3
2 changed files with 16 additions and 5 deletions

View File

@ -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;
}

View File

@ -11,6 +11,8 @@ define internal void @bar() {
ret void
}
; CHECK: @anon.acbd18db4cc2f85cedef654fccc4a4d8.3 = global i8 0
; CHECK: @anon.acbd18db4cc2f85cedef654fccc4a4d8.4 = alias i8, i8* @anon.acbd18db4cc2f85cedef654fccc4a4d8.3
; CHECK: define void @anon.acbd18db4cc2f85cedef654fccc4a4d8.0()
; CHECK: define void @anon.acbd18db4cc2f85cedef654fccc4a4d8.1()
; CHECK: define void @anon.acbd18db4cc2f85cedef654fccc4a4d8.2()
@ -25,3 +27,7 @@ define void @2() {
ret void
}
@3 = global i8 0
@4 = alias i8, i8 *@3