mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-28 15:54:00 +00: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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281744 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1af818627a
commit
4dbfcbba39
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user