Add a pass to name anonymous/nameless function
Summary:
For correct handling of alias to nameless
function, we need to be able to refer them through a GUID in the summary.
Here we name them using a hash of the non-private global names in the module.
Reviewers: tejohnson
Subscribers: joker.eph, llvm-commits
Differential Revision: http://reviews.llvm.org/D18883
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266132
diff --git a/llvm/test/Transforms/NameAnonFunctions/rename.ll b/llvm/test/Transforms/NameAnonFunctions/rename.ll
new file mode 100644
index 0000000..851746f
--- /dev/null
+++ b/llvm/test/Transforms/NameAnonFunctions/rename.ll
@@ -0,0 +1,27 @@
+; RUN: opt -S -name-anon-functions < %s | FileCheck %s
+
+
+; foo contribute to the unique hash for the module
+define void @foo() {
+ ret void
+}
+
+; bar is internal, and does not contribute to the unique hash for the module
+define internal void @bar() {
+ ret void
+}
+
+; CHECK: define void @anon.acbd18db4cc2f85cedef654fccc4a4d8.0()
+; CHECK: define void @anon.acbd18db4cc2f85cedef654fccc4a4d8.1()
+; CHECK: define void @anon.acbd18db4cc2f85cedef654fccc4a4d8.2()
+
+define void @0() {
+ ret void
+}
+define void @1() {
+ ret void
+}
+define void @2() {
+ ret void
+}
+