From: Adrian Prantl Date: Fri, 4 Aug 2017 23:08:57 +0000 (+0000) Subject: Debug Info: Set the DICompileUnit's isOptimized flag when compiling with LTO. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e6ae7627deb09f3433bbc24ac6d6218e084032b5;p=clang Debug Info: Set the DICompileUnit's isOptimized flag when compiling with LTO. rdar://problem/27640939 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@310147 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index c9aa04815f..e5955c0b8b 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -527,16 +527,15 @@ void CGDebugInfo::CreateCompileUnit() { // Create new compile unit. // FIXME - Eliminate TheCU. + auto &CGOpts = CGM.getCodeGenOpts(); TheCU = DBuilder.createCompileUnit( LangTag, DBuilder.createFile(remapDIPath(MainFileName), remapDIPath(getCurrentDirname()), CSKind, Checksum), - Producer, LO.Optimize, CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers, - CGM.getCodeGenOpts().EnableSplitDwarf - ? "" - : CGM.getCodeGenOpts().SplitDwarfFile, - EmissionKind, 0 /* DWOid */, CGM.getCodeGenOpts().SplitDwarfInlining, - CGM.getCodeGenOpts().DebugInfoForProfiling); + Producer, LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex, + CGOpts.DwarfDebugFlags, RuntimeVers, + CGOpts.EnableSplitDwarf ? "" : CGOpts.SplitDwarfFile, EmissionKind, + 0 /* DWOid */, CGOpts.SplitDwarfInlining, CGOpts.DebugInfoForProfiling); } llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) { diff --git a/test/CodeGen/debug-info-lto.c b/test/CodeGen/debug-info-lto.c new file mode 100644 index 0000000000..5dab0a1264 --- /dev/null +++ b/test/CodeGen/debug-info-lto.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -flto -emit-llvm -debug-info-kind=standalone %s -o - | FileCheck %s +// RUN: %clang_cc1 -flto=thin -emit-llvm -debug-info-kind=standalone %s -o - | FileCheck %s +// The "o" in LTO stands for optimization! +// CHECK: !DICompileUnit({{.*}} isOptimized: true