Author: ahatanak Date: Sat Dec 29 09:28:30 2018 New Revision: 350157 URL: http://llvm.org/viewvc/llvm-project?rev=350157&view=rev Log: [CodeGen] Replace '@' characters in block descriptors' symbol names with '\1'.
'@' can't be used in block descriptors' symbol names since it is reserved on ELF platforms as a separator between symbol names and symbol versions. See the discussion here: https://reviews.llvm.org/D50783. Differential Revision: https://reviews.llvm.org/D54539 Added: cfe/trunk/test/CodeGenObjC/block-desc-str.m Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp cfe/trunk/test/CodeGenObjCXX/block-nested-in-lambda.mm Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=350157&r1=350156&r2=350157&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Sat Dec 29 09:28:30 2018 @@ -161,6 +161,9 @@ static std::string getBlockDescriptorNam std::string TypeAtEncoding = CGM.getContext().getObjCEncodingForBlock(BlockInfo.getBlockExpr()); + /// Replace occurrences of '@' with '\1'. '@' is reserved on ELF platforms as + /// a separator between symbol name and symbol version. + std::replace(TypeAtEncoding.begin(), TypeAtEncoding.end(), '@', '\1'); Name += "e" + llvm::to_string(TypeAtEncoding.size()) + "_" + TypeAtEncoding; Name += "l" + CGM.getObjCRuntime().getRCBlockLayoutStr(CGM, BlockInfo); return Name; Added: cfe/trunk/test/CodeGenObjC/block-desc-str.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/block-desc-str.m?rev=350157&view=auto ============================================================================== --- cfe/trunk/test/CodeGenObjC/block-desc-str.m (added) +++ cfe/trunk/test/CodeGenObjC/block-desc-str.m Sat Dec 29 09:28:30 2018 @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-freebsd -emit-llvm -fobjc-runtime=gnustep-1.7 -fblocks -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -fobjc-runtime=gcc -fblocks -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -fblocks -o - %s | FileCheck %s + +// Test that descriptor symbol names don't include '@'. + +// CHECK: @[[STR:.*]] = private unnamed_addr constant [6 x i8] c"v8@?0\00" +// CHECK: @"__block_descriptor_40_8_32o_e5_v8\01?0l" = linkonce_odr hidden unnamed_addr constant { i64, i64, i8*, i8*, i8*, {{.*}} } { i64 0, i64 40, i8* bitcast ({{.*}} to i8*), i8* bitcast ({{.*}} to i8*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @[[STR]], i32 0, i32 0), {{.*}} }, align 8 + +typedef void (^BlockTy)(void); + +void test(id a) { + BlockTy b = ^{ (void)a; }; +} Modified: cfe/trunk/test/CodeGenObjCXX/block-nested-in-lambda.mm URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/block-nested-in-lambda.mm?rev=350157&r1=350156&r2=350157&view=diff ============================================================================== --- cfe/trunk/test/CodeGenObjCXX/block-nested-in-lambda.mm (original) +++ cfe/trunk/test/CodeGenObjCXX/block-nested-in-lambda.mm Sat Dec 29 09:28:30 2018 @@ -35,7 +35,7 @@ void use(id); // CHECK-LABEL: define void @_ZN18CaptureByReference5test0Ev( // CHECK-LABEL: define internal void @"_ZZN18CaptureByReference5test0EvENK3$_1clEv"( // CHECK: %[[BLOCK_DESCRIPTOR:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8** }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8** }>* %{{.*}}, i32 0, i32 4 -// CHECK: store %[[STRUCT_BLOCK_DESCRIPTOR]]* bitcast ({ i64, i64, i8*, i64 }* @"__block_descriptor_40_e5_v8@?0ls32l8" to %[[STRUCT_BLOCK_DESCRIPTOR]]*), %[[STRUCT_BLOCK_DESCRIPTOR]]** %[[BLOCK_DESCRIPTOR]], align 8 +// CHECK: store %[[STRUCT_BLOCK_DESCRIPTOR]]* bitcast ({ i64, i64, i8*, i64 }* @"__block_descriptor_40_e5_v8\01?0ls32l8" to %[[STRUCT_BLOCK_DESCRIPTOR]]*), %[[STRUCT_BLOCK_DESCRIPTOR]]** %[[BLOCK_DESCRIPTOR]], align 8 void test0() { id a = getObj(); @@ -48,7 +48,7 @@ void test0() { // CHECK-LABEL: define void @_ZN18CaptureByReference5test1Ev( // CHECK-LABEL: define internal void @"_ZZN18CaptureByReference5test1EvENK3$_2clEv"( // CHECK: %[[BLOCK_DESCRIPTOR:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8** }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8** }>* %{{.*}}, i32 0, i32 4 -// CHECK: store %[[STRUCT_BLOCK_DESCRIPTOR]]* bitcast ({ i64, i64, i8*, i8*, i8*, i64 }* @"__block_descriptor_56_8_32s40s_e5_v8@?0l" to %[[STRUCT_BLOCK_DESCRIPTOR]]*), %[[STRUCT_BLOCK_DESCRIPTOR]]** %[[BLOCK_DESCRIPTOR]], align 8 +// CHECK: store %[[STRUCT_BLOCK_DESCRIPTOR]]* bitcast ({ i64, i64, i8*, i8*, i8*, i64 }* @"__block_descriptor_56_8_32s40s_e5_v8\01?0l" to %[[STRUCT_BLOCK_DESCRIPTOR]]*), %[[STRUCT_BLOCK_DESCRIPTOR]]** %[[BLOCK_DESCRIPTOR]], align 8 // CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block_8_32s40s( // CHECK-NOT: call void @llvm.objc.storeStrong( _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits