-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[DWARF] Add support for DW_TAG_template_alias for template aliases #88943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fix issue llvm#54624 Split from PR llvm#87623. Clang front end changes to follow. Use DICompositeType to represnt the template alias, using its extraData field as a tuple of DITemplateParameter to describe the template parameters. Added template-alias.ll - Check DWARF emission. Modified frame-types.s - Check llvm-symbolizer understands the DIE.
@llvm/pr-subscribers-llvm-binary-utilities @llvm/pr-subscribers-debuginfo Author: Orlando Cazalet-Hyams (OCHyams) ChangesPart 1 of fix for issue #54624 Split from PR #87623. Clang front end changes to follow. Use DICompositeType to represent the template alias, using its extraData field as a tuple of DITemplateParameter to describe the template parameters. Added template-alias.ll - Check DWARF emission. @adrian-prantl this is all the LLVM-IR-side code from #87623, which I believe you are happy with? Patch is 61.32 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/88943.diff 11 Files Affected:
diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h
index 002f2db6da5447..97ea38f041baad 100644
--- a/llvm/include/llvm/IR/DIBuilder.h
+++ b/llvm/include/llvm/IR/DIBuilder.h
@@ -310,6 +310,24 @@ namespace llvm {
DINode::DIFlags Flags = DINode::FlagZero,
DINodeArray Annotations = nullptr);
+ /// Create debugging information entry for a template alias.
+ /// \param Ty Original type.
+ /// \param Name Alias name.
+ /// \param File File where this type is defined.
+ /// \param LineNo Line number.
+ /// \param Context The surrounding context for the alias.
+ /// \param TParams The template arguments.
+ /// \param AlignInBits Alignment. (optional)
+ /// \param Flags Flags to describe inheritance attribute (optional),
+ /// e.g. private.
+ /// \param Annotations Annotations. (optional)
+ DIDerivedType *createTemplateAlias(DIType *Ty, StringRef Name, DIFile *File,
+ unsigned LineNo, DIScope *Context,
+ DINodeArray TParams,
+ uint32_t AlignInBits = 0,
+ DINode::DIFlags Flags = DINode::FlagZero,
+ DINodeArray Annotations = nullptr);
+
/// Create debugging information entry for a 'friend'.
DIDerivedType *createFriend(DIType *Ty, DIType *FriendTy);
diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h
index 2805f6c4780578..42291d45da2bef 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -1093,14 +1093,19 @@ class DIDerivedType : public DIType {
/// Get extra data associated with this derived type.
///
/// Class type for pointer-to-members, objective-c property node for ivars,
- /// global constant wrapper for static members, or virtual base pointer offset
- /// for inheritance.
+ /// global constant wrapper for static members, virtual base pointer offset
+ /// for inheritance, or a tuple of template parameters for template aliases.
///
/// TODO: Separate out types that need this extra operand: pointer-to-member
/// types and member fields (static members and ivars).
Metadata *getExtraData() const { return getRawExtraData(); }
Metadata *getRawExtraData() const { return getOperand(4); }
+ /// Get the template parameters from a template alias.
+ DITemplateParameterArray getTemplateParams() const {
+ return cast_or_null<MDTuple>(getExtraData());
+ }
+
/// Get annotations associated with this derived type.
DINodeArray getAnnotations() const {
return cast_or_null<MDTuple>(getRawAnnotations());
diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
index f00ff1565c665f..24cd1b15a57369 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
@@ -154,7 +154,8 @@ uint64_t DebugHandlerBase::getBaseTypeSize(const DIType *Ty) {
if (Tag != dwarf::DW_TAG_member && Tag != dwarf::DW_TAG_typedef &&
Tag != dwarf::DW_TAG_const_type && Tag != dwarf::DW_TAG_volatile_type &&
Tag != dwarf::DW_TAG_restrict_type && Tag != dwarf::DW_TAG_atomic_type &&
- Tag != dwarf::DW_TAG_immutable_type)
+ Tag != dwarf::DW_TAG_immutable_type &&
+ Tag != dwarf::DW_TAG_template_alias)
return DDTy->getSizeInBits();
DIType *BaseType = DDTy->getBaseType();
@@ -210,7 +211,8 @@ bool DebugHandlerBase::isUnsignedDIType(const DIType *Ty) {
assert(T == dwarf::DW_TAG_typedef || T == dwarf::DW_TAG_const_type ||
T == dwarf::DW_TAG_volatile_type ||
T == dwarf::DW_TAG_restrict_type || T == dwarf::DW_TAG_atomic_type ||
- T == dwarf::DW_TAG_immutable_type);
+ T == dwarf::DW_TAG_immutable_type ||
+ T == dwarf::DW_TAG_template_alias);
assert(DTy->getBaseType() && "Expected valid base type");
return isUnsignedDIType(DTy->getBaseType());
}
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 6b5ad62e083e3b..5f10a6d9547f17 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2483,6 +2483,7 @@ static dwarf::PubIndexEntryDescriptor computeIndexValue(DwarfUnit *CU,
case dwarf::DW_TAG_typedef:
case dwarf::DW_TAG_base_type:
case dwarf::DW_TAG_subrange_type:
+ case dwarf::DW_TAG_template_alias:
return dwarf::PubIndexEntryDescriptor(dwarf::GIEK_TYPE, dwarf::GIEL_STATIC);
case dwarf::DW_TAG_namespace:
return dwarf::GIEK_TYPE;
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index c40beeeb925e0e..56c288ee95b431 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -803,6 +803,11 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DIDerivedType *DTy) {
if (DTy->getDWARFAddressSpace())
addUInt(Buffer, dwarf::DW_AT_address_class, dwarf::DW_FORM_data4,
*DTy->getDWARFAddressSpace());
+
+ // Add template alias template parameters.
+ if (Tag == dwarf::DW_TAG_template_alias)
+ addTemplateParams(Buffer, DTy->getTemplateParams());
+
if (auto PtrAuthData = DTy->getPtrAuthData()) {
addUInt(Buffer, dwarf::DW_AT_LLVM_ptrauth_key, dwarf::DW_FORM_data1,
PtrAuthData->key());
diff --git a/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp b/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
index 60f664ece7eef9..3149d9b1d6624f 100644
--- a/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
@@ -116,6 +116,7 @@ static bool isTypeTag(uint16_t Tag) {
case dwarf::DW_TAG_string_type:
case dwarf::DW_TAG_structure_type:
case dwarf::DW_TAG_subroutine_type:
+ case dwarf::DW_TAG_template_alias:
case dwarf::DW_TAG_typedef:
case dwarf::DW_TAG_union_type:
case dwarf::DW_TAG_ptr_to_member_type:
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
index 66492f7bf80433..410842a80b0151 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -515,6 +515,7 @@ getTypeSizeImpl(DWARFDie Die, uint64_t PointerSize,
case DW_TAG_immutable_type:
case DW_TAG_volatile_type:
case DW_TAG_restrict_type:
+ case DW_TAG_template_alias:
case DW_TAG_typedef: {
if (DWARFDie BaseType = Die.getAttributeValueAsReferencedDie(DW_AT_type))
return getTypeSizeImpl(BaseType, PointerSize, Visited);
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index f86e557b8def21..f39149ae0dad4c 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -356,6 +356,17 @@ DIDerivedType *DIBuilder::createTypedef(DIType *Ty, StringRef Name,
nullptr, Annotations);
}
+DIDerivedType *
+DIBuilder::createTemplateAlias(DIType *Ty, StringRef Name, DIFile *File,
+ unsigned LineNo, DIScope *Context,
+ DINodeArray TParams, uint32_t AlignInBits,
+ DINode::DIFlags Flags, DINodeArray Annotations) {
+ return DIDerivedType::get(VMContext, dwarf::DW_TAG_template_alias, Name, File,
+ LineNo, getNonCompileUnitScope(Context), Ty, 0,
+ AlignInBits, 0, std::nullopt, std::nullopt, Flags,
+ TParams.get(), Annotations);
+}
+
DIDerivedType *DIBuilder::createFriend(DIType *Ty, DIType *FriendTy) {
assert(Ty && "Invalid type!");
assert(FriendTy && "Invalid friend type!");
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 819722566831c6..418dbf0cf3faf3 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -1240,7 +1240,8 @@ void Verifier::visitDIDerivedType(const DIDerivedType &N) {
(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,
+ N.getTag() == dwarf::DW_TAG_set_type ||
+ N.getTag() == dwarf::DW_TAG_template_alias,
"invalid tag", &N);
if (N.getTag() == dwarf::DW_TAG_ptr_to_member_type) {
CheckDI(isType(N.getRawExtraData()), "invalid pointer to member type", &N,
diff --git a/llvm/test/DebugInfo/X86/template-alias.ll b/llvm/test/DebugInfo/X86/template-alias.ll
new file mode 100644
index 00000000000000..0e3d9313ed0e53
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/template-alias.ll
@@ -0,0 +1,71 @@
+; RUN: llc %s -o - --filetype=obj | llvm-dwarfdump - --name A --show-children | FileCheck %s --check-prefix=TREE
+
+;; -ggnu-pubnames (nameTableKind: GNU).
+; RUN: llc %s -o - --filetype=obj \
+; RUN: | llvm-dwarfdump - --debug-gnu-pubtypes \
+; RUN: | FileCheck %s --check-prefix=GNU-TYPES
+
+;; -gpubnames (remove nameTableKind field from DICompileUnit).
+; RUN: sed 's/, nameTableKind: GNU//g' < %s \
+; RUN: | llc - -o - --filetype=obj \
+; RUN: | llvm-dwarfdump - --debug-pubtypes \
+; RUN: | FileCheck %s --check-prefix=PUB-TYPES
+
+;; C++ source from clang/test/CodeGenCXX/template-alias.cpp, compiled with -gsce:
+;; template<typename Y, int Z>
+;; struct X {
+;; Y m1 = Z;
+;; };
+;;
+;; template<typename B, int C>
+;; using A = X<B, C>;
+;;
+;; A<int, 5> a;
+
+;; Test emission of DIDerivedType with tag: DW_TAG_template_alias.
+
+; TREE: DW_TAG_template_alias
+; TREE: DW_AT_type (0x{{[0-9a-f]+}} "X<int, 5>")
+; TREE: DW_AT_name ("A")
+; TREE: DW_TAG_template_type_parameter
+; TREE: DW_AT_type (0x{{[0-9a-f]+}} "int")
+; TREE: DW_AT_name ("B")
+; TREE: DW_TAG_template_value_parameter
+; TREE: DW_AT_type (0x{{[0-9a-f]+}} "int")
+; TREE: DW_AT_name ("C")
+; TREE: DW_AT_const_value (5)
+; TREE: NULL
+
+; GNU-TYPES: STATIC TYPE "A"
+; PUB-TYPES: "A"
+
+target triple = "x86_64-unknown-unkown"
+
+%struct.X = type { i32 }
+
+@a = global %struct.X { i32 5 }, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!17, !18}
+!llvm.ident = !{!19}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !5, line: 14, type: !6, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 19.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: GNU)
+!3 = !DIFile(filename: "<stdin>", directory: "/")
+!4 = !{!0}
+!5 = !DIFile(filename: "clang/test/CodeGenCXX/template-alias.cpp", directory: "/")
+!6 = !DIDerivedType(tag: DW_TAG_template_alias, name: "A", file: !5, line: 12, baseType: !7, extraData: !14)
+!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "X<int, 5>", file: !5, line: 7, size: 32, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !8, templateParams: !11, identifier: "_ZTS1XIiLi5EE")
+!8 = !{!9}
+!9 = !DIDerivedType(tag: DW_TAG_member, name: "m1", scope: !7, file: !5, line: 8, baseType: !10, size: 32)
+!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!11 = !{!12, !13}
+!12 = !DITemplateTypeParameter(name: "Y", type: !10)
+!13 = !DITemplateValueParameter(name: "Z", type: !10, value: i32 5)
+!14 = !{!15, !16}
+!15 = !DITemplateTypeParameter(name: "B", type: !10)
+!16 = !DITemplateValueParameter(name: "C", type: !10, value: i32 5)
+!17 = !{i32 2, !"Debug Info Version", i32 3}
+!18 = !{i32 1, !"wchar_size", i32 4}
+!19 = !{!"clang version 19.0.0git"}
diff --git a/llvm/test/tools/llvm-symbolizer/frame-types.s b/llvm/test/tools/llvm-symbolizer/frame-types.s
index f511c83bc0d25f..7f38b1767a617d 100644
--- a/llvm/test/tools/llvm-symbolizer/frame-types.s
+++ b/llvm/test/tools/llvm-symbolizer/frame-types.s
@@ -5,52 +5,56 @@
// CHECK: f
// CHECK-NEXT: a
-// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:4
-// CHECK-NEXT: -1 1 ??
+// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:11
+// CHECK-NEXT: -5 1 ??
// CHECK-NEXT: f
// CHECK-NEXT: b
-// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:5
-// CHECK-NEXT: -8 4 ??
+// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:12
+// CHECK-NEXT: -12 4 ??
// CHECK-NEXT: f
// CHECK-NEXT: c
-// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:6
-// CHECK-NEXT: -12 4 ??
+// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:13
+// CHECK-NEXT: -16 4 ??
// CHECK-NEXT: f
// CHECK-NEXT: d
-// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:7
-// CHECK-NEXT: -16 4 ??
+// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:14
+// CHECK-NEXT: -20 4 ??
// CHECK-NEXT: f
// CHECK-NEXT: e
-// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:8
+// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:15
// CHECK-NEXT: -32 8 ??
// CHECK-NEXT: f
// CHECK-NEXT: f
-// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:9
+// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:16
// CHECK-NEXT: -36 4 ??
// CHECK-NEXT: f
// CHECK-NEXT: g
-// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:10
+// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:17
// CHECK-NEXT: -37 1 ??
// CHECK-NEXT: f
// CHECK-NEXT: h
-// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:11
+// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:18
// CHECK-NEXT: -38 1 ??
// CHECK-NEXT: f
// CHECK-NEXT: i
-// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:12
+// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:19
// CHECK-NEXT: -44 4 ??
// CHECK-NEXT: f
// CHECK-NEXT: j
-// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:14
+// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:21
// CHECK-NEXT: -45 1 ??
// CHECK-NEXT: f
// CHECK-NEXT: k
-// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:15
+// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:22
// CHECK-NEXT: -57 12 ??
// CHECK-NEXT: f
// CHECK-NEXT: l
-// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:16
+// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:23
// CHECK-NEXT: -345 288 ??
+// CHECK-NEXT: f
+// CHECK-NEXT: m
+// CHECK-NEXT: /tmp{{/|\\}}frame-types.cpp:24
+// CHECK-NEXT: -352 4 ??
// Generated from:
//
@@ -76,14 +80,13 @@
.text
.file "frame-types.cpp"
- .globl _Z1fv # -- Begin function _Z1fv
+ .globl _Z1fv # -- Begin function _Z1fv
.p2align 4, 0x90
.type _Z1fv,@function
_Z1fv: # @_Z1fv
.Lfunc_begin0:
- .file 1 "/tmp" "frame-types.cpp"
- .loc 1 3 0 # frame-types.cpp:3:0
- .cfi_sections .debug_frame
+ .file 0 "/tmp" "frame-types.cpp"
+ .loc 0 10 0 # frame-types.cpp:10:0
.cfi_startproc
# %bb.0: # %entry
pushl %ebp
@@ -91,441 +94,579 @@ _Z1fv: # @_Z1fv
.cfi_offset %ebp, -8
movl %esp, %ebp
.cfi_def_cfa_register %ebp
- subl $352, %esp # imm = 0x160
.Ltmp0:
- .loc 1 6 9 prologue_end # frame-types.cpp:6:9
- leal -1(%ebp), %eax
+ pushl %ebx
+ subl $372, %esp # imm = 0x174
+ .cfi_offset %ebx, -12
+ .loc 0 13 9 prologue_end # frame-types.cpp:13:9
+ calll .L0$pb
+.L0$pb:
+ popl %ebx
.Ltmp1:
- #DEBUG_VALUE: f:a <- [$eax+0]
- movl %eax, -12(%ebp)
- .loc 1 7 14 # frame-types.cpp:7:14
- movb $1, -17(%ebp)
- .loc 1 7 10 is_stmt 0 # frame-types.cpp:7:10
- leal -17(%ebp), %eax
-.Ltmp2:
+ addl $_GLOBAL_OFFSET_TABLE_+(.Ltmp1-.L0$pb), %ebx
+ leal -5(%ebp), %eax
movl %eax, -16(%ebp)
- .loc 1 10 14 is_stmt 1 # frame-types.cpp:10:14
+ .loc 0 14 14 # frame-types.cpp:14:14
+ movb $1, -21(%ebp)
+ .loc 0 14 10 is_stmt 0 # frame-types.cpp:14:10
+ leal -21(%ebp), %eax
+ movl %eax, -20(%ebp)
+ .loc 0 17 14 is_stmt 1 # frame-types.cpp:17:14
movb $2, -37(%ebp)
- .loc 1 17 1 # frame-types.cpp:17:1
- addl $352, %esp # imm = 0x160
+ .loc 0 24 14 # frame-types.cpp:24:14
+ leal -352(%ebp), %eax
+ xorl %ecx, %ecx
+ movl %eax, (%esp)
+ movl $0, 4(%esp)
+ movl $4, 8(%esp)
+ calll memset@PLT
+ .loc 0 25 1 epilogue_begin # frame-types.cpp:25:1
+ addl $372, %esp # imm = 0x174
+ popl %ebx
popl %ebp
.cfi_def_cfa %esp, 4
retl
-.Ltmp3:
+.Ltmp2:
.Lfunc_end0:
.size _Z1fv, .Lfunc_end0-_Z1fv
.cfi_endproc
# -- End function
- .section .debug_str,"MS",@progbits,1
-.Linfo_string0:
- .asciz "clang version 9.0.0 " # string offset=0
-.Linfo_string1:
- .asciz "frame-types.cpp" # string offset=21
-.Linfo_string2:
- .asciz "/tmp" # string offset=37
-.Linfo_string3:
- .asciz "_Z1fv" # string offset=42
-.Linfo_string4:
- .asciz "f" # string offset=48
-.Linfo_string5:
- .asciz "a" # string offset=50
-.Linfo_string6:
- .asciz "char" # string offset=52
-.Linfo_string7:
- .asciz "b" # string offset=57
-.Linfo_string8:
- .asciz "c" # string offset=59
-.Linfo_string9:
- .asciz "d" # string offset=61
-.Linfo_string10:
- .asciz "e" # string offset=63
-.Linfo_string11:
- .asciz "S" # string offset=65
-.Linfo_string12:
- .asciz "g" # string offset=67
-.Linfo_string13:
- .asciz "h" # string offset=69
-.Linfo_string14:
- .asciz "i" # string offset=71
-.Linfo_string15:
- .asciz "j" # string offset=73
-.Linfo_string16:
- .asciz "char_typedef" # string offset=75
-.Linfo_string17:
- .asciz "k" # string offset=88
-.Linfo_string18:
- .asciz "__ARRAY_SIZE_TYPE__" # string offset=90
-.Linfo_string19:
- .asciz "l" # string offset=110
.section .debug_abbrev,"",@progbits
- .byte 1 # Abbreviation Code
- .byte 17 # DW_TAG_compile_unit
- .byte 1 # DW_CHILDREN_yes
- .byte 37 # DW_AT_producer
- .byte 14 # DW_FORM_strp
- .byte 19 # DW_AT_language
- .byte 5 # DW_FORM_data2
- .byte 3 # DW_AT_name
- .byte 14 # DW_FORM_strp
- .byte 16 # DW_AT_stmt_list
- .byte 23 # DW_FORM_sec_offset
- .byte 27 # DW_AT_comp_dir
- .byte 14 # DW_FORM_strp
- .byte 17 # DW_AT_low_pc
- .byte 1 # DW_FORM_addr
- .byte 18 # DW_AT_high_pc
- .byte 6 # DW_FORM_data4
- .byte 0 # EOM(1)
- .byte 0 # EOM(2)
- .byte 2 # Abbreviation Code
- .byte 46 # DW_TAG_subprogram
- .byte 1 # DW_CHILDREN_yes
- .byte 17 # DW_AT_low_pc
- .byte 1 # DW_FORM_addr
- .byte 18 # DW_AT_high_pc
- .byte 6 # DW_FORM_data4
- .byte 64 # DW_AT_frame_base
- .byte 24 # DW_FORM_exprloc
- .byte 110 # DW_AT_linkage_name
- .byte 14 # DW_FORM_strp
- .byte 3 # DW_AT_name
- .byte 14 # DW_FORM_strp
- .byte 58 # DW_AT_decl_file
- .byte 11 # DW_FORM_data1
- .byte 59 # DW_AT_decl_line
- .byte 11 # DW_FORM_data1
- .byte 63 # DW_AT_external
- .byte 25 # DW_FORM_flag_present
- .byte 0 # EOM(1)
- .byte 0 # EOM(2)
- .byte 3 # Abbreviation Code
- .byte 52 # DW_TAG_variable
- .byte 0 # DW_CHILDREN_no
- .byte 2 # DW_AT_location
- .byte 24 # DW_FORM_exprloc
- .byte 3 # DW_AT_name
- .byte 14 # DW_FORM_strp
- .byte 58 # DW_AT_decl_file
- .byte 11 # DW_FORM_data1
- .byte 59 # DW_AT_decl_line
- .byte 11 # DW_FORM_data...
[truncated]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this patch also need to add handling for DW_TAG_template_alias
in llvm/lib/DWARFLinker/Parallel/
? I see similar tags like DW_TAG_typedef
are handled there in a few files, but I'm not sure if that's either unnecessary or separate work. Other than that this looks fine to me, given the amount of discussion this has already had on the previous PR (which looks to have ended in approval).
Thanks @SLTozer
I believe llvm/lib/DWARFLinker/Parallel/ is for dysymutil (which is indeed follow-up work). |
Fix issue #54624 Add front end flags -gtemplate-alias (also a cc1 flag) and -gno-template-alias to enable/disable usage of the feature. It's enabled by default in the front end for SCE debugger tuning only. GCC emits DW_TAG_typedef for template aliases (as does Clang with this feature disabled), and GDB and LLDB appear not to support DW_TAG_template_alias. The -Xclang option -gsimple-template-names=mangled is treated the same as =full, which is not a regression from current behaviour for template aliases. The current implementation omits defaulted arguments and as a consequence also omits empty parameter packs that come after defaulted arguments. Again, this isn't a regression as the DW_TAG_typedef name doesn't contain defaulted arguments. LLVM support added in #88943 Added template-alias.cpp - Check the metadata construction & interaction with -gsimple-template-names. Added variadic-template-alias.cpp - Check template parameter packs work. Added defaulted-template-alias.cpp - Check defaulted args (don't) work. Modified debug-options.c - Check Clang generates correct cc1 flags.
brings in [DWARF] Add support for DW_TAG_template_alias for template aliases (llvm#88943) Change-Id: I4e94f2bd6bd14986694ab6bf7d399489f7fdda0d
Part 1 of fix for issue #54624
Split from PR #87623. Clang front end changes to follow.
Use DICompositeType to represent the template alias, using its extraData field as a tuple of DITemplateParameter to describe the template parameters.
Added template-alias.ll - Check DWARF emission.
Modified frame-types.s - Check llvm-symbolizer understands the DIE.
@adrian-prantl this is all the LLVM-IR-side code from #87623, which I believe you are happy with?