-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[clang][Sema] Optimize ~SemaDiagnosticBuilder #142252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Call getDiagnosticLevel(), which is expensive, only if ShowCallStack is set. Small gains: https://llvm-compile-time-tracker.com/compare.php?from=843e362318e884991e517a54446b4faeacdad789&to=5cef0c18466318a426924b3c45f7abaaa8f6b535&stat=instructions:u
@llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) ChangesCall getDiagnosticLevel(), which is expensive, only if ShowCallStack is set. Full diff: https://github.com/llvm/llvm-project/pull/142252.diff 1 Files Affected:
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 1901d19b14dfc..ff4c0d833e573 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -2062,11 +2062,14 @@ Sema::SemaDiagnosticBuilder::~SemaDiagnosticBuilder() {
if (ImmediateDiag) {
// Emit our diagnostic and, if it was a warning or error, output a callstack
// if Fn isn't a priori known-emitted.
- bool IsWarningOrError = S.getDiagnostics().getDiagnosticLevel(
- DiagID, Loc) >= DiagnosticsEngine::Warning;
ImmediateDiag.reset(); // Emit the immediate diag.
- if (IsWarningOrError && ShowCallStack)
- emitCallStackNotes(S, Fn);
+
+ if (ShowCallStack) {
+ bool IsWarningOrError = S.getDiagnostics().getDiagnosticLevel(
+ DiagID, Loc) >= DiagnosticsEngine::Warning;
+ if (IsWarningOrError)
+ emitCallStackNotes(S, Fn);
+ }
} else {
assert((!PartialDiagId || ShowCallStack) &&
"Must always show call stack for deferred diags.");
|
The original code looks like the ordering with the |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/45/builds/12825 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/132/builds/1299 Here is the relevant piece of the build log for the reference
|
Call getDiagnosticLevel(), which is expensive, only if ShowCallStack is set.
Small gains:
https://llvm-compile-time-tracker.com/compare.php?from=843e362318e884991e517a54446b4faeacdad789&to=5cef0c18466318a426924b3c45f7abaaa8f6b535&stat=instructions:u