Skip to content

Commit 13aa9d3

Browse files
committed
update
1 parent 92ad710 commit 13aa9d3

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

clang/lib/CodeGen/CGObjC.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -781,19 +781,15 @@ void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD,
781781
OMD->getLocation(), StartLoc);
782782

783783
if (OMD->isDirectMethod()) {
784-
if (CGM.getLangOpts().ObjCRuntime.isNeXTFamily()) {
785-
// Having `InnerFn` indicates that we are generating a nil check thunk.
786-
// In that case our job is done here.
787-
if (InnerFn)
788-
return;
789-
if (CGM.shouldHaveNilCheckThunk(OMD))
790-
// Go generate a nil check thunk around `Fn`
791-
CodeGenFunction(CGM, /*InnerFn=*/Fn).GenerateObjCDirectThunk(OMD, CD);
792-
CGM.getObjCRuntime().GenerateDirectMethodPrologue(*this, Fn, OMD, CD);
793-
} else {
794-
// For GNU family, since GNU Step2 also supports direct methods now.
795-
CGM.getObjCRuntime().GenerateDirectMethodPrologue(*this, Fn, OMD, CD);
796-
}
784+
// Having `InnerFn` indicates that we are generating a nil check thunk.
785+
// In that case our job is done here.
786+
if (InnerFn)
787+
return;
788+
// Only NeXTFamily can have nil check thunk.
789+
if (CGM.shouldHaveNilCheckThunk(OMD))
790+
// Go generate a nil check thunk around `Fn`
791+
CodeGenFunction(CGM, /*InnerFn=*/Fn).GenerateObjCDirectThunk(OMD, CD);
792+
CGM.getObjCRuntime().GenerateDirectMethodPrologue(*this, Fn, OMD, CD);
797793
}
798794

799795
// In ARC, certain methods get an extra cleanup.

clang/lib/CodeGen/CGObjCMac.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3946,9 +3946,8 @@ void CGObjCCommonMac::GenerateDirectMethodPrologue(
39463946
bool ReceiverCanBeNull = true;
39473947
auto selfAddr = CGF.GetAddrOfLocalVar(OMD->getSelfDecl());
39483948
auto selfValue = Builder.CreateLoad(selfAddr);
3949-
bool shouldHaveNilCheckThunk =
3950-
CGF.CGM.shouldHaveNilCheckThunk(OMD) bool isNilCheckThunk =
3951-
shouldHaveNilCheckThunk && CGF.InnerFn;
3949+
bool shouldHaveNilCheckThunk = CGF.CGM.shouldHaveNilCheckThunk(OMD);
3950+
bool isNilCheckThunk = shouldHaveNilCheckThunk && CGF.InnerFn;
39523951

39533952
// Generate:
39543953
//
@@ -3992,8 +3991,7 @@ void CGObjCCommonMac::GenerateDirectMethodPrologue(
39923991

39933992
// Only emit nil check if this is a nil check thunk or the method
39943993
// decides that its receiver can be null
3995-
if (isNilCheckThunk ||
3996-
(!CGF.CGM.shouldHaveNilCheckThunk(OMD) && ReceiverCanBeNull)) {
3994+
if (isNilCheckThunk || (!shouldHaveNilCheckThunk && ReceiverCanBeNull)) {
39973995
llvm::BasicBlock *SelfIsNilBlock =
39983996
CGF.createBasicBlock("objc_direct_method.self_is_nil");
39993997
llvm::BasicBlock *ContBlock =

0 commit comments

Comments
 (0)