llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Nikita Popov (nikic)

<details>
<summary>Changes</summary>

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&amp;to=21050e6765b51ed2eecab8d0cafc7ee9696d3632&amp;stat=instructions:u

Suggested by LLM. Original motivation was to reduce ASLR noise on 
beman-execution.

---
Full diff: https://github.com/llvm/llvm-project/pull/237621.diff


1 Files Affected:

- (modified) clang/lib/AST/Decl.cpp (+3-2) 


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

``````````

</details>


https://github.com/llvm/llvm-project/pull/237621
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to