fix PR5869: mangle static symbols like gcc does to make it easier to diff symbol tables
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92911 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp
index 10fd1f5..d873cfe 100644
--- a/lib/CodeGen/Mangle.cpp
+++ b/lib/CodeGen/Mangle.cpp
@@ -199,10 +199,13 @@
return;
}
- // <mangled-name> ::= _Z <encoding>
+ // <mangled-name> ::= _Z [L] <encoding>
// ::= <data name>
// ::= <special-name>
Out << Prefix;
+ if (D->getLinkage() == NamedDecl::InternalLinkage) // match gcc behavior
+ Out << 'L';
+
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
mangleFunctionEncoding(FD);
else
diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp
index e8770df..5947587 100644
--- a/test/CodeGenCXX/mangle.cpp
+++ b/test/CodeGenCXX/mangle.cpp
@@ -308,4 +308,9 @@
}
// CHECK: define void @_Z1fU13block_pointerFiiiE
-void f(int (^)(int, int)) { }
\ No newline at end of file
+void f(int (^)(int, int)) { }
+
+// PR5869
+// CHECK: define internal void @_ZL2f2v
+static void f2() {}
+void f3() { f2(); }