[all-commits] [llvm/llvm-project] 4683a2: [llvm][misexpect] Avoid division by 0 when using s...

Paul Kirth via All-commits all-commits at lists.llvm.org
Fri Apr 22 15:48:17 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4683a2effa72c8fdc5e09b1dc9ee3170988f75fa
  Author: Paul Kirth <paulkirth at google.com>
  Date:   2022-04-22 (Fri, 22 Apr 2022)

  Changed paths:
    M llvm/lib/Transforms/IPO/SampleProfile.cpp
    M llvm/lib/Transforms/Utils/MisExpect.cpp

  Log Message:
  [llvm][misexpect] Avoid division by 0 when using sample profiling

MisExpect diagnostics should not prevent compilation from succeeding, and the
assertion is insufficient to prevent division by zero in release builds.

This patch addresses that by replacing the assert with an early return.

Additionally, it disables MisExpect diagnostics when using sample profiling,
since this is the only known case where this error has manifested.

Reviewed By: tejohnson

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

More information about the All-commits mailing list