llvm-6502/test/Linker/global_ctors.ll
Reid Kleckner 1ce3088669 Add comdat key field to llvm.global_ctors and llvm.global_dtors
This allows us to put dynamic initializers for weak data into the same
comdat group as the data being initialized.  This is necessary for MSVC
ABI compatibility.  Once we have comdats for guard variables, we can use
the combination to help GlobalOpt fire more often for weak data with
guarded initialization on other platforms.

Reviewers: nlewycky

Differential Revision: http://reviews.llvm.org/D3499

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209015 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-16 20:39:27 +00:00

30 lines
1.2 KiB
LLVM

; RUN: llvm-as %s -o %t.new.bc
; RUN: llvm-link %t.new.bc %S/Inputs/old_global_ctors.3.4.bc | llvm-dis | FileCheck %s
; old_global_ctors.3.4.bc contains the following LLVM IL, assembled into
; bitcode by llvm-as from 3.4. It uses a two element @llvm.global_ctors array.
; ---
; declare void @a_global_ctor()
; declare void @b_global_ctor()
;
; @llvm.global_ctors = appending global [2 x { i32, void ()* } ] [
; { i32, void ()* } { i32 65535, void ()* @a_global_ctor },
; { i32, void ()* } { i32 65535, void ()* @b_global_ctor }
; ]
; ---
declare void @c_global_ctor()
declare void @d_global_ctor()
@llvm.global_ctors = appending global [2 x { i32, void ()*, i8* } ] [
{ i32, void ()*, i8* } { i32 65535, void ()* @c_global_ctor, i8* null },
{ i32, void ()*, i8* } { i32 65535, void ()* @d_global_ctor, i8* null }
]
; CHECK: @llvm.global_ctors = appending global [4 x { i32, void ()*, i8* }] [
; CHECK-DAG: { i32, void ()*, i8* } { i32 65535, void ()* @a_global_ctor, i8* null }
; CHECK-DAG: { i32, void ()*, i8* } { i32 65535, void ()* @b_global_ctor, i8* null }
; CHECK-DAG: { i32, void ()*, i8* } { i32 65535, void ()* @c_global_ctor, i8* null }
; CHECK-DAG: { i32, void ()*, i8* } { i32 65535, void ()* @d_global_ctor, i8* null }
; CHECK: ]