https://github.com/ZequanWu created 
https://github.com/llvm/llvm-project/pull/115196

We observed 2X slowdown in lldb's expression evaluation with 
https://github.com/llvm/llvm-project/pull/109147. It turns out that calling 
`isRedundantInlineQualifierFor` is quite expensive. Using short-circuit 
evaluation in the if statement to avoid unnecessary calls to that function.

>From ecf707635421044ec04cc0e0122ac38c6fde5e3e Mon Sep 17 00:00:00 2001
From: Zequan Wu <zequa...@google.com>
Date: Wed, 6 Nov 2024 11:04:16 -0800
Subject: [PATCH] [clang] Avoid unnecessary call to
 clang::NamespaceDecl::isRedundantInlineQualifierFor().

---
 clang/lib/AST/Decl.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 8204e3509dd563..a65dc85e04a83d 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1738,13 +1738,12 @@ void NamedDecl::printNestedNameSpecifier(raw_ostream 
&OS,
 
     // Suppress inline namespace if it doesn't make the result ambiguous.
     if (Ctx->isInlineNamespace() && NameInScope) {
-      bool isRedundant =
-          cast<NamespaceDecl>(Ctx)->isRedundantInlineQualifierFor(NameInScope);
       if (P.SuppressInlineNamespace ==
               PrintingPolicy::SuppressInlineNamespaceMode::All ||
           (P.SuppressInlineNamespace ==
                PrintingPolicy::SuppressInlineNamespaceMode::Redundant &&
-           isRedundant)) {
+           cast<NamespaceDecl>(Ctx)->isRedundantInlineQualifierFor(
+               NameInScope))) {
         continue;
       }
     }

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to