Index: include/llvm/IR/DIBuilder.h =================================================================== --- include/llvm/IR/DIBuilder.h +++ include/llvm/IR/DIBuilder.h @@ -87,7 +87,7 @@ public: explicit DIBuilder(Module &M); enum ComplexAddrKind { OpPlus=1, OpDeref }; - enum DebugEmissionKind { FullDebug=1, LineTablesOnly }; + enum DebugEmissionKind { FullDebug=1, LineTablesOnly, LocTrackingOnly }; /// finalize - Construct any deferred debug info descriptors. void finalize(); @@ -108,6 +108,7 @@ /// Objective-C. /// @param SplitName The name of the file that we'll split debug info out /// into. + /// @param Kind The kind of debug information to generate. DICompileUnit createCompileUnit(unsigned Lang, StringRef File, StringRef Dir, StringRef Producer, bool isOptimized, StringRef Flags, Index: lib/IR/DIBuilder.cpp =================================================================== --- lib/IR/DIBuilder.cpp +++ lib/IR/DIBuilder.cpp @@ -140,8 +140,14 @@ MDNode *CUNode = 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(CUNode); + // Note that we only generate this when the caller wants to actually + // emit debug information. When we are only interested in tracking + // source line locations throughout the backend, we prevent codegen from + // emitting debug info in the final output by not generating llvm.dbg.cu. + if (Kind != LocTrackingOnly) { + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu"); + NMD->addOperand(CUNode); + } return DICompileUnit(CUNode); }