shafik created this revision.
shafik added a reviewer: aprantl.

clang has an extension for block invocations 
<https://github.com/llvm-mirror/llvm/blob/master/include/llvm/Demangle/ItaniumDemangle.h#L5535>
 whose mangled name starts with `___Z`. Currently when generating debug-info 
for block invocations we are setting the `Name` to the mangled name as opposed 
to the `LinkageName`.  This means we see the mangled name for block invcations 
ends up in `DW_AT_Name` as opposed to `DW_AT_linkage_name`.

This patch fixes this case so the `LinkageName` for block invocations is set to 
the mangled name.


https://reviews.llvm.org/D73282

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-block-invocation-linkage-name.cpp


Index: clang/test/CodeGenCXX/debug-info-block-invocation-linkage-name.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-block-invocation-linkage-name.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -fblocks -triple 
%itanium_abi_triple %s -o - | FileCheck %s
+
+// CHECK: !DISubprogram(linkageName: "___Z1fU13block_pointerFviE_block_invoke"
+void g(void (^call)(int));
+
+void f(void (^callback)(int)) {
+  g(^(int x){
+    callback(x);
+  });
+}
+
+void h() {
+  f(^(int x){});
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3656,7 +3656,11 @@
                                      Fn);
   } else {
     // Use llvm function name.
-    Name = Fn->getName();
+    if (Fn->getName().startswith("___Z"))
+      LinkageName = Fn->getName();
+    else
+      Name = Fn->getName();
+
     Flags |= llvm::DINode::FlagPrototyped;
   }
   if (Name.startswith("\01"))


Index: clang/test/CodeGenCXX/debug-info-block-invocation-linkage-name.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-block-invocation-linkage-name.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -fblocks -triple %itanium_abi_triple %s -o - | FileCheck %s
+
+// CHECK: !DISubprogram(linkageName: "___Z1fU13block_pointerFviE_block_invoke"
+void g(void (^call)(int));
+
+void f(void (^callback)(int)) {
+  g(^(int x){
+    callback(x);
+  });
+}
+
+void h() {
+  f(^(int x){});
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3656,7 +3656,11 @@
                                      Fn);
   } else {
     // Use llvm function name.
-    Name = Fn->getName();
+    if (Fn->getName().startswith("___Z"))
+      LinkageName = Fn->getName();
+    else
+      Name = Fn->getName();
+
     Flags |= llvm::DINode::FlagPrototyped;
   }
   if (Name.startswith("\01"))
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to