[PATCH] D92739: [ValueTracking] Branch on poison is UB

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 6 12:56:37 PST 2020


nikic created this revision.
nikic added reviewers: aqjune, spatel, lebedev.ri, nlopes.
Herald added subscribers: zzheng, hiraditya.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Teach getGuaranteedNonPoisonOps() and thus programUndefinedIfPoison() that branching on poison is undefined behavior.

LangRef for `br` and `switch`:

> If ‘cond’ is poison or undef, this instruction has undefined behavior.
>  If ‘value’ is poison or undef, this instruction has undefined behavior.

Ran into this while attempting to fix https://bugs.llvm.org/show_bug.cgi?id=46943, where this would be helpful to detect whether there is an existing UB-on-poison use of the postinc IV, and branches are the most important use when it comes to loops.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92739

Files:
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/test/Analysis/ScalarEvolution/exact-exit-count-more-precise.ll
  llvm/test/Analysis/ScalarEvolution/limit-depth.ll
  llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info.ll
  llvm/test/Analysis/ScalarEvolution/trip-count12.ll
  llvm/test/Analysis/ScalarEvolution/trip-count9.ll
  llvm/test/Transforms/IndVarSimplify/X86/loop-invariant-conditions.ll
  llvm/test/Transforms/IndVarSimplify/lftr-reuse.ll
  llvm/test/Transforms/LoopUnroll/runtime-small-upperbound.ll
  llvm/test/Transforms/LoopVectorize/X86/small-size.ll
  llvm/test/Transforms/LoopVectorize/consecutive-ptr-uniforms.ll
  llvm/unittests/Analysis/ValueTrackingTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92739.309789.patch
Type: text/x-patch
Size: 23780 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201206/2d90f09d/attachment.bin>


More information about the llvm-commits mailing list