aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen
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/CodeGen
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/CodeGen')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index c6d9fcf..316e05ba 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1043,6 +1043,11 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
addUInt(Buffer, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
CC);
}
+
+ if (auto *SpecifiedFrom = CTy->getSpecification())
+ addDIEEntry(Buffer, dwarf::DW_AT_specification,
+ *getOrCreateContextDIE(SpecifiedFrom));
+
break;
}
default: