diff options
author | Michael Buch <michaelbuch12@gmail.com> | 2023-11-15 09:36:47 +0000 |
---|---|---|
committer | Michael Buch <michaelbuch12@gmail.com> | 2023-11-15 10:26:35 +0000 |
commit | da90fd75241d5b149fd307e3eeae84f7317d9d9b (patch) | |
tree | 43ccb676f24659ac014887478c7bdfbcac356a4c /llvm/lib/IR | |
parent | 808caa9d4608b4383743043f6dbdab6faf608bcc (diff) | |
download | llvm-da90fd75241d5b149fd307e3eeae84f7317d9d9b.zip llvm-da90fd75241d5b149fd307e3eeae84f7317d9d9b.tar.gz llvm-da90fd75241d5b149fd307e3eeae84f7317d9d9b.tar.bz2 |
Reland "[llvm][DebugInfo] DWARFv5: static data members declarations are DW_TAG_variable (#72234)"
This was reverted because it broke the OCaml LLVM bindings.
Relanding the original patch but without changing the C-API.
They'll continue to work just fine as they do today. If in the
future there is a need to pass a new tag to the C-API for creating
static members, then we'll make the change to the OCaml bindings
at that time.
Original commit message:
"""
This patch adds the LLVM-side infrastructure to implement DWARFv5 issue
161118.1: "DW_TAG for C++ static data members".
The clang-side of this patch will simply construct the DIDerivedType
with a different DW_TAG.
"""
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/DIBuilder.cpp | 9 | ||||
-rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/IR/DebugInfoMetadata.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 1 |
4 files changed, 12 insertions, 12 deletions
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp index 1ce8c17..58a7e07 100644 --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -405,12 +405,11 @@ DIDerivedType * DIBuilder::createStaticMemberType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, DIType *Ty, DINode::DIFlags Flags, llvm::Constant *Val, - uint32_t AlignInBits) { + unsigned Tag, uint32_t AlignInBits) { Flags |= DINode::FlagStaticMember; - return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File, - LineNumber, getNonCompileUnitScope(Scope), Ty, 0, - AlignInBits, 0, std::nullopt, Flags, - getConstantOrNull(Val)); + return DIDerivedType::get(VMContext, Tag, Name, File, LineNumber, + getNonCompileUnitScope(Scope), Ty, 0, AlignInBits, + 0, std::nullopt, Flags, getConstantOrNull(Val)); } DIDerivedType * diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index 390a27c..bb6d6126 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -1315,17 +1315,15 @@ LLVMDIBuilderCreateUnspecifiedType(LLVMDIBuilderRef Builder, const char *Name, return wrap(unwrap(Builder)->createUnspecifiedType({Name, NameLen})); } -LLVMMetadataRef -LLVMDIBuilderCreateStaticMemberType( +LLVMMetadataRef LLVMDIBuilderCreateStaticMemberType( LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, LLVMMetadataRef Type, LLVMDIFlags Flags, LLVMValueRef ConstantVal, uint32_t AlignInBits) { return wrap(unwrap(Builder)->createStaticMemberType( - unwrapDI<DIScope>(Scope), {Name, NameLen}, - unwrapDI<DIFile>(File), LineNumber, unwrapDI<DIType>(Type), - map_from_llvmDIFlags(Flags), unwrap<Constant>(ConstantVal), - AlignInBits)); + unwrapDI<DIScope>(Scope), {Name, NameLen}, unwrapDI<DIFile>(File), + LineNumber, unwrapDI<DIType>(Type), map_from_llvmDIFlags(Flags), + unwrap<Constant>(ConstantVal), DW_TAG_member, AlignInBits)); } LLVMMetadataRef diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp index 0e14ec9..943826c 100644 --- a/llvm/lib/IR/DebugInfoMetadata.cpp +++ b/llvm/lib/IR/DebugInfoMetadata.cpp @@ -711,7 +711,9 @@ Constant *DIDerivedType::getStorageOffsetInBits() const { } Constant *DIDerivedType::getConstant() const { - assert(getTag() == dwarf::DW_TAG_member && isStaticMember()); + assert((getTag() == dwarf::DW_TAG_member || + getTag() == dwarf::DW_TAG_variable) && + isStaticMember()); if (auto *C = cast_or_null<ConstantAsMetadata>(getExtraData())) return C->getValue(); return nullptr; diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index b1d1075..25981d8 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -1172,6 +1172,7 @@ void Verifier::visitDIDerivedType(const DIDerivedType &N) { N.getTag() == dwarf::DW_TAG_restrict_type || N.getTag() == dwarf::DW_TAG_atomic_type || N.getTag() == dwarf::DW_TAG_member || + (N.getTag() == dwarf::DW_TAG_variable && N.isStaticMember()) || N.getTag() == dwarf::DW_TAG_inheritance || N.getTag() == dwarf::DW_TAG_friend || N.getTag() == dwarf::DW_TAG_set_type, |