[PATCH] D147752: [GuardUtils] Add asserts about loop varying widenable conditions

Anna Thomas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 6 17:52:21 PDT 2023


anna created this revision.
anna added reviewers: mkazantsev, apilipenko.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
anna requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147752

Files:
  llvm/include/llvm/Transforms/Utils/GuardUtils.h
  llvm/lib/Transforms/Scalar/GuardWidening.cpp
  llvm/lib/Transforms/Scalar/LoopPredication.cpp
  llvm/lib/Transforms/Utils/GuardUtils.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147752.511576.patch
Type: text/x-patch
Size: 5180 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230407/b8f93ce4/attachment.bin>


More information about the llvm-commits mailing list