This is an archive of the discontinued LLVM Phabricator instance.

Make FindAvailableLoadedValue TBAA aware
ClosedPublic

Authored by thopre on Mar 23 2021, 12:16 PM.

Details

Summary

FindAvailableLoadedValue() relies on FindAvailablePtrLoadStore() to run
the alias analysis when searching for an equivalent value. However,
FindAvailablePtrLoadStore() calls the alias analysis framework with a
memory location for the load constructed from an address and a size,
which thus lacks TBAA metadata info. This commit modifies
FindAvailablePtrLoadStore() to accept an optional memory location as
parameter to allow FindAvailableLoadedValue() to create it based on the
load instruction, which would then have TBAA metadata info attached.

Diff Detail

Event Timeline

thopre created this revision.Mar 23 2021, 12:16 PM
thopre requested review of this revision.Mar 23 2021, 12:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2021, 12:16 PM

Note: the test added in this commit currently fails because of https://reviews.llvm.org/D99022 (issue reported in https://reviews.llvm.org/D99022#2644973).

nikic added inline comments.Mar 23 2021, 12:36 PM
llvm/include/llvm/Analysis/Loads.h
168

Why make it optional? The only None use seems to be in JumpThreading, and we should be able to pass a location there as well.

(Could also drop the Ptr argument if it's required, as the memory location includes the pointer.)

Looks fine conceptually. I'd recommend dropping the dependency on the LoopRotate patch and testing this via InstCombine instead, which uses this in a much more direct way.

jdoerfert added inline comments.Mar 23 2021, 9:41 PM
llvm/include/llvm/Analysis/Loads.h
168

+1, you can always make a MemoryLocation from a pointer anyway.

This seems like a worthwhile change regardless of LoopRotate.
Can you perhaps add a test for one of the passes that already use FindAvailableLoadedValue()?

thopre updated this revision to Diff 333007.Mar 24 2021, 8:42 AM
thopre marked 2 inline comments as done.
  • Make patch standalone
  • Add InstCombine testcase
  • Fix naming of function while modifying parameters
  • Make MemoryLocation mandatory
lebedev.ri added inline comments.Mar 24 2021, 9:09 AM
llvm/test/Transforms/InstCombine/load-no-aliasing.ll
1 ↗(On Diff #333007)

Please precommit using llvm/utils/update_test_checks.py

lebedev.ri edited the summary of this revision. (Show Details)Mar 24 2021, 9:09 AM
nikic added inline comments.Mar 24 2021, 9:42 AM
llvm/lib/Transforms/Scalar/JumpThreading.cpp
1396

The AATags have already been extracted above (before the loop), so there should be no need to do so again here.

llvm/test/Transforms/InstCombine/load-no-aliasing.ll
1 ↗(On Diff #333007)

The -evaluate-aa-metadata flag here is not needed -- this is used for directly printing modref information, not for normal transformation tests.

thopre updated this revision to Diff 333033.Mar 24 2021, 10:10 AM
thopre marked 3 inline comments as done.
  • Remove redundant AAAATags
  • Rebase on committed baseline testcase
  • Remove -evaluate-aa-metadata
llvm/test/Transforms/InstCombine/load-no-aliasing.ll
1 ↗(On Diff #333007)

Sorry I only saw that after committing.

nikic accepted this revision.Mar 24 2021, 10:13 AM

LGTM

This revision is now accepted and ready to land.Mar 24 2021, 10:13 AM
This revision was landed with ongoing or failed builds.Mar 24 2021, 10:20 AM
This revision was automatically updated to reflect the committed changes.