Skip to content

Commit

Permalink
Merged master:6861d938e5c9 into amd-gfx:fd0ff17ffcc9
Browse files Browse the repository at this point in the history
Local branch amd-gfx fd0ff17 Merged master:c8f4e06b29f4 into amd-gfx:21cc0393fbff
Remote branch master 6861d93 Revert "clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM"
  • Loading branch information
Sw authored and Sw committed Nov 14, 2020
2 parents fd0ff17 + 6861d93 commit a3d2301
Show file tree
Hide file tree
Showing 53 changed files with 62 additions and 1,871 deletions.
9 changes: 0 additions & 9 deletions clang/docs/DiagnosticsReference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7977,15 +7977,6 @@ This diagnostic is enabled by default.
+------------------------------------------------------------------------------------------------+


-Wmisexpect
-----------
**Diagnostic text:**

+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|:warning:`warning:` |nbsp| :diagtext:`Potential performance regression from use of \_\_builtin\_expect(): Annotation was correct on` |nbsp| :placeholder:`A` |nbsp| :diagtext:`of profiled executions.`|
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+


-Wmisleading-indentation
------------------------
**Diagnostic text:**
Expand Down
6 changes: 0 additions & 6 deletions clang/include/clang/Basic/DiagnosticFrontendKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,6 @@ 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

}
1 change: 0 additions & 1 deletion clang/include/clang/Basic/DiagnosticGroups.td
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,6 @@ def BackendOptimizationFailure : DiagGroup<"pass-failed">;
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">;
Expand Down
36 changes: 0 additions & 36 deletions clang/lib/CodeGen/CodeGenAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,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.
Expand Down Expand Up @@ -674,36 +671,6 @@ void BackendConsumer::UnsupportedDiagHandler(
<< Filename << Line << Column;
}

void BackendConsumer::MisExpectDiagHandler(
const llvm::DiagnosticInfoMisExpect &D) {
StringRef Filename;
unsigned Line, Column;
bool BadDebugInfo = false;
FullSourceLoc Loc;
std::string Msg;
raw_string_ostream MsgStream(Msg);
DiagnosticPrinterRawOStream DP(MsgStream);

// Context will be nullptr for IR input files, we will construct the diag
// message from llvm::DiagnosticInfoMisExpect.
if (Context != nullptr) {
Loc = getBestLocationFromDebugLoc(D, BadDebugInfo, Filename, Line, Column);
MsgStream << D.getMsg();
} else {
DiagnosticPrinterRawOStream DP(MsgStream);
D.print(DP);
}
Diags.Report(Loc, diag::warn_profile_data_misexpect) << MsgStream.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.
Expand Down Expand Up @@ -881,9 +848,6 @@ void BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &DI) {
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);
Expand Down
13 changes: 10 additions & 3 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7186,9 +7186,16 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(Input.getFilename());

const char *Exec = getToolChain().getDriver().getClangProgramPath();
C.addCommand(std::make_unique<Command>(JA, *this,
ResponseFileSupport::AtFileUTF8(),
Exec, CmdArgs, Inputs, Output));
if (D.CC1Main && !D.CCGenDiagnostics) {
// Invoke cc1as directly in this process.
C.addCommand(std::make_unique<CC1Command>(JA, *this,
ResponseFileSupport::AtFileUTF8(),
Exec, CmdArgs, Inputs, Output));
} else {
C.addCommand(std::make_unique<Command>(JA, *this,
ResponseFileSupport::AtFileUTF8(),
Exec, CmdArgs, Inputs, Output));
}
}

// Begin OffloadBundler
Expand Down
3 changes: 0 additions & 3 deletions clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3833,9 +3833,6 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
}
}

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);

Expand Down
2 changes: 0 additions & 2 deletions clang/test/CodeGen/thinlto-clang-diagnostic-handler-in-be.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// RUN: llvm-lto -thinlto -o %t %t1.bo
// RUN: %clang -cc1 -O2 -fexperimental-new-pass-manager -x ir %t1.bo -fthinlto-index=%t.thinlto.bc -emit-obj -Rpass-analysis=info 2>&1 | FileCheck %s -check-prefix=CHECK-REMARK
// RUN: llvm-profdata merge -o %t2.profdata %S/Inputs/thinlto_expect2.proftext
// RUN: %clang -cc1 -O2 -fexperimental-new-pass-manager -x ir %t1.bo -fthinlto-index=%t.thinlto.bc -fprofile-instrument-use-path=%t2.profdata -emit-obj -Wmisexpect 2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
// RUN: %clang -cc1 -O2 -fexperimental-new-pass-manager -x ir %t1.bo -fthinlto-index=%t.thinlto.bc -fprofile-instrument-use-path=%t2.profdata -emit-obj 2>&1 | FileCheck %s -allow-empty -check-prefix=CHECK-NOWARNING

int sum;
Expand All @@ -20,5 +19,4 @@ __attribute__((noinline)) void foo(int m) {
bar();
}
// CHECK-REMARK: remark: {{.*}}.c:
// CHECK-WARNING: warning: Potential performance regression from use of __builtin_expect(): Annotation was correct on {{.*}}.c:{{[0-9]*}}:{{[0-9]*}}: 50.00% (12 / 24) of profiled executions.
// CHECK-NOWARNING-NOT: warning: {{.*}}.c:{{[0-9]*}}:26: 50.00% (12 / 24)
30 changes: 15 additions & 15 deletions clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void ab0(int &i) {
// CHECK: br {{.*}}end{{$}}
// CHECK: br {{.*}}end{{$}}
// CHECK: br {{.*}}end{{$}}
// CHECK: br {{.*}} !prof !10
// CHECK: br {{.*}} !prof !9
if (__builtin_expect(a() && b() && c(), 0)) {
++i;
} else {
Expand All @@ -48,7 +48,7 @@ void au(int &i) {
// CHECK-LABEL: define{{.*}}au
// CHECK: br {{.*}}else{{$}}
// CHECK: br {{.*}}else{{$}}
// CHECK: br {{.*}} !prof !10
// CHECK: br {{.*}} !prof !9
if (a() && b() && c()) [[unlikely]] {
++i;
} else {
Expand Down Expand Up @@ -83,9 +83,9 @@ void ol(int &i) {

void ob0(int &i) {
// CHECK-LABEL: define{{.*}}ob0
// CHECK: br {{.*}} !prof !10
// CHECK: br {{.*}} !prof !10
// CHECK: br {{.*}} !prof !10
// CHECK: br {{.*}} !prof !9
// CHECK: br {{.*}} !prof !9
// CHECK: br {{.*}} !prof !9
if (__builtin_expect(a() || b() || c(), 0)) {
i = 0;
} else {
Expand All @@ -95,9 +95,9 @@ void ob0(int &i) {

void ou(int &i) {
// CHECK-LABEL: define{{.*}}ou
// CHECK: br {{.*}} !prof !10
// CHECK: br {{.*}} !prof !10
// CHECK: br {{.*}} !prof !10
// CHECK: br {{.*}} !prof !9
// CHECK: br {{.*}} !prof !9
// CHECK: br {{.*}} !prof !9
if (a() || b() || c()) [[unlikely]] {
i = 0;
} else {
Expand Down Expand Up @@ -127,7 +127,7 @@ void nl(int &i) {

void nb0(int &i) {
// CHECK-LABEL: define{{.*}}nb0
// CHECK: br {{.*}} !prof !10
// CHECK: br {{.*}} !prof !9
if (__builtin_expect(!a(), 0)) {
++i;
} else {
Expand All @@ -137,7 +137,7 @@ void nb0(int &i) {

void nu(int &i) {
// CHECK-LABEL: define{{.*}}nu
// CHECK: br {{.*}} !prof !10
// CHECK: br {{.*}} !prof !9
if (bool d = !a()) [[unlikely]] {
++i;
} else {
Expand Down Expand Up @@ -188,7 +188,7 @@ void tb0(int &i) {
// CHECK: br {{.*}}false{{$}}
// CHECK: br {{.*}}end{{$}}
// CHECK: br {{.*}}end{{$}}
// CHECK: br {{.*}} !prof !10
// CHECK: br {{.*}} !prof !9
if (__builtin_expect(a() ? b() : c(), 0)) {
++i;
} else {
Expand All @@ -201,7 +201,7 @@ void tu(int &i) {
// CHECK: br {{.*}}false{{$}}
// CHECK: br {{.*}}end{{$}}
// CHECK: br {{.*}}end{{$}}
// CHECK: br {{.*}} !prof !10
// CHECK: br {{.*}} !prof !9
if (bool d = a() ? b() : c()) [[unlikely]] {
++i;
} else {
Expand All @@ -212,8 +212,8 @@ void tu(int &i) {
void tu2(int &i) {
// CHECK-LABEL: define{{.*}}tu
// CHECK: br {{.*}}false{{$}}
// CHECK: br {{.*}} !prof !10
// CHECK: br {{.*}} !prof !10
// CHECK: br {{.*}} !prof !9
// CHECK: br {{.*}} !prof !9
if (a() ? b() : c()) [[unlikely]] {
++i;
} else {
Expand All @@ -222,4 +222,4 @@ void tu2(int &i) {
}

// CHECK: !6 = !{!"branch_weights", i32 2000, i32 1}
// CHECK: !10 = !{!"branch_weights", i32 1, i32 2000}
// CHECK: !9 = !{!"branch_weights", i32 1, i32 2000}
5 changes: 5 additions & 0 deletions clang/test/Driver/cc1-spawnprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@

// Three jobs, thus integrated-cc1 is disabled.
// RUN: %clang -fintegrated-cc1 -c %t1.cpp %t2.cpp %t3.cpp -### 2>&1 | FileCheck %s --check-prefix=NO

// -fintegrated-cc1 works with cc1as.
// RUN: echo > %t.s
// RUN: %clang -fintegrated-cc1 -fintegrated-as -c -### %t.s 2>&1 | FileCheck %s --check-prefix=YES
// RUN: %clang -fno-integrated-cc1 -c -### %t.s 2>&1 | FileCheck %s --check-prefix=NO

This file was deleted.

9 changes: 0 additions & 9 deletions clang/test/Profile/Inputs/misexpect-branch.proftext

This file was deleted.

12 changes: 0 additions & 12 deletions clang/test/Profile/Inputs/misexpect-switch-default-only.proftext

This file was deleted.

16 changes: 0 additions & 16 deletions clang/test/Profile/Inputs/misexpect-switch-default.proftext

This file was deleted.

17 changes: 0 additions & 17 deletions clang/test/Profile/Inputs/misexpect-switch-nonconst.proftext

This file was deleted.

16 changes: 0 additions & 16 deletions clang/test/Profile/Inputs/misexpect-switch.proftext

This file was deleted.

26 changes: 0 additions & 26 deletions clang/test/Profile/misexpect-branch-cold.c

This file was deleted.

23 changes: 0 additions & 23 deletions clang/test/Profile/misexpect-branch-nonconst-expected-val.c

This file was deleted.

Loading

0 comments on commit a3d2301

Please sign in to comment.