Skip to content

Commit b468535

Browse files
committed
rebase, modify names and update test
Signed-off-by: Peter Rong <[email protected]>
1 parent d6b024a commit b468535

7 files changed

+49
-49
lines changed

clang/lib/AST/Mangle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void clang::mangleObjCMethodName(raw_ostream &OS, bool includePrefixByte,
4545
OS << MethodName;
4646
OS << ']';
4747
if (!isThunk)
48-
OS << "_inner";
48+
OS << "_nonnull";
4949
}
5050
// FIXME: For blocks we currently mimic GCC's mangling scheme, which leaves
5151
// much to be desired. Come up with a better mangling scheme.

clang/test/CodeGenObjC/direct-method-nil-check-thunk-arc.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ + (Shape*) default {
7373
return [[Shape alloc] initDefault];
7474
}
7575

76-
// CHECK-LABEL: define {{.*}} @"\01-[Shape clone]_inner"
76+
// CHECK-LABEL: define {{.*}} @"\01-[Shape clone]_nonnull"
7777
// CHECK: [[CALL_INIT:%.*]] = call ptr @"\01-[Shape initWithX:Y:]"
7878
// CHECK-NEXT: [[AUTORELEASE_CLONE:%.*]] = tail call ptr @llvm.objc.autoreleaseReturnValue(ptr [[CALL_INIT]])
7979
// CHECK-NEXT: ret ptr [[AUTORELEASE_CLONE]]
8080
// CHECK-LABEL: }
8181

8282
// CHECK-LABEL: define {{.*}} @"\01-[Shape clone]"
83-
// CHECK: [[CALL_INNER:%.*]] = call ptr @"\01-[Shape clone]_inner"
83+
// CHECK: [[CALL_INNER:%.*]] = call ptr @"\01-[Shape clone]_nonnull"
8484
// CHECK-NEXT: call void asm sideeffect "mov\09fp, fp\09\09// marker for objc_retainAutoreleaseReturnValue", ""()
8585
// CHECK-NEXT: [[RETAINED:%.*]] = call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr [[CALL_INNER]])
8686
// CHECK-NEXT: store ptr [[RETAINED]], ptr [[RETADDR:%.*]]
@@ -93,7 +93,7 @@ - (instancetype) clone {
9393
}
9494

9595
// InnerFn will release the value since it is "consumed".
96-
// CHECK: define hidden double @"\01-[Shape distanceFrom:]_inner"(ptr noundef nonnull %{{.*}}, ptr noundef [[S:%.*]]) #0 {
96+
// CHECK: define hidden double @"\01-[Shape distanceFrom:]_nonnull"(ptr noundef nonnull %{{.*}}, ptr noundef [[S:%.*]]) #0 {
9797
// CHECK: {{%.*}} = alloca ptr
9898
// CHECK: [[S_ADDR:%.*]] = alloca ptr
9999
// CHECK: store ptr [[S]], ptr [[S_ADDR]]

clang/test/CodeGenObjC/direct-method-nil-check-thunk-consumed.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ - (instancetype)initWithX:(int)x Y:(int)y {
2727
// 1. Call inner set (because we alreaday know self is not null)
2828
// 2. Call thunk get (because we don't know if s is null)
2929
// 3. Release s.
30-
// CHECK-LABEL: define hidden void @"\01-[Shape move:]_inner"
30+
// CHECK-LABEL: define hidden void @"\01-[Shape move:]_nonnull"
3131
// CHECK: {{.*}} = call i32 @"\01-[Shape x]"
32-
// CHECK: call void @"\01-[Shape setX:]_inner"
32+
// CHECK: call void @"\01-[Shape setX:]_nonnull"
3333
// CHECK: {{.*}} = call i32 @"\01-[Shape y]"
34-
// CHECK: call void @"\01-[Shape setY:]_inner"
34+
// CHECK: call void @"\01-[Shape setY:]_nonnull"
3535
// CHECK: call void @llvm.objc.storeStrong
3636
// CHECK-LABEL: }
3737

clang/test/CodeGenObjC/direct-method-nil-check-thunk-opt.m

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ - (int)fibWithN:(int)n __attribute__((objc_direct));
1616

1717
@implementation Fib
1818
// With optimization, the inner function call should be a tail call.
19-
// OPT-LABEL: define hidden i32 @"\01-[Fib fibWithN:]_inner"
20-
// OPT: {{.*}} tail call i32 @"\01-[Fib fibWithN:]_inner"
19+
// OPT-LABEL: define hidden i32 @"\01-[Fib fibWithN:]_nonnull"
20+
// OPT: {{.*}} tail call i32 @"\01-[Fib fibWithN:]_nonnull"
2121

2222
// The inner function knows that self is non null so it can call the method without the nil check.
23-
// CHECK-LABEL: define hidden i32 @"\01-[Fib fibWithN:]_inner"
24-
// CHECK: {{.*}} call i32 @"\01-[Fib fibWithN:]_inner"
25-
// CHECK: {{.*}} call i32 @"\01-[Fib fibWithN:]_inner"
23+
// CHECK-LABEL: define hidden i32 @"\01-[Fib fibWithN:]_nonnull"
24+
// CHECK: {{.*}} call i32 @"\01-[Fib fibWithN:]_nonnull"
25+
// CHECK: {{.*}} call i32 @"\01-[Fib fibWithN:]_nonnull"
2626

2727
// Thunk function calls the inner function as usual.
2828
// CHECK-LABEL: define hidden i32 @"\01-[Fib fibWithN:]"
29-
// CHECK: {{.*}} call i32 @"\01-[Fib fibWithN:]_inner"
29+
// CHECK: {{.*}} call i32 @"\01-[Fib fibWithN:]_nonnull"
3030
- (int)fibWithN:(int)n {
3131
if (n <= 0) return 0;
3232
if (n == 1) return 1;
@@ -43,13 +43,13 @@ - (int)privateMethod:(int)n __attribute__((objc_direct));
4343
@implementation SubRoot
4444
- (int)calculateWithPtr:(int*)ptr {
4545
// For inner functions, it is trivial to reason that the receiver `self` can't be null
46-
// CHECK-LABEL: define hidden i32 @"\01-[SubRoot calculateWithPtr:]_inner"
47-
// CHECK: {{.*}} = call i32 @"\01-[SubRoot val]_inner"
48-
// CHECK: call void @"\01-[SubRoot setVal:]_inner"
49-
// CHECK: {{.*}} = call i32 @"\01-[Root privateLoadWithOffset:]_inner"
50-
// CHECK: {{.*}} = call i32 @"\01-[SubRoot privateMethod:]_inner"
51-
// CHECK: {{.*}} = call i32 @"\01-[Root idx]_inner"
52-
// CHECK: call void @"\01-[Root setIdx:]_inner"
46+
// CHECK-LABEL: define hidden i32 @"\01-[SubRoot calculateWithPtr:]_nonnull"
47+
// CHECK: {{.*}} = call i32 @"\01-[SubRoot val]_nonnull"
48+
// CHECK: call void @"\01-[SubRoot setVal:]_nonnull"
49+
// CHECK: {{.*}} = call i32 @"\01-[Root privateLoadWithOffset:]_nonnull"
50+
// CHECK: {{.*}} = call i32 @"\01-[SubRoot privateMethod:]_nonnull"
51+
// CHECK: {{.*}} = call i32 @"\01-[Root idx]_nonnull"
52+
// CHECK: call void @"\01-[Root setIdx:]_nonnull"
5353
int ret = [self val];
5454
[self setVal:*ptr];
5555
ret += [self privateLoadWithOffset:ptr];
@@ -62,7 +62,7 @@ - (int)calculateWithPtr:(int*)ptr {
6262

6363
// The thunk declarations don't exist since all calls to them are non null.
6464
// We trust that these symbols will be generated when the definition is available.
65-
// CHECK-LABEL: declare i32 @"\01-[Root privateLoadWithOffset:]_inner"(ptr, ptr)
66-
// CHECK-LABEL: declare i32 @"\01-[SubRoot privateMethod:]_inner"(ptr, i32)
67-
// CHECK-LABEL: declare i32 @"\01-[Root idx]_inner"(ptr)
68-
// CHECK-LABEL: declare void @"\01-[Root setIdx:]_inner"(ptr, i32)
65+
// CHECK-LABEL: declare i32 @"\01-[Root privateLoadWithOffset:]_nonnull"(ptr, ptr)
66+
// CHECK-LABEL: declare i32 @"\01-[SubRoot privateMethod:]_nonnull"(ptr, i32)
67+
// CHECK-LABEL: declare i32 @"\01-[Root idx]_nonnull"(ptr)
68+
// CHECK-LABEL: declare void @"\01-[Root setIdx:]_nonnull"(ptr, i32)

clang/test/CodeGenObjC/direct-method-nil-check-thunk-vararg.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ - (void)printWithFormat:(const char *)format, ... {
2525
va_list args;
2626
// CHECK: call void @llvm.va_start
2727
va_start(args, format);
28-
// CHECK: call void @"\01-[Root vprintWithFormat:Args:]_inner"
28+
// CHECK: call void @"\01-[Root vprintWithFormat:Args:]_nonnull"
2929
[self vprintWithFormat:format Args:args];
3030
// CHECK: call void @llvm.va_end
3131
va_end(args);
3232
}
3333
// CHECK-NOT: <Root printWithFormat]_inner
3434

3535
// CHECK-LABEL: define {{.*}} void @"\01-[Root vprintWithFormat:Args:]"
36-
// CHECK: call void @"\01-[Root vprintWithFormat:Args:]_inner"
36+
// CHECK: call void @"\01-[Root vprintWithFormat:Args:]_nonnull"
3737

38-
// CHECK-LABEL: define {{.*}} void @"\01-[Root vprintWithFormat:Args:]_inner"
38+
// CHECK-LABEL: define {{.*}} void @"\01-[Root vprintWithFormat:Args:]_nonnull"
3939
-(void)vprintWithFormat:(const char *)format Args:(va_list) args{
40-
// CHECK: call void @"\01-[Root vprintWithFormat:Args:]_inner"
40+
// CHECK: call void @"\01-[Root vprintWithFormat:Args:]_nonnull"
4141
[self vprintWithFormat:format Args:args];
4242
// CHECK: call i32 @vprintf
4343
vprintf(format, args);

clang/test/CodeGenObjC/direct-method-nil-check-thunk.m

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ - (int)getInt __attribute__((objc_direct));
2323
@end
2424

2525
@implementation Root
26-
// CHECK-LABEL: define hidden i32 @"\01-[Root intProperty2]_inner"(ptr noundef nonnull %{{.*}}
26+
// CHECK-LABEL: define hidden i32 @"\01-[Root intProperty2]_nonnull"(ptr noundef nonnull %{{.*}}
2727
// CHECK-LABEL: define hidden i32 @"\01-[Root intProperty2]"(ptr noundef %{{.*}}
2828
- (int)intProperty2 {
2929
return 42;
3030
}
3131

32-
// CHECK-LABEL: define hidden i32 @"\01-[Root getInt]_inner"(ptr noundef nonnull %{{.*}}
32+
// CHECK-LABEL: define hidden i32 @"\01-[Root getInt]_nonnull"(ptr noundef nonnull %{{.*}}
3333
// CHECK-NEXT: entry:
3434
// CHECK-NEXT: [[SELFADDR:%.*]] = alloca ptr,
3535
// CHECK-NEXT: store ptr %{{.*}}, ptr [[SELFADDR]],
@@ -54,7 +54,7 @@ - (int)getInt __attribute__((objc_direct)) {
5454

5555
// set value
5656
// CHECK-LABEL: objc_direct_method.cont:
57-
// CHECK-NEXT: [[RET:%.*]] = call i32 @"\01-[Root getInt]_inner"(ptr noundef nonnull [[ARG0]]
57+
// CHECK-NEXT: [[RET:%.*]] = call i32 @"\01-[Root getInt]_nonnull"(ptr noundef nonnull [[ARG0]]
5858
// CHECK-NEXT: store i32 [[RET]], ptr [[RETVAL]]
5959
// CHECK-NEXT: br label %return
6060

@@ -65,7 +65,7 @@ - (int)getInt __attribute__((objc_direct)) {
6565
return 42;
6666
}
6767

68-
// CHECK-NOT: @"\01+[Root classGetInt]_inner"
68+
// CHECK-NOT: @"\01+[Root classGetInt]_nonnull"
6969
+ (int)classGetInt __attribute__((objc_direct)) {
7070
// CHECK: define hidden i32 @"\01+[Root classGetInt]"(ptr noundef [[ARGSELF:%.*]])
7171
// [self self]
@@ -80,7 +80,7 @@ + (int)classGetInt __attribute__((objc_direct)) {
8080
return 42;
8181
}
8282

83-
// CHECK-LABEL: define hidden i64 @"\01-[Root getComplex]_inner"(ptr noundef nonnull %{{.*}}
83+
// CHECK-LABEL: define hidden i64 @"\01-[Root getComplex]_nonnull"(ptr noundef nonnull %{{.*}}
8484
// CHECK-LABEL: entry:
8585
// CHECK-NEXT: [[RETVAL:%.*]] = alloca
8686
// CHECK-NEXT: [[SELFADDR:%.*]] = alloca ptr,
@@ -107,7 +107,7 @@ - (struct my_complex_struct)getComplex __attribute__((objc_direct)) {
107107

108108
// call the inner function set value
109109
// CHECK-LABEL: objc_direct_method.cont:
110-
// CHECK-NEXT: [[CALL:%.*]] = call i64 @"\01-[Root getComplex]_inner"(ptr noundef nonnull [[ARGSELF]])
110+
// CHECK-NEXT: [[CALL:%.*]] = call i64 @"\01-[Root getComplex]_nonnull"(ptr noundef nonnull [[ARGSELF]])
111111
// CHECK-NEXT: store i64 [[CALL]], ptr [[RETVAL]]
112112
// CHECK-NEXT: br label
113113

@@ -119,14 +119,14 @@ - (struct my_complex_struct)getComplex __attribute__((objc_direct)) {
119119
return st;
120120
}
121121

122-
// CHECK-NOT: @"\01+[Root classGetComplex]_inner"
122+
// CHECK-NOT: @"\01+[Root classGetComplex]_nonnull"
123123
+ (struct my_complex_struct)classGetComplex __attribute__((objc_direct)) {
124124
// CHECK-LABEL: define hidden i64 @"\01+[Root classGetComplex]"(ptr noundef
125125
struct my_complex_struct st = {.a = 42};
126126
return st;
127127
}
128128

129-
// CHECK-LABEL: define hidden void @"\01-[Root getAggregate]_inner"(
129+
// CHECK-LABEL: define hidden void @"\01-[Root getAggregate]_nonnull"(
130130
// CHECK: ptr {{.*}} sret(%struct.my_aggregate_struct) align 4 [[RETVAL:%[^,]*]], ptr noundef nonnull %self
131131
// CHECK-LABEL: entry:
132132
// CHECK-NEXT: [[SELFADDR:%.*]] = alloca ptr,
@@ -155,7 +155,7 @@ - (struct my_aggregate_struct)getAggregate __attribute__((objc_direct)) {
155155

156156
// set value
157157
// CHECK-LABEL: objc_direct_method.cont:
158-
// CHECK-NEXT: call void @"\01-[Root getAggregate]_inner"(ptr dead_on_unwind noalias writable sret(%struct.my_aggregate_struct) align 4 [[RETVAL]], ptr noundef nonnull [[ARGSELF]])
158+
// CHECK-NEXT: call void @"\01-[Root getAggregate]_nonnull"(ptr dead_on_unwind noalias writable sret(%struct.my_aggregate_struct) align 4 [[RETVAL]], ptr noundef nonnull [[ARGSELF]])
159159
// CHECK-NEXT: br label
160160

161161
// return
@@ -166,13 +166,13 @@ - (struct my_aggregate_struct)getAggregate __attribute__((objc_direct)) {
166166
}
167167

168168
// CHECK-LABEL: define hidden void @"\01+[Root classGetAggregate]"({{.*}}, ptr noundef {{.*}})
169-
// CHECK-NOT: @"\01+[Root classGetAggregate]_inner"
169+
// CHECK-NOT: @"\01+[Root classGetAggregate]_nonnull"
170170
+ (struct my_aggregate_struct)classGetAggregate __attribute__((objc_direct)) {
171171
struct my_aggregate_struct st = {.a = 42};
172172
return st;
173173
}
174174

175-
// CHECK-LABEL: define hidden void @"\01-[Root accessCmd]_inner"(ptr noundef nonnull
175+
// CHECK-LABEL: define hidden void @"\01-[Root accessCmd]_nonnull"(ptr noundef nonnull
176176
// CHECK-LABEL: entry:
177177
// CHECK-NEXT: [[SELFADDR:%.*]] = alloca ptr,
178178
// CHECK-NEXT: [[CMDVAL:%_cmd]] = alloca ptr,
@@ -192,18 +192,18 @@ - (void)accessCmd __attribute__((objc_direct)) {
192192
// CHECK-NEXT: br label %return
193193

194194
// CHECK-LABEL: objc_direct_method.cont:
195-
// CHECK-NEXT: call void @"\01-[Root accessCmd]_inner"(ptr noundef nonnull %{{.*}})
195+
// CHECK-NEXT: call void @"\01-[Root accessCmd]_nonnull"(ptr noundef nonnull %{{.*}})
196196
// CHECK-NEXT: br label %return
197197
SEL sel = _cmd;
198198
}
199199

200200
@end
201-
// CHECK-LABEL: define hidden i32 @"\01-[Root intProperty]_inner"(ptr noundef nonnull %{{.*}})
201+
// CHECK-LABEL: define hidden i32 @"\01-[Root intProperty]_nonnull"(ptr noundef nonnull %{{.*}})
202202
// CHECK-LABEL: define hidden i32 @"\01-[Root intProperty]"(ptr noundef %{{.*}})
203203

204204
// Check the synthesized objectProperty calls objc_getProperty(); this also
205205
// checks that the synthesized method passes undef for the `cmd` argument.
206-
// CHECK-LABEL: define hidden ptr @"\01-[Root objectProperty]_inner"(ptr noundef nonnull {{%.*}})
206+
// CHECK-LABEL: define hidden ptr @"\01-[Root objectProperty]_nonnull"(ptr noundef nonnull {{%.*}})
207207
// CHECK-NEXT: entry:
208208
// CHECK-NEXT: [[SELFADDR:%.*]] = alloca ptr,
209209
// CHECK-NEXT: store ptr %{{.*}}, ptr [[SELFADDR]],
@@ -215,7 +215,7 @@ - (void)accessCmd __attribute__((objc_direct)) {
215215
// CHECK: [[RETADDR:%.*]] = alloca ptr,
216216

217217
// CHECK-LABEL: objc_direct_method.cont:
218-
// CHECK-NEXT: [[RETVAL:%.*]] = call ptr @"\01-[Root objectProperty]_inner"
218+
// CHECK-NEXT: [[RETVAL:%.*]] = call ptr @"\01-[Root objectProperty]_nonnull"
219219
// CHECK-NEXT: [[RETAINED_RET:%.*]] = notail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr [[RETVAL]])
220220
// CHECK-NEXT: store ptr [[RETAINED_RET]], ptr [[RETADDR]],
221221
// CHECK-NEXT: br label %return
@@ -243,27 +243,27 @@ - (int)directMethodInCategory __attribute__((objc_direct));
243243

244244
__attribute__((objc_direct_members))
245245
@implementation Foo
246-
// CHECK-LABEL: define hidden i32 @"\01-[Foo directMethodInExtension]_inner"(
246+
// CHECK-LABEL: define hidden i32 @"\01-[Foo directMethodInExtension]_nonnull"(
247247
// CHECK-LABEL: define hidden i32 @"\01-[Foo directMethodInExtension]"(
248248
- (int)directMethodInExtension {
249249
return 42;
250250
}
251-
// CHECK-LABEL: define hidden i32 @"\01-[Foo getDirect_setDynamic]_inner"(
251+
// CHECK-LABEL: define hidden i32 @"\01-[Foo getDirect_setDynamic]_nonnull"(
252252
// CHECK-LABEL: define hidden i32 @"\01-[Foo getDirect_setDynamic]"(
253253
// CHECK-LABEL: define internal void @"\01-[Foo setGetDirect_setDynamic:]"(
254254
// CHECK-LABEL: define internal i32 @"\01-[Foo getDynamic_setDirect]"(
255-
// CHECK-LABEL: define hidden void @"\01-[Foo setGetDynamic_setDirect:]_inner"(
255+
// CHECK-LABEL: define hidden void @"\01-[Foo setGetDynamic_setDirect:]_nonnull"(
256256
// CHECK-LABEL: define hidden void @"\01-[Foo setGetDynamic_setDirect:]"(
257257
// CHECK-LABEL: define internal void @"\01-[Foo .cxx_destruct]"(
258258
@end
259259

260260
@implementation Foo (Cat)
261-
// CHECK-LABEL: define hidden i32 @"\01-[Foo directMethodInCategory]_inner"(
261+
// CHECK-LABEL: define hidden i32 @"\01-[Foo directMethodInCategory]_nonnull"(
262262
// CHECK-LABEL: define hidden i32 @"\01-[Foo directMethodInCategory]"(
263263
- (int)directMethodInCategory {
264264
return 42;
265265
}
266-
// CHECK-LABEL: define hidden i32 @"\01-[Foo directMethodInCategoryNoDecl]_inner"(
266+
// CHECK-LABEL: define hidden i32 @"\01-[Foo directMethodInCategoryNoDecl]_nonnull"(
267267
// CHECK-LABEL: define hidden i32 @"\01-[Foo directMethodInCategoryNoDecl]"(
268268
- (int)directMethodInCategoryNoDecl __attribute__((objc_direct)) {
269269
return 42;

clang/test/CodeGenObjC/direct-method-ret-mismatch.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ - (id)method {
1919
}
2020
@end
2121
// The inner function should not contain any nil check anymore.
22-
// CHECK-THUNK-LABEL: define hidden ptr @"\01-[Root method]_inner"(ptr noundef nonnull
22+
// CHECK-THUNK-LABEL: define hidden ptr @"\01-[Root method]_nonnull"(ptr noundef nonnull
2323
// CHECK-THUNK-NOT: br i1 %1, label %objc_direct_method.self_is_nil, label %objc_direct_method.cont
2424

2525
// The direct function contains the nil check.

0 commit comments

Comments
 (0)