r220383 - Support using sample profiles with partial debug info (driver)
Diego Novillo
dnovillo at google.com
Wed Oct 22 06:00:05 PDT 2014
Author: dnovillo
Date: Wed Oct 22 08:00:05 2014
New Revision: 220383
URL: http://llvm.org/viewvc/llvm-project?rev=220383&view=rev
Log:
Support using sample profiles with partial debug info (driver)
Summary:
When using a profile, we used to require the use -gmlt so that we could
get access to the line locations. This is used to match line numbers in
the input profile to the line numbers in the function's IR.
But this is actually not necessary. The driver can provide source
location tracking without the emission of debug information. In these
cases, the annotation 'llvm.dbg.cu' is missing from the IR, but the
actual line location annotations are still present.
This patch tells the driver to only emit source location tracking
when -fprofile-sample-use is present in the command line.
Reviewers: echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D5888
Added:
cfe/trunk/test/Frontend/Inputs/profile-sample-use-loc-tracking.prof
cfe/trunk/test/Frontend/profile-sample-use-loc-tracking.c
Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=220383&r1=220382&r2=220383&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Oct 22 08:00:05 2014
@@ -575,8 +575,14 @@ static bool ParseCodeGenArgs(CodeGenOpti
NeedLocTracking = true;
}
- // If the user requested one of the flags in the -Rpass family, make sure
- // that the backend tracks source location information.
+ // If the user requested to use a sample profile for PGO, then the
+ // backend will need to track source location information so the profile
+ // can be incorporated into the IR.
+ if (!Opts.SampleProfileFile.empty())
+ NeedLocTracking = true;
+
+ // If the user requested a flag that requires source locations available in
+ // the backend, make sure that the backend tracks source location information.
if (NeedLocTracking && Opts.getDebugInfo() == CodeGenOptions::NoDebugInfo)
Opts.setDebugInfo(CodeGenOptions::LocTrackingOnly);
Added: cfe/trunk/test/Frontend/Inputs/profile-sample-use-loc-tracking.prof
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/Inputs/profile-sample-use-loc-tracking.prof?rev=220383&view=auto
==============================================================================
--- cfe/trunk/test/Frontend/Inputs/profile-sample-use-loc-tracking.prof (added)
+++ cfe/trunk/test/Frontend/Inputs/profile-sample-use-loc-tracking.prof Wed Oct 22 08:00:05 2014
@@ -0,0 +1,2 @@
+bar:100:100
+1: 2000
Added: cfe/trunk/test/Frontend/profile-sample-use-loc-tracking.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/profile-sample-use-loc-tracking.c?rev=220383&view=auto
==============================================================================
--- cfe/trunk/test/Frontend/profile-sample-use-loc-tracking.c (added)
+++ cfe/trunk/test/Frontend/profile-sample-use-loc-tracking.c Wed Oct 22 08:00:05 2014
@@ -0,0 +1,19 @@
+// This file tests that -fprofile-sample-use enables location tracking
+// generation in the same way that -Rpass does. The sample profiler needs
+// to associate line locations in the profile to the code, so it needs the
+// frontend to emit source location annotations.
+
+// RUN: %clang_cc1 %s -fprofile-sample-use=%S/Inputs/profile-sample-use-loc-tracking.prof -emit-llvm -o - 2>/dev/null | FileCheck %s
+
+// -fprofile-sample-use should produce source location annotations, exclusively
+// (just like -gmlt).
+// CHECK: , !dbg !
+// CHECK-NOT: DW_TAG_base_type
+
+// But llvm.dbg.cu should be missing (to prevent writing debug info to
+// the final output).
+// CHECK-NOT: !llvm.dbg.cu = !{
+
+int bar(int j) {
+ return (j + j - 2) * (j - 2) * j;
+}
More information about the cfe-commits
mailing list