[llvm] [IntrinsicEmitter] Make AttributesMap bits adaptive (PR #157965)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 14 06:01:46 PDT 2025


================
@@ -629,21 +629,24 @@ static constexpr uint16_t IntrinsicsToAttributesMap[] = {)";
     UniqAttributes.try_emplace(&Int, ID);
   }
 
-  constexpr uint16_t NoFunctionAttrsID = 255;
-  if (UniqAttributes.size() > 256)
-    PrintFatalError("Too many unique argument attributes for table!");
-  // Note, ID 255 is used to indicate no function attributes.
-  if (UniqFnAttributes.size() > 255)
-    PrintFatalError("Too many unique function attributes for table!");
-
-  // Assign a 16-bit packed ID for each intrinsic. The lower 8-bits will be its
-  // "argument attribute ID" (index in UniqAttributes) and upper 8 bits will be
+  const uint8_t UniqAttributesBitSize = Log2_32_Ceil(UniqAttributes.size() + 1);
----------------
jurahul wrote:

@elvinw-intel why is the +1 needed here? Assuming UniqAttributes.size() == 256, we should be able to use 8 bits, but it seems here it will return 9?

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


More information about the llvm-commits mailing list