[clang] 314b927 - Revert "[CGBlocks] Improve line info in backtraces containing *_helper_block"

Adrian Prantl via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 5 09:58:57 PST 2020


Author: Adrian Prantl
Date: 2020-03-05T09:58:42-08:00
New Revision: 314b9278f0975b12e15d6e12f896eaf7c4519ef2

URL: https://github.com/llvm/llvm-project/commit/314b9278f0975b12e15d6e12f896eaf7c4519ef2
DIFF: https://github.com/llvm/llvm-project/commit/314b9278f0975b12e15d6e12f896eaf7c4519ef2.diff

LOG: Revert "[CGBlocks] Improve line info in backtraces containing *_helper_block"

Block copy/destroy helpers are now linkonce_odr functions, meant to be uniqued, and thus attaching debug information from one translation unit (or even just from one instance of many inside one translation unit) would be misleading and wrong in the general case.

This effectively reverts commit 9c6b6826ce3720ca8bb9bd15f3abf71261e6b911.

<rdar://problem/59137040>

Differential Revision: https://reviews.llvm.org/D75615

Added: 
    

Modified: 
    clang/lib/CodeGen/CGBlocks.cpp
    clang/test/CodeGenObjC/debug-info-blocks.m

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 33fad77eb4da..9ec37385c4a7 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -2032,11 +2032,13 @@ CodeGenFunction::GenerateCopyHelperFunction(const CGBlockInfo &blockInfo) {
   FunctionDecl *FD = FunctionDecl::Create(
       C, C.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), II,
       FunctionTy, nullptr, SC_Static, false, false);
-
   setBlockHelperAttributesVisibility(blockInfo.CapturesNonExternalType, Fn, FI,
                                      CGM);
+  // This is necessary to avoid inheriting the previous line number.
+  FD->setImplicit();
   StartFunction(FD, ReturnTy, Fn, FI, args);
-  ApplyDebugLocation NL{*this, blockInfo.getBlockExpr()->getBeginLoc()};
+  auto AL = ApplyDebugLocation::CreateArtificial(*this);
+
   llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
 
   Address src = GetAddrOfLocalVar(&SrcDecl);
@@ -2227,10 +2229,12 @@ CodeGenFunction::GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo) {
 
   setBlockHelperAttributesVisibility(blockInfo.CapturesNonExternalType, Fn, FI,
                                      CGM);
+  // This is necessary to avoid inheriting the previous line number.
+  FD->setImplicit();
   StartFunction(FD, ReturnTy, Fn, FI, args);
   markAsIgnoreThreadCheckingAtRuntime(Fn);
 
-  ApplyDebugLocation NL{*this, blockInfo.getBlockExpr()->getBeginLoc()};
+  auto AL = ApplyDebugLocation::CreateArtificial(*this);
 
   llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
 

diff  --git a/clang/test/CodeGenObjC/debug-info-blocks.m b/clang/test/CodeGenObjC/debug-info-blocks.m
index 9204f8d56c07..257045b05c32 100644
--- a/clang/test/CodeGenObjC/debug-info-blocks.m
+++ b/clang/test/CodeGenObjC/debug-info-blocks.m
@@ -17,13 +17,17 @@
 // CHECK-NOT: ret
 // CHECK: call {{.*}}, !dbg ![[DBG_LINE:[0-9]+]]
 // CHECK-NOT: ret
-// CHECK: load {{.*}}, !dbg ![[COPY_LINE:[0-9]+]]
-// CHECK: ret void, !dbg ![[COPY_LINE]]
-// CHECK: define {{.*}} @__destroy_helper_block_{{.*}}(i8* %0)
+// CHECK: load {{.*}}, !dbg ![[DBG_LINE]]
+// CHECK: ret {{.*}}, !dbg ![[DBG_LINE]]
+// CHECK: define {{.*}} @__destroy_helper_block_{{.*}}(i8*
 // CHECK-NOT: ret
 // CHECK: load {{.*}}, !dbg ![[DESTROY_LINE:[0-9]+]]
-// CHECK: ret void, !dbg ![[DESTROY_LINE]]
+// CHECK: ret {{.*}}, !dbg ![[DESTROY_LINE]]
 
+// CHECK-DAG: [[DBG_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
+// CHECK-DAG: [[COPY_SP]] = distinct !DISubprogram(name: "__copy_helper_block_
+// CHECK-DAG: [[DESTROY_LINE]] = !DILocation(line: 0, scope: ![[DESTROY_SP:[0-9]+]])
+// CHECK-DAG: [[DESTROY_SP]] = distinct !DISubprogram(name: "__destroy_helper_block_
 typedef unsigned int NSUInteger;
 
 @protocol NSObject
@@ -57,11 +61,6 @@ @implementation A
 - (id)init
 {
     if ((self = [super init])) {
-      // CHECK-DAG: [[DBG_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
-      // CHECK-DAG: [[COPY_LINE]] = !DILocation(line: [[@LINE+7]], scope: ![[COPY_SP:[0-9]+]])
-      // CHECK-DAG: [[COPY_SP]] = distinct !DISubprogram(name: "__copy_helper_block_8_32o"
-      // CHECK-DAG: [[DESTROY_LINE]] = !DILocation(line: [[@LINE+5]], scope: ![[DESTROY_SP:[0-9]+]])
-      // CHECK-DAG: [[DESTROY_SP]] = distinct !DISubprogram(name: "__destroy_helper_block_8_32o"
       // CHECK-DAG: !DILocalVariable(arg: 1, scope: ![[COPY_SP]], {{.*}}, flags: DIFlagArtificial)
       // CHECK-DAG: !DILocalVariable(arg: 2, scope: ![[COPY_SP]], {{.*}}, flags: DIFlagArtificial)
       // CHECK-DAG: !DILocalVariable(arg: 1, scope: ![[DESTROY_SP]], {{.*}}, flags: DIFlagArtificial)


        


More information about the cfe-commits mailing list