1 ; RUN: opt < %s -globalopt -S | FileCheck %s
5 ; Make it easier to verify that alignment is correct/optimal:
6 ; 16-bit pointers with 32-bit ABI alignment and 128-bit preferred alignment
8 target datalayout = "p:16:32:128"
10 %struct.ButtonInitData = type { i8* }
12 @_ZL14buttonInitData = internal global [1 x %struct.ButtonInitData] zeroinitializer, align 4
14 @"\01L_OBJC_METH_VAR_NAME_40" = internal global [7 x i8] c"print:\00", section "__TEXT,__objc_methname,cstring_literals", align 1
15 @"\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"
17 @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_a, i8* null }]
18 @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*)]
20 ; Choose the preferred alignment.
22 ; CHECK: @[[_ZL14BUTTONINITDATA_0_0:[a-zA-Z0-9_$"\\.-]+]] = internal unnamed_addr global i8* null, align 16
24 define internal void @__cxx_global_var_init() section "__TEXT,__StaticInit,regular,pure_instructions" {
25 %1 = load i8*, i8** @"\01L_OBJC_SELECTOR_REFERENCES_41", !invariant.load !2009
26 store i8* %1, i8** getelementptr inbounds ([1 x %struct.ButtonInitData], [1 x %struct.ButtonInitData]* @_ZL14buttonInitData, i32 0, i32 0, i32 0), align 4
30 define internal void @_GLOBAL__I_a() section "__TEXT,__StaticInit,regular,pure_instructions" {
31 call void @__cxx_global_var_init()
35 declare void @test(i8*)
37 ; The preferred alignment is available.
39 define void @print() {
40 ; CHECK-LABEL: @print(
41 ; CHECK-NEXT: [[TMP1:%.*]] = load i8*, i8** @_ZL14buttonInitData.0.0, align 16
42 ; CHECK-NEXT: call void @test(i8* [[TMP1]])
43 ; CHECK-NEXT: ret void
45 %1 = load i8*, i8** getelementptr inbounds ([1 x %struct.ButtonInitData], [1 x %struct.ButtonInitData]* @_ZL14buttonInitData, i32 0, i32 0, i32 0), align 4
46 call void @test(i8* %1)