[llvm] [DebugInfo] Add a new DI flag to record if the name of a template function/type has been simplified (1/3). (PR #175130)
Liu Ke via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 12 00:50:36 PST 2026
https://github.com/Sockke updated https://github.com/llvm/llvm-project/pull/175130
>From 46941077421f2ce0eac79ab1eb51d10d0d138a8a Mon Sep 17 00:00:00 2001
From: "liuke.gehry" <liuke.gehry at bytedance.com>
Date: Fri, 9 Jan 2026 13:42:55 +0800
Subject: [PATCH 1/2] [DebugInfo] Add a new DI flag to record if the name of a
template function/type has been simplified (1/3).
---
llvm/include/llvm/IR/DebugInfoFlags.def | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/include/llvm/IR/DebugInfoFlags.def b/llvm/include/llvm/IR/DebugInfoFlags.def
index df375b6c68e81..44946b1fb83b7 100644
--- a/llvm/include/llvm/IR/DebugInfoFlags.def
+++ b/llvm/include/llvm/IR/DebugInfoFlags.def
@@ -58,6 +58,7 @@ HANDLE_DI_FLAG((1 << 26), NonTrivial)
HANDLE_DI_FLAG((1 << 27), BigEndian)
HANDLE_DI_FLAG((1 << 28), LittleEndian)
HANDLE_DI_FLAG((1 << 29), AllCallsDescribed)
+HANDLE_DI_FLAG((1 << 30), NameIsSimplified)
// To avoid needing a dedicated value for IndirectVirtualBase, we use
// the bitwise or of Virtual and FwdDecl, which does not otherwise
@@ -67,7 +68,7 @@ HANDLE_DI_FLAG((1 << 2) | (1 << 5), IndirectVirtualBase)
#ifdef DI_FLAG_LARGEST_NEEDED
// intended to be used with ADT/BitmaskEnum.h
// NOTE: always must be equal to largest flag, check this when adding new flag
-HANDLE_DI_FLAG((1 << 29), Largest)
+HANDLE_DI_FLAG((1 << 30), Largest)
#undef DI_FLAG_LARGEST_NEEDED
#endif
>From f2d2adad05a3fead58734b29da48c85120162f27 Mon Sep 17 00:00:00 2001
From: "liuke.gehry" <liuke.gehry at bytedance.com>
Date: Mon, 12 Jan 2026 16:49:56 +0800
Subject: [PATCH 2/2] added round-trip tests
---
llvm/test/Assembler/debug-info.ll | 7 +++++--
llvm/test/Assembler/disubprogram.ll | 7 +++++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/llvm/test/Assembler/debug-info.ll b/llvm/test/Assembler/debug-info.ll
index 09282b2114c8f..a1978ef375a9e 100644
--- a/llvm/test/Assembler/debug-info.ll
+++ b/llvm/test/Assembler/debug-info.ll
@@ -1,8 +1,8 @@
; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
; RUN: verify-uselistorder %s
-; CHECK: !named = !{!0, !0, !1, !2, !3, !4, !5, !6, !7, !8, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !27, !28, !29, !30, !31, !32, !33, !34, !35, !36, !37, !38, !39, !40, !41, !42, !43, !44, !45, !46, !47}
-!named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28, !29, !30, !31, !32, !33, !34, !35, !36, !37, !38, !39, !40, !41, !42, !43, !44, !45, !46, !47, !48, !49, !50}
+; CHECK: !named = !{!0, !0, !1, !2, !3, !4, !5, !6, !7, !8, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !27, !28, !29, !30, !31, !32, !33, !34, !35, !36, !37, !38, !39, !40, !41, !42, !43, !44, !45, !46, !47, !48}
+!named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28, !29, !30, !31, !32, !33, !34, !35, !36, !37, !38, !39, !40, !41, !42, !43, !44, !45, !46, !47, !48, !49, !50, !51}
; CHECK: !0 = !DISubrange(count: 3, lowerBound: 0)
; CHECK-NEXT: !1 = !DISubrange(count: 3, lowerBound: 4)
@@ -122,3 +122,6 @@
; CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "SpecificationType", file: !10, size: 64, identifier: "SpecificationType", specification: !46)
!50 = !DICompositeType(tag: DW_TAG_structure_type, name: "SpecificationType", file: !12, size: 64, identifier: "SpecificationType", specification: !49)
+
+; CHECK: distinct !DICompositeType(tag: DW_TAG_class_type, name: "SimpleType", file: !10, size: 8, flags: DIFlagTypePassByValue | DIFlagNameIsSimplified, elements: !20, templateParams: !18, identifier: "_ZTS10SimpleTypeIiE")
+!51 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "SimpleType", file: !12, size: 8, flags: DIFlagTypePassByValue | DIFlagNameIsSimplified, elements: !22, templateParams: !20, identifier: "_ZTS10SimpleTypeIiE")
diff --git a/llvm/test/Assembler/disubprogram.ll b/llvm/test/Assembler/disubprogram.ll
index 6feb27ce48012..99a747d15e7dd 100644
--- a/llvm/test/Assembler/disubprogram.ll
+++ b/llvm/test/Assembler/disubprogram.ll
@@ -6,8 +6,8 @@ define void @_Z3foov() !dbg !9 {
ret void
}
-; CHECK: !named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19}
-!named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !17, !19, !20, !21}
+; CHECK: !named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20}
+!named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !17, !19, !20, !21, !22}
!0 = !{null}
!1 = distinct !DICompositeType(tag: DW_TAG_structure_type)
@@ -92,3 +92,6 @@ define void @_Z3foov() !dbg !9 {
!19 = distinct !DISubprogram(name: "subroutine2", scope: !1, file: !2, line: 5, type: !18, scopeLine: 6, spFlags: DISPFlagDefinition | DISPFlagElemental, unit: !8, retainedNodes: !6)
!20 = distinct !DISubprogram(name: "subroutine3", scope: !1, file: !2, line: 9, type: !18, scopeLine: 10, spFlags: DISPFlagDefinition | DISPFlagRecursive, unit: !8, retainedNodes: !6)
!21 = distinct !DISubprogram(name: "subroutine4", scope: !1, file: !2, line: 13, type: !18, scopeLine: 14, spFlags: DISPFlagDefinition | DISPFlagPure | DISPFlagElemental | DISPFlagRecursive, unit: !8, retainedNodes: !6)
+
+; CHECK: !DISubprogram({{.*}}SimpleFunc{{.*}}, flags: DIFlagPrototyped | DIFlagNameIsSimplified,
+!22 = distinct !DISubprogram(name: "SimpleFunc", linkageName: "_Z10SimpleFuncIiEvv", scope: !1, file: !2, type: !3, flags: DIFlagPrototyped | DIFlagNameIsSimplified, spFlags: DISPFlagDefinition, unit: !8, templateParams: !5)
More information about the llvm-commits
mailing list