https://github.com/nikic created https://github.com/llvm/llvm-project/pull/237621
This is fairly expensive, so make sure we only call it once. Improves compile-time for C++ code, by -0.4% on the clang build: https://llvm-compile-time-tracker.com/compare.php?from=1b886f3957be9797805466410f538ec42909f22b&to=21050e6765b51ed2eecab8d0cafc7ee9696d3632&stat=instructions:u Suggested by LLM. Original motivation was to reduce ASLR noise on beman-execution. >From 270a631b1de9bb51b4fd51c99501ae66252102a0 Mon Sep 17 00:00:00 2001 From: Nikita Popov <[email protected]> Date: Sat, 31 Oct 2026 20:41:12 +0100 Subject: [PATCH] [AST] Avoid duplicate isOutOfLine() calls (NFC) This is fairly expensive, so make sure we only call it once. Improves compile-time for C++ code, by -0.4% on the clang build: https://llvm-compile-time-tracker.com/compare.php?from=1b886f3957be9797805466410f538ec42909f22b&to=21050e6765b51ed2eecab8d0cafc7ee9696d3632&stat=instructions:u Suggested by LLM. Original motivation was to reduce ASLR noise on beman-execution. --- clang/lib/AST/Decl.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index f9f38230cd0782..bbc1e37602ec76 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -2256,7 +2256,8 @@ VarDecl::isThisDeclarationADefinition(ASTContext &C) const { // FIXME: How do you declare (but not define) a partial specialization of // a static data member template outside the containing class? if (isStaticDataMember()) { - if (isOutOfLine() && + bool IsOutOfLine = isOutOfLine(); + if (IsOutOfLine && !(getCanonicalDecl()->isInline() && getCanonicalDecl()->isConstexpr() && !getCanonicalDecl()->isOutOfLine()) && (hasInit() || @@ -2269,7 +2270,7 @@ VarDecl::isThisDeclarationADefinition(ASTContext &C) const { TSK_ExplicitSpecialization) || isa<VarTemplatePartialSpecializationDecl>(this))) return Definition; - if (!isOutOfLine() && (isInline() || hasDefiningAttr())) + if (!IsOutOfLine && (isInline() || hasDefiningAttr())) return Definition; return DeclarationOnly; } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
