[PATCH] Anonymous namespaces are missing import DW_TAG_imported_module.
Katya Romanova
Katya_Romanova at playstation.sony.com
Sat Feb 28 00:27:26 PST 2015
Reduced the test, based on David's suggestion.
http://reviews.llvm.org/D7895
Files:
lib/CodeGen/AsmPrinter/DwarfUnit.cpp
test/DebugInfo/X86/gnu-public-names.ll
test/DebugInfo/anonymous-namespace.ll
Index: lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1207,12 +1207,21 @@
DIE &NDie = createAndAddDIE(dwarf::DW_TAG_namespace, *ContextDIE, NS);
StringRef Name = NS.getName();
- if (!Name.empty())
+ bool IsAnonymous = Name.empty();
+ if (!IsAnonymous)
addString(NDie, dwarf::DW_AT_name, NS.getName());
else
Name = "(anonymous namespace)";
DD->addAccelNamespace(Name, NDie);
addGlobalName(Name, NDie, NS.getContext());
+ if (IsAnonymous) {
+ // For anonymous namespaces, add a DW_TAG_imported_module tag
+ // containing a DW_AT_import attribute with the reference to this
+ // namespace entry.
+ DIE &IDie = createAndAddDIE(dwarf::DW_TAG_imported_module, *ContextDIE);
+ addDIEEntry(IDie, dwarf::DW_AT_import, NDie);
+ addFlag(IDie, dwarf::DW_AT_artificial);
+ }
addSourceLine(NDie, NS);
return &NDie;
}
Index: test/DebugInfo/X86/gnu-public-names.ll
===================================================================
--- test/DebugInfo/X86/gnu-public-names.ll
+++ test/DebugInfo/X86/gnu-public-names.ll
@@ -127,6 +127,8 @@
; in clang.
; CHECK: DW_TAG_imported_module
; CHECK-NOT: {{DW_TAG|NULL}}
+; CHECK: DW_TAG_imported_module
+; CHECK-NOT: {{DW_TAG|NULL}}
; CHECK: NULL
; CHECK-NOT: {{DW_TAG|NULL}}
@@ -147,6 +149,7 @@
; CHECK: DW_AT_name {{.*}} "i"
; CHECK-NOT: {{DW_TAG|NULL}}
; CHECK: NULL
+; CHECK: DW_TAG_imported_module
; CHECK-NOT: {{DW_TAG|NULL}}
; CHECK: [[MEM_FUNC:0x[0-9a-f]+]]: DW_TAG_subprogram
Index: test/DebugInfo/anonymous-namespace.ll
===================================================================
--- test/DebugInfo/anonymous-namespace.ll
+++ test/DebugInfo/anonymous-namespace.ll
@@ -0,0 +1,37 @@
+; RUN: llc -O0 < %s | FileCheck %s
+; If the namespace is anonymous, add a DW_TAG_imported_module tag
+; containing DW_AT_import attribute with the reference to this namespace
+; entry.
+
+; namespace
+; {
+; int a = 5;
+; }
+; int *b = &a;
+
+; ModuleID = 'anon.cpp'
+
+ at _ZN12_GLOBAL__N_11aE = internal global i32 5, align 4
+ at b = global i32* @_ZN12_GLOBAL__N_11aE, align 8
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!10, !11}
+!llvm.ident = !{!12}
+
+!0 = !{!"0x11\004\00clang version 3.7.0 (trunk 230293) (llvm/trunk 230292:230313M)\000\00\000\00\001", !1, !2, !2, !2, !3, !2} ; [ DW_TAG_compile_unit ] [/home/kromanova/anon.cpp] [DW_LANG_C_plus_plus]
+!1 = !{!"anon.cpp", !"/home/kromanova"}
+!2 = !{}
+!3 = !{!4, !8}
+!4 = !{!"0x34\00b\00b\00\005\000\001", null, !5, !6, i32** @b, null} ; [ DW_TAG_variable ] [b] [line 5] [def]
+!5 = !{!"0x29", !1} ; [ DW_TAG_file_type ] [/home/kromanova/anon.cpp]
+!6 = !{!"0xf\00\000\0064\0064\000\000", null, null, !7} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from int]
+!7 = !{!"0x24\00int\000\0032\0032\000\000\005", null, null} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
+!8 = !{!"0x34\00a\00a\00_ZN12_GLOBAL__N_11aE\003\001\001", !9, !5, !7, i32* @_ZN12_GLOBAL__N_11aE, null} ; [ DW_TAG_variable ] [a] [line 3] [local] [def]
+!9 = !{!"0x39\00\002", !1, null} ; [ DW_TAG_namespace ] [line 2]
+!10 = !{i32 2, !"Dwarf Version", i32 4}
+!11 = !{i32 2, !"Debug Info Version", i32 2}
+!12 = !{!"clang version 3.7.0 (trunk 230293) (llvm/trunk 230292:230313M)"}
+
+;CHECK: DW_TAG_imported_module
+;CHECK-NEXT: DW_AT_import
+;CHECK-NEXT: DW_AT_artificial
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7895.20928.patch
Type: text/x-patch
Size: 3577 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150228/efde2f3f/attachment.bin>
More information about the llvm-commits
mailing list