Skip to content

Commit

Permalink
Revert "[misexpect] Re-implement MisExpect Diagnostics"
Browse files Browse the repository at this point in the history
This reverts commit 2add3fb.
  • Loading branch information
ilovepi committed Mar 29, 2022
1 parent 6c77972 commit 90cb325
Show file tree
Hide file tree
Showing 49 changed files with 2 additions and 2,043 deletions.
75 changes: 0 additions & 75 deletions clang/docs/MisExpect.rst

This file was deleted.

3 changes: 0 additions & 3 deletions clang/docs/ReleaseNotes.rst
Expand Up @@ -105,9 +105,6 @@ Improvements to Clang's diagnostics
- ``-Wunused-but-set-variable`` now also warns if the variable is only used
by unary operators.

- ``-Wmisexpect`` warns when the branch weights collected during profiling
conflict with those added by ``llvm.expect``.

Non-comprehensive list of changes in this release
-------------------------------------------------
- The builtin function __builtin_dump_struct would crash clang when the target
Expand Down
1 change: 0 additions & 1 deletion clang/include/clang/Basic/CodeGenOptions.def
Expand Up @@ -175,7 +175,6 @@ CODEGENOPT(NoExecStack , 1, 0) ///< Set when -Wa,--noexecstack is enabled.
CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
///< enabled.
CODEGENOPT(NoWarn , 1, 0) ///< Set when -Wa,--no-warn is enabled.
CODEGENOPT(MisExpect , 1, 0) ///< Set when -Wmisexpect is enabled
CODEGENOPT(EnableSegmentedStacks , 1, 0) ///< Set when -fsplit-stack is enabled.
CODEGENOPT(NoInlineLineTables, 1, 0) ///< Whether debug info should contain
///< inline line tables.
Expand Down
4 changes: 0 additions & 4 deletions clang/include/clang/Basic/CodeGenOptions.h
Expand Up @@ -420,10 +420,6 @@ class CodeGenOptions : public CodeGenOptionsBase {
/// If threshold option is not specified, it is disabled by default.
Optional<uint64_t> DiagnosticsHotnessThreshold = 0;

/// The maximum percentage profiling weights can deviate from the expected
/// values in order to be included in misexpect diagnostics.
Optional<uint64_t> DiagnosticsMisExpectTolerance = 0;

public:
// Define accessors/mutators for code generation options of enumeration type.
#define CODEGENOPT(Name, Bits, Default)
Expand Down
5 changes: 0 additions & 5 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Expand Up @@ -149,8 +149,6 @@ def err_drv_invalid_darwin_version : Error<
"invalid Darwin version number: %0">;
def err_drv_invalid_diagnotics_hotness_threshold : Error<
"invalid argument in '%0', only integer or 'auto' is supported">;
def err_drv_invalid_diagnotics_misexpect_tolerance : Error<
"invalid argument in '%0', only integers are supported">;
def err_drv_missing_argument : Error<
"argument to '%0' is missing (expected %1 value%s1)">;
def err_drv_invalid_Xarch_argument_with_args : Error<
Expand Down Expand Up @@ -378,9 +376,6 @@ def warn_drv_empty_joined_argument : Warning<
def warn_drv_diagnostics_hotness_requires_pgo : Warning<
"argument '%0' requires profile-guided optimization information">,
InGroup<UnusedCommandLineArgument>;
def warn_drv_diagnostics_misexpect_requires_pgo : Warning<
"argument '%0' requires profile-guided optimization information">,
InGroup<UnusedCommandLineArgument>;
def warn_drv_clang_unsupported : Warning<
"the clang compiler does not support '%0'">;
def warn_drv_deprecated_arg : Warning<
Expand Down
5 changes: 0 additions & 5 deletions clang/include/clang/Basic/DiagnosticFrontendKinds.td
Expand Up @@ -311,11 +311,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>;
} // end of instrumentation issue category

}
1 change: 0 additions & 1 deletion clang/include/clang/Basic/DiagnosticGroups.td
Expand Up @@ -1254,7 +1254,6 @@ def BackendWarningAttributes : DiagGroup<"attribute-warning">;
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
3 changes: 0 additions & 3 deletions clang/include/clang/Driver/Options.td
Expand Up @@ -1426,9 +1426,6 @@ def fdiagnostics_hotness_threshold_EQ : Joined<["-"], "fdiagnostics-hotness-thre
Group<f_Group>, Flags<[CC1Option]>, MetaVarName<"<value>">,
HelpText<"Prevent optimization remarks from being output if they do not have at least this profile count. "
"Use 'auto' to apply the threshold from profile summary">;
def fdiagnostics_misexpect_tolerance_EQ : Joined<["-"], "fdiagnostics-misexpect-tolerance=">,
Group<f_Group>, Flags<[CC1Option]>, MetaVarName<"<value>">,
HelpText<"Prevent misexpect diagnostics from being output if the profile counts are within N% of the expected. ">;
defm diagnostics_show_option : BoolFOption<"diagnostics-show-option",
DiagnosticOpts<"ShowOptionNames">, DefaultTrue,
NegFlag<SetFalse, [CC1Option]>, PosFlag<SetTrue, [], "Print option name with mappable diagnostics">>;
Expand Down
1 change: 0 additions & 1 deletion clang/lib/CodeGen/BackendUtil.cpp
Expand Up @@ -650,7 +650,6 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
Entry.IgnoreSysRoot ? Entry.Path : HSOpts.Sysroot + Entry.Path);
Options.MCOptions.Argv0 = CodeGenOpts.Argv0;
Options.MCOptions.CommandLineArgs = CodeGenOpts.CommandLineArgs;
Options.MisExpect = CodeGenOpts.MisExpect;

return true;
}
Expand Down
34 changes: 0 additions & 34 deletions clang/lib/CodeGen/CodeGenAction.cpp
Expand Up @@ -340,15 +340,6 @@ namespace clang {
CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone)
Ctx.setDiagnosticsHotnessRequested(true);

if (CodeGenOpts.MisExpect) {
Ctx.setMisExpectWarningRequested(true);
}

if (CodeGenOpts.DiagnosticsMisExpectTolerance) {
Ctx.setDiagnosticsMisExpectTolerance(
CodeGenOpts.DiagnosticsMisExpectTolerance);
}

// Link each LinkModule into our module.
if (LinkInModules())
return;
Expand Down Expand Up @@ -449,9 +440,6 @@ namespace clang {
void OptimizationFailureHandler(
const llvm::DiagnosticInfoOptimizationFailure &D);
void DontCallDiagHandler(const DiagnosticInfoDontCall &D);
/// Specialized handler for misexpect warnings.
/// Note that misexpect remarks are emitted through ORE
void MisExpectDiagHandler(const llvm::DiagnosticInfoMisExpect &D);
};

void BackendConsumer::anchor() {}
Expand Down Expand Up @@ -833,25 +821,6 @@ void BackendConsumer::DontCallDiagHandler(const DiagnosticInfoDontCall &D) {
<< llvm::demangle(D.getFunctionName().str()) << D.getNote();
}

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

/// This function is invoked when the backend needs
/// to report something to the user.
void BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &DI) {
Expand Down Expand Up @@ -926,9 +895,6 @@ void BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &DI) {
case llvm::DK_DontCall:
DontCallDiagHandler(cast<DiagnosticInfoDontCall>(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
41 changes: 0 additions & 41 deletions clang/lib/Frontend/CompilerInvocation.cpp
Expand Up @@ -106,20 +106,6 @@ using namespace driver;
using namespace options;
using namespace llvm::opt;

//===----------------------------------------------------------------------===//
// Helpers.
//===----------------------------------------------------------------------===//

// Parse misexpect tolerance argument value.
// Valid option values are integers in the range [0, 100)
inline Expected<Optional<uint64_t>> parseToleranceOption(StringRef Arg) {
int64_t Val;
if (Arg.getAsInteger(10, Val))
return llvm::createStringError(llvm::inconvertibleErrorCode(),
"Not an integer: %s", Arg.data());
return Val;
}

//===----------------------------------------------------------------------===//
// Initialization.
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -1549,9 +1535,6 @@ void CompilerInvocation::GenerateCodeGenArgs(
: "auto",
SA);

GenerateArg(Args, OPT_fdiagnostics_misexpect_tolerance_EQ,
Twine(*Opts.DiagnosticsMisExpectTolerance), SA);

for (StringRef Sanitizer : serializeSanitizerKinds(Opts.SanitizeRecover))
GenerateArg(Args, OPT_fsanitize_recover_EQ, Sanitizer, SA);

Expand Down Expand Up @@ -1969,23 +1952,6 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
}
}

if (auto *arg =
Args.getLastArg(options::OPT_fdiagnostics_misexpect_tolerance_EQ)) {
auto ResultOrErr = parseToleranceOption(arg->getValue());

if (!ResultOrErr) {
Diags.Report(diag::err_drv_invalid_diagnotics_misexpect_tolerance)
<< "-fdiagnostics-misexpect-tolerance=";
} else {
Opts.DiagnosticsMisExpectTolerance = *ResultOrErr;
if ((!Opts.DiagnosticsMisExpectTolerance.hasValue() ||
Opts.DiagnosticsMisExpectTolerance.getValue() > 0) &&
!UsingProfile)
Diags.Report(diag::warn_drv_diagnostics_misexpect_requires_pgo)
<< "-fdiagnostics-misexpect-tolerance=";
}
}

// 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.
Expand Down Expand Up @@ -4611,13 +4577,6 @@ bool CompilerInvocation::CreateFromArgsImpl(
if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
LangOpts.ObjCExceptions = 1;

for (auto Warning : Res.getDiagnosticOpts().Warnings) {
if (Warning == "misexpect" &&
!Diags.isIgnored(diag::warn_profile_data_misexpect, SourceLocation())) {
Res.getCodeGenOpts().MisExpect = true;
}
}

if (LangOpts.CUDA) {
// During CUDA device-side compilation, the aux triple is the
// triple used for host compilation.
Expand Down

This file was deleted.

17 changes: 0 additions & 17 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.

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

This file was deleted.

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

This file was deleted.

0 comments on commit 90cb325

Please sign in to comment.