[all-commits] [llvm/llvm-project] b0c8c4: Avoid BlockFrequency overflow problems (#66280)

Matthias Braun via All-commits all-commits at lists.llvm.org
Thu Sep 14 11:11:41 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b0c8c454238b495ebe4df25a161a120d1707c230
      https://github.com/llvm/llvm-project/commit/b0c8c454238b495ebe4df25a161a120d1707c230
  Author: Matthias Braun <matze at braunis.de>
  Date:   2023-09-14 (Thu, 14 Sep 2023)

  Changed paths:
    M llvm/include/llvm/Support/BlockFrequency.h
    M llvm/lib/Analysis/InlineCost.cpp
    M llvm/lib/CodeGen/CodeGenPrepare.cpp
    M llvm/lib/Support/BlockFrequency.cpp

  Log Message:
  -----------
  Avoid BlockFrequency overflow problems (#66280)

Multiplying raw block frequency with an integer carries a high risk
of overflow.

- Add `BlockFrequency::mul` return an std::optional with the product
  or `nullopt` to indicate an overflow.
- Fix two instances where overflow was likely.




More information about the All-commits mailing list