llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Anonmiraj (AnonMiraj)

<details>
<summary>Changes</summary>

I noticed ParseGNUAttributes() computes the presumed location for every 
__attribute__ (to check if it's in a built-in) before checking if the attribute 
even came from a macro.

Swapping the order to check the cheap macro condition first avoids this 
unnecessary work.

it is a small speed up across the board

https://llvm-compile-time-tracker.com/compare.php?from=99a148b807da7942d629fd8e807d12026fcb5e20&amp;to=68867c40d2a11d340e1ba3ebf50877bbb53b4d79&amp;stat=instructions%3Au

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


1 Files Affected:

- (modified) clang/lib/Parse/ParseDecl.cpp (+2-2) 


``````````diff
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index e452c312702491..95e79ee32bf8a4 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -289,8 +289,8 @@ void Parser::ParseGNUAttributes(ParsedAttributes &Attrs,
     // If this was declared in a macro, attach the macro IdentifierInfo to the
     // parsed attribute.
     auto &SM = PP.getSourceManager();
-    if (!SM.isWrittenInBuiltinFile(SM.getSpellingLoc(AttrTokLoc)) &&
-        FindLocsWithCommonFileID(PP, AttrTokLoc, Loc)) {
+    if (FindLocsWithCommonFileID(PP, AttrTokLoc, Loc) &&
+        !SM.isWrittenInBuiltinFile(SM.getSpellingLoc(AttrTokLoc))) {
       CharSourceRange ExpansionRange = SM.getExpansionRange(AttrTokLoc);
       StringRef FoundName =
           Lexer::getSourceText(ExpansionRange, SM, PP.getLangOpts());

``````````

</details>


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

Reply via email to