Skip to content

Commit

Permalink
[MLIR] Fix parseInteger(uint64_t) for large values
Browse files Browse the repository at this point in the history
This is a regression from e692af8
  • Loading branch information
d0k committed Oct 14, 2024
1 parent ab902ee commit 7900daa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion mlir/include/mlir/IR/OpImplementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions mlir/test/mlir-tblgen/attr-or-type-format-roundtrip.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7900daa

Please sign in to comment.