aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/DIBuilder.cpp
diff options
context:
space:
mode:
authorAugusto Noronha <anoronha@apple.com>2024-11-13 09:55:37 -0800
committerGitHub <noreply@github.com>2024-11-13 09:55:37 -0800
commit67fb2686fba9abd6e607ff9a09b7018b2b8ae31b (patch)
tree9f2e90b07e93c45b480ac7d83022de740066966f /llvm/lib/IR/DIBuilder.cpp
parent2bd6af8cbc75ba67c20382757e03b85829d77a32 (diff)
downloadllvm-67fb2686fba9abd6e607ff9a09b7018b2b8ae31b.zip
llvm-67fb2686fba9abd6e607ff9a09b7018b2b8ae31b.tar.gz
llvm-67fb2686fba9abd6e607ff9a09b7018b2b8ae31b.tar.bz2
[DebugInfo] Add a specification attribute to LLVM DebugInfo (#115362)
Add a specification attribute to LLVM DebugInfo, which is analogous to DWARF's DW_AT_specification. According to the DWARF spec: "A debugging information entry that represents a declaration that completes another (earlier) non-defining declaration may have a DW_AT_specification attribute whose value is a reference to the debugging information entry representing the non-defining declaration." This patch allows types to be specifications of other types. This is used by Swift to represent generic types. For example, given this Swift program: ``` struct MyStruct<T> { let t: T } let variable = MyStruct<Int>(t: 43) ``` The Swift compiler emits (roughly) an unsubtituted type for MyStruct<T>: ``` DW_TAG_structure_type DW_AT_name ("MyStruct") // "$s1w8MyStructVyxGD" is a Swift mangled name roughly equivalent to // MyStruct<T> DW_AT_linkage_name ("$s1w8MyStructVyxGD") // other attributes here ``` And a specification for MyStruct<Int>: ``` DW_TAG_structure_type DW_AT_specification (<link to "MyStruct">) // "$s1w8MyStructVySiGD" is a Swift mangled name equivalent to // MyStruct<Int> DW_AT_linkage_name ("$s1w8MyStructVySiGD") DW_AT_byte_size (0x08) // other attributes here ```
Diffstat (limited to 'llvm/lib/IR/DIBuilder.cpp')
-rw-r--r--llvm/lib/IR/DIBuilder.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index 3d8e12e..3af397b 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -521,13 +521,13 @@ DICompositeType *DIBuilder::createStructType(
DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags,
DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang,
- DIType *VTableHolder, StringRef UniqueIdentifier,
+ DIType *VTableHolder, StringRef UniqueIdentifier, DIType *Specification,
uint32_t NumExtraInhabitants) {
auto *R = DICompositeType::get(
VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
getNonCompileUnitScope(Context), DerivedFrom, SizeInBits, AlignInBits, 0,
Flags, Elements, RunTimeLang, VTableHolder, nullptr, UniqueIdentifier,
- nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, Specification,
NumExtraInhabitants);
trackIfUnresolved(R);
return R;