Do not bother to emit debug info for nameless global variable.
authorDevang Patel <dpatel@apple.com>
Fri, 6 Nov 2009 17:58:12 +0000 (17:58 +0000)
committerDevang Patel <dpatel@apple.com>
Fri, 6 Nov 2009 17:58:12 +0000 (17:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86259 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/DebugInfo.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
test/DebugInfo/2009-11-06-NamelessGlobalVariable.ll [new file with mode: 0644]

index b64dbf433aae066d7e7cc0f00dc82519413eea00..7c1cc35ee9dc85eacda330f166f02cf424dfcf29 100644 (file)
@@ -366,6 +366,9 @@ bool DIGlobalVariable::Verify() const {
   if (isNull())
     return false;
 
+  if (!getDisplayName())
+    return false;
+
   if (getContext().isNull())
     return false;
 
index 6b54e618c3d3dd4ac9793367f1e78cd9ed4ee900..de8cfc6b999b4fcfae3fc56e29e2afc1218c8de0 100644 (file)
@@ -1098,8 +1098,8 @@ DIE *DwarfDebug::ConstructEnumTypeDIE(CompileUnit *DW_Unit, DIEnumerator *ETy) {
 DIE *DwarfDebug::CreateGlobalVariableDIE(CompileUnit *DW_Unit,
                                          const DIGlobalVariable &GV) {
   // If the global variable was optmized out then no need to create debug info entry.
-  if (!GV.getGlobal())
-    return NULL;
+  if (!GV.getGlobal()) return NULL;
+  if (!GV.getDisplayName()) return NULL;
 
   DIE *GVDie = new DIE(dwarf::DW_TAG_variable);
   AddString(GVDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, 
diff --git a/test/DebugInfo/2009-11-06-NamelessGlobalVariable.ll b/test/DebugInfo/2009-11-06-NamelessGlobalVariable.ll
new file mode 100644 (file)
index 0000000..739def8
--- /dev/null
@@ -0,0 +1,8 @@
+; RUN: llc %s -o /dev/null
+@0 = internal constant i32 1                      ; <i32*> [#uses=1]
+
+!llvm.dbg.gv = !{!0}
+
+!0 = metadata !{i32 458804, i32 0, metadata !1, metadata !"", metadata !"", metadata !"", metadata !1, i32 378, metadata !2, i1 true, i1 true, i32* @0}; [DW_TAG_variable ]
+!1 = metadata !{i32 458769, i32 0, i32 1, metadata !"cbdsqr.f", metadata !"/home/duncan/LLVM/dragonegg/unsolved/", metadata !"4.5.0 20091030 (experimental)", i1 true, i1 false, metadata !"", i32 0}; [DW_TAG_compile_unit ]
+!2 = metadata !{i32 458788, metadata !1, metadata !"integer(kind=4)", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5}; [DW_TAG_base_type ]