[llvm] Attributor: Avoid calling identifyDefaultAbstractAttributes on declarations (PR #182663)

via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 21 01:46:21 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Matt Arsenault (arsenm)

<details>
<summary>Changes</summary>

Previously it would be called and inserted into a visited map,
but would never be used. This could possibly go one step further
and never add declarations to the SetVector of Functions. If I try
that, only one call graph printing test fails.

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


1 Files Affected:

- (modified) llvm/lib/Transforms/IPO/Attributor.cpp (+8-2) 


``````````diff
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 9a35696b7627c..776ba4b347521 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -3340,10 +3340,10 @@ void Attributor::checkAndQueryIRAttr(const IRPosition &IRP, AttributeSet Attrs,
 }
 
 void Attributor::identifyDefaultAbstractAttributes(Function &F) {
+  assert(!F.isDeclaration());
+
   if (!VisitedFunctions.insert(&F).second)
     return;
-  if (F.isDeclaration())
-    return;
 
   // In non-module runs we need to look at the call sites of a function to
   // determine if it is part of a must-tail call edge. This will influence what
@@ -3876,6 +3876,9 @@ static bool runAttributorOnFunctions(InformationCache &InfoCache,
   }
 
   for (Function *F : Functions) {
+    if (F->isDeclaration())
+      continue;
+
     if (F->hasExactDefinition())
       NumFnWithExactDefinition++;
     else
@@ -3939,6 +3942,9 @@ static bool runAttributorLightOnFunctions(InformationCache &InfoCache,
   Attributor A(Functions, InfoCache, AC);
 
   for (Function *F : Functions) {
+    if (F->isDeclaration())
+      continue;
+
     if (F->hasExactDefinition())
       NumFnWithExactDefinition++;
     else

``````````

</details>


https://github.com/llvm/llvm-project/pull/182663


More information about the llvm-commits mailing list