1*9880d681SAndroid Build Coastguard Worker; RUN: opt -objc-arc -S < %s | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker; rdar://11744105 3*9880d681SAndroid Build Coastguard Worker; bugzilla://14584 4*9880d681SAndroid Build Coastguard Worker 5*9880d681SAndroid Build Coastguard Workertarget 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" 6*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-apple-macosx10.9.0" 7*9880d681SAndroid Build Coastguard Worker 8*9880d681SAndroid Build Coastguard Worker%0 = type opaque 9*9880d681SAndroid Build Coastguard Worker%struct._class_t = type { %struct._class_t*, %struct._class_t*, %struct._objc_cache*, i8* (i8*, i8*)**, %struct._class_ro_t* } 10*9880d681SAndroid Build Coastguard Worker%struct._objc_cache = type opaque 11*9880d681SAndroid Build Coastguard Worker%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*9880d681SAndroid Build Coastguard Worker%struct.__method_list_t = type { i32, i32, [0 x %struct._objc_method] } 13*9880d681SAndroid Build Coastguard Worker%struct._objc_method = type { i8*, i8*, i8* } 14*9880d681SAndroid Build Coastguard Worker%struct._objc_protocol_list = type { i64, [0 x %struct._protocol_t*] } 15*9880d681SAndroid Build Coastguard Worker%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*9880d681SAndroid Build Coastguard Worker%struct._prop_list_t = type { i32, i32, [0 x %struct._prop_t] } 17*9880d681SAndroid Build Coastguard Worker%struct._prop_t = type { i8*, i8* } 18*9880d681SAndroid Build Coastguard Worker%struct._ivar_list_t = type { i32, i32, [0 x %struct._ivar_t] } 19*9880d681SAndroid Build Coastguard Worker%struct._ivar_t = type { i64*, i8*, i8*, i32, i32 } 20*9880d681SAndroid Build Coastguard Worker%struct.NSConstantString = type { i32*, i32, i8*, i64 } 21*9880d681SAndroid Build Coastguard Worker 22*9880d681SAndroid Build Coastguard Worker@"OBJC_CLASS_$_NSObject" = external global %struct._class_t 23*9880d681SAndroid Build Coastguard Worker@"\01L_OBJC_CLASSLIST_REFERENCES_$_" = internal global %struct._class_t* @"OBJC_CLASS_$_NSObject", section "__DATA, __objc_classrefs, regular, no_dead_strip", align 8 24*9880d681SAndroid Build Coastguard Worker@"\01L_OBJC_METH_VAR_NAME_" = internal global [4 x i8] c"new\00", section "__TEXT,__objc_methname,cstring_literals", align 1 25*9880d681SAndroid Build Coastguard Worker@"\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" 26*9880d681SAndroid Build Coastguard Worker@__CFConstantStringClassReference = external global [0 x i32] 27*9880d681SAndroid Build Coastguard Worker@.str = private unnamed_addr constant [11 x i8] c"Failed: %@\00", align 1 28*9880d681SAndroid Build Coastguard Worker@_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" 29*9880d681SAndroid Build Coastguard Worker@"OBJC_CLASS_$_NSException" = external global %struct._class_t 30*9880d681SAndroid Build Coastguard Worker@"\01L_OBJC_CLASSLIST_REFERENCES_$_1" = internal global %struct._class_t* @"OBJC_CLASS_$_NSException", section "__DATA, __objc_classrefs, regular, no_dead_strip", align 8 31*9880d681SAndroid Build Coastguard Worker@.str2 = private unnamed_addr constant [4 x i8] c"Foo\00", align 1 32*9880d681SAndroid Build Coastguard Worker@_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" 33*9880d681SAndroid Build Coastguard Worker@"\01L_OBJC_METH_VAR_NAME_4" = internal global [14 x i8] c"raise:format:\00", section "__TEXT,__objc_methname,cstring_literals", align 1 34*9880d681SAndroid Build Coastguard Worker@"\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*9880d681SAndroid Build Coastguard Worker@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" 36*9880d681SAndroid Build Coastguard Worker 37*9880d681SAndroid Build Coastguard Workerdefine i32 @main() uwtable ssp personality i8* bitcast (i32 (...)* @__objc_personality_v0 to i8*) !dbg !5 { 38*9880d681SAndroid Build Coastguard Workerentry: 39*9880d681SAndroid Build Coastguard Worker %tmp = load %struct._class_t*, %struct._class_t** @"\01L_OBJC_CLASSLIST_REFERENCES_$_", align 8, !dbg !37 40*9880d681SAndroid Build Coastguard Worker %tmp1 = load i8*, i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8, !dbg !37, !invariant.load !38 41*9880d681SAndroid Build Coastguard Worker %tmp2 = bitcast %struct._class_t* %tmp to i8*, !dbg !37 42*9880d681SAndroid Build Coastguard Worker; CHECK: call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* %tmp2, i8* %tmp1) 43*9880d681SAndroid Build Coastguard Worker %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 44*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.value(metadata i8* %call, i64 0, metadata !25, metadata !DIExpression()), !dbg !37 45*9880d681SAndroid Build Coastguard Worker; CHECK: call i8* @objc_retain(i8* %call) [[NUW:#[0-9]+]] 46*9880d681SAndroid Build Coastguard Worker %tmp3 = call i8* @objc_retain(i8* %call) nounwind, !dbg !39 47*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.value(metadata i8* %call, i64 0, metadata !25, metadata !DIExpression()), !dbg !39 48*9880d681SAndroid Build Coastguard Worker invoke fastcc void @ThrowFunc(i8* %call) 49*9880d681SAndroid Build Coastguard Worker to label %eh.cont unwind label %lpad, !dbg !40, !clang.arc.no_objc_arc_exceptions !38 50*9880d681SAndroid Build Coastguard Worker 51*9880d681SAndroid Build Coastguard Workereh.cont: ; preds = %entry 52*9880d681SAndroid Build Coastguard Worker; CHECK: call void @objc_release(i8* %call) 53*9880d681SAndroid Build Coastguard Worker call void @objc_release(i8* %call) nounwind, !dbg !42, !clang.imprecise_release !38 54*9880d681SAndroid Build Coastguard Worker br label %if.end, !dbg !43 55*9880d681SAndroid Build Coastguard Worker 56*9880d681SAndroid Build Coastguard Workerlpad: ; preds = %entry 57*9880d681SAndroid Build Coastguard Worker %tmp4 = landingpad { i8*, i32 } 58*9880d681SAndroid Build Coastguard Worker catch i8* null, !dbg !40 59*9880d681SAndroid Build Coastguard Worker %tmp5 = extractvalue { i8*, i32 } %tmp4, 0, !dbg !40 60*9880d681SAndroid Build Coastguard Worker %exn.adjusted = call i8* @objc_begin_catch(i8* %tmp5) nounwind, !dbg !44 61*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.value(metadata i8 0, i64 0, metadata !21, metadata !DIExpression()), !dbg !46 62*9880d681SAndroid Build Coastguard Worker call void @objc_end_catch(), !dbg !49, !clang.arc.no_objc_arc_exceptions !38 63*9880d681SAndroid Build Coastguard Worker; CHECK: call void @objc_release(i8* %call) 64*9880d681SAndroid Build Coastguard Worker call void @objc_release(i8* %call) nounwind, !dbg !42, !clang.imprecise_release !38 65*9880d681SAndroid Build Coastguard Worker call void (i8*, ...) @NSLog(i8* bitcast (%struct.NSConstantString* @_unnamed_cfstring_ to i8*), i8* %call), !dbg !50, !clang.arc.no_objc_arc_exceptions !38 66*9880d681SAndroid Build Coastguard Worker br label %if.end, !dbg !52 67*9880d681SAndroid Build Coastguard Worker 68*9880d681SAndroid Build Coastguard Workerif.end: ; preds = %lpad, %eh.cont 69*9880d681SAndroid Build Coastguard Worker call void (i8*, ...) @NSLog(i8* bitcast (%struct.NSConstantString* @_unnamed_cfstring_ to i8*), i8* %call), !dbg !53, !clang.arc.no_objc_arc_exceptions !38 70*9880d681SAndroid Build Coastguard Worker; CHECK: call void @objc_release(i8* %call) 71*9880d681SAndroid Build Coastguard Worker call void @objc_release(i8* %call) nounwind, !dbg !54, !clang.imprecise_release !38 72*9880d681SAndroid Build Coastguard Worker ret i32 0, !dbg !54 73*9880d681SAndroid Build Coastguard Worker} 74*9880d681SAndroid Build Coastguard Worker 75*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone 76*9880d681SAndroid Build Coastguard Worker 77*9880d681SAndroid Build Coastguard Workerdeclare i8* @objc_msgSend(i8*, i8*, ...) nonlazybind 78*9880d681SAndroid Build Coastguard Worker 79*9880d681SAndroid Build Coastguard Workerdeclare i8* @objc_retain(i8*) nonlazybind 80*9880d681SAndroid Build Coastguard Worker 81*9880d681SAndroid Build Coastguard Workerdeclare i8* @objc_begin_catch(i8*) 82*9880d681SAndroid Build Coastguard Worker 83*9880d681SAndroid Build Coastguard Workerdeclare void @objc_end_catch() 84*9880d681SAndroid Build Coastguard Worker 85*9880d681SAndroid Build Coastguard Workerdeclare void @objc_exception_rethrow() 86*9880d681SAndroid Build Coastguard Worker 87*9880d681SAndroid Build Coastguard Workerdefine internal fastcc void @ThrowFunc(i8* %obj) uwtable noinline ssp !dbg !27 { 88*9880d681SAndroid Build Coastguard Workerentry: 89*9880d681SAndroid Build Coastguard Worker %tmp = call i8* @objc_retain(i8* %obj) nounwind 90*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.value(metadata i8* %obj, i64 0, metadata !32, metadata !DIExpression()), !dbg !55 91*9880d681SAndroid Build Coastguard Worker %tmp1 = load %struct._class_t*, %struct._class_t** @"\01L_OBJC_CLASSLIST_REFERENCES_$_1", align 8, !dbg !56 92*9880d681SAndroid Build Coastguard Worker %tmp2 = load i8*, i8** @"\01L_OBJC_SELECTOR_REFERENCES_5", align 8, !dbg !56, !invariant.load !38 93*9880d681SAndroid Build Coastguard Worker %tmp3 = bitcast %struct._class_t* %tmp1 to i8*, !dbg !56 94*9880d681SAndroid Build Coastguard Worker 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 95*9880d681SAndroid Build Coastguard Worker call void @objc_release(i8* %obj) nounwind, !dbg !58, !clang.imprecise_release !38 96*9880d681SAndroid Build Coastguard Worker ret void, !dbg !58 97*9880d681SAndroid Build Coastguard Worker} 98*9880d681SAndroid Build Coastguard Worker 99*9880d681SAndroid Build Coastguard Workerdeclare i32 @__objc_personality_v0(...) 100*9880d681SAndroid Build Coastguard Worker 101*9880d681SAndroid Build Coastguard Workerdeclare void @objc_release(i8*) nonlazybind 102*9880d681SAndroid Build Coastguard Worker 103*9880d681SAndroid Build Coastguard Workerdeclare void @NSLog(i8*, ...) 104*9880d681SAndroid Build Coastguard Worker 105*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone 106*9880d681SAndroid Build Coastguard Worker 107*9880d681SAndroid Build Coastguard Worker; CHECK: attributes #0 = { ssp uwtable } 108*9880d681SAndroid Build Coastguard Worker; CHECK: attributes #1 = { nounwind readnone } 109*9880d681SAndroid Build Coastguard Worker; CHECK: attributes #2 = { nonlazybind } 110*9880d681SAndroid Build Coastguard Worker; CHECK: attributes #3 = { noinline ssp uwtable } 111*9880d681SAndroid Build Coastguard Worker; CHECK: attributes [[NUW]] = { nounwind } 112*9880d681SAndroid Build Coastguard Worker 113*9880d681SAndroid Build Coastguard Worker!llvm.dbg.cu = !{!0} 114*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!33, !34, !35, !36, !61} 115*9880d681SAndroid Build Coastguard Worker 116*9880d681SAndroid Build Coastguard Worker!0 = distinct !DICompileUnit(language: DW_LANG_ObjC, producer: "clang version 3.3 ", isOptimized: true, runtimeVersion: 2, emissionKind: FullDebug, file: !60, enums: !1, retainedTypes: !1, globals: !1) 117*9880d681SAndroid Build Coastguard Worker!1 = !{} 118*9880d681SAndroid Build Coastguard Worker!5 = distinct !DISubprogram(name: "main", line: 9, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: true, unit: !0, scopeLine: 10, file: !60, scope: !6, type: !7, variables: !11) 119*9880d681SAndroid Build Coastguard Worker!6 = !DIFile(filename: "test.m", directory: "/Volumes/Files/gottesmmcab/Radar/12906997") 120*9880d681SAndroid Build Coastguard Worker!7 = !DISubroutineType(types: !8) 121*9880d681SAndroid Build Coastguard Worker!8 = !{!9} 122*9880d681SAndroid Build Coastguard Worker!9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 123*9880d681SAndroid Build Coastguard Worker!11 = !{!12, !21, !25} 124*9880d681SAndroid Build Coastguard Worker!12 = !DILocalVariable(name: "obj", line: 11, scope: !13, file: !6, type: !14) 125*9880d681SAndroid Build Coastguard Worker!13 = distinct !DILexicalBlock(line: 10, column: 0, file: !60, scope: !5) 126*9880d681SAndroid Build Coastguard Worker!14 = !DIDerivedType(tag: DW_TAG_typedef, name: "id", line: 11, file: !60, baseType: !15) 127*9880d681SAndroid Build Coastguard Worker!15 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, file: !60, baseType: !16) 128*9880d681SAndroid Build Coastguard Worker!16 = !DICompositeType(tag: DW_TAG_structure_type, name: "objc_object", file: !60, elements: !17) 129*9880d681SAndroid Build Coastguard Worker!17 = !{!18} 130*9880d681SAndroid Build Coastguard Worker!18 = !DIDerivedType(tag: DW_TAG_member, name: "isa", size: 64, file: !60, scope: !16, baseType: !19) 131*9880d681SAndroid Build Coastguard Worker!19 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, baseType: !20) 132*9880d681SAndroid Build Coastguard Worker!20 = !DICompositeType(tag: DW_TAG_structure_type, name: "objc_class", flags: DIFlagFwdDecl, file: !60) 133*9880d681SAndroid Build Coastguard Worker!21 = !DILocalVariable(name: "ok", line: 13, scope: !22, file: !6, type: !23) 134*9880d681SAndroid Build Coastguard Worker!22 = distinct !DILexicalBlock(line: 12, column: 0, file: !60, scope: !13) 135*9880d681SAndroid Build Coastguard Worker!23 = !DIDerivedType(tag: DW_TAG_typedef, name: "BOOL", line: 62, file: !60, baseType: !24) 136*9880d681SAndroid Build Coastguard Worker!24 = !DIBasicType(tag: DW_TAG_base_type, name: "signed char", size: 8, align: 8, encoding: DW_ATE_signed_char) 137*9880d681SAndroid Build Coastguard Worker!25 = !DILocalVariable(name: "obj2", line: 15, scope: !26, file: !6, type: !14) 138*9880d681SAndroid Build Coastguard Worker!26 = distinct !DILexicalBlock(line: 14, column: 0, file: !60, scope: !22) 139*9880d681SAndroid Build Coastguard Worker!27 = distinct !DISubprogram(name: "ThrowFunc", line: 4, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 5, file: !60, scope: !6, type: !28, variables: !31) 140*9880d681SAndroid Build Coastguard Worker!28 = !DISubroutineType(types: !29) 141*9880d681SAndroid Build Coastguard Worker!29 = !{null, !14} 142*9880d681SAndroid Build Coastguard Worker!31 = !{!32} 143*9880d681SAndroid Build Coastguard Worker!32 = !DILocalVariable(name: "obj", line: 4, arg: 1, scope: !27, file: !6, type: !14) 144*9880d681SAndroid Build Coastguard Worker!33 = !{i32 1, !"Objective-C Version", i32 2} 145*9880d681SAndroid Build Coastguard Worker!34 = !{i32 1, !"Objective-C Image Info Version", i32 0} 146*9880d681SAndroid Build Coastguard Worker!35 = !{i32 1, !"Objective-C Image Info Section", !"__DATA, __objc_imageinfo, regular, no_dead_strip"} 147*9880d681SAndroid Build Coastguard Worker!36 = !{i32 4, !"Objective-C Garbage Collection", i32 0} 148*9880d681SAndroid Build Coastguard Worker!37 = !DILocation(line: 11, scope: !13) 149*9880d681SAndroid Build Coastguard Worker!38 = !{} 150*9880d681SAndroid Build Coastguard Worker!39 = !DILocation(line: 15, scope: !26) 151*9880d681SAndroid Build Coastguard Worker!40 = !DILocation(line: 17, scope: !41) 152*9880d681SAndroid Build Coastguard Worker!41 = distinct !DILexicalBlock(line: 16, column: 0, file: !60, scope: !26) 153*9880d681SAndroid Build Coastguard Worker!42 = !DILocation(line: 22, scope: !26) 154*9880d681SAndroid Build Coastguard Worker!43 = !DILocation(line: 23, scope: !22) 155*9880d681SAndroid Build Coastguard Worker!44 = !DILocation(line: 19, scope: !41) 156*9880d681SAndroid Build Coastguard Worker!45 = !{i8 0} 157*9880d681SAndroid Build Coastguard Worker!46 = !DILocation(line: 20, scope: !47) 158*9880d681SAndroid Build Coastguard Worker!47 = distinct !DILexicalBlock(line: 19, column: 0, file: !60, scope: !48) 159*9880d681SAndroid Build Coastguard Worker!48 = distinct !DILexicalBlock(line: 19, column: 0, file: !60, scope: !26) 160*9880d681SAndroid Build Coastguard Worker!49 = !DILocation(line: 21, scope: !47) 161*9880d681SAndroid Build Coastguard Worker!50 = !DILocation(line: 24, scope: !51) 162*9880d681SAndroid Build Coastguard Worker!51 = distinct !DILexicalBlock(line: 23, column: 0, file: !60, scope: !22) 163*9880d681SAndroid Build Coastguard Worker!52 = !DILocation(line: 25, scope: !51) 164*9880d681SAndroid Build Coastguard Worker!53 = !DILocation(line: 27, scope: !13) 165*9880d681SAndroid Build Coastguard Worker!54 = !DILocation(line: 28, scope: !13) 166*9880d681SAndroid Build Coastguard Worker!55 = !DILocation(line: 4, scope: !27) 167*9880d681SAndroid Build Coastguard Worker!56 = !DILocation(line: 6, scope: !57) 168*9880d681SAndroid Build Coastguard Worker!57 = distinct !DILexicalBlock(line: 5, column: 0, file: !60, scope: !27) 169*9880d681SAndroid Build Coastguard Worker!58 = !DILocation(line: 7, scope: !57) 170*9880d681SAndroid Build Coastguard Worker!60 = !DIFile(filename: "test.m", directory: "/Volumes/Files/gottesmmcab/Radar/12906997") 171*9880d681SAndroid Build Coastguard Worker!61 = !{i32 1, !"Debug Info Version", i32 3} 172