blob: 2e22ff06444497ca7a9b8168288cc5b030fb1275 [file] [log] [blame]
Michael Gottesmane2376cd2013-02-05 06:53:26 +00001; RUN: opt < %s -globalopt -S | FileCheck %s
2; rdar://12580965.
3; ObjC++ test case.
4
5%struct.ButtonInitData = type { i8* }
6
7@_ZL14buttonInitData = internal global [1 x %struct.ButtonInitData] zeroinitializer, align 4
8
9@"\01L_OBJC_METH_VAR_NAME_40" = internal global [7 x i8] c"print:\00", section "__TEXT,__objc_methname,cstring_literals", align 1
David Blaikief72d05b2015-03-13 18:20:45 +000010@"\01L_OBJC_SELECTOR_REFERENCES_41" = internal externally_initialized global i8* getelementptr inbounds ([7 x i8], [7 x i8]* @"\01L_OBJC_METH_VAR_NAME_40", i32 0, i32 0), section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
Michael Gottesmane2376cd2013-02-05 06:53:26 +000011
12@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }]
David Blaikief72d05b2015-03-13 18:20:45 +000013@llvm.used = appending global [2 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @"\01L_OBJC_METH_VAR_NAME_40", i32 0, i32 0), i8* bitcast (i8** @"\01L_OBJC_SELECTOR_REFERENCES_41" to i8*)]
Michael Gottesmane2376cd2013-02-05 06:53:26 +000014
15define internal void @__cxx_global_var_init() section "__TEXT,__StaticInit,regular,pure_instructions" {
David Blaikiea79ac142015-02-27 21:17:42 +000016 %1 = load i8*, i8** @"\01L_OBJC_SELECTOR_REFERENCES_41", !invariant.load !2009
David Blaikief72d05b2015-03-13 18:20:45 +000017 store i8* %1, i8** getelementptr inbounds ([1 x %struct.ButtonInitData], [1 x %struct.ButtonInitData]* @_ZL14buttonInitData, i32 0, i32 0, i32 0), align 4
Michael Gottesmane2376cd2013-02-05 06:53:26 +000018 ret void
19}
20
21define internal void @_GLOBAL__I_a() section "__TEXT,__StaticInit,regular,pure_instructions" {
22 call void @__cxx_global_var_init()
23 ret void
24}
25
26declare void @test(i8*)
27
28define void @print() {
Mehdi Amini46a43552015-03-04 18:43:29 +000029; CHECK: %1 = load i8*, i8** @_ZL14buttonInitData.0.0, align 4
David Blaikief72d05b2015-03-13 18:20:45 +000030 %1 = load i8*, i8** getelementptr inbounds ([1 x %struct.ButtonInitData], [1 x %struct.ButtonInitData]* @_ZL14buttonInitData, i32 0, i32 0, i32 0), align 4
Michael Gottesmane2376cd2013-02-05 06:53:26 +000031 call void @test(i8* %1)
32 ret void
33}
34
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000035!2009 = !{}