From 913690c7bc1baf27d6a170d5d266023f04d790fb Mon Sep 17 00:00:00 2001 From: Diego Novillo Date: Tue, 24 Jun 2014 17:02:17 +0000 Subject: Add new debug kind LocTrackingOnly. Summary: This new debug emission kind supports emitting line location information in all instructions, but stops code generation from emitting debug info to the final output. This mode is useful when the backend wants to track source locations during code generation, but it does not want to produce debug info. This is currently used by optimization remarks (-Rpass, -Rpass-missed and -Rpass-analysis). When one of the -Rpass flags is used, the front end will enable location tracking, only if no other debug option is enabled. To prevent debug information from being generated, a new debug info kind LocTrackingOnly causes DIBuilder::createCompileUnit() to not emit the llvm.dbg.cu annotation. This blocks final code generation from generating debug info in the back end. Depends on D4234. Reviewers: echristo, dblaikie Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4235 llvm-svn: 211610 --- clang/lib/Frontend/CompilerInvocation.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'clang/lib/Frontend/CompilerInvocation.cpp') diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 71138861d06..e4cee346858 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -550,18 +550,30 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, } Opts.DependentLibraries = Args.getAllArgValues(OPT_dependent_lib); + bool NeedLocTracking = false; - if (Arg *A = Args.getLastArg(OPT_Rpass_EQ)) + if (Arg *A = Args.getLastArg(OPT_Rpass_EQ)) { Opts.OptimizationRemarkPattern = GenerateOptimizationRemarkRegex(Diags, Args, A); + NeedLocTracking = true; + } - if (Arg *A = Args.getLastArg(OPT_Rpass_missed_EQ)) + if (Arg *A = Args.getLastArg(OPT_Rpass_missed_EQ)) { Opts.OptimizationRemarkMissedPattern = GenerateOptimizationRemarkRegex(Diags, Args, A); + NeedLocTracking = true; + } - if (Arg *A = Args.getLastArg(OPT_Rpass_analysis_EQ)) + if (Arg *A = Args.getLastArg(OPT_Rpass_analysis_EQ)) { Opts.OptimizationRemarkAnalysisPattern = GenerateOptimizationRemarkRegex(Diags, Args, A); + NeedLocTracking = true; + } + + // If the user requested one of the flags in the -Rpass family, make sure + // that the backend tracks source location information. + if (NeedLocTracking && Opts.getDebugInfo() == CodeGenOptions::NoDebugInfo) + Opts.setDebugInfo(CodeGenOptions::LocTrackingOnly); return Success; } -- cgit v1.2.3