r329882 - ObjCGNU: Fix empty v3 protocols being emitted two fields short

David Chisnall via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 12 00:36:59 PDT 2018


It does seem to be.  I used arc to apply the change, so I’m not sure what happened - I thought it normally set the author correctly.

David

> On 12 Apr 2018, at 08:09, Shoaib Meenai <smeenai at fb.com> wrote:
> 
> This is missing an attribution of changes, right?
>  
> From: cfe-commits <cfe-commits-bounces at lists.llvm.org> on behalf of David Chisnall via cfe-commits <cfe-commits at lists.llvm.org>
> Reply-To: David Chisnall <csdavec at swan.ac.uk>
> Date: Wednesday, April 11, 2018 at 11:49 PM
> To: "cfe-commits at lists.llvm.org" <cfe-commits at lists.llvm.org>
> Subject: r329882 - ObjCGNU: Fix empty v3 protocols being emitted two fields short
>  
> Author: theraven
> Date: Wed Apr 11 23:46:15 2018
> New Revision: 329882
>  
> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D329882-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=kOSrBx9BPwaPzisR4ZjTMKz416HW7XRohfwPXtT5O9E&s=69tkdQlTNiO-wOTuNHO7a35iqDVy9hW6Jrw-hSq_q6s&e=
> Log:
> ObjCGNU: Fix empty v3 protocols being emitted two fields short
>  
> Summary:
> Protocols that were being referenced but could not be fully realized were being emitted without `properties`/`optional_properties`. Since all v3 protocols must be 9 processor words wide, the lack of these fields is catastrophic for the runtime.
>  
> As an example, the runtime cannot know [here](https://github.com/gnustep/libobjc2/blob/master/protocol.c#L73) that `properties` and `optional_properties` are invalid.
>  
> Reviewers: rjmccall, theraven
>  
> Reviewed By: rjmccall, theraven
>  
> Subscribers: cfe-commits
>  
> Tags: #clang
>  
> Differential Revision: https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D45305&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=kOSrBx9BPwaPzisR4ZjTMKz416HW7XRohfwPXtT5O9E&s=JoyP68pCdLsffM8xX9NMx9VXafshpTnxECegbsdc4rc&e=
>  
> Added:
>     cfe/trunk/test/CodeGenObjC/gnu-empty-protocol-v3.m
> Modified:
>     cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
>  
> Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_CodeGen_CGObjCGNU.cpp-3Frev-3D329882-26r1-3D329881-26r2-3D329882-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=kOSrBx9BPwaPzisR4ZjTMKz416HW7XRohfwPXtT5O9E&s=v2_iviP5qFoN3SvBUJtLVbxpLsyewCRlyAbxv96yJiI&e=
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Wed Apr 11 23:46:15 2018
> @@ -1748,11 +1748,13 @@ CGObjCGNU::GenerateEmptyProtocol(const s
>            llvm::ConstantInt::get(Int32Ty, ProtocolVersion), IdTy));
>    Elements.add(MakeConstantString(ProtocolName, ".objc_protocol_name"));
> -  Elements.add(ProtocolList);
> -  Elements.add(MethodList);
> -  Elements.add(MethodList);
> -  Elements.add(MethodList);
> -  Elements.add(MethodList);
> +  Elements.add(ProtocolList); /* .protocol_list */
> +  Elements.add(MethodList);   /* .instance_methods */
> +  Elements.add(MethodList);   /* .class_methods */
> +  Elements.add(MethodList);   /* .optional_instance_methods */
> +  Elements.add(MethodList);   /* .optional_class_methods */
> +  Elements.add(NULLPtr);      /* .properties */
> +  Elements.add(NULLPtr);      /* .optional_properties */
>    return Elements.finishAndCreateGlobal(".objc_protocol",
>                                          CGM.getPointerAlign());
> }
>  
> Added: cfe/trunk/test/CodeGenObjC/gnu-empty-protocol-v3.m
> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_test_CodeGenObjC_gnu-2Dempty-2Dprotocol-2Dv3.m-3Frev-3D329882-26view-3Dauto&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=kOSrBx9BPwaPzisR4ZjTMKz416HW7XRohfwPXtT5O9E&s=arR3-NaqV7bUw3lmGH8VA1UAMCgPZ2Xf4Zbn-tKJY-A&e=
> ==============================================================================
> --- cfe/trunk/test/CodeGenObjC/gnu-empty-protocol-v3.m (added)
> +++ cfe/trunk/test/CodeGenObjC/gnu-empty-protocol-v3.m Wed Apr 11 23:46:15 2018
> @@ -0,0 +1,25 @@
> +// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fobjc-runtime=gnustep-1.9 -emit-llvm -o - %s | FileCheck %s
> +
> + at protocol X;
> +
> +__attribute__((objc_root_class))
> + at interface Z <X>
> + at end
> +
> + at implementation Z
> + at end
> +
> +// CHECK:      @.objc_protocol_list = internal global { i8*, i32, [0 x i8*] } zeroinitializer, align 4
> +// CHECK:      @.objc_method_list = internal global { i32, [0 x { i8*, i8* }] } zeroinitializer, align 4
> +// CHECK:      @.objc_protocol_name = private unnamed_addr constant [2 x i8] c"X\00", align 1
> +// CHECK:      @.objc_protocol = internal global { i8*, i8*, { i8*, i32, [0 x i8*] }*, { i32, [0 x { i8*, i8* }] }*, { i32, [0 x { i8*, i8* }] }*, { i32, [0 x { i8*, i8* }] }*, { i32, [0 x { i8*, i8* }] }*, i8*, i8* } {
> +// CHECK-SAME:     i8* inttoptr (i32 3 to i8*),
> +// CHECK-SAME:     i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.objc_protocol_name, i32 0, i32 0),
> +// CHECK-SAME:     { i8*, i32, [0 x i8*] }* @.objc_protocol_list,
> +// CHECK-SAME:     { i32, [0 x { i8*, i8* }] }* @.objc_method_list,
> +// CHECK-SAME:     { i32, [0 x { i8*, i8* }] }* @.objc_method_list,
> +// CHECK-SAME:     { i32, [0 x { i8*, i8* }] }* @.objc_method_list,
> +// CHECK-SAME:     { i32, [0 x { i8*, i8* }] }* @.objc_method_list,
> +// CHECK-SAME:     i8* null,
> +// CHECK-SAME:     i8* null
> +// CHECK-SAME: }, align 4
>  
>  
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Dcommits&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=kOSrBx9BPwaPzisR4ZjTMKz416HW7XRohfwPXtT5O9E&s=Q1HFYy3TTBlWcfbxZ9gbB5ZIaEkI9A-mieMWoI2qrOM&e=



More information about the cfe-commits mailing list