Skip to content

Commit 8b3e720

Browse files
committed
Small bug fix, shouldn't mark class method as nonnull
1 parent 13aa9d3 commit 8b3e720

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

clang/lib/CodeGen/CGCall.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2745,10 +2745,9 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
27452745
// Direct method prologue should not contain nil check anymore.
27462746
// As a result, we can set `self` to be NonNull to prepare for further
27472747
// optimizations.
2748-
if (getLangOpts().ObjCEmitNilCheckThunk && TargetDecl) {
2748+
if (TargetDecl) {
27492749
auto OMD = dyn_cast<ObjCMethodDecl>(TargetDecl);
2750-
bool isDirect = OMD && OMD->isDirectMethod();
2751-
if (isDirect && !IsThunk) {
2750+
if (shouldHaveNilCheckThunk(OMD) && !IsThunk) {
27522751
auto IRArgs = IRFunctionArgs.getIRArgs(0);
27532752
ArgAttrs[IRArgs.first] = ArgAttrs[IRArgs.first].addAttribute(
27542753
getLLVMContext(), llvm::Attribute::NonNull);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ - (int)getInt __attribute__((objc_direct)) {
6767

6868
// CHECK-NOT: @"\01+[Root classGetInt]_inner"
6969
+ (int)classGetInt __attribute__((objc_direct)) {
70-
// CHECK: define hidden i32 @"\01+[Root classGetInt]"(ptr noundef nonnull [[ARGSELF:%.*]])
70+
// CHECK: define hidden i32 @"\01+[Root classGetInt]"(ptr noundef [[ARGSELF:%.*]])
7171
// [self self]
7272
// CHECK-LABEL: entry:
7373
// CHECK-NEXT: [[SELFADDR:%.*]] = alloca ptr,
@@ -165,7 +165,7 @@ - (struct my_aggregate_struct)getAggregate __attribute__((objc_direct)) {
165165
return st;
166166
}
167167

168-
// CHECK-LABEL: define hidden void @"\01+[Root classGetAggregate]"({{.*}}, ptr noundef nonnull {{.*}})
168+
// CHECK-LABEL: define hidden void @"\01+[Root classGetAggregate]"({{.*}}, ptr noundef {{.*}})
169169
// CHECK-NOT: @"\01+[Root classGetAggregate]_inner"
170170
+ (struct my_aggregate_struct)classGetAggregate __attribute__((objc_direct)) {
171171
struct my_aggregate_struct st = {.a = 42};

0 commit comments

Comments
 (0)