[PATCH] D76493: mlir: Fix attribute parser errors for ui64
Frej Drejhammar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 20 07:00:15 PDT 2020
frej created this revision.
frej added a reviewer: antiagainst.
Herald added subscribers: llvm-commits, bader, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, shauheen, burmako, jpienaar, rriddle, mehdi_amini.
Herald added a reviewer: mravishankar.
Herald added a reviewer: rriddle.
Herald added a project: LLVM.
The attribute parser fails to correctly parse unsigned 64 bit
attributes as the check `isNegative ? (int64_t)-val.getValue() >= 0
: (int64_t)val.getValue() < 0` will falsely detect an overflow for
unsigned values larger than 2^63-1.
This patch reworks the overflow logic to instead of doing arithmetic
on int64_t use APInt::isSignBitSet() and knowledge of the attribute
type.
Test-cases which verify the de-facto behavior of the parser and
triggered the previous faulty handing of unsigned 64 bit attrbutes are
also added.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D76493
Files:
mlir/lib/Parser/Parser.cpp
mlir/test/Dialect/SPIRV/canonicalize.mlir
mlir/test/IR/attribute.mlir
mlir/test/lib/TestDialect/TestOps.td
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76493.251622.patch
Type: text/x-patch
Size: 7763 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200320/e3c229a5/attachment.bin>
More information about the llvm-commits
mailing list