[Mlir-commits] [mlir] 7900daa - [MLIR] Fix parseInteger(uint64_t) for large values

Benjamin Kramer llvmlistbot at llvm.org
Mon Oct 14 08:09:28 PDT 2024


Author: Benjamin Kramer
Date: 2024-10-14T17:07:27+02:00
New Revision: 7900daaa7ba57b5f9729bbbdb54f4e0599a45cd7

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

LOG: [MLIR] Fix parseInteger(uint64_t) for large values

This is a regression from e692af85966903614d470a7742ed89d124baf1a6

Added: 
    

Modified: 
    mlir/include/mlir/IR/OpImplementation.h
    mlir/test/mlir-tblgen/attr-or-type-format-roundtrip.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h
index 606a56c7fd55b5..a7222794f320b2 100644
--- a/mlir/include/mlir/IR/OpImplementation.h
+++ b/mlir/include/mlir/IR/OpImplementation.h
@@ -749,7 +749,8 @@ class AsmParser {
     // zero for non-negated integers.
     result =
         (IntT)uintResult.sextOrTrunc(sizeof(IntT) * CHAR_BIT).getLimitedValue();
-    if (APInt(uintResult.getBitWidth(), result, /*isSigned=*/true,
+    if (APInt(uintResult.getBitWidth(), result,
+              /*isSigned=*/std::is_signed_v<IntT>,
               /*implicitTrunc=*/true) != uintResult)
       return emitError(loc, "integer value too large");
     return success();

diff  --git a/mlir/test/mlir-tblgen/attr-or-type-format-roundtrip.mlir b/mlir/test/mlir-tblgen/attr-or-type-format-roundtrip.mlir
index 160c388cedf756..f0d1571d583877 100644
--- a/mlir/test/mlir-tblgen/attr-or-type-format-roundtrip.mlir
+++ b/mlir/test/mlir-tblgen/attr-or-type-format-roundtrip.mlir
@@ -23,10 +23,10 @@ attributes {
   attr7 = #test.custom_anchor<5>,
   // CHECK: #test.custom_anchor<5, true>
   attr8 = #test.custom_anchor<5, true>,
-  // CHECK: #test.attr_with_optional_signed<-12>
-  attr9 = #test.attr_with_optional_signed<-12>,
-  // CHECK: #test.attr_with_optional_unsigned<22>
-  attr_10 = #test.attr_with_optional_unsigned<22>
+  // CHECK: #test.attr_with_optional_signed<-9223372036854775808>
+  attr9 = #test.attr_with_optional_signed<-9223372036854775808>,
+  // CHECK: #test.attr_with_optional_unsigned<18446744073709551615>
+  attr_10 = #test.attr_with_optional_unsigned<18446744073709551615>
 }
 
 // CHECK-LABEL: @test_roundtrip_default_parsers_struct


        


More information about the Mlir-commits mailing list