diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h --- a/clang/include/clang/Basic/CodeGenOptions.h +++ b/clang/include/clang/Basic/CodeGenOptions.h @@ -424,7 +424,7 @@ /// The maximum percentage profiling weights can deviate from the expected /// values in order to be included in misexpect diagnostics. - Optional DiagnosticsMisExpectTolerance = 0; + Optional DiagnosticsMisExpectTolerance = 0; public: // Define accessors/mutators for code generation options of enumeration type. diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -113,8 +113,8 @@ // Parse misexpect tolerance argument value. // Valid option values are integers in the range [0, 100) -inline Expected> parseToleranceOption(StringRef Arg) { - int64_t Val; +inline Expected> parseToleranceOption(StringRef Arg) { + uint32_t Val; if (Arg.getAsInteger(10, Val)) return llvm::createStringError(llvm::inconvertibleErrorCode(), "Not an integer: %s", Arg.data()); diff --git a/llvm/include/llvm/IR/LLVMContext.h b/llvm/include/llvm/IR/LLVMContext.h --- a/llvm/include/llvm/IR/LLVMContext.h +++ b/llvm/include/llvm/IR/LLVMContext.h @@ -204,8 +204,8 @@ bool getMisExpectWarningRequested() const; void setMisExpectWarningRequested(bool Requested); - void setDiagnosticsMisExpectTolerance(Optional Tolerance); - uint64_t getDiagnosticsMisExpectTolerance() const; + void setDiagnosticsMisExpectTolerance(Optional Tolerance); + uint32_t getDiagnosticsMisExpectTolerance() const; /// Return the minimum hotness value a diagnostic would need in order /// to be included in optimization diagnostics. diff --git a/llvm/lib/IR/LLVMContext.cpp b/llvm/lib/IR/LLVMContext.cpp --- a/llvm/lib/IR/LLVMContext.cpp +++ b/llvm/lib/IR/LLVMContext.cpp @@ -148,10 +148,10 @@ return pImpl->DiagnosticsHotnessThreshold.value_or(UINT64_MAX); } void LLVMContext::setDiagnosticsMisExpectTolerance( - Optional Tolerance) { + Optional Tolerance) { pImpl->DiagnosticsMisExpectTolerance = Tolerance; } -uint64_t LLVMContext::getDiagnosticsMisExpectTolerance() const { +uint32_t LLVMContext::getDiagnosticsMisExpectTolerance() const { return pImpl->DiagnosticsMisExpectTolerance.value_or(0); } diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h --- a/llvm/lib/IR/LLVMContextImpl.h +++ b/llvm/lib/IR/LLVMContextImpl.h @@ -1387,8 +1387,8 @@ Optional DiagnosticsHotnessThreshold = 0; /// The percentage of difference between profiling branch weights and - // llvm.expect branch weights to tolerate when emiting MisExpect diagnostics - Optional DiagnosticsMisExpectTolerance = 0; + /// llvm.expect branch weights to tolerate when emiting MisExpect diagnostics + Optional DiagnosticsMisExpectTolerance = 0; bool MisExpectWarningRequested = false; /// The specialized remark streamer used by LLVM's OptimizationRemarkEmitter. diff --git a/llvm/lib/Transforms/Utils/MisExpect.cpp b/llvm/lib/Transforms/Utils/MisExpect.cpp --- a/llvm/lib/Transforms/Utils/MisExpect.cpp +++ b/llvm/lib/Transforms/Utils/MisExpect.cpp @@ -58,7 +58,7 @@ cl::desc("Use this option to turn on/off " "warnings about incorrect usage of llvm.expect intrinsics.")); -static cl::opt MisExpectTolerance( +static cl::opt MisExpectTolerance( "misexpect-tolerance", cl::init(0), cl::desc("Prevents emiting diagnostics when profile counts are " "within N% of the threshold..")); @@ -72,7 +72,7 @@ } uint64_t getMisExpectTolerance(LLVMContext &Ctx) { - return std::max(static_cast(MisExpectTolerance), + return std::max(static_cast(MisExpectTolerance), Ctx.getDiagnosticsMisExpectTolerance()); }