1// RUN: %clang_cc1 -I %S/Inputs -triple armv7-apple-ios8.0.0 -emit-llvm -fobjc-arc -O2 -disable-llvm-passes -o - %s | FileCheck %s 2 3#import "nsvalue-boxed-expressions-support.h" 4 5// CHECK: [[CLASS:@.*]] = external global %struct._class_t 6// CHECK: [[NSVALUE:@.*]] = {{.*}}[[CLASS]]{{.*}} 7// CHECK: [[RANGE_STR:.*]] = {{.*}}_NSRange=II{{.*}} 8// CHECK: [[METH:@.*]] = private unnamed_addr constant {{.*}}valueWithBytes:objCType:{{.*}} 9// CHECK: [[VALUE_SEL:@.*]] = {{.*}}[[METH]]{{.*}} 10// CHECK: [[POINT_STR:.*]] = {{.*}}CGPoint=dd{{.*}} 11// CHECK: [[SIZE_STR:.*]] = {{.*}}CGSize=dd{{.*}} 12// CHECK: [[RECT_STR:.*]] = {{.*}}CGRect={CGPoint=dd}{CGSize=dd}}{{.*}} 13// CHECK: [[EDGE_STR:.*]] = {{.*}}NSEdgeInsets=dddd{{.*}} 14 15// CHECK-LABEL: define{{.*}} void @doRange() 16void doRange() { 17 // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSRange{{.*}} 18 // CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSRange{{.*}} 19 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] 20 // CHECK: [[TEMP_CAST:%.*]] = bitcast %struct._NSRange* [[TEMP_VAR]]{{.*}} 21 // CHECK: [[LOCAL_CAST:%.*]] = bitcast %struct._NSRange* [[LOCAL_VAR]]{{.*}} 22 // CHECK: call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}} 23 // CHECK: [[PARAM_CAST:%.*]] = bitcast %struct._NSRange* [[TEMP_VAR]]{{.*}} 24 // CHECK: [[SEL:%.*]] = load i8*, i8** [[VALUE_SEL]] 25 // CHECK: [[RECV:%.*]] = bitcast %struct._class_t* [[RECV_PTR]] to i8* 26 NSRange ns_range = { .location = 0, .length = 42 }; 27 // CHECK: call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8* {{.*}}[[RANGE_STR]]{{.*}}) 28 // CHECK: call i8* @llvm.objc.retainAutoreleasedReturnValue 29 NSValue *range = @(ns_range); 30 // CHECK: call void @llvm.objc.release 31 // CHECK: ret void 32} 33 34// CHECK-LABEL: define{{.*}} void @doPoint() 35void doPoint() { 36 // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGPoint{{.*}} 37 // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGPoint{{.*}} 38 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] 39 // CHECK: [[TEMP_CAST:%.*]] = bitcast %struct.CGPoint* [[TEMP_VAR]]{{.*}} 40 // CHECK: [[LOCAL_CAST:%.*]] = bitcast %struct.CGPoint* [[LOCAL_VAR]]{{.*}} 41 // CHECK: call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}} 42 // CHECK: [[PARAM_CAST:%.*]] = bitcast %struct.CGPoint* [[TEMP_VAR]]{{.*}} 43 // CHECK: [[SEL:%.*]] = load i8*, i8** [[VALUE_SEL]] 44 // CHECK: [[RECV:%.*]] = bitcast %struct._class_t* [[RECV_PTR]] to i8* 45 CGPoint cg_point = { .x = 42, .y = 24 }; 46 // CHECK: call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8* {{.*}}[[POINT_STR]]{{.*}}) 47 // CHECK: call i8* @llvm.objc.retainAutoreleasedReturnValue 48 NSValue *point = @(cg_point); 49 // CHECK: call void @llvm.objc.release 50 // CHECK: ret void 51} 52 53// CHECK-LABEL: define{{.*}} void @doSize() 54void doSize() { 55 // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGSize{{.*}} 56 // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGSize{{.*}} 57 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] 58 // CHECK: [[TEMP_CAST:%.*]] = bitcast %struct.CGSize* [[TEMP_VAR]]{{.*}} 59 // CHECK: [[LOCAL_CAST:%.*]] = bitcast %struct.CGSize* [[LOCAL_VAR]]{{.*}} 60 // CHECK: call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}} 61 // CHECK: [[PARAM_CAST:%.*]] = bitcast %struct.CGSize* [[TEMP_VAR]]{{.*}} 62 // CHECK: [[SEL:%.*]] = load i8*, i8** [[VALUE_SEL]] 63 // CHECK: [[RECV:%.*]] = bitcast %struct._class_t* [[RECV_PTR]] to i8* 64 CGSize cg_size = { .width = 42, .height = 24 }; 65 // CHECK: call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8* {{.*}}[[SIZE_STR]]{{.*}}) 66 // CHECK: call i8* @llvm.objc.retainAutoreleasedReturnValue 67 NSValue *size = @(cg_size); 68 // CHECK: call void @llvm.objc.release 69 // CHECK: ret void 70} 71 72// CHECK-LABEL: define{{.*}} void @doRect() 73void doRect() { 74 // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGRect{{.*}} 75 // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGRect{{.*}} 76 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] 77 // CHECK: [[TEMP_CAST:%.*]] = bitcast %struct.CGRect* [[TEMP_VAR]]{{.*}} 78 // CHECK: [[LOCAL_CAST:%.*]] = bitcast %struct.CGRect* [[LOCAL_VAR]]{{.*}} 79 // CHECK: call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}} 80 // CHECK: [[PARAM_CAST:%.*]] = bitcast %struct.CGRect* [[TEMP_VAR]]{{.*}} 81 // CHECK: [[SEL:%.*]] = load i8*, i8** [[VALUE_SEL]] 82 // CHECK: [[RECV:%.*]] = bitcast %struct._class_t* [[RECV_PTR]] to i8* 83 CGPoint cg_point = { .x = 42, .y = 24 }; 84 CGSize cg_size = { .width = 42, .height = 24 }; 85 CGRect cg_rect = { .origin = cg_point, .size = cg_size }; 86 // CHECK: call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8*{{.*}}[[RECT_STR]]{{.*}}) 87 // CHECK: call i8* @llvm.objc.retainAutoreleasedReturnValue 88 NSValue *rect = @(cg_rect); 89 // CHECK: call void @llvm.objc.release 90 // CHECK: ret void 91} 92 93// CHECK-LABEL: define{{.*}} void @doNSEdgeInsets() 94void doNSEdgeInsets() { 95 // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}} 96 // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}} 97 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] 98 // CHECK: [[TEMP_CAST:%.*]] = bitcast %struct.NSEdgeInsets* [[TEMP_VAR]]{{.*}} 99 // CHECK: [[LOCAL_CAST:%.*]] = bitcast %struct.NSEdgeInsets* [[LOCAL_VAR]]{{.*}} 100 // CHECK: call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}} 101 // CHECK: [[PARAM_CAST:%.*]] = bitcast %struct.NSEdgeInsets* [[TEMP_VAR]]{{.*}} 102 // CHECK: [[SEL:%.*]] = load i8*, i8** [[VALUE_SEL]] 103 // CHECK: [[RECV:%.*]] = bitcast %struct._class_t* [[RECV_PTR]] to i8* 104 NSEdgeInsets ns_edge_insets; 105 // CHECK: call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8*{{.*}}[[EDGE_STR]]{{.*}}) 106 // CHECK: call i8* @llvm.objc.retainAutoreleasedReturnValue 107 NSValue *edge_insets = @(ns_edge_insets); 108 // CHECK: call void @llvm.objc.release 109 // CHECK: ret void 110} 111 112// CHECK-LABEL: define{{.*}} void @doRangeRValue() 113void doRangeRValue() { 114 // CHECK: [[COERCE:%.*]] = alloca %struct._NSRange{{.*}} 115 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]] 116 // CHECK: call {{.*}} @getRange {{.*}} [[COERCE]]{{.*}} 117 // CHECK: [[COERCE_CAST:%.*]] = bitcast %struct._NSRange* [[COERCE]]{{.*}} 118 // CHECK: [[SEL:%.*]] = load i8*, i8** [[VALUE_SEL]] 119 // CHECK: [[RECV:%.*]] = bitcast %struct._class_t* [[RECV_PTR]] to i8* 120 // CHECK: call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[COERCE_CAST]], i8* {{.*}}[[RANGE_STR]]{{.*}}) 121 // CHECK: call i8* @llvm.objc.retainAutoreleasedReturnValue 122 NSValue *range_rvalue = @(getRange()); 123 // CHECK: call void @llvm.objc.release 124 // CHECK: ret void 125} 126 127