[llvm] [LLVM][Intrinsics] Reduce stack size for `Intrinsic::getAttributes` (PR #152219)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 6 04:51:40 PDT 2025


================
@@ -652,53 +652,61 @@ static constexpr uint16_t IntrinsicsToAttributesMap[] = {)";
 
 AttributeList Intrinsic::getAttributes(LLVMContext &C, ID id,
                                        FunctionType *FT) {)";
+  // Find the max number of attributes to create the local array.
+  unsigned MaxNumAttrs = 0;
+  for (const auto [IntPtr, UniqueID] : UniqAttributes) {
+    const CodeGenIntrinsic &Int = *IntPtr;
+    unsigned NumAttrs =
+        llvm::count_if(Int.ArgumentAttributes,
+                       [](const auto &Attrs) { return !Attrs.empty(); });
----------------
jurahul wrote:

Yes, empty attributes do occupy an index in the final AttributeList created, but not in the input for AttributeList::get() which accepts a sparse list of non-empty attributes (a pair of index and AttributeSet) and has an explicit check to verify that no empty attributes are passed into this sparse list.

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


More information about the llvm-commits mailing list