Reapply "[clang][DebugInfo] Emit DW_AT_object_pointer on function declarations with explicit this
" (#123455)
This reverts commit c3a935e3f967f8f22f5db240d145459ee621c1e0. The only change to the reverted commit is that this also updates the OCaml bindings according to the C debug-info API changes. The build failure originally introduced was: ``` 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, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ```
This commit is contained in:
parent
3f1be86a1a
commit
a5fb2bbb2a
@ -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(
|
||||
|
@ -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
|
||||
|
@ -616,9 +616,10 @@ value llvm_dibuild_create_member_pointer_type_bytecode(value *argv, int argn) {
|
||||
);
|
||||
}
|
||||
|
||||
value llvm_dibuild_create_object_pointer_type(value Builder, value Type) {
|
||||
value llvm_dibuild_create_object_pointer_type(value Builder, value Type,
|
||||
value Implicit) {
|
||||
LLVMMetadataRef Metadata = LLVMDIBuilderCreateObjectPointerType(
|
||||
DIBuilder_val(Builder), Metadata_val(Type));
|
||||
DIBuilder_val(Builder), Metadata_val(Type), Bool_val(Implicit));
|
||||
return to_val(Metadata);
|
||||
}
|
||||
|
||||
|
@ -398,7 +398,7 @@ external dibuild_create_member_pointer_type :
|
||||
= "llvm_dibuild_create_member_pointer_type_bytecode" "llvm_dibuild_create_member_pointer_type_native"
|
||||
|
||||
external dibuild_create_object_pointer_type :
|
||||
lldibuilder -> Llvm.llmetadata -> Llvm.llmetadata
|
||||
lldibuilder -> Llvm.llmetadata -> implicit:bool -> Llvm.llmetadata
|
||||
= "llvm_dibuild_create_object_pointer_type"
|
||||
|
||||
external dibuild_create_qualified_type :
|
||||
|
@ -471,10 +471,11 @@ val dibuild_create_member_pointer_type :
|
||||
a pointer to member. See LLVMDIBuilderCreateMemberPointerType *)
|
||||
|
||||
val dibuild_create_object_pointer_type :
|
||||
lldibuilder -> Llvm.llmetadata -> Llvm.llmetadata
|
||||
lldibuilder -> Llvm.llmetadata -> implicit:bool -> Llvm.llmetadata
|
||||
(** [dibuild_create_object_pointer_type dib ty] Create a uniqued DIType* clone
|
||||
with FlagObjectPointer and FlagArtificial set. [dib] is the dibuilder
|
||||
value and [ty] the underlying type to which this pointer points. *)
|
||||
with FlagObjectPointer. [dib] is the dibuilder
|
||||
value and [ty] the underlying type to which this pointer points. If
|
||||
[implicit] is true, also set FlagArtificial. *)
|
||||
|
||||
val dibuild_create_qualified_type :
|
||||
lldibuilder -> tag:int -> Llvm.llmetadata -> Llvm.llmetadata
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user