summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@google.com>2014-06-24 17:02:17 +0000
committerDiego Novillo <dnovillo@google.com>2014-06-24 17:02:17 +0000
commit913690c7bc1baf27d6a170d5d266023f04d790fb (patch)
tree198cded6b5e0f3c2aed812904aa681cdb00bb42b /clang/lib
parent56653fdada178e97bbdaf9682cd691b8c3184d93 (diff)
downloadbcm5719-llvm-913690c7bc1baf27d6a170d5d266023f04d790fb.tar.gz
bcm5719-llvm-913690c7bc1baf27d6a170d5d266023f04d790fb.zip
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
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp9
-rw-r--r--clang/lib/CodeGen/CodeGenAction.cpp10
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp18
3 files changed, 21 insertions, 16 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index d0861507bcd..048c8f8f367 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -375,9 +375,10 @@ void CGDebugInfo::CreateCompileUnit() {
TheCU = DBuilder.createCompileUnit(
LangTag, Filename, getCurrentDirname(), Producer, LO.Optimize,
CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers, SplitDwarfFilename,
- DebugKind == CodeGenOptions::DebugLineTablesOnly
+ DebugKind <= CodeGenOptions::DebugLineTablesOnly
? llvm::DIBuilder::LineTablesOnly
- : llvm::DIBuilder::FullDebug);
+ : llvm::DIBuilder::FullDebug,
+ DebugKind != CodeGenOptions::LocTrackingOnly);
}
/// CreateType - Get the Basic type from the cache or create a new
@@ -2341,7 +2342,7 @@ llvm::DIScope CGDebugInfo::getDeclarationOrDefinition(const Decl *D) {
/// getFunctionDeclaration - Return debug info descriptor to describe method
/// declaration for the given method definition.
llvm::DISubprogram CGDebugInfo::getFunctionDeclaration(const Decl *D) {
- if (!D || DebugKind == CodeGenOptions::DebugLineTablesOnly)
+ if (!D || DebugKind <= CodeGenOptions::DebugLineTablesOnly)
return llvm::DISubprogram();
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D);
@@ -2386,7 +2387,7 @@ llvm::DISubprogram CGDebugInfo::getFunctionDeclaration(const Decl *D) {
llvm::DICompositeType CGDebugInfo::getOrCreateFunctionType(const Decl *D,
QualType FnType,
llvm::DIFile F) {
- if (!D || DebugKind == CodeGenOptions::DebugLineTablesOnly)
+ if (!D || DebugKind <= CodeGenOptions::DebugLineTablesOnly)
// Create fake but valid subroutine type. Otherwise
// llvm::DISubprogram::Verify() would return false, and
// subprogram DIE will miss DW_AT_decl_file and
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp
index 407fe940499..f162c30700b 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -443,15 +443,7 @@ void BackendConsumer::EmitOptimizationRemark(
Diags.Report(Loc, DiagID) << AddFlagValue(D.getPassName())
<< D.getMsg().str();
- if (Line == 0)
- // If we could not extract a source location for the diagnostic,
- // inform the user how they can get source locations back.
- //
- // FIXME: We should really be generating !srcloc annotations when
- // -Rpass is used. !srcloc annotations need to be emitted in
- // approximately the same spots as !dbg nodes.
- Diags.Report(Loc, diag::note_fe_backend_optimization_remark_missing_loc);
- else if (DILoc.isInvalid())
+ if (DILoc.isInvalid())
// If we were not able to translate the file:line:col information
// back to a SourceLocation, at least emit a note stating that
// we could not translate this location. This can happen in the
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;
}
OpenPOWER on IntegriCloud