1 ; RUN: llc -filetype=asm %s -o - -mtriple arm64-apple-ios -addrsig | FileCheck %s
2 ; RUN: llc -filetype=obj %s -o %t -mtriple arm64-apple-ios -addrsig
3 ; RUN: llvm-objdump --macho --section-headers %t | FileCheck %s --check-prefix=SECTIONS
4 ; RUN: llvm-objdump --macho --reloc %t | FileCheck %s --check-prefix=RELOCS
6 ; CHECK: .section __DATA,__data
7 ; CHECK: _i1.lazy_pointer:
8 ; CHECK: .section __TEXT,__text,regular,pure_instructions
10 ; CHECK: _i1.stub_helper:
11 ; CHECK: .section __DATA,__data
12 ; CHECK: _i2.lazy_pointer:
13 ; CHECK: .section __TEXT,__text,regular,pure_instructions
15 ; CHECK: _i2.stub_helper:
17 ; CHECK: .section __DWARF
19 ; CHECK: .addrsig{{$}}
20 ; CHECK-NEXT: .addrsig_sym _func03_takeaddr
21 ; CHECK-NEXT: .addrsig_sym _f1
22 ; CHECK-NEXT: .addrsig_sym _metadata_f2
23 ; CHECK-NEXT: .addrsig_sym _result
24 ; CHECK-NEXT: .addrsig_sym _g1
25 ; CHECK-NEXT: .addrsig_sym _a1
26 ; CHECK-NEXT: .addrsig_sym _i1
28 ; The __debug_line section (which should be generated for the given input file)
29 ; should appear immediately after the addrsig section. Use it to make sure
30 ; addrsig's section size has been properly set during section layout. This
31 ; catches a regression where the next section would overlap addrsig's
33 ; SECTIONS: __llvm_addrsig 00000008 [[#%.16x,ADDR:]]
34 ; SECTIONS-NEXT: __debug_line {{[[:xdigit:]]+}} [[#%.16x,8+ADDR]]
36 ; RELOCS: Relocation information (__DATA,__llvm_addrsig) 7 entries
37 ; RELOCS: address pcrel length extern type scattered symbolnum/value
38 ; RELOCS: 00000000 False ?( 3) True UNSIGND False _i1
39 ; RELOCS: 00000000 False ?( 3) True UNSIGND False _a1
40 ; RELOCS: 00000000 False ?( 3) True UNSIGND False _g1
41 ; RELOCS: 00000000 False ?( 3) True UNSIGND False _result
42 ; RELOCS: 00000000 False ?( 3) True UNSIGND False _metadata_f2
43 ; RELOCS: 00000000 False ?( 3) True UNSIGND False _f1
44 ; RELOCS: 00000000 False ?( 3) True UNSIGND False _func03_takeaddr
46 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
47 target triple = "arm64-apple-ios7.0.0"
49 @result = global i32 0, align 4
51 ; Function Attrs: minsize nofree noinline norecurse nounwind optsize ssp uwtable
52 define void @func01() local_unnamed_addr #0 {
54 %0 = load volatile i32, ptr @result, align 4
55 %add = add nsw i32 %0, 1
56 store volatile i32 %add, ptr @result, align 4
60 ; Function Attrs: minsize nofree noinline norecurse nounwind optsize ssp uwtable
61 define void @func02() local_unnamed_addr #0 {
63 %0 = load volatile i32, ptr @result, align 4
64 %add = add nsw i32 %0, 1
65 store volatile i32 %add, ptr @result, align 4
69 ; Function Attrs: minsize nofree noinline norecurse nounwind optsize ssp uwtable
70 define void @func03_takeaddr() #0 !dbg !9 {
72 %0 = load volatile i32, ptr @result, align 4
73 %add = add nsw i32 %0, 1
74 store volatile i32 %add, ptr @result, align 4
78 ; Function Attrs: minsize nofree norecurse nounwind optsize ssp uwtable
79 define void @callAllFunctions() local_unnamed_addr {
81 tail call void @func01()
82 tail call void @func02()
83 tail call void @func03_takeaddr()
84 %0 = load volatile i32, ptr @result, align 4
85 %add = add nsw i32 %0, ptrtoint (ptr @func03_takeaddr to i32)
86 store volatile i32 %add, ptr @result, align 4
92 %f1 = bitcast ptr @f1 to ptr
93 %f2 = bitcast ptr @f2 to ptr
94 %f3 = bitcast ptr @f3 to ptr
95 %g1 = bitcast ptr @g1 to ptr
96 %g2 = bitcast ptr @g2 to ptr
97 %g3 = bitcast ptr @g3 to ptr
98 %dllimport = bitcast ptr @dllimport to ptr
99 %tls = bitcast ptr @tls to ptr
100 %a1 = bitcast ptr @a1 to ptr
101 %a2 = bitcast ptr @a2 to ptr
102 %i1 = bitcast ptr @i1 to ptr
103 %i2 = bitcast ptr @i2 to ptr
104 call void @llvm.dbg.value(metadata ptr @metadata_f1, metadata !6, metadata !DIExpression()), !dbg !8
105 call void @llvm.dbg.value(metadata ptr @metadata_f2, metadata !6, metadata !DIExpression()), !dbg !8
106 call void @f4(ptr @metadata_f2)
110 declare void @f4(ptr) unnamed_addr
112 declare void @metadata_f1()
113 declare void @metadata_f2()
115 define internal ptr @f2() local_unnamed_addr {
119 declare void @f3() unnamed_addr
122 @g2 = internal local_unnamed_addr global i32 0
123 @g3 = external unnamed_addr global i32
125 @unref = external global i32
127 @dllimport = external dllimport global i32
129 @tls = thread_local global i32 0
131 @a1 = alias i32, ptr @g1
132 @a2 = internal local_unnamed_addr alias i32, ptr @g2
134 @i1 = ifunc void(), ptr @f1
135 @i2 = internal local_unnamed_addr ifunc void(), ptr @f2
137 declare void @llvm.dbg.value(metadata, metadata, metadata)
139 attributes #0 = { noinline }
141 !llvm.module.flags = !{!2, !3}
143 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug)
144 !1 = !DIFile(filename: "test.c", directory: "/tmp")
145 !2 = !{i32 7, !"Dwarf Version", i32 4}
146 !3 = !{i32 2, !"Debug Info Version", i32 3}
148 !4 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
149 !5 = !DILocation(line: 0, scope: !4)
150 !6 = !DILocalVariable(scope: !7)
151 !7 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
152 !8 = !DILocation(line: 0, scope: !7, inlinedAt: !5)
153 !9 = distinct !DISubprogram(scope: null, file: !1, line: 1, type: !10, unit: !0)
154 !10 = !DISubroutineType(types: !{})