[all-commits] [llvm/llvm-project] 567575: [GuardUtils] Add asserts about loop varying widena...

annamthomas via All-commits all-commits at lists.llvm.org
Tue Apr 11 07:54:27 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5675757f5fc6e27ce01b3b12bdfd04044df53aa3
      https://github.com/llvm/llvm-project/commit/5675757f5fc6e27ce01b3b12bdfd04044df53aa3
  Author: Anna Thomas <anna at azul.com>
  Date:   2023-04-11 (Tue, 11 Apr 2023)

  Changed paths:
    M llvm/include/llvm/Transforms/Utils/GuardUtils.h
    M llvm/lib/Transforms/Scalar/GuardWidening.cpp
    M llvm/lib/Transforms/Scalar/LoopPredication.cpp
    M llvm/lib/Transforms/Utils/GuardUtils.cpp

  Log Message:
  -----------
  [GuardUtils] Add asserts about loop varying widenable conditions

We have now seen two miscompiles because of widening widenable
conditions at incorrect IR points and thereby changing a branch's loop
invariant condition to a loop-varying one (see PR60234 and PR61963).

This patch adds asserts in common guard utilities that we use for
widening to proactively catch these bugs in future.
Note that these asserts will not fire if we were to sink a widenable
condition from out of a loop into a loop (that's also incorrect for the
same reason as above).

Tested this without the fix for PR60234 (guard widening miscompile) and
confirmed the assert fires.

WARNING: Sometimes, the assert can fire if we failed to hoist the
invariant condition out of the loop. This is a pass-ordering issue or a
limitation in LICM, which would need an investigation. See details in
review.

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




More information about the All-commits mailing list