Skip to content

[clang][DebugInfo] Emit DW_AT_object_pointer on function declarations with explicit this #122928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Michael137
Copy link
Member

In #122897 we started attaching DW_AT_object_pointer to function definitions. This patch does the same but for function declarations (which we do for implicit object pointers already).

Fixes #120974

@Michael137
Copy link
Member Author

Will be rebased on top of #122897

…with explicit `this`

We currently don't emit `DW_AT_object_pointer` on function
declarations or definitions. The DWARFv5 spec doesn't mandate
this attribute be present *only* for implicit object parameters:
```
If the member function entry describes a non-static member function,
then that entry has a DW_AT_object_pointer attribute whose value is a reference to
the formal parameter entry that corresponds to the object for which the
function is called.

That parameter also has a DW_AT_artificial attribute whose value is true.
```

The part about `DW_AT_artificial` seems overly restrictive, and not true for
explicit object parameters. We probably should relax this part of the DWARF spec.

This will help LLDB identify static vs. non-static member functions (see
llvm#120856).

GCC suffers from the same issue: https://godbolt.org/z/h4jeT54G5

Partially fixes llvm#120974
@Michael137 Michael137 force-pushed the clang/explicit-object-pointer-on-declaration branch from b1a937b to 88125a0 Compare January 17, 2025 14:24
@Michael137 Michael137 marked this pull request as ready for review January 17, 2025 14:26
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:codegen IR generation bugs: mangling, exceptions, etc. debuginfo llvm:ir labels Jan 17, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 17, 2025

@llvm/pr-subscribers-llvm-ir
@llvm/pr-subscribers-debuginfo

@llvm/pr-subscribers-clang

Author: Michael Buch (Michael137)

Changes

In #122897 we started attaching DW_AT_object_pointer to function definitions. This patch does the same but for function declarations (which we do for implicit object pointers already).

Fixes #120974


Full diff: https://github.com/llvm/llvm-project/pull/122928.diff

6 Files Affected:

  • (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+15-6)
  • (modified) clang/test/CodeGenCXX/debug-info-object-pointer.cpp (+3-4)
  • (modified) llvm/include/llvm-c/DebugInfo.h (+7-4)
  • (modified) llvm/include/llvm/IR/DIBuilder.h (+3-3)
  • (modified) llvm/lib/IR/DIBuilder.cpp (+6-2)
  • (modified) llvm/lib/IR/DebugInfo.cpp (+5-4)
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index f88f56c98186da..6cbcaf03844102 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2016,13 +2016,15 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
   // First element is always return type. For 'void' functions it is NULL.
   Elts.push_back(Args[0]);
 
-  // "this" pointer is always first argument.
-  // ThisPtr may be null if the member function has an explicit 'this'
-  // parameter.
-  if (!ThisPtr.isNull()) {
+  const bool HasExplicitObjectParameter = ThisPtr.isNull();
+
+  // "this" pointer is always first argument. For explicit "this"
+  // parameters, it will already be in Args[1].
+  if (!HasExplicitObjectParameter) {
     llvm::DIType *ThisPtrType = getOrCreateType(ThisPtr, Unit);
     TypeCache[ThisPtr.getAsOpaquePtr()].reset(ThisPtrType);
-    ThisPtrType = DBuilder.createObjectPointerType(ThisPtrType);
+    ThisPtrType =
+        DBuilder.createObjectPointerType(ThisPtrType, /*Implicit=*/true);
     Elts.push_back(ThisPtrType);
   }
 
@@ -2030,6 +2032,13 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
   for (unsigned i = 1, e = Args.size(); i != e; ++i)
     Elts.push_back(Args[i]);
 
+  // Attach FlagObjectPointer to the explicit "this" parameter.
+  if (HasExplicitObjectParameter) {
+    assert(Elts.size() >= 2 && Args.size() >= 2 &&
+           "Expected at least return type and object parameter.");
+    Elts[1] = DBuilder.createObjectPointerType(Args[1], /*Implicit=*/false);
+  }
+
   llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
 
   return DBuilder.createSubroutineType(EltTypeArray, OriginalFunc->getFlags(),
@@ -5118,7 +5127,7 @@ llvm::DIType *CGDebugInfo::CreateSelfType(const QualType &QualTy,
   llvm::DIType *CachedTy = getTypeOrNull(QualTy);
   if (CachedTy)
     Ty = CachedTy;
-  return DBuilder.createObjectPointerType(Ty);
+  return DBuilder.createObjectPointerType(Ty, /*Implicit=*/true);
 }
 
 void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
diff --git a/clang/test/CodeGenCXX/debug-info-object-pointer.cpp b/clang/test/CodeGenCXX/debug-info-object-pointer.cpp
index 594d4da791ee84..49079f59909968 100644
--- a/clang/test/CodeGenCXX/debug-info-object-pointer.cpp
+++ b/clang/test/CodeGenCXX/debug-info-object-pointer.cpp
@@ -5,12 +5,11 @@
 // CHECK: !DIDerivedType(tag: DW_TAG_pointer_type
 // CHECK-SAME:           flags: DIFlagArtificial | DIFlagObjectPointer
 //
-// // FIXME: DIFlagObjectPointer not attached to the explicit object
-// // argument in the subprogram declaration.
 // CHECK: !DISubprogram(name: "explicit_this",
 //                      flags: DIFlagPrototyped
-// CHECK-NOT: DIFlagObjectPointer
-// CHECK-NOT: DIFlagArtificial
+//
+// CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type
+// CHECK-SAME:           flags: DIFlagObjectPointer)
 //
 // CHECK: !DILocalVariable(name: "this", arg: 1
 // CHECK-SAME:             flags: DIFlagArtificial | DIFlagObjectPointer
diff --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h
index 07f87d44088e7e..ac7ee5a7cc9a19 100644
--- a/llvm/include/llvm-c/DebugInfo.h
+++ b/llvm/include/llvm-c/DebugInfo.h
@@ -870,13 +870,16 @@ LLVMDIBuilderCreateObjCProperty(LLVMDIBuilderRef Builder,
                                 LLVMMetadataRef Ty);
 
 /**
- * Create a uniqued DIType* clone with FlagObjectPointer and FlagArtificial set.
+ * Create a uniqued DIType* clone with FlagObjectPointer. If \c Implicit
+ * is true, then also set FlagArtificial.
  * \param Builder   The DIBuilder.
  * \param Type      The underlying type to which this pointer points.
+ * \param Implicit  Indicates whether this pointer was implicitly generated
+ *                  (i.e., not spelled out in source).
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
-                                     LLVMMetadataRef Type);
+LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
+                                                     LLVMMetadataRef Type,
+                                                     LLVMBool Implicit);
 
 /**
  * Create debugging information entry for a qualified
diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h
index cb1150c269a1da..6c479415b9ed27 100644
--- a/llvm/include/llvm/IR/DIBuilder.h
+++ b/llvm/include/llvm/IR/DIBuilder.h
@@ -662,9 +662,9 @@ namespace llvm {
     /// Create a uniqued clone of \p Ty with FlagArtificial set.
     static DIType *createArtificialType(DIType *Ty);
 
-    /// Create a uniqued clone of \p Ty with FlagObjectPointer and
-    /// FlagArtificial set.
-    static DIType *createObjectPointerType(DIType *Ty);
+    /// Create a uniqued clone of \p Ty with FlagObjectPointer set.
+    /// If \p Implicit is true, also set FlagArtificial.
+    static DIType *createObjectPointerType(DIType *Ty, bool Implicit);
 
     /// Create a permanent forward-declared type.
     DICompositeType *createForwardDecl(unsigned Tag, StringRef Name,
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index b240a2a39de362..d9bd4f11e89a39 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -644,11 +644,15 @@ DIType *DIBuilder::createArtificialType(DIType *Ty) {
   return createTypeWithFlags(Ty, DINode::FlagArtificial);
 }
 
-DIType *DIBuilder::createObjectPointerType(DIType *Ty) {
+DIType *DIBuilder::createObjectPointerType(DIType *Ty, bool Implicit) {
   // FIXME: Restrict this to the nodes where it's valid.
   if (Ty->isObjectPointer())
     return Ty;
-  DINode::DIFlags Flags = DINode::FlagObjectPointer | DINode::FlagArtificial;
+  DINode::DIFlags Flags = DINode::FlagObjectPointer;
+
+  if (Implicit)
+    Flags |= DINode::FlagArtificial;
+
   return createTypeWithFlags(Ty, Flags);
 }
 
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index e5b45e0082a823..4ce518009bd3ea 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -1432,10 +1432,11 @@ LLVMDIBuilderCreateObjCProperty(LLVMDIBuilderRef Builder,
                   PropertyAttributes, unwrapDI<DIType>(Ty)));
 }
 
-LLVMMetadataRef
-LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
-                                     LLVMMetadataRef Type) {
-  return wrap(unwrap(Builder)->createObjectPointerType(unwrapDI<DIType>(Type)));
+LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
+                                                     LLVMMetadataRef Type,
+                                                     LLVMBool Implicit) {
+  return wrap(unwrap(Builder)->createObjectPointerType(unwrapDI<DIType>(Type),
+                                                       Implicit));
 }
 
 LLVMMetadataRef

@llvmbot
Copy link
Member

llvmbot commented Jan 17, 2025

@llvm/pr-subscribers-clang-codegen

Author: Michael Buch (Michael137)

Changes

In #122897 we started attaching DW_AT_object_pointer to function definitions. This patch does the same but for function declarations (which we do for implicit object pointers already).

Fixes #120974


Full diff: https://github.com/llvm/llvm-project/pull/122928.diff

6 Files Affected:

  • (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+15-6)
  • (modified) clang/test/CodeGenCXX/debug-info-object-pointer.cpp (+3-4)
  • (modified) llvm/include/llvm-c/DebugInfo.h (+7-4)
  • (modified) llvm/include/llvm/IR/DIBuilder.h (+3-3)
  • (modified) llvm/lib/IR/DIBuilder.cpp (+6-2)
  • (modified) llvm/lib/IR/DebugInfo.cpp (+5-4)
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index f88f56c98186da..6cbcaf03844102 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2016,13 +2016,15 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
   // First element is always return type. For 'void' functions it is NULL.
   Elts.push_back(Args[0]);
 
-  // "this" pointer is always first argument.
-  // ThisPtr may be null if the member function has an explicit 'this'
-  // parameter.
-  if (!ThisPtr.isNull()) {
+  const bool HasExplicitObjectParameter = ThisPtr.isNull();
+
+  // "this" pointer is always first argument. For explicit "this"
+  // parameters, it will already be in Args[1].
+  if (!HasExplicitObjectParameter) {
     llvm::DIType *ThisPtrType = getOrCreateType(ThisPtr, Unit);
     TypeCache[ThisPtr.getAsOpaquePtr()].reset(ThisPtrType);
-    ThisPtrType = DBuilder.createObjectPointerType(ThisPtrType);
+    ThisPtrType =
+        DBuilder.createObjectPointerType(ThisPtrType, /*Implicit=*/true);
     Elts.push_back(ThisPtrType);
   }
 
@@ -2030,6 +2032,13 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
   for (unsigned i = 1, e = Args.size(); i != e; ++i)
     Elts.push_back(Args[i]);
 
+  // Attach FlagObjectPointer to the explicit "this" parameter.
+  if (HasExplicitObjectParameter) {
+    assert(Elts.size() >= 2 && Args.size() >= 2 &&
+           "Expected at least return type and object parameter.");
+    Elts[1] = DBuilder.createObjectPointerType(Args[1], /*Implicit=*/false);
+  }
+
   llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
 
   return DBuilder.createSubroutineType(EltTypeArray, OriginalFunc->getFlags(),
@@ -5118,7 +5127,7 @@ llvm::DIType *CGDebugInfo::CreateSelfType(const QualType &QualTy,
   llvm::DIType *CachedTy = getTypeOrNull(QualTy);
   if (CachedTy)
     Ty = CachedTy;
-  return DBuilder.createObjectPointerType(Ty);
+  return DBuilder.createObjectPointerType(Ty, /*Implicit=*/true);
 }
 
 void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
diff --git a/clang/test/CodeGenCXX/debug-info-object-pointer.cpp b/clang/test/CodeGenCXX/debug-info-object-pointer.cpp
index 594d4da791ee84..49079f59909968 100644
--- a/clang/test/CodeGenCXX/debug-info-object-pointer.cpp
+++ b/clang/test/CodeGenCXX/debug-info-object-pointer.cpp
@@ -5,12 +5,11 @@
 // CHECK: !DIDerivedType(tag: DW_TAG_pointer_type
 // CHECK-SAME:           flags: DIFlagArtificial | DIFlagObjectPointer
 //
-// // FIXME: DIFlagObjectPointer not attached to the explicit object
-// // argument in the subprogram declaration.
 // CHECK: !DISubprogram(name: "explicit_this",
 //                      flags: DIFlagPrototyped
-// CHECK-NOT: DIFlagObjectPointer
-// CHECK-NOT: DIFlagArtificial
+//
+// CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type
+// CHECK-SAME:           flags: DIFlagObjectPointer)
 //
 // CHECK: !DILocalVariable(name: "this", arg: 1
 // CHECK-SAME:             flags: DIFlagArtificial | DIFlagObjectPointer
diff --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h
index 07f87d44088e7e..ac7ee5a7cc9a19 100644
--- a/llvm/include/llvm-c/DebugInfo.h
+++ b/llvm/include/llvm-c/DebugInfo.h
@@ -870,13 +870,16 @@ LLVMDIBuilderCreateObjCProperty(LLVMDIBuilderRef Builder,
                                 LLVMMetadataRef Ty);
 
 /**
- * Create a uniqued DIType* clone with FlagObjectPointer and FlagArtificial set.
+ * Create a uniqued DIType* clone with FlagObjectPointer. If \c Implicit
+ * is true, then also set FlagArtificial.
  * \param Builder   The DIBuilder.
  * \param Type      The underlying type to which this pointer points.
+ * \param Implicit  Indicates whether this pointer was implicitly generated
+ *                  (i.e., not spelled out in source).
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
-                                     LLVMMetadataRef Type);
+LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
+                                                     LLVMMetadataRef Type,
+                                                     LLVMBool Implicit);
 
 /**
  * Create debugging information entry for a qualified
diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h
index cb1150c269a1da..6c479415b9ed27 100644
--- a/llvm/include/llvm/IR/DIBuilder.h
+++ b/llvm/include/llvm/IR/DIBuilder.h
@@ -662,9 +662,9 @@ namespace llvm {
     /// Create a uniqued clone of \p Ty with FlagArtificial set.
     static DIType *createArtificialType(DIType *Ty);
 
-    /// Create a uniqued clone of \p Ty with FlagObjectPointer and
-    /// FlagArtificial set.
-    static DIType *createObjectPointerType(DIType *Ty);
+    /// Create a uniqued clone of \p Ty with FlagObjectPointer set.
+    /// If \p Implicit is true, also set FlagArtificial.
+    static DIType *createObjectPointerType(DIType *Ty, bool Implicit);
 
     /// Create a permanent forward-declared type.
     DICompositeType *createForwardDecl(unsigned Tag, StringRef Name,
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index b240a2a39de362..d9bd4f11e89a39 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -644,11 +644,15 @@ DIType *DIBuilder::createArtificialType(DIType *Ty) {
   return createTypeWithFlags(Ty, DINode::FlagArtificial);
 }
 
-DIType *DIBuilder::createObjectPointerType(DIType *Ty) {
+DIType *DIBuilder::createObjectPointerType(DIType *Ty, bool Implicit) {
   // FIXME: Restrict this to the nodes where it's valid.
   if (Ty->isObjectPointer())
     return Ty;
-  DINode::DIFlags Flags = DINode::FlagObjectPointer | DINode::FlagArtificial;
+  DINode::DIFlags Flags = DINode::FlagObjectPointer;
+
+  if (Implicit)
+    Flags |= DINode::FlagArtificial;
+
   return createTypeWithFlags(Ty, Flags);
 }
 
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index e5b45e0082a823..4ce518009bd3ea 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -1432,10 +1432,11 @@ LLVMDIBuilderCreateObjCProperty(LLVMDIBuilderRef Builder,
                   PropertyAttributes, unwrapDI<DIType>(Ty)));
 }
 
-LLVMMetadataRef
-LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
-                                     LLVMMetadataRef Type) {
-  return wrap(unwrap(Builder)->createObjectPointerType(unwrapDI<DIType>(Type)));
+LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
+                                                     LLVMMetadataRef Type,
+                                                     LLVMBool Implicit) {
+  return wrap(unwrap(Builder)->createObjectPointerType(unwrapDI<DIType>(Type),
+                                                       Implicit));
 }
 
 LLVMMetadataRef

Copy link
Collaborator

@dwblaikie dwblaikie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK to me.

@Michael137 Michael137 merged commit 10fdd09 into llvm:main Jan 17, 2025
14 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 17, 2025

LLVM Buildbot has detected a new failure on builder clang-x86_64-debian-fast running on gribozavr4 while building clang,llvm at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/56/builds/16520

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
  /// \returns \c nullptr if this \p Record should be skipped, or a pointer to
      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 warnings generated.
22.694 [2055/96/3946] Copying llvm_debuginfo.ml to build area
22.713 [2054/96/3947] Copying llvm_debuginfo.mli to build area
22.718 [2053/96/3948] Building OCaml stub object file bitreader_ocaml.o
22.721 [2052/96/3949] Copying debuginfo_ocaml.c to build area
22.735 [2051/96/3950] Building OCaml stub object file analysis_ocaml.o
22.743 [2050/96/3951] Building OCaml stub object file bitwriter_ocaml.o
22.787 [2049/96/3952] Building OCaml stub object file debuginfo_ocaml.o
FAILED: bindings/ocaml/debuginfo/debuginfo_ocaml.o /b/1/clang-x86_64-debian-fast/llvm.obj/bindings/ocaml/debuginfo/debuginfo_ocaml.o 
cd /b/1/clang-x86_64-debian-fast/llvm.obj/bindings/ocaml/debuginfo && /usr/bin/ocamlfind ocamlc -c /b/1/clang-x86_64-debian-fast/llvm.obj/bindings/ocaml/debuginfo/debuginfo_ocaml.c -ccopt "-I/b/1/clang-x86_64-debian-fast/llvm.src/llvm/bindings/ocaml/debuginfo/../llvm -D_GNU_SOURCE -D_DEBUG -D_GLIBCXX_ASSERTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/1/clang-x86_64-debian-fast/llvm.obj/include -I/b/1/clang-x86_64-debian-fast/llvm.src/llvm/include  -DNDEBUG "
/b/1/clang-x86_64-debian-fast/llvm.obj/bindings/ocaml/debuginfo/debuginfo_ocaml.c: In function ‘llvm_dibuild_create_object_pointer_type’:
/b/1/clang-x86_64-debian-fast/llvm.obj/bindings/ocaml/debuginfo/debuginfo_ocaml.c:620:30: error: too few arguments to function ‘LLVMDIBuilderCreateObjectPointerType’
  620 |   LLVMMetadataRef Metadata = LLVMDIBuilderCreateObjectPointerType(
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /b/1/clang-x86_64-debian-fast/llvm.obj/bindings/ocaml/debuginfo/debuginfo_ocaml.c:23:
/b/1/clang-x86_64-debian-fast/llvm.src/llvm/include/llvm-c/DebugInfo.h:880:17: note: declared here
  880 | LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22.795 [2049/95/3953] Building OCaml library llvm_analysis
22.795 [2049/94/3954] Building OCaml library llvm_bitreader
22.822 [2049/93/3955] Building OCaml library llvm_bitwriter
22.840 [2049/92/3956] Building CXX object lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/MachineOutliner.cpp.o
22.848 [2049/91/3957] Building CXX object tools/clang/lib/ARCMigrate/CMakeFiles/obj.clangARCMigrate.dir/ObjCMT.cpp.o
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/lib/ARCMigrate/ObjCMT.cpp:9:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/lib/ARCMigrate/Transforms.h:13:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/RecursiveASTVisitor.h:17:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/Attr.h:18:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/Decl.h:17:
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/APValue.h:370:14: warning: parameter 'UninitArray' not found in the function declaration [-Wdocumentation]
  /// \param UninitArray Marker. Pass an empty UninitArray.
             ^~~~~~~~~~~
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/APValue.h:378:14: warning: parameter 'UninitStruct' not found in the function declaration [-Wdocumentation]
  /// \param UninitStruct Marker. Pass an empty UninitStruct.
             ^~~~~~~~~~~~
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/lib/ARCMigrate/ObjCMT.cpp:9:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/lib/ARCMigrate/Transforms.h:13:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/RecursiveASTVisitor.h:17:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/Attr.h:18:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/Decl.h:22:
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/ExternalASTSource.h:165:39: warning: empty paragraph passed to '\param' command [-Wdocumentation]
  /// specializations for the \param D.
                              ~~~~~~~~^
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/ExternalASTSource.h:165:38: warning: parameter 'D.' not found in the function declaration [-Wdocumentation]
  /// specializations for the \param D.
                                     ^~
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/ExternalASTSource.h:171:44: warning: empty paragraph passed to '\param' command [-Wdocumentation]
  /// args specified by \param TemplateArgs.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 17, 2025

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-expensive-checks-debian running on gribozavr4 while building clang,llvm at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/16/builds/12191

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
16.564 [831/29/3161] Copying llvm_debuginfo.ml to build area
16.564 [831/28/3162] Copying debuginfo_ocaml.c to build area
16.564 [830/28/3163] Copying llvm_irreader.ml to build area
16.564 [830/27/3164] Copying llvm_irreader.mli to build area
16.564 [830/26/3165] Copying irreader_ocaml.c to build area
16.564 [829/26/3166] Copying llvm_target.mli to build area
16.564 [829/25/3167] Copying llvm_target.ml to build area
16.564 [829/24/3168] Copying target_ocaml.c to build area
16.595 [828/24/3169] Building OCaml stub object file irreader_ocaml.o
16.595 [827/24/3170] Building OCaml stub object file debuginfo_ocaml.o
FAILED: bindings/ocaml/debuginfo/debuginfo_ocaml.o /b/1/llvm-clang-x86_64-expensive-checks-debian/build/bindings/ocaml/debuginfo/debuginfo_ocaml.o 
cd /b/1/llvm-clang-x86_64-expensive-checks-debian/build/bindings/ocaml/debuginfo && /usr/bin/ocamlfind ocamlc -c /b/1/llvm-clang-x86_64-expensive-checks-debian/build/bindings/ocaml/debuginfo/debuginfo_ocaml.c -ccopt "-I/b/1/llvm-clang-x86_64-expensive-checks-debian/llvm-project/llvm/bindings/ocaml/debuginfo/../llvm -D_GNU_SOURCE -D_DEBUG -D_GLIBCXX_ASSERTIONS -DEXPENSIVE_CHECKS -D_GLIBCXX_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/1/llvm-clang-x86_64-expensive-checks-debian/build/include -I/b/1/llvm-clang-x86_64-expensive-checks-debian/llvm-project/llvm/include  -DNDEBUG "
/b/1/llvm-clang-x86_64-expensive-checks-debian/build/bindings/ocaml/debuginfo/debuginfo_ocaml.c: In function ‘llvm_dibuild_create_object_pointer_type’:
/b/1/llvm-clang-x86_64-expensive-checks-debian/build/bindings/ocaml/debuginfo/debuginfo_ocaml.c:620:30: error: too few arguments to function ‘LLVMDIBuilderCreateObjectPointerType’
  620 |   LLVMMetadataRef Metadata = LLVMDIBuilderCreateObjectPointerType(
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /b/1/llvm-clang-x86_64-expensive-checks-debian/build/bindings/ocaml/debuginfo/debuginfo_ocaml.c:23:
/b/1/llvm-clang-x86_64-expensive-checks-debian/llvm-project/llvm/include/llvm-c/DebugInfo.h:880:17: note: declared here
  880 | LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16.598 [827/23/3171] Building OCaml stub object file bitreader_ocaml.o
16.598 [827/22/3172] Building OCaml stub object file bitwriter_ocaml.o
16.598 [827/21/3173] Building AMDGPUGenRegBankGICombiner.inc...
16.600 [827/20/3174] Building OCaml stub object file analysis_ocaml.o
16.628 [827/19/3175] Building OCaml library llvm_irreader
16.642 [827/18/3176] Building OCaml stub object file target_ocaml.o
16.644 [827/17/3177] Building CXX object lib/Transforms/IPO/CMakeFiles/LLVMipo.dir/IROutliner.cpp.o
17.237 [827/16/3178] Building CXX object lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/MachineOutliner.cpp.o
17.493 [827/15/3179] Building CXX object lib/Transforms/Utils/CMakeFiles/LLVMTransformUtils.dir/Local.cpp.o
19.945 [827/14/3180] Building CXX object lib/Transforms/Scalar/CMakeFiles/LLVMScalarOpts.dir/SROA.cpp.o
20.100 [827/13/3181] Building CXX object lib/Transforms/InstCombine/CMakeFiles/LLVMInstCombine.dir/InstructionCombining.cpp.o
20.389 [827/12/3182] Building CXX object lib/CodeGen/AsmPrinter/CMakeFiles/LLVMAsmPrinter.dir/AsmPrinter.cpp.o
21.118 [827/11/3183] Building CXX object lib/LTO/CMakeFiles/LLVMLTO.dir/LTO.cpp.o
23.807 [827/10/3184] Building RISCVGenSubtargetInfo.inc...
24.224 [827/9/3185] Building AMDGPUGenAsmWriter.inc...
24.666 [827/8/3186] Building X86GenAsmMatcher.inc...
24.691 [827/7/3187] Building CXX object lib/Frontend/OpenMP/CMakeFiles/LLVMFrontendOpenMP.dir/OMPIRBuilder.cpp.o
25.858 [827/6/3188] Building AMDGPUGenInstrInfo.inc...
26.205 [827/5/3189] Building AMDGPUGenGlobalISel.inc...
26.968 [827/4/3190] Building AMDGPUGenDAGISel.inc...
29.373 [827/3/3191] Building AMDGPUGenRegisterBank.inc...
30.843 [827/2/3192] Building AMDGPUGenRegisterInfo.inc...
36.015 [827/1/3193] Building AMDGPUGenAsmMatcher.inc...
ninja: build stopped: subcommand failed.

@mgorny
Copy link
Member

mgorny commented Jan 18, 2025

I'm going to revert because of the buildbot failures.

mgorny added a commit that referenced this pull request Jan 18, 2025
github-actions bot pushed a commit to arm/arm-toolchain that referenced this pull request Jan 18, 2025
@Michael137
Copy link
Member Author

@mgorny thanks for the ping. I relanded in a5fb2bb. Confirmed that the OCaml bindings build and tests pass.

@mgorny
Copy link
Member

mgorny commented Jan 18, 2025

Thanks!

junlarsen added a commit to junlarsen/llvm-project that referenced this pull request Jan 23, 2025
…compatability

llvm#122928 Introduces a change to the C DebugInfo API which breaks compatability with older versions. This patch proposes the same functionality through a new function instead.

I'm not that familiar with Clang development, but from how things are described in the original patch (and its parent) it seems like it should be an avoidable breakage.
@junlarsen
Copy link
Member

This causes a breaking change in the C-API which I believe can easily be avoided. I've submitted #124144 as a suggestion to keep compatability

@Michael137
Copy link
Member Author

Michael137 commented Jan 23, 2025

This causes a breaking change in the C-API which I believe can easily be avoided. I've submitted #124144 as a suggestion to keep compatability

Yea that's not unexpected, since the APIs are not stable/are experimental. I commented on the PR and CC'd Paul who might have an opinion on this

@junlarsen
Copy link
Member

junlarsen commented Jan 23, 2025

Thanks, I'm not very opinionated on it, but since a lot of libraries in various languages rely on the C API I think it's fair to keep compatible if it makes sense

@pogo59
Copy link
Collaborator

pogo59 commented Jan 23, 2025

The C API must remain stable and backward compatible. It's the C++ APIs that we are willing to change without worrying.

@Michael137
Copy link
Member Author

Michael137 commented Jan 23, 2025

The C API must remain stable and backward compatible. It's the C++ APIs that we are willing to change without worrying.

In that case should we adjust the documentation in the header?

//===----------------------------------------------------------------------===//
///
/// This file declares the C API endpoints for generating DWARF Debug Info
///
/// Note: This interface is experimental. It is *NOT* stable, and may be
/// changed without warning.
///
//===----------------------------------------------------------------------===//

I was changing these without worrying about compatibility precisely due to this comment

@dwblaikie
Copy link
Collaborator

yeah, I was going to say - thought we carved out part (the debug info part, maybe some other things - ORC?) of the C API as unstable, so I'm OK continuing with that (lack of) guarantee...

@pogo59
Copy link
Collaborator

pogo59 commented Jan 23, 2025

Aha. I didn't know or had forgotten about the exception. The breakage isn't great but is allowed.

@junlarsen
Copy link
Member

I wasn't aware of that exception either, so my apologies there. I still think it's fair policy to keep things as compatible if easily possible though.

abidh pushed a commit to abidh/llvm-project that referenced this pull request Feb 4, 2025
… with explicit `this` (llvm#122928)

In llvm#122897 we started attaching
`DW_AT_object_pointer` to function definitions. This patch does the same
but for function declarations (which we do for implicit object pointers
already).

Fixes llvm#120974
abidh pushed a commit to abidh/llvm-project that referenced this pull request Feb 4, 2025
…erm/restore-10fdd09c3bda

reland: 10fdd09 [clang][DebugInfo] Emit DW_AT_object_pointer on function declarations with explicit `this` (llvm#122928)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen IR generation bugs: mangling, exceptions, etc. clang Clang issues not falling into any other category debuginfo llvm:ir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DebugInfo] DW_AT_object_pointer not emitted for explicit object parameter
7 participants