[llvm-branch-commits] [llvm] d5486a2 - Attributor: Make IRPosition::verify inline without expensive checks (#241087)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Nov 11 01:52:04 PST 2026


Author: Matt Arsenault
Date: 2026-11-10T19:43:31-08:00
New Revision: d5486a279ccc4167247ad496ef76113c84d358d6

URL: https://github.com/llvm/llvm-project/commit/d5486a279ccc4167247ad496ef76113c84d358d6
DIFF: https://github.com/llvm/llvm-project/commit/d5486a279ccc4167247ad496ef76113c84d358d6.diff

LOG: Attributor: Make IRPosition::verify inline without expensive checks (#241087)

IRPosition::verify only checks anything with EXPENSIVE_CHECKS, but
every IRPosition constructor still called it out of line. This
prevented keeping the position in registers plus the cost of the call.

Instruction counts (callgrind) over 68 llvm-test-suite TUs, with other
pending attributor-light changes applied, median:
attributor-light -0.71% (-0.45%), attributor-light-cgscc -0.31%
(-0.38%), attributor -0.35% (-0.45%).

Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>

Added: 
    

Modified: 
    llvm/include/llvm/Transforms/IPO/Attributor.h
    llvm/lib/Transforms/IPO/Attributor.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index ffe110b1fb72d..0ad1313c18f37 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -972,7 +972,11 @@ struct IRPosition {
   }
 
   /// Verify internal invariants.
+#ifdef EXPENSIVE_CHECKS
   LLVM_ABI void verify();
+#else
+  void verify() {}
+#endif
 
   /// Return the underlying pointer as Value *, valid for all positions but
   /// IRP_CALL_SITE_ARGUMENT.

diff  --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 273b2578ca66e..fc83dc54dd725 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -1407,8 +1407,8 @@ SubsumingPositionIterator::SubsumingPositionIterator(const IRPosition &IRP) {
   }
 }
 
-void IRPosition::verify() {
 #ifdef EXPENSIVE_CHECKS
+void IRPosition::verify() {
   switch (getPositionKind()) {
   case IRP_INVALID:
     assert((CBContext == nullptr) &&
@@ -1472,8 +1472,8 @@ void IRPosition::verify() {
     return;
   }
   }
-#endif
 }
+#endif
 
 std::optional<Constant *>
 Attributor::getAssumedConstant(const IRPosition &IRP,


        


More information about the llvm-branch-commits mailing list