[PATCH] D137027: [llvm] Improve performance of programUndefinedIfUndefOrPoison

Geza Lore via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 29 14:58:14 PDT 2022


gezalore created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
gezalore requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

programUndefinedIfUndefOrPoison used to eagerly propagate the fact that
a value is poison to the users of the value. The problem is that if the
value has a lot of uses (orders of magnitude more than the scanning
limit we use in this function), then we spend the bulk of our time in
eagerly propagating the poison property, which we will mostly never use
later anyway due to the scanning limit.

I have a test case (of ~50k lines of machine generated C++), where this
results in ~60% of 35s compilation time being spent doing just this
eager propagation.

This patch changes programUndefinedIfUndefOrPoison to only eagerly
propagate to the first few uses of a poison value, and then rely on lazy
propagation for the rest. This hopefully gives us the best of both
worlds, when we have a small number of uses (in which case being eager
is likely faster), and also when we have a very large number of uses
(when being lazy is much faster due to the small scanning limit already
present in the function).

This patch regains virtually all of the 60% compilation time spent in
this function in my test case (i.e.: a 2.5x total compilation speedup).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137027

Files:
  llvm/lib/Analysis/ValueTracking.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137027.471785.patch
Type: text/x-patch
Size: 3515 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221029/80814c29/attachment.bin>


More information about the llvm-commits mailing list