Skip to content

Commit

Permalink
Revert "[llvm][DebugInfo] DWARFv5: static data members declarations a…
Browse files Browse the repository at this point in the history
…re DW_TAG_variable (#72234)"

This reverts commit 9a9933f.

The OCaml bindings were using `LLVMDIBuilderCreateStaticMemberType`,
causing the API change in `9a9933fae23249fbf6cf5b3c090e630f578b7f98`
to break buildbots that built the bindings. Revert until we figure out
whether to fixup the bindings or just not change the C-API
  • Loading branch information
Michael137 committed Nov 15, 2023
1 parent 8936100 commit 8e8bad7
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 129 deletions.
3 changes: 1 addition & 2 deletions clang/lib/CodeGen/CGDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1681,8 +1681,7 @@ CGDebugInfo::CreateRecordStaticField(const VarDecl *Var, llvm::DIType *RecordTy,
llvm::DINode::DIFlags Flags = getAccessFlag(Var->getAccess(), RD);
auto Align = getDeclAlignIfRequired(Var, CGM.getContext());
llvm::DIDerivedType *GV = DBuilder.createStaticMemberType(
RecordTy, VName, VUnit, LineNumber, VTy, Flags, /* Val */ nullptr,
llvm::dwarf::DW_TAG_member, Align);
RecordTy, VName, VUnit, LineNumber, VTy, Flags, /* Val */ nullptr, Align);
StaticDataMemberCache[Var->getCanonicalDecl()].reset(GV);
StaticDataMemberDefinitionsToEmit.push_back(Var->getCanonicalDecl());
return GV;
Expand Down
6 changes: 3 additions & 3 deletions llvm/include/llvm-c/DebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -785,14 +785,14 @@ LLVMMetadataRef LLVMDIBuilderCreateMemberType(
* \param Type Type of the static member.
* \param Flags Flags to encode member attribute, e.g. private.
* \param ConstantVal Const initializer of the member.
* \param Tag DWARF tag of the static member.
* \param AlignInBits Member alignment.
*/
LLVMMetadataRef LLVMDIBuilderCreateStaticMemberType(
LLVMMetadataRef
LLVMDIBuilderCreateStaticMemberType(
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
LLVMMetadataRef Type, LLVMDIFlags Flags, LLVMValueRef ConstantVal,
unsigned Tag, uint32_t AlignInBits);
uint32_t AlignInBits);

/**
* Create debugging information entry for a pointer to member.
Expand Down
3 changes: 1 addition & 2 deletions llvm/include/llvm/IR/DIBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,11 @@ namespace llvm {
/// \param Ty Type of the static member.
/// \param Flags Flags to encode member attribute, e.g. private.
/// \param Val Const initializer of the member.
/// \param Tag DWARF tag of the static member.
/// \param AlignInBits Member alignment.
DIDerivedType *createStaticMemberType(DIScope *Scope, StringRef Name,
DIFile *File, unsigned LineNo,
DIType *Ty, DINode::DIFlags Flags,
Constant *Val, unsigned Tag,
Constant *Val,
uint32_t AlignInBits = 0);

/// Create debugging information entry for Objective-C
Expand Down
9 changes: 5 additions & 4 deletions llvm/lib/IR/DIBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,12 @@ DIDerivedType *
DIBuilder::createStaticMemberType(DIScope *Scope, StringRef Name, DIFile *File,
unsigned LineNumber, DIType *Ty,
DINode::DIFlags Flags, llvm::Constant *Val,
unsigned Tag, uint32_t AlignInBits) {
uint32_t AlignInBits) {
Flags |= DINode::FlagStaticMember;
return DIDerivedType::get(VMContext, Tag, Name, File, LineNumber,
getNonCompileUnitScope(Scope), Ty, 0, AlignInBits,
0, std::nullopt, Flags, getConstantOrNull(Val));
return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File,
LineNumber, getNonCompileUnitScope(Scope), Ty, 0,
AlignInBits, 0, std::nullopt, Flags,
getConstantOrNull(Val));
}

DIDerivedType *
Expand Down
12 changes: 7 additions & 5 deletions llvm/lib/IR/DebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1315,15 +1315,17 @@ 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,
unsigned Tag, uint32_t AlignInBits) {
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), Tag, AlignInBits));
unwrapDI<DIScope>(Scope), {Name, NameLen},
unwrapDI<DIFile>(File), LineNumber, unwrapDI<DIType>(Type),
map_from_llvmDIFlags(Flags), unwrap<Constant>(ConstantVal),
AlignInBits));
}

LLVMMetadataRef
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/IR/DebugInfoMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,9 +711,7 @@ Constant *DIDerivedType::getStorageOffsetInBits() const {
}

Constant *DIDerivedType::getConstant() const {
assert((getTag() == dwarf::DW_TAG_member ||
getTag() == dwarf::DW_TAG_variable) &&
isStaticMember());
assert(getTag() == dwarf::DW_TAG_member && isStaticMember());
if (auto *C = cast_or_null<ConstantAsMetadata>(getExtraData()))
return C->getValue();
return nullptr;
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/IR/Verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,6 @@ 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,
Expand Down
109 changes: 0 additions & 109 deletions llvm/test/DebugInfo/Generic/dwarf5-debug-info-static-member.ll

This file was deleted.

0 comments on commit 8e8bad7

Please sign in to comment.