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
7 ; CHECK-NEXT: .addrsig_sym _func03_takeaddr
8 ; CHECK-NEXT: .addrsig_sym _f1
9 ; CHECK-NEXT: .addrsig_sym _metadata_f2
10 ; CHECK-NEXT: .addrsig_sym _result
11 ; CHECK-NEXT: .addrsig_sym _g1
12 ; CHECK-NEXT: .addrsig_sym _a1
13 ; CHECK-NEXT: .addrsig_sym _i1
15 ; The __debug_line section (which should be generated for the given input file)
16 ; should appear immediately after the addrsig section. Use it to make sure
17 ; addrsig's section size has been properly set during section layout. This
18 ; catches a regression where the next section would overlap addrsig's
20 ; SECTIONS: __llvm_addrsig 00000008 [[#%.16x,ADDR:]]
21 ; SECTIONS-NEXT: __debug_line {{[[:xdigit:]]+}} [[#%.16x,8+ADDR]]
23 ; RELOCS: Relocation information (__DATA,__llvm_addrsig) 7 entries
24 ; RELOCS: address pcrel length extern type scattered symbolnum/value
25 ; RELOCS: 00000000 False ?( 3) True UNSIGND False _i1
26 ; RELOCS: 00000000 False ?( 3) True UNSIGND False _a1
27 ; RELOCS: 00000000 False ?( 3) True UNSIGND False _g1
28 ; RELOCS: 00000000 False ?( 3) True UNSIGND False _result
29 ; RELOCS: 00000000 False ?( 3) True UNSIGND False _metadata_f2
30 ; RELOCS: 00000000 False ?( 3) True UNSIGND False _f1
31 ; RELOCS: 00000000 False ?( 3) True UNSIGND False _func03_takeaddr
33 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
34 target triple = "arm64-apple-ios7.0.0"
36 @result = global i32 0, align 4
38 ; Function Attrs: minsize nofree noinline norecurse nounwind optsize ssp uwtable
39 define void @func01() local_unnamed_addr #0 {
41 %0 = load volatile i32, ptr @result, align 4
42 %add = add nsw i32 %0, 1
43 store volatile i32 %add, ptr @result, align 4
47 ; Function Attrs: minsize nofree noinline norecurse nounwind optsize ssp uwtable
48 define void @func02() local_unnamed_addr #0 {
50 %0 = load volatile i32, ptr @result, align 4
51 %add = add nsw i32 %0, 1
52 store volatile i32 %add, ptr @result, align 4
56 ; Function Attrs: minsize nofree noinline norecurse nounwind optsize ssp uwtable
57 define void @func03_takeaddr() #0 !dbg !9 {
59 %0 = load volatile i32, ptr @result, align 4
60 %add = add nsw i32 %0, 1
61 store volatile i32 %add, ptr @result, align 4
65 ; Function Attrs: minsize nofree norecurse nounwind optsize ssp uwtable
66 define void @callAllFunctions() local_unnamed_addr {
68 tail call void @func01()
69 tail call void @func02()
70 tail call void @func03_takeaddr()
71 %0 = load volatile i32, ptr @result, align 4
72 %add = add nsw i32 %0, ptrtoint (ptr @func03_takeaddr to i32)
73 store volatile i32 %add, ptr @result, align 4
78 define void()* @f1() {
79 %f1 = bitcast void()* ()* @f1 to i8*
80 %f2 = bitcast void()* ()* @f2 to i8*
81 %f3 = bitcast void()* @f3 to i8*
82 %g1 = bitcast i32* @g1 to i8*
83 %g2 = bitcast i32* @g2 to i8*
84 %g3 = bitcast i32* @g3 to i8*
85 %dllimport = bitcast i32* @dllimport to i8*
86 %tls = bitcast i32* @tls to i8*
87 %a1 = bitcast i32* @a1 to i8*
88 %a2 = bitcast i32* @a2 to i8*
89 %i1 = bitcast void()* @i1 to i8*
90 %i2 = bitcast void()* @i2 to i8*
91 call void @llvm.dbg.value(metadata i8* bitcast (void()* @metadata_f1 to i8*), metadata !6, metadata !DIExpression()), !dbg !8
92 call void @llvm.dbg.value(metadata i8* bitcast (void()* @metadata_f2 to i8*), metadata !6, metadata !DIExpression()), !dbg !8
93 call void @f4(i8* bitcast (void()* @metadata_f2 to i8*))
97 declare void @f4(i8*) unnamed_addr
99 declare void @metadata_f1()
100 declare void @metadata_f2()
102 define internal void()* @f2() local_unnamed_addr {
106 declare void @f3() unnamed_addr
109 @g2 = internal local_unnamed_addr global i32 0
110 @g3 = external unnamed_addr global i32
112 @unref = external global i32
114 @dllimport = external dllimport global i32
116 @tls = thread_local global i32 0
118 @a1 = alias i32, i32* @g1
119 @a2 = internal local_unnamed_addr alias i32, i32* @g2
121 @i1 = ifunc void(), void()* ()* @f1
122 @i2 = internal local_unnamed_addr ifunc void(), void()* ()* @f2
124 declare void @llvm.dbg.value(metadata, metadata, metadata)
126 attributes #0 = { noinline }
128 !llvm.module.flags = !{!2, !3}
130 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug)
131 !1 = !DIFile(filename: "test.c", directory: "/tmp")
132 !2 = !{i32 7, !"Dwarf Version", i32 4}
133 !3 = !{i32 2, !"Debug Info Version", i32 3}
135 !4 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
136 !5 = !DILocation(line: 0, scope: !4)
137 !6 = !DILocalVariable(scope: !7)
138 !7 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
139 !8 = !DILocation(line: 0, scope: !7, inlinedAt: !5)
140 !9 = distinct !DISubprogram(scope: null, file: !1, line: 1, type: !10, unit: !0)
141 !10 = !DISubroutineType(types: !{})