r371488 - Revert "clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM"

Petr Hosek via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 9 23:25:13 PDT 2019


Author: phosek
Date: Mon Sep  9 23:25:13 2019
New Revision: 371488

URL: http://llvm.org/viewvc/llvm-project?rev=371488&view=rev
Log:
Revert "clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM"

This reverts commit r371484: this broke sanitizer-x86_64-linux-fast bot.

Removed:
    cfe/trunk/test/Profile/Inputs/misexpect-branch-nonconst-expect-arg.proftext
    cfe/trunk/test/Profile/Inputs/misexpect-branch.proftext
    cfe/trunk/test/Profile/Inputs/misexpect-switch-default-only.proftext
    cfe/trunk/test/Profile/Inputs/misexpect-switch-default.proftext
    cfe/trunk/test/Profile/Inputs/misexpect-switch.proftext
    cfe/trunk/test/Profile/misexpect-branch-cold.c
    cfe/trunk/test/Profile/misexpect-branch-nonconst-expected-val.c
    cfe/trunk/test/Profile/misexpect-branch-unpredictable.c
    cfe/trunk/test/Profile/misexpect-branch.c
    cfe/trunk/test/Profile/misexpect-switch-default.c
    cfe/trunk/test/Profile/misexpect-switch-nonconst.c
    cfe/trunk/test/Profile/misexpect-switch-only-default-case.c
    cfe/trunk/test/Profile/misexpect-switch.c
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
    cfe/trunk/include/clang/Basic/DiagnosticGroups.td
    cfe/trunk/lib/CodeGen/CodeGenAction.cpp
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=371488&r1=371487&r2=371488&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Mon Sep  9 23:25:13 2019
@@ -275,12 +275,7 @@ def warn_profile_data_missing : Warning<
 def warn_profile_data_unprofiled : Warning<
   "no profile data available for file \"%0\"">,
   InGroup<ProfileInstrUnprofiled>;
-def warn_profile_data_misexpect : Warning<
-  "Potential performance regression from use of __builtin_expect(): "
-  "Annotation was correct on %0 of profiled executions.">,
-  BackendInfo,
-  InGroup<MisExpect>,
-  DefaultIgnore;
+
 } // end of instrumentation issue category
 
 }

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=371488&r1=371487&r2=371488&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Mon Sep  9 23:25:13 2019
@@ -1042,7 +1042,6 @@ def BackendOptimizationFailure : DiagGro
 def ProfileInstrMissing : DiagGroup<"profile-instr-missing">;
 def ProfileInstrOutOfDate : DiagGroup<"profile-instr-out-of-date">;
 def ProfileInstrUnprofiled : DiagGroup<"profile-instr-unprofiled">;
-def MisExpect : DiagGroup<"misexpect">;
 
 // AddressSanitizer frontend instrumentation remarks.
 def SanitizeAddressRemarks : DiagGroup<"sanitize-address">;

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=371488&r1=371487&r2=371488&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Mon Sep  9 23:25:13 2019
@@ -14,7 +14,6 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclGroup.h"
-#include "clang/Basic/DiagnosticFrontend.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangStandard.h"
 #include "clang/Basic/SourceManager.h"
@@ -366,9 +365,6 @@ namespace clang {
     bool StackSizeDiagHandler(const llvm::DiagnosticInfoStackSize &D);
     /// Specialized handler for unsupported backend feature diagnostic.
     void UnsupportedDiagHandler(const llvm::DiagnosticInfoUnsupported &D);
-    /// Specialized handler for misexpect warnings.
-    /// Note that misexpect remarks are emitted through ORE
-    void MisExpectDiagHandler(const llvm::DiagnosticInfoMisExpect &D);
     /// Specialized handlers for optimization remarks.
     /// Note that these handlers only accept remarks and they always handle
     /// them.
@@ -621,25 +617,6 @@ void BackendConsumer::UnsupportedDiagHan
         << Filename << Line << Column;
 }
 
-void BackendConsumer::MisExpectDiagHandler(
-    const llvm::DiagnosticInfoMisExpect &D) {
-  StringRef Filename;
-  unsigned Line, Column;
-  bool BadDebugInfo = false;
-  FullSourceLoc Loc =
-      getBestLocationFromDebugLoc(D, BadDebugInfo, Filename, Line, Column);
-
-  Diags.Report(Loc, diag::warn_profile_data_misexpect) << D.getMsg().str();
-
-  if (BadDebugInfo)
-    // 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
-    // case of #line directives.
-    Diags.Report(Loc, diag::note_fe_backend_invalid_loc)
-        << Filename << Line << Column;
-}
-
 void BackendConsumer::EmitOptimizationMessage(
     const llvm::DiagnosticInfoOptimizationBase &D, unsigned DiagID) {
   // We only support warnings and remarks.
@@ -810,9 +787,6 @@ void BackendConsumer::DiagnosticHandlerI
   case llvm::DK_Unsupported:
     UnsupportedDiagHandler(cast<DiagnosticInfoUnsupported>(DI));
     return;
-  case llvm::DK_MisExpect:
-    MisExpectDiagHandler(cast<DiagnosticInfoMisExpect>(DI));
-    return;
   default:
     // Plugin IDs are not bound to any value as they are set dynamically.
     ComputeDiagRemarkID(Severity, backend_plugin, DiagID);

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=371488&r1=371487&r2=371488&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Sep  9 23:25:13 2019
@@ -3453,9 +3453,6 @@ bool CompilerInvocation::CreateFromArgs(
     }
   }
 
-  if (Diags.isIgnored(diag::warn_profile_data_misexpect, SourceLocation()))
-    Res.FrontendOpts.LLVMArgs.push_back("-pgo-warn-misexpect");
-
   LangOpts.FunctionAlignment =
       getLastArgIntValue(Args, OPT_function_alignment, 0, Diags);
 

Removed: cfe/trunk/test/Profile/Inputs/misexpect-branch-nonconst-expect-arg.proftext
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/Inputs/misexpect-branch-nonconst-expect-arg.proftext?rev=371487&view=auto
==============================================================================
--- cfe/trunk/test/Profile/Inputs/misexpect-branch-nonconst-expect-arg.proftext (original)
+++ cfe/trunk/test/Profile/Inputs/misexpect-branch-nonconst-expect-arg.proftext (removed)
@@ -1,9 +0,0 @@
-bar
-# Func Hash:
-11262309464
-# Num Counters:
-2
-# Counter Values:
-200000
-2
-

Removed: cfe/trunk/test/Profile/Inputs/misexpect-branch.proftext
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/Inputs/misexpect-branch.proftext?rev=371487&view=auto
==============================================================================
--- cfe/trunk/test/Profile/Inputs/misexpect-branch.proftext (original)
+++ cfe/trunk/test/Profile/Inputs/misexpect-branch.proftext (removed)
@@ -1,9 +0,0 @@
-bar
-# Func Hash:
-45795613684824
-# Num Counters:
-2
-# Counter Values:
-200000
-0
-

Removed: cfe/trunk/test/Profile/Inputs/misexpect-switch-default-only.proftext
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/Inputs/misexpect-switch-default-only.proftext?rev=371487&view=auto
==============================================================================
--- cfe/trunk/test/Profile/Inputs/misexpect-switch-default-only.proftext (original)
+++ cfe/trunk/test/Profile/Inputs/misexpect-switch-default-only.proftext (removed)
@@ -1,12 +0,0 @@
-main
-# Func Hash:
-79676873694057560
-# Num Counters:
-5
-# Counter Values:
-1
-20
-20000
-20000
-20000
-

Removed: cfe/trunk/test/Profile/Inputs/misexpect-switch-default.proftext
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/Inputs/misexpect-switch-default.proftext?rev=371487&view=auto
==============================================================================
--- cfe/trunk/test/Profile/Inputs/misexpect-switch-default.proftext (original)
+++ cfe/trunk/test/Profile/Inputs/misexpect-switch-default.proftext (removed)
@@ -1,16 +0,0 @@
-main
-# Func Hash:
-8712453512413296413
-# Num Counters:
-9
-# Counter Values:
-1
-20000
-20000
-4066
-11889
-0
-0
-4045
-0
-

Removed: cfe/trunk/test/Profile/Inputs/misexpect-switch.proftext
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/Inputs/misexpect-switch.proftext?rev=371487&view=auto
==============================================================================
--- cfe/trunk/test/Profile/Inputs/misexpect-switch.proftext (original)
+++ cfe/trunk/test/Profile/Inputs/misexpect-switch.proftext (removed)
@@ -1,16 +0,0 @@
-main
-# Func Hash:
-1965403898329309329
-# Num Counters:
-9
-# Counter Values:
-1
-20
-20000
-20000
-12
-26
-0
-0
-19962
-

Removed: cfe/trunk/test/Profile/misexpect-branch-cold.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/misexpect-branch-cold.c?rev=371487&view=auto
==============================================================================
--- cfe/trunk/test/Profile/misexpect-branch-cold.c (original)
+++ cfe/trunk/test/Profile/misexpect-branch-cold.c (removed)
@@ -1,26 +0,0 @@
-// Test that misexpect emits no warning when prediction is correct
-
-// RUN: llvm-profdata merge %S/Inputs/misexpect-branch.proftext -o %t.profdata
-// RUN: %clang_cc1 %s -O2 -o - -disable-llvm-passes -emit-llvm -fprofile-instrument-use-path=%t.profdata -verify -Wmisexpect
-
-// expected-no-diagnostics
-#define likely(x) __builtin_expect(!!(x), 1)
-#define unlikely(x) __builtin_expect(!!(x), 0)
-
-int foo(int);
-int baz(int);
-int buzz();
-
-const int inner_loop = 100;
-const int outer_loop = 2000;
-
-int bar() {
-  int rando = buzz();
-  int x = 0;
-  if (unlikely(rando % (outer_loop * inner_loop) == 0)) {
-    x = baz(rando);
-  } else {
-    x = foo(50);
-  }
-  return x;
-}

Removed: cfe/trunk/test/Profile/misexpect-branch-nonconst-expected-val.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/misexpect-branch-nonconst-expected-val.c?rev=371487&view=auto
==============================================================================
--- cfe/trunk/test/Profile/misexpect-branch-nonconst-expected-val.c (original)
+++ cfe/trunk/test/Profile/misexpect-branch-nonconst-expected-val.c (removed)
@@ -1,23 +0,0 @@
-// Test that misexpect emits no warning when condition is not a compile-time constant
-
-// RUN: llvm-profdata merge %S/Inputs/misexpect-branch-nonconst-expect-arg.proftext -o %t.profdata
-// RUN: %clang_cc1 %s -O2 -o - -disable-llvm-passes -emit-llvm -fprofile-instrument-use-path=%t.profdata -verify -Wmisexpect
-
-// expected-no-diagnostics
-int foo(int);
-int baz(int);
-int buzz();
-
-const int inner_loop = 100;
-const int outer_loop = 2000;
-
-int bar() {
-  int rando = buzz();
-  int x = 0;
-  if (__builtin_expect(rando % (outer_loop * inner_loop) == 0, buzz())) {
-    x = baz(rando);
-  } else {
-    x = foo(50);
-  }
-  return x;
-}

Removed: cfe/trunk/test/Profile/misexpect-branch-unpredictable.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/misexpect-branch-unpredictable.c?rev=371487&view=auto
==============================================================================
--- cfe/trunk/test/Profile/misexpect-branch-unpredictable.c (original)
+++ cfe/trunk/test/Profile/misexpect-branch-unpredictable.c (removed)
@@ -1,25 +0,0 @@
-// Test that misexpect emits no warning when prediction is correct
-
-// RUN: llvm-profdata merge %S/Inputs/misexpect-branch.proftext -o %t.profdata
-// RUN: %clang_cc1 %s -O2 -o - -disable-llvm-passes -emit-llvm -fprofile-instrument-use-path=%t.profdata -verify -Wmisexpect
-
-// expected-no-diagnostics
-#define unpredictable(x) __builtin_unpredictable(!!(x))
-
-int foo(int);
-int baz(int);
-int buzz();
-
-const int inner_loop = 100;
-const int outer_loop = 2000;
-
-int bar() {
-  int rando = buzz();
-  int x = 0;
-  if (unpredictable(rando % (outer_loop * inner_loop) == 0)) {
-    x = baz(rando);
-  } else {
-    x = foo(50);
-  }
-  return x;
-}

Removed: cfe/trunk/test/Profile/misexpect-branch.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/misexpect-branch.c?rev=371487&view=auto
==============================================================================
--- cfe/trunk/test/Profile/misexpect-branch.c (original)
+++ cfe/trunk/test/Profile/misexpect-branch.c (removed)
@@ -1,28 +0,0 @@
-// Test that misexpect detects mis-annotated branches
-
-// RUN: llvm-profdata merge %S/Inputs/misexpect-branch.proftext -o %t.profdata
-// RUN: %clang_cc1 %s -O2 -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata -verify=imprecise -Wmisexpect
-// RUN: %clang_cc1 %s -O2 -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata -verify=exact -Wmisexpect -debug-info-kind=line-tables-only
-// RUN: %clang_cc1 %s -O2 -o - -disable-llvm-passes -emit-llvm -fprofile-instrument-use-path=%t.profdata -verify=foo
-
-// foo-no-diagnostics
-#define likely(x) __builtin_expect(!!(x), 1)
-#define unlikely(x) __builtin_expect(!!(x), 0)
-
-int foo(int);
-int baz(int);
-int buzz();
-
-const int inner_loop = 100;
-const int outer_loop = 2000;
-
-int bar() { // imprecise-warning-re {{Potential performance regression from use of __builtin_expect(): Annotation was correct on {{.+}}% ({{[0-9]+ / [0-9]+}}) of profiled executions.}}
-  int rando = buzz();
-  int x = 0;
-  if (likely(rando % (outer_loop * inner_loop) == 0)) { // exact-warning-re {{Potential performance regression from use of __builtin_expect(): Annotation was correct on {{.+}}% ({{[0-9]+ / [0-9]+}}) of profiled executions.}}
-    x = baz(rando);
-  } else {
-    x = foo(50);
-  }
-  return x;
-}

Removed: cfe/trunk/test/Profile/misexpect-switch-default.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/misexpect-switch-default.c?rev=371487&view=auto
==============================================================================
--- cfe/trunk/test/Profile/misexpect-switch-default.c (original)
+++ cfe/trunk/test/Profile/misexpect-switch-default.c (removed)
@@ -1,40 +0,0 @@
-// Test that misexpect detects mis-annotated switch statements for default case
-
-// RUN: llvm-profdata merge %S/Inputs/misexpect-switch-default.proftext -o %t.profdata
-// RUN: %clang_cc1 %s -O2 -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata -verify -Wmisexpect -debug-info-kind=line-tables-only
-
-int sum(int *buff, int size);
-int random_sample(int *buff, int size);
-int rand();
-void init_arry();
-
-const int inner_loop = 1000;
-const int outer_loop = 20;
-const int arry_size = 25;
-
-int arry[arry_size] = {0};
-
-int main() {
-  init_arry();
-  int val = 0;
-  int j;
-  for (j = 0; j < outer_loop * inner_loop; ++j) {
-    unsigned condition = rand() % 5;
-    switch (__builtin_expect(condition, 6)) { // expected-warning-re {{Potential performance regression from use of __builtin_expect(): Annotation was correct on {{.+}}% ({{[0-9]+ / [0-9]+}}) of profiled executions.}}
-    case 0:
-      val += sum(arry, arry_size);
-      break;
-    case 1:
-    case 2:
-    case 3:
-      break;
-    case 4:
-      val += random_sample(arry, arry_size);
-      break;
-    default:
-      __builtin_unreachable();
-    } // end switch
-  }   // end outer_loop
-
-  return 0;
-}

Removed: cfe/trunk/test/Profile/misexpect-switch-nonconst.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/misexpect-switch-nonconst.c?rev=371487&view=auto
==============================================================================
--- cfe/trunk/test/Profile/misexpect-switch-nonconst.c (original)
+++ cfe/trunk/test/Profile/misexpect-switch-nonconst.c (removed)
@@ -1,43 +0,0 @@
-// Test that misexpect emits no warning when switch condition is non-const
-
-// RUN: llvm-profdata merge %S/Inputs/misexpect-switch.proftext -o %t.profdata
-// RUN: %clang_cc1 %s -O2 -o - -disable-llvm-passes -emit-llvm -fprofile-instrument-use-path=%t.profdata -verify -Wmisexpect
-
-// expected-no-diagnostics
-int sum(int *buff, int size);
-int random_sample(int *buff, int size);
-int rand();
-void init_arry();
-
-const int inner_loop = 1000;
-const int outer_loop = 20;
-const int arry_size = 25;
-
-int arry[arry_size] = {0};
-
-int main() {
-  init_arry();
-  int val = 0;
-
-  int j, k;
-  for (j = 0; j < outer_loop; ++j) {
-    for (k = 0; k < inner_loop; ++k) {
-      unsigned condition = rand() % 10000;
-      switch (__builtin_expect(condition, rand())) {
-      case 0:
-        val += sum(arry, arry_size);
-        break;
-      case 1:
-      case 2:
-      case 3:
-      case 4:
-        val += random_sample(arry, arry_size);
-        break;
-      default:
-        __builtin_unreachable();
-      } // end switch
-    }   // end inner_loop
-  }     // end outer_loop
-
-  return 0;
-}

Removed: cfe/trunk/test/Profile/misexpect-switch-only-default-case.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/misexpect-switch-only-default-case.c?rev=371487&view=auto
==============================================================================
--- cfe/trunk/test/Profile/misexpect-switch-only-default-case.c (original)
+++ cfe/trunk/test/Profile/misexpect-switch-only-default-case.c (removed)
@@ -1,35 +0,0 @@
-// Test that misexpect emits no warning when there is only one switch case
-
-// RUN: llvm-profdata merge %S/Inputs/misexpect-switch-default-only.proftext -o %t.profdata
-// RUN: %clang_cc1 %s -O2 -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata -verify -Wmisexpect -debug-info-kind=line-tables-only
-
-// expected-no-diagnostics
-int sum(int *buff, int size);
-int random_sample(int *buff, int size);
-int rand();
-void init_arry();
-
-const int inner_loop = 1000;
-const int outer_loop = 20;
-const int arry_size = 25;
-
-int arry[arry_size] = {0};
-
-int main() {
-  init_arry();
-  int val = 0;
-
-  int j, k;
-  for (j = 0; j < outer_loop; ++j) {
-    for (k = 0; k < inner_loop; ++k) {
-      unsigned condition = rand() % 10000;
-      switch (__builtin_expect(condition, 0)) {
-      default:
-        val += random_sample(arry, arry_size);
-        break;
-      }; // end switch
-    }    // end inner_loop
-  }      // end outer_loop
-
-  return 0;
-}

Removed: cfe/trunk/test/Profile/misexpect-switch.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/misexpect-switch.c?rev=371487&view=auto
==============================================================================
--- cfe/trunk/test/Profile/misexpect-switch.c (original)
+++ cfe/trunk/test/Profile/misexpect-switch.c (removed)
@@ -1,41 +0,0 @@
-// Test that misexpect detects mis-annotated switch statements
-
-// RUN: llvm-profdata merge %S/Inputs/misexpect-switch.proftext -o %t.profdata
-// RUN: %clang_cc1 %s -O2 -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata -verify -Wmisexpect -debug-info-kind=line-tables-only
-
-int sum(int *buff, int size);
-int random_sample(int *buff, int size);
-int rand();
-void init_arry();
-
-const int inner_loop = 1000;
-const int outer_loop = 20;
-const int arry_size = 25;
-
-int arry[arry_size] = {0};
-
-int main() {
-  init_arry();
-  int val = 0;
-
-  int j, k;
-  for (j = 0; j < outer_loop; ++j) {
-    for (k = 0; k < inner_loop; ++k) {
-      unsigned condition = rand() % 10000;
-      switch (__builtin_expect(condition, 0)) { // expected-warning-re {{Potential performance regression from use of __builtin_expect(): Annotation was correct on {{.+}}% ({{[0-9]+ / [0-9]+}}) of profiled executions.}}
-      case 0:
-        val += sum(arry, arry_size);
-        break;
-      case 1:
-      case 2:
-      case 3:
-        break;
-      default:
-        val += random_sample(arry, arry_size);
-        break;
-      } // end switch
-    }   // end inner_loop
-  }     // end outer_loop
-
-  return 0;
-}




More information about the cfe-commits mailing list