annotate clang/test/CodeGenObjCXX/arc-constexpr.mm @ 150:1d019706d866

LLVM10
author anatofuz
date Thu, 13 Feb 2020 15:10:13 +0900
parents
children 2e18cbf3894f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fobjc-runtime-has-weak -o - -std=c++11 %s | FileCheck %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 // CHECK: %[[TYPE:[a-z0-9]+]] = type opaque
anatofuz
parents:
diff changeset
4 // CHECK: @[[CFSTRING:[a-z0-9_]+]] = private global %struct.__NSConstantString_tag
anatofuz
parents:
diff changeset
5 @class NSString;
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 // CHECK-LABEL: define void @_Z5test1v
anatofuz
parents:
diff changeset
8 // CHECK: %[[ALLOCA:[A-Z]+]] = alloca %[[TYPE]]*
anatofuz
parents:
diff changeset
9 // CHECK: %[[V0:[0-9]+]] = call i8* @llvm.objc.retain(i8* bitcast (%struct.__NSConstantString_tag* @[[CFSTRING]]
anatofuz
parents:
diff changeset
10 // CHECK: %[[V1:[0-9]+]] = bitcast i8* %[[V0]] to %[[TYPE]]*
anatofuz
parents:
diff changeset
11 // CHECK: store %[[TYPE]]* %[[V1]], %[[TYPE]]** %[[ALLOCA]]
anatofuz
parents:
diff changeset
12 // CHECK: %[[V2:[0-9]+]] = bitcast %[[TYPE]]** %[[ALLOCA]]
anatofuz
parents:
diff changeset
13 // CHECK: call void @llvm.objc.storeStrong(i8** %[[V2]], i8* null)
anatofuz
parents:
diff changeset
14 void test1() {
anatofuz
parents:
diff changeset
15 constexpr NSString *S = @"abc";
anatofuz
parents:
diff changeset
16 }
anatofuz
parents:
diff changeset
17
anatofuz
parents:
diff changeset
18 // CHECK-LABEL: define void @_Z5test2v
anatofuz
parents:
diff changeset
19 // CHECK: %[[CONST:[a-zA-Z]+]] = alloca %[[TYPE]]*
anatofuz
parents:
diff changeset
20 // CHECK: %[[REF_CONST:[a-zA-Z]+]] = alloca %[[TYPE]]*
anatofuz
parents:
diff changeset
21 // CHECK: %[[V0:[0-9]+]] = call i8* @llvm.objc.retain(i8* bitcast (%struct.__NSConstantString_tag* @[[CFSTRING]]
anatofuz
parents:
diff changeset
22 // CHECK-NEXT: %[[V1:[0-9]+]] = bitcast i8* %[[V0]] to %[[TYPE]]*
anatofuz
parents:
diff changeset
23 // CHECK-NEXT: store %[[TYPE]]* %[[V1]], %[[TYPE]]** %[[CONST]]
anatofuz
parents:
diff changeset
24 // CHECK: %[[V2:[0-9]+]] = call i8* @llvm.objc.retain(i8* bitcast (%struct.__NSConstantString_tag* @[[CFSTRING]]
anatofuz
parents:
diff changeset
25 // CHECK-NEXT: %[[V3:[0-9]+]] = bitcast i8* %[[V2]] to %[[TYPE]]*
anatofuz
parents:
diff changeset
26 // CHECK-NEXT: store %[[TYPE]]* %[[V3]], %[[TYPE]]** %[[REF_CONST]]
anatofuz
parents:
diff changeset
27 // CHECK: %[[V4:[0-9]+]] = bitcast %[[TYPE]]** %[[REF_CONST]]
anatofuz
parents:
diff changeset
28 // CHECK-NEXT: call void @llvm.objc.storeStrong(i8** %[[V4]], i8* null)
anatofuz
parents:
diff changeset
29 // CHECK: %[[V5:[0-9]+]] = bitcast %[[TYPE]]** %[[CONST]]
anatofuz
parents:
diff changeset
30 // CHECK-NEXT: call void @llvm.objc.storeStrong(i8** %[[V5]], i8* null)
anatofuz
parents:
diff changeset
31 void test2() {
anatofuz
parents:
diff changeset
32 constexpr NSString *Const = @"abc";
anatofuz
parents:
diff changeset
33 // In IR RefConst should be initialized with Const initializer instead of
anatofuz
parents:
diff changeset
34 // reading from variable.
anatofuz
parents:
diff changeset
35 NSString* RefConst = Const;
anatofuz
parents:
diff changeset
36 }
anatofuz
parents:
diff changeset
37
anatofuz
parents:
diff changeset
38 // CHECK-LABEL: define void @_Z5test3v
anatofuz
parents:
diff changeset
39 // CHECK: %[[WEAK_CONST:[a-zA-Z]+]] = alloca %[[TYPE]]*
anatofuz
parents:
diff changeset
40 // CHECK: %[[REF_WEAK_CONST:[a-zA-Z]+]] = alloca %[[TYPE]]*
anatofuz
parents:
diff changeset
41 // CHECK: %[[V0:[0-9]+]] = bitcast %[[TYPE]]** %[[WEAK_CONST]]
anatofuz
parents:
diff changeset
42 // CHECK-NEXT: %[[V1:[0-9]+]] = call i8* @llvm.objc.initWeak(i8** %[[V0]], i8* bitcast (%struct.__NSConstantString_tag* @[[CFSTRING]]
anatofuz
parents:
diff changeset
43 // CHECK: store %[[TYPE]]* bitcast (%struct.__NSConstantString_tag* @[[CFSTRING]] to %[[TYPE]]*), %[[TYPE]]** %[[REF_WEAK_CONST]]
anatofuz
parents:
diff changeset
44 // CHECK: %[[V2:[0-9]+]] = bitcast %[[TYPE]]** %[[REF_WEAK_CONST]]
anatofuz
parents:
diff changeset
45 // CHECK-NEXT: call void @llvm.objc.storeStrong(i8** %[[V2]], i8* null)
anatofuz
parents:
diff changeset
46 // CHECK: %[[V3:[0-9]+]] = bitcast %[[TYPE]]** %[[WEAK_CONST]]
anatofuz
parents:
diff changeset
47 // CHECK-NEXT: call void @llvm.objc.destroyWeak(i8** %[[V3]])
anatofuz
parents:
diff changeset
48 void test3() {
anatofuz
parents:
diff changeset
49 __weak constexpr NSString *WeakConst = @"abc";
anatofuz
parents:
diff changeset
50 NSString* RefWeakConst = WeakConst;
anatofuz
parents:
diff changeset
51 }