[PATCH] D81796: [LVI] Cache lookup of experimental.guard intrinsic (NFC)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 13 13:53:52 PDT 2020


nikic created this revision.
nikic added reviewers: reames, fhahn.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
nikic marked an inline comment as done.
nikic added inline comments.


================
Comment at: llvm/lib/Analysis/LazyValueInfo.cpp:370
+    /// if it exists in the module.
+    Function *GuardDecl;
+
----------------
The indentation in this class is messed up. I'll address that separately.


When LVI is performing assume intersections, it also checks for `llvm.experimental.guard` intrinsics. To avoid unnecessary block scans, it first checks whether this intrinsic is declared in the module at all. I've noticed that we end up spending quite a lot of time lookup up that function again and again...

Avoid this by only looking it up once when LazyValueInfo is constructed. This of course assumes that we don't introduce new guard intrinsics (which is the case for all existing uses of LVI -- and even if it weren't, it would not introduce miscompiles, just potentially lose optimization power.)

Most of the patch is threading through the Module into getImpl().

Compile-time numbers: https://llvm-compile-time-tracker.com/compare.php?from=d449cb81232e38d1175b0c9c316129c4637d3cbc&to=35c3e576fa3bc961223d4d45ca2aa8fc6db2b1cf&stat=instructions


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81796

Files:
  llvm/lib/Analysis/LazyValueInfo.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81796.270586.patch
Type: text/x-patch
Size: 6998 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200613/344970b0/attachment.bin>


More information about the llvm-commits mailing list