blob: 67a8049d681e12f00443763ccc5c2aabe6def0f1 [file] [log] [blame]
Manman Rene9a52e12013-07-29 18:12:58 +00001; RUN: opt -objc-arc -S < %s | FileCheck %s
Michael Gottesman00dfc682013-01-16 21:07:18 +00002; rdar://11744105
3; bugzilla://14584
4
5target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
6target triple = "x86_64-apple-macosx10.9.0"
7
8%0 = type opaque
9%struct._class_t = type { %struct._class_t*, %struct._class_t*, %struct._objc_cache*, i8* (i8*, i8*)**, %struct._class_ro_t* }
10%struct._objc_cache = type opaque
11%struct._class_ro_t = type { i32, i32, i32, i8*, i8*, %struct.__method_list_t*, %struct._objc_protocol_list*, %struct._ivar_list_t*, i8*, %struct._prop_list_t* }
12%struct.__method_list_t = type { i32, i32, [0 x %struct._objc_method] }
13%struct._objc_method = type { i8*, i8*, i8* }
14%struct._objc_protocol_list = type { i64, [0 x %struct._protocol_t*] }
15%struct._protocol_t = type { i8*, i8*, %struct._objc_protocol_list*, %struct.__method_list_t*, %struct.__method_list_t*, %struct.__method_list_t*, %struct.__method_list_t*, %struct._prop_list_t*, i32, i32, i8** }
16%struct._prop_list_t = type { i32, i32, [0 x %struct._prop_t] }
17%struct._prop_t = type { i8*, i8* }
18%struct._ivar_list_t = type { i32, i32, [0 x %struct._ivar_t] }
19%struct._ivar_t = type { i64*, i8*, i8*, i32, i32 }
20%struct.NSConstantString = type { i32*, i32, i8*, i64 }
21
22@"OBJC_CLASS_$_NSObject" = external global %struct._class_t
23@"\01L_OBJC_CLASSLIST_REFERENCES_$_" = internal global %struct._class_t* @"OBJC_CLASS_$_NSObject", section "__DATA, __objc_classrefs, regular, no_dead_strip", align 8
24@"\01L_OBJC_METH_VAR_NAME_" = internal global [4 x i8] c"new\00", section "__TEXT,__objc_methname,cstring_literals", align 1
David Blaikief72d05b2015-03-13 18:20:45 +000025@"\01L_OBJC_SELECTOR_REFERENCES_" = internal global i8* getelementptr inbounds ([4 x i8], [4 x i8]* @"\01L_OBJC_METH_VAR_NAME_", i64 0, i64 0), section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
Michael Gottesman00dfc682013-01-16 21:07:18 +000026@__CFConstantStringClassReference = external global [0 x i32]
Rafael Espindola2fb5bc32014-03-13 23:18:37 +000027@.str = private unnamed_addr constant [11 x i8] c"Failed: %@\00", align 1
David Blaikief72d05b2015-03-13 18:20:45 +000028@_unnamed_cfstring_ = private constant %struct.NSConstantString { i32* getelementptr inbounds ([0 x i32], [0 x i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0), i64 10 }, section "__DATA,__cfstring"
Michael Gottesman00dfc682013-01-16 21:07:18 +000029@"OBJC_CLASS_$_NSException" = external global %struct._class_t
30@"\01L_OBJC_CLASSLIST_REFERENCES_$_1" = internal global %struct._class_t* @"OBJC_CLASS_$_NSException", section "__DATA, __objc_classrefs, regular, no_dead_strip", align 8
Rafael Espindola2fb5bc32014-03-13 23:18:37 +000031@.str2 = private unnamed_addr constant [4 x i8] c"Foo\00", align 1
David Blaikief72d05b2015-03-13 18:20:45 +000032@_unnamed_cfstring_3 = private constant %struct.NSConstantString { i32* getelementptr inbounds ([0 x i32], [0 x i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str2, i32 0, i32 0), i64 3 }, section "__DATA,__cfstring"
Michael Gottesman00dfc682013-01-16 21:07:18 +000033@"\01L_OBJC_METH_VAR_NAME_4" = internal global [14 x i8] c"raise:format:\00", section "__TEXT,__objc_methname,cstring_literals", align 1
David Blaikief72d05b2015-03-13 18:20:45 +000034@"\01L_OBJC_SELECTOR_REFERENCES_5" = internal global i8* getelementptr inbounds ([14 x i8], [14 x i8]* @"\01L_OBJC_METH_VAR_NAME_4", i64 0, i64 0), section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
35@llvm.used = appending global [6 x i8*] [i8* bitcast (%struct._class_t** @"\01L_OBJC_CLASSLIST_REFERENCES_$_" to i8*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @"\01L_OBJC_METH_VAR_NAME_", i32 0, i32 0), i8* bitcast (i8** @"\01L_OBJC_SELECTOR_REFERENCES_" to i8*), i8* bitcast (%struct._class_t** @"\01L_OBJC_CLASSLIST_REFERENCES_$_1" to i8*), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @"\01L_OBJC_METH_VAR_NAME_4", i32 0, i32 0), i8* bitcast (i8** @"\01L_OBJC_SELECTOR_REFERENCES_5" to i8*)], section "llvm.metadata"
Michael Gottesman00dfc682013-01-16 21:07:18 +000036
David Majnemer7fddecc2015-06-17 20:52:32 +000037define i32 @main() uwtable ssp personality i8* bitcast (i32 (...)* @__objc_personality_v0 to i8*) {
Michael Gottesman00dfc682013-01-16 21:07:18 +000038entry:
David Blaikiea79ac142015-02-27 21:17:42 +000039 %tmp = load %struct._class_t*, %struct._class_t** @"\01L_OBJC_CLASSLIST_REFERENCES_$_", align 8, !dbg !37
40 %tmp1 = load i8*, i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8, !dbg !37, !invariant.load !38
Michael Gottesman00dfc682013-01-16 21:07:18 +000041 %tmp2 = bitcast %struct._class_t* %tmp to i8*, !dbg !37
42; CHECK: call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* %tmp2, i8* %tmp1)
43 %call = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* %tmp2, i8* %tmp1), !dbg !37, !clang.arc.no_objc_arc_exceptions !38
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000044 call void @llvm.dbg.value(metadata i8* %call, i64 0, metadata !25, metadata !DIExpression()), !dbg !37
Bill Wendlinga0323742013-02-22 09:09:42 +000045; CHECK: call i8* @objc_retain(i8* %call) [[NUW:#[0-9]+]]
Michael Gottesman00dfc682013-01-16 21:07:18 +000046 %tmp3 = call i8* @objc_retain(i8* %call) nounwind, !dbg !39
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000047 call void @llvm.dbg.value(metadata i8* %call, i64 0, metadata !25, metadata !DIExpression()), !dbg !39
Michael Gottesman00dfc682013-01-16 21:07:18 +000048 invoke fastcc void @ThrowFunc(i8* %call)
49 to label %eh.cont unwind label %lpad, !dbg !40, !clang.arc.no_objc_arc_exceptions !38
50
51eh.cont: ; preds = %entry
52; CHECK: call void @objc_release(i8* %call)
53 call void @objc_release(i8* %call) nounwind, !dbg !42, !clang.imprecise_release !38
54 br label %if.end, !dbg !43
55
56lpad: ; preds = %entry
David Majnemer7fddecc2015-06-17 20:52:32 +000057 %tmp4 = landingpad { i8*, i32 }
Michael Gottesman00dfc682013-01-16 21:07:18 +000058 catch i8* null, !dbg !40
59 %tmp5 = extractvalue { i8*, i32 } %tmp4, 0, !dbg !40
60 %exn.adjusted = call i8* @objc_begin_catch(i8* %tmp5) nounwind, !dbg !44
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000061 call void @llvm.dbg.value(metadata i8 0, i64 0, metadata !21, metadata !DIExpression()), !dbg !46
Michael Gottesman00dfc682013-01-16 21:07:18 +000062 call void @objc_end_catch(), !dbg !49, !clang.arc.no_objc_arc_exceptions !38
63; CHECK: call void @objc_release(i8* %call)
64 call void @objc_release(i8* %call) nounwind, !dbg !42, !clang.imprecise_release !38
David Blaikie23af6482015-04-16 23:24:18 +000065 call void (i8*, ...) @NSLog(i8* bitcast (%struct.NSConstantString* @_unnamed_cfstring_ to i8*), i8* %call), !dbg !50, !clang.arc.no_objc_arc_exceptions !38
Michael Gottesman00dfc682013-01-16 21:07:18 +000066 br label %if.end, !dbg !52
67
68if.end: ; preds = %lpad, %eh.cont
David Blaikie23af6482015-04-16 23:24:18 +000069 call void (i8*, ...) @NSLog(i8* bitcast (%struct.NSConstantString* @_unnamed_cfstring_ to i8*), i8* %call), !dbg !53, !clang.arc.no_objc_arc_exceptions !38
Michael Gottesman00dfc682013-01-16 21:07:18 +000070; CHECK: call void @objc_release(i8* %call)
71 call void @objc_release(i8* %call) nounwind, !dbg !54, !clang.imprecise_release !38
72 ret i32 0, !dbg !54
73}
74
Adrian Prantl87b7eb92014-10-01 18:55:02 +000075declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
Michael Gottesman00dfc682013-01-16 21:07:18 +000076
77declare i8* @objc_msgSend(i8*, i8*, ...) nonlazybind
78
79declare i8* @objc_retain(i8*) nonlazybind
80
81declare i8* @objc_begin_catch(i8*)
82
83declare void @objc_end_catch()
84
85declare void @objc_exception_rethrow()
86
87define internal fastcc void @ThrowFunc(i8* %obj) uwtable noinline ssp {
88entry:
89 %tmp = call i8* @objc_retain(i8* %obj) nounwind
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000090 call void @llvm.dbg.value(metadata i8* %obj, i64 0, metadata !32, metadata !DIExpression()), !dbg !55
David Blaikiea79ac142015-02-27 21:17:42 +000091 %tmp1 = load %struct._class_t*, %struct._class_t** @"\01L_OBJC_CLASSLIST_REFERENCES_$_1", align 8, !dbg !56
92 %tmp2 = load i8*, i8** @"\01L_OBJC_SELECTOR_REFERENCES_5", align 8, !dbg !56, !invariant.load !38
Michael Gottesman00dfc682013-01-16 21:07:18 +000093 %tmp3 = bitcast %struct._class_t* %tmp1 to i8*, !dbg !56
David Blaikie23af6482015-04-16 23:24:18 +000094 call void (i8*, i8*, %0*, %0*, ...) bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, %0*, %0*, ...)*)(i8* %tmp3, i8* %tmp2, %0* bitcast (%struct.NSConstantString* @_unnamed_cfstring_3 to %0*), %0* bitcast (%struct.NSConstantString* @_unnamed_cfstring_3 to %0*)), !dbg !56, !clang.arc.no_objc_arc_exceptions !38
Michael Gottesman00dfc682013-01-16 21:07:18 +000095 call void @objc_release(i8* %obj) nounwind, !dbg !58, !clang.imprecise_release !38
96 ret void, !dbg !58
97}
98
99declare i32 @__objc_personality_v0(...)
100
101declare void @objc_release(i8*) nonlazybind
102
103declare void @NSLog(i8*, ...)
104
Adrian Prantl87b7eb92014-10-01 18:55:02 +0000105declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
Michael Gottesman00dfc682013-01-16 21:07:18 +0000106
Bill Wendlinga0323742013-02-22 09:09:42 +0000107; CHECK: attributes #0 = { ssp uwtable }
108; CHECK: attributes #1 = { nounwind readnone }
109; CHECK: attributes #2 = { nonlazybind }
110; CHECK: attributes #3 = { noinline ssp uwtable }
111; CHECK: attributes [[NUW]] = { nounwind }
112
Michael Gottesman00dfc682013-01-16 21:07:18 +0000113!llvm.dbg.cu = !{!0}
Manman Ren409558f2013-11-22 21:49:45 +0000114!llvm.module.flags = !{!33, !34, !35, !36, !61}
Michael Gottesman00dfc682013-01-16 21:07:18 +0000115
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000116!0 = !DICompileUnit(language: DW_LANG_ObjC, producer: "clang version 3.3 ", isOptimized: true, runtimeVersion: 2, emissionKind: 0, file: !60, enums: !1, retainedTypes: !1, subprograms: !3, globals: !1)
Duncan P. N. Exon Smith988a7f82015-03-27 20:46:33 +0000117!1 = !{}
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000118!3 = !{!5, !27}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000119!5 = !DISubprogram(name: "main", line: 9, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: true, scopeLine: 10, file: !60, scope: !6, type: !7, function: i32 ()* @main, variables: !11)
120!6 = !DIFile(filename: "test.m", directory: "/Volumes/Files/gottesmmcab/Radar/12906997")
121!7 = !DISubroutineType(types: !8)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000122!8 = !{!9}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000123!9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000124!11 = !{!12, !21, !25}
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +0000125!12 = !DILocalVariable(name: "obj", line: 11, scope: !13, file: !6, type: !14)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000126!13 = distinct !DILexicalBlock(line: 10, column: 0, file: !60, scope: !5)
127!14 = !DIDerivedType(tag: DW_TAG_typedef, name: "id", line: 11, file: !60, baseType: !15)
128!15 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, file: !60, baseType: !16)
129!16 = !DICompositeType(tag: DW_TAG_structure_type, name: "objc_object", file: !60, elements: !17)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000130!17 = !{!18}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000131!18 = !DIDerivedType(tag: DW_TAG_member, name: "isa", size: 64, file: !60, scope: !16, baseType: !19)
132!19 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, baseType: !20)
133!20 = !DICompositeType(tag: DW_TAG_structure_type, name: "objc_class", flags: DIFlagFwdDecl, file: !60)
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +0000134!21 = !DILocalVariable(name: "ok", line: 13, scope: !22, file: !6, type: !23)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000135!22 = distinct !DILexicalBlock(line: 12, column: 0, file: !60, scope: !13)
136!23 = !DIDerivedType(tag: DW_TAG_typedef, name: "BOOL", line: 62, file: !60, baseType: !24)
137!24 = !DIBasicType(tag: DW_TAG_base_type, name: "signed char", size: 8, align: 8, encoding: DW_ATE_signed_char)
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +0000138!25 = !DILocalVariable(name: "obj2", line: 15, scope: !26, file: !6, type: !14)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000139!26 = distinct !DILexicalBlock(line: 14, column: 0, file: !60, scope: !22)
140!27 = !DISubprogram(name: "ThrowFunc", line: 4, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 5, file: !60, scope: !6, type: !28, function: void (i8*)* @ThrowFunc, variables: !31)
141!28 = !DISubroutineType(types: !29)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000142!29 = !{null, !14}
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000143!31 = !{!32}
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +0000144!32 = !DILocalVariable(name: "obj", line: 4, arg: 1, scope: !27, file: !6, type: !14)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000145!33 = !{i32 1, !"Objective-C Version", i32 2}
146!34 = !{i32 1, !"Objective-C Image Info Version", i32 0}
147!35 = !{i32 1, !"Objective-C Image Info Section", !"__DATA, __objc_imageinfo, regular, no_dead_strip"}
148!36 = !{i32 4, !"Objective-C Garbage Collection", i32 0}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000149!37 = !DILocation(line: 11, scope: !13)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000150!38 = !{}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000151!39 = !DILocation(line: 15, scope: !26)
152!40 = !DILocation(line: 17, scope: !41)
153!41 = distinct !DILexicalBlock(line: 16, column: 0, file: !60, scope: !26)
154!42 = !DILocation(line: 22, scope: !26)
155!43 = !DILocation(line: 23, scope: !22)
156!44 = !DILocation(line: 19, scope: !41)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000157!45 = !{i8 0}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000158!46 = !DILocation(line: 20, scope: !47)
159!47 = distinct !DILexicalBlock(line: 19, column: 0, file: !60, scope: !48)
160!48 = distinct !DILexicalBlock(line: 19, column: 0, file: !60, scope: !26)
161!49 = !DILocation(line: 21, scope: !47)
162!50 = !DILocation(line: 24, scope: !51)
163!51 = distinct !DILexicalBlock(line: 23, column: 0, file: !60, scope: !22)
164!52 = !DILocation(line: 25, scope: !51)
165!53 = !DILocation(line: 27, scope: !13)
166!54 = !DILocation(line: 28, scope: !13)
167!55 = !DILocation(line: 4, scope: !27)
168!56 = !DILocation(line: 6, scope: !57)
169!57 = distinct !DILexicalBlock(line: 5, column: 0, file: !60, scope: !27)
170!58 = !DILocation(line: 7, scope: !57)
171!60 = !DIFile(filename: "test.m", directory: "/Volumes/Files/gottesmmcab/Radar/12906997")
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000172!61 = !{i32 1, !"Debug Info Version", i32 3}