This is an archive of the discontinued LLVM Phabricator instance.

[LVI] Cache lookup of experimental.guard intrinsic (NFC)
ClosedPublic

Authored by nikic on Jun 13 2020, 1:32 PM.

Details

Summary

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

Diff Detail

Event Timeline

nikic created this revision.Jun 13 2020, 1:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2020, 1:32 PM
nikic marked an inline comment as done.Jun 13 2020, 1:33 PM
nikic added inline comments.
llvm/lib/Analysis/LazyValueInfo.cpp
370

The indentation in this class is messed up. I'll address that separately.

fhahn accepted this revision.Jun 14 2020, 4:36 AM

LGTM, thanks! Looks like a straight-forward improvement.

This revision is now accepted and ready to land.Jun 14 2020, 4:36 AM
This revision was automatically updated to reflect the committed changes.