[llvm] r269706 - Fail early on unknown appending linkage variables.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon May 16 14:14:25 PDT 2016
Author: rafael
Date: Mon May 16 16:14:24 2016
New Revision: 269706
URL: http://llvm.org/viewvc/llvm-project?rev=269706&view=rev
Log:
Fail early on unknown appending linkage variables.
In practice only a few well known appending linkage variables work.
Currently if codegen sees an unknown appending linkage variable it will
just print it as a regular global. That is wrong as the symbol in the
produced object file has different semantics as the one provided by the
appending linkage.
This just errors early instead of producing a broken .o.
Added:
llvm/trunk/test/CodeGen/X86/AppendingLinkage.ll
Removed:
llvm/trunk/test/CodeGen/X86/2007-08-13-AppendingLinkage.ll
Modified:
llvm/trunk/docs/LangRef.rst
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Modified: llvm/trunk/docs/LangRef.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.rst?rev=269706&r1=269705&r2=269706&view=diff
==============================================================================
--- llvm/trunk/docs/LangRef.rst (original)
+++ llvm/trunk/docs/LangRef.rst Mon May 16 16:14:24 2016
@@ -250,6 +250,11 @@ linkage:
together. This is the LLVM, typesafe, equivalent of having the
system linker append together "sections" with identical names when
.o files are linked.
+
+ Unfortunately this doesn't correspond to any feature in .o files, so it
+ can only be used for variables like ``llvm.global_ctors`` which llvm
+ interprets specially.
+
``extern_weak``
The semantics of this linkage follow the ELF object file model: the
symbol is weak until linked, if not linked, the symbol becomes null
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=269706&r1=269705&r2=269706&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon May 16 16:14:24 2016
@@ -318,17 +318,14 @@ void AsmPrinter::EmitLinkage(const Globa
OutStreamer->EmitSymbolAttribute(GVSym, MCSA_Weak);
}
return;
- case GlobalValue::AppendingLinkage:
- // FIXME: appending linkage variables should go into a section of
- // their name or something. For now, just emit them as external.
case GlobalValue::ExternalLinkage:
- // If external or appending, declare as a global symbol.
- // .globl _foo
+ // If external, declare as a global symbol: .globl _foo
OutStreamer->EmitSymbolAttribute(GVSym, MCSA_Global);
return;
case GlobalValue::PrivateLinkage:
case GlobalValue::InternalLinkage:
return;
+ case GlobalValue::AppendingLinkage:
case GlobalValue::AvailableExternallyLinkage:
case GlobalValue::ExternalWeakLinkage:
llvm_unreachable("Should never emit this");
@@ -1562,7 +1559,7 @@ bool AsmPrinter::EmitSpecialLLVMGlobal(c
return true;
}
- return false;
+ report_fatal_error("unknown special variable");
}
/// EmitLLVMUsedList - For targets that define a MAI::UsedDirective, mark each
Removed: llvm/trunk/test/CodeGen/X86/2007-08-13-AppendingLinkage.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-08-13-AppendingLinkage.ll?rev=269705&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/2007-08-13-AppendingLinkage.ll (original)
+++ llvm/trunk/test/CodeGen/X86/2007-08-13-AppendingLinkage.ll (removed)
@@ -1,12 +0,0 @@
-; RUN: llc < %s -march=x86 | not grep drectve
-; PR1607
-
-%hlvm_programs_element = type { i8*, i32 (i32, i8**)* }
- at hlvm_programs = appending constant [1 x %hlvm_programs_element]
-zeroinitializer
-
-define %hlvm_programs_element* @hlvm_get_programs() {
-entry:
- ret %hlvm_programs_element* getelementptr([1 x %hlvm_programs_element], [1 x %hlvm_programs_element]*
- @hlvm_programs, i32 0, i32 0)
-}
Added: llvm/trunk/test/CodeGen/X86/AppendingLinkage.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/AppendingLinkage.ll?rev=269706&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/AppendingLinkage.ll (added)
+++ llvm/trunk/test/CodeGen/X86/AppendingLinkage.ll Mon May 16 16:14:24 2016
@@ -0,0 +1,4 @@
+; RUN: not llc < %s -march=x86 2>&1 | FileCheck %s
+
+; CHECK: unknown special variable
+ at foo = appending constant [1 x i32 ]zeroinitializer
More information about the llvm-commits
mailing list