[PATCH] Use the correct ObjC EH personality
Use the correct ObjC EH personality This fixes ObjC exceptions on Win64 (which uses SEH), among others. --- lib/CodeGen/CGCleanup.h | 2 ++ lib/CodeGen/CGException.cpp | 8 2 files changed, 10 insertions(+) diff --git a/lib/CodeGen/CGCleanup.h b/lib/CodeGen/CGCleanup.h index 2166490ec1..105c5629d5 100644 --- a/lib/CodeGen/CGCleanup.h +++ b/lib/CodeGen/CGCleanup.h @@ -616,6 +616,8 @@ struct EHPersonality { static const EHPersonality GNU_C_SJLJ; static const EHPersonality GNU_C_SEH; static const EHPersonality GNU_ObjC; + static const EHPersonality GNU_ObjC_SJLJ; + static const EHPersonality GNU_ObjC_SEH; static const EHPersonality GNUstep_ObjC; static const EHPersonality GNU_ObjCXX; static const EHPersonality NeXT_ObjC; diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp index 7b7880e07a..f908bf2b3b 100644 --- a/lib/CodeGen/CGException.cpp +++ b/lib/CodeGen/CGException.cpp @@ -97,6 +97,10 @@ EHPersonality::GNU_CPlusPlus_SEH = { "__gxx_personality_seh0", nullptr }; const EHPersonality EHPersonality::GNU_ObjC = {"__gnu_objc_personality_v0", "objc_exception_throw"}; const EHPersonality +EHPersonality::GNU_ObjC_SJLJ = {"__gnu_objc_personality_sj0", "objc_exception_throw"}; +const EHPersonality +EHPersonality::GNU_ObjC_SEH = {"__gnu_objc_personality_seh0", "objc_exception_throw"}; +const EHPersonality EHPersonality::GNU_ObjCXX = { "__gnustep_objcxx_personality_v0", nullptr }; const EHPersonality EHPersonality::GNUstep_ObjC = { "__gnustep_objc_personality_v0", nullptr }; @@ -137,6 +141,10 @@ static const EHPersonality &getObjCPersonality(const llvm::Triple &T, // fallthrough case ObjCRuntime::GCC: case ObjCRuntime::ObjFW: +if (L.SjLjExceptions) + return EHPersonality::GNU_ObjC_SJLJ; +else if (useLibGCCSEHPersonality(T)) + return EHPersonality::GNU_ObjC_SEH; return EHPersonality::GNU_ObjC; } llvm_unreachable("bad runtime kind"); -- Jonathan ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] Use the correct ObjC EH personality
Sorry, it seems the inline patch has been garbled. Trying as an attachment this time. 0001-Use-the-correct-ObjC-EH-personality.patch Description: Binary data -- Jonathan ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] Use the correct ObjC++ personality
Use the correct EH personality for ObjC++ code. Previously, it would just always use the ObjC DWARF personality, even with SjLj or SEH exceptions. diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp index 228efec51b..ca1535182e 100644 --- a/lib/CodeGen/CGException.cpp +++ b/lib/CodeGen/CGException.cpp @@ -180,8 +180,8 @@ static const EHPersonality &getObjCXXPersonality(const llvm::Triple &T, // The GCC runtime's personality function inherently doesn't support // mixed EH. Use the C++ personality just to avoid returning null. case ObjCRuntime::GCC: - case ObjCRuntime::ObjFW: // XXX: this will change soon -return EHPersonality::GNU_ObjC; + case ObjCRuntime::ObjFW: +return getObjCPersonality(T, L); case ObjCRuntime::GNUstep: return EHPersonality::GNU_ObjCXX; } -- Jonathan ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] Use the correct ObjC++ personality
> Testcase? Shouldn't be necessary for such a simple and extremely obvious one-liner. -- Jonathan ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix objc_sel_{name,types} missing an underscore (PR #88713)
https://github.com/Midar created https://github.com/llvm/llvm-project/pull/88713 The other places all use the underscore. This is just a quick drive-by commit, LMK if more is needed. >From e39e2fc218c588d66937211f98a25eb2acf00a6b Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Mon, 15 Apr 2024 13:36:05 +0200 Subject: [PATCH] Fix objc_sel_{name,types} missing an underscore The other places all use the underscore. --- clang/lib/CodeGen/CGObjCGNU.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index 4e7f777ba1d916..97df8c5ae18c64 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -3873,13 +3873,14 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { for (auto &untypedSel : allSelectors) { std::string selNameStr = untypedSel.getAsString(); - llvm::Constant *selName = ExportUniqueString(selNameStr, ".objc_sel_name"); + llvm::Constant *selName = ExportUniqueString(selNameStr, +".objc_sel_name_"); for (TypedSelector &sel : table[untypedSel]) { llvm::Constant *selectorTypeEncoding = NULLPtr; if (!sel.first.empty()) selectorTypeEncoding = -MakeConstantString(sel.first, ".objc_sel_types"); +MakeConstantString(sel.first, ".objc_sel_types_"); auto selStruct = selectors.beginStruct(selStructTy); selStruct.add(selName); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix objc_sel_{name,types} missing an underscore (PR #88713)
https://github.com/Midar updated https://github.com/llvm/llvm-project/pull/88713 >From 8dc7333c0e9c757bba91ebfbe57280ad0635afa9 Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Mon, 15 Apr 2024 13:36:05 +0200 Subject: [PATCH] Fix objc_sel_{name,types} missing an underscore The other places all use the underscore. This also makes .objc_sel_name_* consistently private. --- clang/lib/CodeGen/CGObjCGNU.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index 4e7f777ba1d916..d2823b7ee3de46 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -3873,13 +3873,14 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { for (auto &untypedSel : allSelectors) { std::string selNameStr = untypedSel.getAsString(); - llvm::Constant *selName = ExportUniqueString(selNameStr, ".objc_sel_name"); + llvm::Constant *selName = ExportUniqueString(selNameStr, +".objc_sel_name_", true); for (TypedSelector &sel : table[untypedSel]) { llvm::Constant *selectorTypeEncoding = NULLPtr; if (!sel.first.empty()) selectorTypeEncoding = -MakeConstantString(sel.first, ".objc_sel_types"); +MakeConstantString(sel.first, ".objc_sel_types_"); auto selStruct = selectors.beginStruct(selStructTy); selStruct.add(selName); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix objc_sel_{name,types} missing an underscore (PR #88713)
Midar wrote: Maybe @rjmccall would be a good reviewer? https://github.com/llvm/llvm-project/pull/88713 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix objc_sel_{name,types} missing an underscore (PR #88713)
Midar wrote: These symbols are just used to deduplicate strings: That's why they're hidden and in COMDAT. So I don't think it'll break or fix the ABI ;). https://github.com/llvm/llvm-project/pull/88713 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Allow direct dispatch for the ObjFW runtime (PR #126382)
https://github.com/Midar edited https://github.com/llvm/llvm-project/pull/126382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Allow direct dispatch for the ObjFW runtime (PR #126382)
https://github.com/Midar edited https://github.com/llvm/llvm-project/pull/126382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Allow direct dispatch for the ObjFW runtime (PR #126382)
https://github.com/Midar created https://github.com/llvm/llvm-project/pull/126382 There was no reason for it to ever be disabled. >From 28cc71ac247b1fc8d4d9d4ecd7ea3f210bca3ef2 Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Sat, 8 Feb 2025 12:12:21 +0100 Subject: [PATCH] Allow direct dispatch for the ObjFW runtime There was no reason for it to ever be disabled. --- clang/include/clang/Basic/ObjCRuntime.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/include/clang/Basic/ObjCRuntime.h b/clang/include/clang/Basic/ObjCRuntime.h index 1ccf60f0b7bee70..df42b4389861118 100644 --- a/clang/include/clang/Basic/ObjCRuntime.h +++ b/clang/include/clang/Basic/ObjCRuntime.h @@ -473,7 +473,7 @@ class ObjCRuntime { case GCC: return false; case GNUstep: return (getVersion() >= VersionTuple(2, 2)); -case ObjFW: return false; +case ObjFW: return true; } llvm_unreachable("bad kind"); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Allow direct dispatch for the ObjFW runtime (PR #126382)
Midar wrote: Would @rjmccall be the appropriate reviewer? https://github.com/llvm/llvm-project/pull/126382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Allow direct dispatch for the ObjFW runtime (PR #126382)
Midar wrote: Also, would it be possible to get this into 20.1? https://github.com/llvm/llvm-project/pull/126382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Allow direct dispatch for the ObjFW runtime (PR #126382)
Midar wrote: Actually, I realized this needs more work, as GenerateDirectMethodPrologue needs to be implemented. Moving to draft. https://github.com/llvm/llvm-project/pull/126382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Allow direct dispatch for the ObjFW runtime (PR #126382)
https://github.com/Midar converted_to_draft https://github.com/llvm/llvm-project/pull/126382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Allow direct dispatch for the ObjFW runtime (PR #126382)
https://github.com/Midar updated https://github.com/llvm/llvm-project/pull/126382 >From 9b076179061731a647921271e400dbdaea31f60d Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Sat, 8 Feb 2025 12:12:21 +0100 Subject: [PATCH] Allow direct dispatch for the ObjFW runtime >= 1.3 --- clang/include/clang/Basic/ObjCRuntime.h | 3 +- clang/lib/CodeGen/CGObjCGNU.cpp | 211 2 files changed, 106 insertions(+), 108 deletions(-) diff --git a/clang/include/clang/Basic/ObjCRuntime.h b/clang/include/clang/Basic/ObjCRuntime.h index 1ccf60f0b7bee70..a848942b01c02a6 100644 --- a/clang/include/clang/Basic/ObjCRuntime.h +++ b/clang/include/clang/Basic/ObjCRuntime.h @@ -473,7 +473,8 @@ class ObjCRuntime { case GCC: return false; case GNUstep: return (getVersion() >= VersionTuple(2, 2)); -case ObjFW: return false; +case ObjFW: + return (getVersion() >= VersionTuple(1, 3)); } llvm_unreachable("bad kind"); } diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index ebd88bb38849e15..6b5a41eedc97e00 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -2029,112 +2029,6 @@ class CGObjCGNUstep2 : public CGObjCGNUstep { llvm::StructType::get(CGM.getLLVMContext(), { PtrToInt8Ty, PtrToInt8Ty, PtrToInt8Ty, PtrToInt8Ty, PtrToInt8Ty }); } - -void GenerateDirectMethodPrologue(CodeGenFunction &CGF, llvm::Function *Fn, - const ObjCMethodDecl *OMD, - const ObjCContainerDecl *CD) override { - auto &Builder = CGF.Builder; - bool ReceiverCanBeNull = true; - auto selfAddr = CGF.GetAddrOfLocalVar(OMD->getSelfDecl()); - auto selfValue = Builder.CreateLoad(selfAddr); - - // Generate: - // - // /* unless the receiver is never NULL */ - // if (self == nil) { - // return (ReturnType){ }; - // } - // - // /* for class methods only to force class lazy initialization */ - // if (!__objc_{class}_initialized) - // { - // objc_send_initialize(class); - // __objc_{class}_initialized = 1; - // } - // - // _cmd = @selector(...) - // ... - - if (OMD->isClassMethod()) { -const ObjCInterfaceDecl *OID = cast(CD); - -// Nullable `Class` expressions cannot be messaged with a direct method -// so the only reason why the receive can be null would be because -// of weak linking. -ReceiverCanBeNull = isWeakLinkedClass(OID); - } - - llvm::MDBuilder MDHelper(CGM.getLLVMContext()); - if (ReceiverCanBeNull) { -llvm::BasicBlock *SelfIsNilBlock = -CGF.createBasicBlock("objc_direct_method.self_is_nil"); -llvm::BasicBlock *ContBlock = -CGF.createBasicBlock("objc_direct_method.cont"); - -// if (self == nil) { -auto selfTy = cast(selfValue->getType()); -auto Zero = llvm::ConstantPointerNull::get(selfTy); - -Builder.CreateCondBr(Builder.CreateICmpEQ(selfValue, Zero), - SelfIsNilBlock, ContBlock, - MDHelper.createUnlikelyBranchWeights()); - -CGF.EmitBlock(SelfIsNilBlock); - -// return (ReturnType){ }; -auto retTy = OMD->getReturnType(); -Builder.SetInsertPoint(SelfIsNilBlock); -if (!retTy->isVoidType()) { - CGF.EmitNullInitialization(CGF.ReturnValue, retTy); -} -CGF.EmitBranchThroughCleanup(CGF.ReturnBlock); -// } - -// rest of the body -CGF.EmitBlock(ContBlock); -Builder.SetInsertPoint(ContBlock); - } - - if (OMD->isClassMethod()) { -// Prefix of the class type. -auto *classStart = -llvm::StructType::get(PtrTy, PtrTy, PtrTy, LongTy, LongTy); -auto &astContext = CGM.getContext(); -// FIXME: The following few lines up to and including the call to -// `CreateLoad` were known to miscompile when MSVC 19.40.33813 is used -// to build Clang. When the bug is fixed in future MSVC releases, we -// should revert these lines to their previous state. See discussion in -// https://github.com/llvm/llvm-project/pull/102681 -llvm::Value *Val = Builder.CreateStructGEP(classStart, selfValue, 4); -auto Align = CharUnits::fromQuantity( -astContext.getTypeAlign(astContext.UnsignedLongTy)); -auto flags = Builder.CreateLoad(Address{Val, LongTy, Align}); -auto isInitialized = -Builder.CreateAnd(flags, ClassFlags::ClassFlagInitialized); -llvm::BasicBlock *notInitializedBlock = -CGF.createBasicBlock("objc_direct_method.class_uninitialized"); -llvm::BasicBlock *initializedBlock = -CGF.createBasicBlock("objc_direct_method.class_initialized"); -Builder.CreateCondBr(Builder.CreateICmpE
[clang] Allow direct dispatch for the ObjFW runtime (PR #126382)
https://github.com/Midar edited https://github.com/llvm/llvm-project/pull/126382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Allow direct dispatch for the ObjFW runtime >= 1.3 (PR #126382)
https://github.com/Midar edited https://github.com/llvm/llvm-project/pull/126382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Allow direct dispatch for the ObjFW runtime >= 1.3 (PR #126382)
https://github.com/Midar edited https://github.com/llvm/llvm-project/pull/126382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Allow direct dispatch for the ObjFW runtime (PR #126382)
https://github.com/Midar edited https://github.com/llvm/llvm-project/pull/126382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Allow direct dispatch for the ObjFW runtime >= 1.3 (PR #126382)
https://github.com/Midar updated https://github.com/llvm/llvm-project/pull/126382 >From ddc24b92cb8cc629082d0943de0f726a7604241e Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Sat, 8 Feb 2025 12:12:21 +0100 Subject: [PATCH] Allow direct dispatch for the ObjFW runtime --- clang/include/clang/Basic/ObjCRuntime.h | 2 +- clang/lib/CodeGen/CGObjCGNU.cpp | 90 + 2 files changed, 91 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Basic/ObjCRuntime.h b/clang/include/clang/Basic/ObjCRuntime.h index 1ccf60f0b7bee7..df42b438986111 100644 --- a/clang/include/clang/Basic/ObjCRuntime.h +++ b/clang/include/clang/Basic/ObjCRuntime.h @@ -473,7 +473,7 @@ class ObjCRuntime { case GCC: return false; case GNUstep: return (getVersion() >= VersionTuple(2, 2)); -case ObjFW: return false; +case ObjFW: return true; } llvm_unreachable("bad kind"); } diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index ebd88bb38849e1..d2c882122ab087 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -,6 +,96 @@ class CGObjCObjFW: public CGObjCGNU { return ClassSymbol; } + void GenerateDirectMethodPrologue( + CodeGenFunction &CGF, llvm::Function *Fn, const ObjCMethodDecl *OMD, + const ObjCContainerDecl *CD) override { +auto &Builder = CGF.Builder; +bool ReceiverCanBeNull = true; +auto selfAddr = CGF.GetAddrOfLocalVar(OMD->getSelfDecl()); +auto selfValue = Builder.CreateLoad(selfAddr); + +// Generate: +// +// /* for class methods only to force class lazy initialization */ +// self = [self self]; +// +// /* unless the receiver is never NULL */ +// if (self == nil) { +// return (ReturnType){ }; +// } +// +// _cmd = @selector(...) +// ... + +if (OMD->isClassMethod()) { + const ObjCInterfaceDecl *OID = cast(CD); + assert( + OID && + "GenerateDirectMethod() should be called with the Class Interface"); + Selector SelfSel = GetNullarySelector("self", CGM.getContext()); + auto ResultType = CGF.getContext().getObjCIdType(); + RValue result; + CallArgList Args; + + // TODO: If this method is inlined, the caller might know that `self` is + // already initialized; for example, it might be an ordinary Objective-C + // method which always receives an initialized `self`, or it might have + // just forced initialization on its own. + // + // We should find a way to eliminate this unnecessary initialization in + // such cases in LLVM. + result = GeneratePossiblySpecializedMessageSend( + CGF, ReturnValueSlot(), ResultType, SelfSel, selfValue, Args, OID, + nullptr, true); + Builder.CreateStore(result.getScalarVal(), selfAddr); + + // Nullable `Class` expressions cannot be messaged with a direct method + // so the only reason why the receive can be null would be because + // of weak linking. + ReceiverCanBeNull = isWeakLinkedClass(OID); +} + +if (ReceiverCanBeNull) { + llvm::BasicBlock *SelfIsNilBlock = + CGF.createBasicBlock("objc_direct_method.self_is_nil"); + llvm::BasicBlock *ContBlock = + CGF.createBasicBlock("objc_direct_method.cont"); + + // if (self == nil) { + auto selfTy = cast(selfValue->getType()); + auto Zero = llvm::ConstantPointerNull::get(selfTy); + + llvm::MDBuilder MDHelper(CGM.getLLVMContext()); + Builder.CreateCondBr(Builder.CreateICmpEQ(selfValue, Zero), + SelfIsNilBlock, ContBlock, + MDHelper.createUnlikelyBranchWeights()); + + CGF.EmitBlock(SelfIsNilBlock); + + // return (ReturnType){ }; + auto retTy = OMD->getReturnType(); + Builder.SetInsertPoint(SelfIsNilBlock); + if (!retTy->isVoidType()) { +CGF.EmitNullInitialization(CGF.ReturnValue, retTy); + } + CGF.EmitBranchThroughCleanup(CGF.ReturnBlock); + // } + + // rest of the body + CGF.EmitBlock(ContBlock); + Builder.SetInsertPoint(ContBlock); +} + +// only synthesize _cmd if it's referenced +if (OMD->getCmdDecl()->isUsed()) { + // `_cmd` is not a parameter to direct methods, so storage must be + // explicitly declared for it. + CGF.EmitVarDecl(*OMD->getCmdDecl()); + Builder.CreateStore(GetSelector(CGF, OMD), + CGF.GetAddrOfLocalVar(OMD->getCmdDecl())); +} + } + public: CGObjCObjFW(CodeGenModule &Mod): CGObjCGNU(Mod, 9, 3) { // IMP objc_msg_lookup(id, SEL); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Allow direct dispatch for the ObjFW runtime >= 1.3 (PR #126382)
https://github.com/Midar ready_for_review https://github.com/llvm/llvm-project/pull/126382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Allow direct dispatch for the ObjFW runtime >= 1.3 (PR #126382)
Midar wrote: Copied the necessary parts from CGObjCMac to just ObjFW, as GNUstep decided to do it very differently. Theoretically, the same could be done for the GCC runtime. Should it? https://github.com/llvm/llvm-project/pull/126382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Allow direct dispatch for the ObjFW runtime (PR #126382)
Midar wrote: Thanks, that looks like it'll have to wait for 21. https://github.com/llvm/llvm-project/pull/126382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Allow direct dispatch for the ObjFW runtime (PR #126382)
Midar wrote: @rjmccall What's required to get this merged now that it has your LGTM? https://github.com/llvm/llvm-project/pull/126382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Allow direct dispatch for the ObjFW runtime (PR #126382)
Midar wrote: @rjmccall @davidchisnall @ahatanak Could any of you have a look, please? I'd think this is rather straightforward. https://github.com/llvm/llvm-project/pull/126382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Allow direct dispatch for the ObjFW runtime (PR #126382)
@@ -,6 +,96 @@ class CGObjCObjFW: public CGObjCGNU { return ClassSymbol; } + void GenerateDirectMethodPrologue( + CodeGenFunction &CGF, llvm::Function *Fn, const ObjCMethodDecl *OMD, + const ObjCContainerDecl *CD) override { +auto &Builder = CGF.Builder; +bool ReceiverCanBeNull = true; +auto selfAddr = CGF.GetAddrOfLocalVar(OMD->getSelfDecl()); +auto selfValue = Builder.CreateLoad(selfAddr); + +// Generate: +// +// /* for class methods only to force class lazy initialization */ +// self = [self self]; +// +// /* unless the receiver is never NULL */ +// if (self == nil) { +// return (ReturnType){ }; +// } +// +// _cmd = @selector(...) +// ... + +if (OMD->isClassMethod()) { + const ObjCInterfaceDecl *OID = cast(CD); + assert( + OID && + "GenerateDirectMethod() should be called with the Class Interface"); Midar wrote: This is straight up copied from CGObjCMac, so I have no idea why it was done this way :) https://github.com/llvm/llvm-project/pull/126382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Allow direct dispatch for the ObjFW runtime (PR #126382)
Midar wrote: Thanks for merging! Is there a way to get this into 20.1.2? https://github.com/llvm/llvm-project/pull/126382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits