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.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
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).
llvm/include/llvm/Analysis/Loads.h | ||
---|---|---|
167–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.
llvm/include/llvm/Analysis/Loads.h | ||
---|---|---|
167–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()?
- Make patch standalone
- Add InstCombine testcase
- Fix naming of function while modifying parameters
- Make MemoryLocation mandatory
llvm/test/Transforms/InstCombine/load-no-aliasing.ll | ||
---|---|---|
1 | Please precommit using llvm/utils/update_test_checks.py |
llvm/lib/Transforms/Scalar/JumpThreading.cpp | ||
---|---|---|
1394 | 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 | The -evaluate-aa-metadata flag here is not needed -- this is used for directly printing modref information, not for normal transformation tests. |
- Remove redundant AAAATags
- Rebase on committed baseline testcase
- Remove -evaluate-aa-metadata
llvm/test/Transforms/InstCombine/load-no-aliasing.ll | ||
---|---|---|
1 | Sorry I only saw that after committing. |
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.)