[all-commits] [llvm/llvm-project] d8981c: [mlir][Parser] Fix attribute parser errors for ui64

Frej Drejhammar via All-commits all-commits at lists.llvm.org
Wed Mar 25 11:57:22 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: d8981ce5b9f8caa567613b2bf5aa3095e0156130
      https://github.com/llvm/llvm-project/commit/d8981ce5b9f8caa567613b2bf5aa3095e0156130
  Author: Frej Drejhammar <frej.drejhammar at gmail.com>
  Date:   2020-03-25 (Wed, 25 Mar 2020)

  Changed paths:
    M mlir/lib/Parser/Parser.cpp
    M mlir/test/Dialect/SPIRV/canonicalize.mlir
    M mlir/test/IR/attribute.mlir
    M mlir/test/IR/invalid.mlir

  Log Message:
  -----------
  [mlir][Parser] Fix attribute parser errors for ui64

Summary:
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.

Differential Revision: https://reviews.llvm.org/D76493




More information about the All-commits mailing list