[llvm] Add the 'initializes' attribute langref and support (PR #84803)

Jan Voung via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 11 07:13:41 PDT 2024


================
@@ -2350,12 +2361,42 @@ Error BitcodeReader::parseAttributeGroupBlock() {
           if (!Attribute::isConstantRangeAttrKind(Kind))
             return error("Not a ConstantRange attribute");
 
-          Expected<ConstantRange> MaybeCR = readConstantRange(Record, i);
+          Expected<ConstantRange> MaybeCR =
+              readBitWidthAndConstantRange(Record, i);
           if (!MaybeCR)
             return MaybeCR.takeError();
           i--;
 
           B.addConstantRangeAttr(Kind, MaybeCR.get());
+        } else if (Record[i] == 8) {
+          Attribute::AttrKind Kind;
+
+          i++;
+          if (Error Err = parseAttrKind(Record[i++], &Kind))
+            return Err;
+          if (!Attribute::isConstantRangeListAttrKind(Kind))
+            return error("Not a constant range list attribute");
+
+          SmallVector<ConstantRange, 2> Val;
+          if (i + 2 > e)
+            return error("Too few records for constant range list");
+          unsigned RangeSize = Record[i++];
+          unsigned BitWidth = Record[i++];
+          if (i + 2 * RangeSize > e)
----------------
jvoung wrote:

I think you can remove this hoisted `i + 2 * RangeSize > e` check, since it's not always 2 elements per RangeSize anymore and readConstantRange is doing the checks in the loop.

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


More information about the llvm-commits mailing list