vsk created this revision.

Clang warns that a profile is out-of-date if it can't find a profile
record for any function in a TU. This warning is now noisy because llvm
can dead-strip functions with profiling instrumentation.

Only emit the out-of-date warning if there is an actual record mismatch.


https://reviews.llvm.org/D28867

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/Profile/c-outdated-data.c


Index: test/Profile/c-outdated-data.c
===================================================================
--- test/Profile/c-outdated-data.c
+++ test/Profile/c-outdated-data.c
@@ -4,23 +4,23 @@
 // doesn't play well with warnings that have no line number.
 
 // RUN: llvm-profdata merge %S/Inputs/c-outdated-data.proftext -o %t.profdata
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name 
c-outdated-data.c %s -o /dev/null -emit-llvm 
-fprofile-instrument-use-path=%t.profdata -Wprofile-instr-dropped 2>&1 | 
FileCheck %s
-// CHECK: warning: profile data may be out of date: of 3 functions, 1 has no 
data and 1 has mismatched data that will be ignored
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name 
c-outdated-data.c %s -o /dev/null -emit-llvm 
-fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck %s 
-check-prefix=OUTDATED
+// OUTDATED: warning: profile data may be out of date: of 3 functions, 1 has 
no data and 1 has mismatched data that will be ignored
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -DGENERATE_USABLE_DATA 
-main-file-name c-outdated-data.c %s -o /dev/null -emit-llvm 
-fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck %s 
-check-prefix=USABLE -allow-empty
+// USABLE-NOT: warning: profile data may be out of date
 
 void no_usable_data() {
   int i = 0;
 
   if (i) {}
 
-#ifdef GENERATE_OUTDATED_DATA
+#ifdef GENERATE_USABLE_DATA
   if (i) {}
 #endif
 }
 
-#ifndef GENERATE_OUTDATED_DATA
 void no_data() {
 }
-#endif
 
 int main(int argc, const char *argv[]) {
   no_usable_data();
Index: lib/CodeGen/CodeGenModule.cpp
===================================================================
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -367,7 +367,7 @@
     if (MainFile.empty())
       MainFile = "<stdin>";
     Diags.Report(diag::warn_profile_data_unprofiled) << MainFile;
-  } else
+  } else if (Mismatched > 0)
     Diags.Report(diag::warn_profile_data_out_of_date) << Visited << Missing
                                                       << Mismatched;
 }


Index: test/Profile/c-outdated-data.c
===================================================================
--- test/Profile/c-outdated-data.c
+++ test/Profile/c-outdated-data.c
@@ -4,23 +4,23 @@
 // doesn't play well with warnings that have no line number.
 
 // RUN: llvm-profdata merge %S/Inputs/c-outdated-data.proftext -o %t.profdata
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-outdated-data.c %s -o /dev/null -emit-llvm -fprofile-instrument-use-path=%t.profdata -Wprofile-instr-dropped 2>&1 | FileCheck %s
-// CHECK: warning: profile data may be out of date: of 3 functions, 1 has no data and 1 has mismatched data that will be ignored
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-outdated-data.c %s -o /dev/null -emit-llvm -fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck %s -check-prefix=OUTDATED
+// OUTDATED: warning: profile data may be out of date: of 3 functions, 1 has no data and 1 has mismatched data that will be ignored
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -DGENERATE_USABLE_DATA -main-file-name c-outdated-data.c %s -o /dev/null -emit-llvm -fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck %s -check-prefix=USABLE -allow-empty
+// USABLE-NOT: warning: profile data may be out of date
 
 void no_usable_data() {
   int i = 0;
 
   if (i) {}
 
-#ifdef GENERATE_OUTDATED_DATA
+#ifdef GENERATE_USABLE_DATA
   if (i) {}
 #endif
 }
 
-#ifndef GENERATE_OUTDATED_DATA
 void no_data() {
 }
-#endif
 
 int main(int argc, const char *argv[]) {
   no_usable_data();
Index: lib/CodeGen/CodeGenModule.cpp
===================================================================
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -367,7 +367,7 @@
     if (MainFile.empty())
       MainFile = "<stdin>";
     Diags.Report(diag::warn_profile_data_unprofiled) << MainFile;
-  } else
+  } else if (Mismatched > 0)
     Diags.Report(diag::warn_profile_data_out_of_date) << Visited << Missing
                                                       << Mismatched;
 }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to