[PATCH] Anonymous namespaces are missing import DW_TAG_imported_module.

Katya Romanova Katya_Romanova at playstation.sony.com
Wed Mar 18 01:13:18 PDT 2015


Added PS4 flag (as David requested).
Modified the tests accordingly.


http://reviews.llvm.org/D7895

Files:
  lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  test/DebugInfo/anonymous-namespace.ll

Index: lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1231,6 +1231,14 @@
     Name = "(anonymous namespace)";
   DD->addAccelNamespace(Name, NDie);
   addGlobalName(Name, NDie, NS.getContext());
+  if (Triple(Asm->getTargetTriple()).isPS4() && !Name.empty()) { 
+    // 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/anonymous-namespace.ll
===================================================================
--- test/DebugInfo/anonymous-namespace.ll
+++ test/DebugInfo/anonymous-namespace.ll
@@ -0,0 +1,36 @@
+; RUN: %llc_dwarf -mtriple=x86_64-scei-ps4 -O0 -filetype=obj %s -o - | llvm-dwarfdump -debug-dump=info - | 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 = !{!9, !10}
+!llvm.ident = !{!11}
+
+!0 = !MDCompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.7.0 (trunk 232565)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !2, globals: !3, imports: !2)
+!1 = !MDFile(filename: "test.cpp", directory: "/home/test/DebugInfo")
+!2 = !{}
+!3 = !{!4, !7}
+!4 = !MDGlobalVariable(name: "b", scope: !0, file: !1, line: 5, type: !5, isLocal: false, isDefinition: true, variable: i32** @b)
+!5 = !MDDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64, align: 64)
+!6 = !MDBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!7 = !MDGlobalVariable(name: "a", linkageName: "_ZN12_GLOBAL__N_11aE", scope: !8, file: !1, line: 3, type: !6, isLocal: true, isDefinition: true, variable: i32* @_ZN12_GLOBAL__N_11aE)
+!8 = !MDNamespace(scope: null, file: !1, line: 2)
+!9 = !{i32 2, !"Dwarf Version", i32 4}
+!10 = !{i32 2, !"Debug Info Version", i32 3}
+!11 = !{!"clang version 3.7.0 (trunk 232565)"}
+
+;CHECK: DW_TAG_imported_module
+;CHECK: 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.22164.patch
Type: text/x-patch
Size: 2641 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150318/68e8ee24/attachment.bin>


More information about the llvm-commits mailing list