summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-12-11 22:18:44 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-12-11 22:18:44 +0000
commit2b5a0c9e68ef960ade8fe5241ca0f0690ef7bfb3 (patch)
treec122cc459af614ab40cbe951c9abae31c9ad9860 /llvm
parent727747eb29baaf61c5058bae7d9f6c8fa350b96f (diff)
downloadbcm5719-llvm-2b5a0c9e68ef960ade8fe5241ca0f0690ef7bfb3.tar.gz
bcm5719-llvm-2b5a0c9e68ef960ade8fe5241ca0f0690ef7bfb3.zip
On ELF and COFF treat linker_private like private.
The linkers on these systems don't have anything special to do with these symbols. Since the intent is for them to be absent from the final object, just treat them as private. llvm-svn: 197080
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/MC/MCAsmInfo.h17
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp2
-rw-r--r--llvm/test/CodeGen/X86/linker-private.ll10
3 files changed, 23 insertions, 6 deletions
diff --git a/llvm/include/llvm/MC/MCAsmInfo.h b/llvm/include/llvm/MC/MCAsmInfo.h
index f09428d28c2..5bd42e90f57 100644
--- a/llvm/include/llvm/MC/MCAsmInfo.h
+++ b/llvm/include/llvm/MC/MCAsmInfo.h
@@ -124,10 +124,12 @@ namespace llvm {
/// file.
const char *PrivateGlobalPrefix; // Defaults to "L"
- /// LinkerPrivateGlobalPrefix - This prefix is used for symbols that should
- /// be passed through the assembler but be removed by the linker. This
- /// is "l" on Darwin, currently used for some ObjC metadata.
- const char *LinkerPrivateGlobalPrefix; // Defaults to ""
+ /// This prefix is used for symbols that should be passed through the
+ /// assembler but be removed by the linker. This is 'l' on Darwin,
+ /// currently used for some ObjC metadata.
+ /// The default of "" meast that for this system a plain private symbol
+ /// should be used.
+ const char *LinkerPrivateGlobalPrefix; // Defaults to "".
/// InlineAsmStart/End - If these are nonempty, they contain a directive to
/// emit before and after an inline assembly statement.
@@ -441,8 +443,13 @@ namespace llvm {
const char *getPrivateGlobalPrefix() const {
return PrivateGlobalPrefix;
}
+ bool hasLinkerPrivateGlobalPrefix() const {
+ return LinkerPrivateGlobalPrefix[0] != '\0';
+ }
const char *getLinkerPrivateGlobalPrefix() const {
- return LinkerPrivateGlobalPrefix;
+ if (hasLinkerPrivateGlobalPrefix())
+ return LinkerPrivateGlobalPrefix;
+ return getPrivateGlobalPrefix();
}
const char *getInlineAsmStart() const {
return InlineAsmStart;
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index ad542737447..5d49831a6f1 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1175,7 +1175,7 @@ void AsmPrinter::EmitJumpTableInfo() {
// before each jump table. The first label is never referenced, but tells
// the assembler and linker the extents of the jump table object. The
// second label is actually referenced by the code.
- if (JTInDiffSection && MAI->getLinkerPrivateGlobalPrefix()[0])
+ if (JTInDiffSection && MAI->hasLinkerPrivateGlobalPrefix())
// FIXME: This doesn't have to have any specific name, just any randomly
// named and numbered 'l' label would work. Simplify GetJTISymbol.
OutStreamer.EmitLabel(GetJTISymbol(JTI, true));
diff --git a/llvm/test/CodeGen/X86/linker-private.ll b/llvm/test/CodeGen/X86/linker-private.ll
new file mode 100644
index 00000000000..ecea34235df
--- /dev/null
+++ b/llvm/test/CodeGen/X86/linker-private.ll
@@ -0,0 +1,10 @@
+; RUN: llc < %s -mtriple=x86_64-pc-linux | FileCheck --check-prefix=ELF %s
+; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck --check-prefix=MACHO %s
+
+@foo = linker_private global i32 42
+;ELF: {{^}}.Lfoo:
+;MACHO: {{^}}l_foo:
+
+define i32* @f() {
+ ret i32* @foo
+}
OpenPOWER on IntegriCloud