diff --git a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp index 6ec69e321980..74fada5b4584 100644 --- a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp +++ b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp @@ -19,6 +19,7 @@ #include "llvm/Analysis/TypeMetadataUtils.h" #include "llvm/Bitcode/BitcodeWriter.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/DebugInfo.h" #include "llvm/IR/Intrinsics.h" #include "llvm/IR/Module.h" #include "llvm/IR/PassManager.h" @@ -261,6 +262,7 @@ void splitAndWriteThinLTOBitcode(raw_ostream &OS, Module &M) { ValueToValueMapTy VMap; std::unique_ptr MergedM(CloneModule(&M, VMap, IsInMergedM)); + StripDebugInfo(*MergedM); filterModule(&M, [&](const GlobalValue *GV) { return !IsInMergedM(GV); }); diff --git a/llvm/test/Transforms/ThinLTOBitcodeWriter/split.ll b/llvm/test/Transforms/ThinLTOBitcodeWriter/split.ll index b86d7017c8bb..98799a2c01fb 100644 --- a/llvm/test/Transforms/ThinLTOBitcodeWriter/split.ll +++ b/llvm/test/Transforms/ThinLTOBitcodeWriter/split.ll @@ -26,3 +26,10 @@ define i8* @f() { ; M1: !0 = !{i32 0, !"typeid"} !0 = !{i32 0, !"typeid"} + +; M0: !llvm.dbg.cu +; M1-NOT: !llvm.dbg.cu +!llvm.dbg.cu = !{} + +!1 = !{i32 2, !"Debug Info Version", i32 3} +!llvm.module.flags = !{!1}