From 28ffd3261ff1ff2c096e8c7136e3f2579f6c07c5 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 8 Feb 2017 20:44:00 +0000 Subject: [PATCH] ThinLTOBitcodeWriter: Strip debug info from merged module. This module will contain nothing but vtable definitions and (soon) available_externally function definitions, so there is no point in keeping debug info in the module. Differential Revision: https://reviews.llvm.org/D28913 llvm-svn: 294511 --- llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp | 2 ++ llvm/test/Transforms/ThinLTOBitcodeWriter/split.ll | 7 +++++++ 2 files changed, 9 insertions(+) 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}