Use llvm.dbg.cu named metadata to collect compile units.
authorDevang Patel <dpatel@apple.com>
Tue, 3 May 2011 16:18:28 +0000 (16:18 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 3 May 2011 16:18:28 +0000 (16:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130756 91177308-0d34-0410-b5e6-96231b3b80d8

docs/SourceLevelDebugging.html
lib/Analysis/DIBuilder.cpp

index c9ae0202def4e42c399e18e1862d4c20d389c914..4c4439fd59ff28a42a79105cd17d8a0fcada4d20 100644 (file)
@@ -342,7 +342,9 @@ height="369">
    that produced it.</p>
 
 <p>Compile unit descriptors provide the root context for objects declared in a
-   specific compilation unit. File descriptors are defined using this context.</p>
+   specific compilation unit. File descriptors are defined using this context.
+   These descriptors are collected by a named metadata 
+   <tt>!llvm.dbg.cu</tt>.
 
 </div>
 
index dc98c9e67a801ae9c3bf8ff531fca4eb451640c4..1375e497ac675be4bf762f7934dfeac7321dceef 100644 (file)
@@ -51,6 +51,10 @@ void DIBuilder::createCompileUnit(unsigned Lang, StringRef Filename,
     ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeVer)
   };
   TheCU = DICompileUnit(MDNode::get(VMContext, Elts));
+
+  // Create a named metadata so that it is easier to find cu in a module.
+  NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
+  NMD->addOperand(TheCU);
 }
 
 /// createFile - Create a file descriptor to hold debugging information