[all-commits] [llvm/llvm-project] 4db3dc: [llvm] produce a more consistent estimates of bit ...

Jeremy Kun via All-commits all-commits at lists.llvm.org
Fri Sep 25 14:05:51 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4db3dceb8d7bffa4b69042fe043652d616396237
      https://github.com/llvm/llvm-project/commit/4db3dceb8d7bffa4b69042fe043652d616396237
  Author: Jeremy Kun <jkun at google.com>
  Date:   2026-09-25 (Fri, 25 Sep 2026)

  Changed paths:
    M llvm/lib/Support/StringRef.cpp
    M llvm/unittests/ADT/StringRefTest.cpp

  Log Message:
  -----------
  [llvm] produce a more consistent estimates of bit width needed when parsing an integer (#205947)

A colleague of mine noticed that `"12535824225335233"` parses in MLIR's
integer attribute parser as a 68-bit integer, even though it is a 53-bit
constant. I traced this back to `StringRef::consumeInteger`'s heuristic
estimate of the bit size. This change replaces that heuristic with a
default 64-bit storage, doubling the storage as more digits are parsed.
This produces a potentially larger over-estimate of the total storage
required, but does so in a less arbitrary manner and reduces the
over-approximation for numbers close to the 64-bit boundary.

Nb., A first iteration of this change tightened that estimate to at most
a 1-bit overapproximation with a lookup-table.

Assisted by Gemini



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list