[PATCH] D20179: Fail early on unknown appending linkage variables
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Thu May 12 15:47:41 PDT 2016
The patch LGTM with an update to LangRef. Has this been discussed on
llvm-dev though? It seems like an IR change, since whether or not the
old behaviour was a good idea, it was certainly tested for...
> On 2016-May-11, at 12:13, Rafael Ávila de Espíndola <rafael.espindola at gmail.com> wrote:
>
> rafael created this revision.
> rafael added a reviewer: dexonsmith.
> rafael added a subscriber: llvm-commits.
>
> 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.
>
> http://reviews.llvm.org/D20179
>
> Files:
> lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> test/CodeGen/X86/2007-08-13-AppendingLinkage.ll
> test/CodeGen/X86/AppendingLinkage.ll
>
> Index: test/CodeGen/X86/AppendingLinkage.ll
> ===================================================================
> --- /dev/null
> +++ test/CodeGen/X86/AppendingLinkage.ll
> @@ -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
> Index: test/CodeGen/X86/2007-08-13-AppendingLinkage.ll
> ===================================================================
> --- test/CodeGen/X86/2007-08-13-AppendingLinkage.ll
> +++ /dev/null
> @@ -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)
> -}
> Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> ===================================================================
> --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> +++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> @@ -318,17 +318,14 @@
> 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 @@
> return true;
> }
>
> - return false;
> + report_fatal_error("unknown special variable");
> }
>
> /// EmitLLVMUsedList - For targets that define a MAI::UsedDirective, mark each
>
>
> <D20179.56948.patch>
More information about the llvm-commits
mailing list