[clang] [clang][DebugInfo] Set linkage name for dynamic initializer/destructor debug info (PR #189794)
Haohai Wen via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 2 03:30:49 PDT 2026
================
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -debug-info-kind=limited -emit-llvm %s -o - | \
+// RUN: FileCheck %s
+
+// Verify that compiler-generated atexit destructors for global variables have
+// a non-empty linkageName in their DISubprogram. Without this, different
+// template instantiations would be indistinguishable in the debug info.
+
+struct Foo {
+ ~Foo();
+};
+
+template <typename T>
+struct Bar {
+ static Foo &get() {
+ static Foo instance;
+ return instance;
+ }
+};
+
+void use() {
+ Bar<int>::get();
+ Bar<float>::get();
+}
+
+// Both atexit destructors should have distinct linkageNames.
+// CHECK-DAG: distinct !DISubprogram({{.*}}linkageName: "??__Finstance@?2??get@?$Bar at H@@SAAEAUFoo@@XZ at YAXXZ"
+// CHECK-DAG: distinct !DISubprogram({{.*}}linkageName: "??__Finstance@?2??get@?$Bar at M@@SAAEAUFoo@@XZ at YAXXZ"
----------------
HaohaiWen wrote:
Updated.
https://github.com/llvm/llvm-project/pull/189794
More information about the cfe-commits
mailing list