This is an archive of the discontinued LLVM Phabricator instance.

[Attributor] Introduce getPotentialCopiesOfStoredValue and use it
ClosedPublic

Authored by jdoerfert on Jul 16 2021, 1:23 PM.

Details

Summary

This patch introduces getPotentialCopiesOfStoredValue which uses
AAPointerInfo to determine all "aliases" or "potential copies" of a
value that is stored into memory. This operation can fail but if it
succeeds it means we can visit all "uses" of a value even if it is
temporarily stored in memory.

There are two users for the function:

  1. Attributor::checkForAllUses which will now ignore the value use in a store if all "potential copies" can be identified and instead be visited. This allows various AAs, including AAPointerInfo itself, to look through memory.
  2. AANoCapture which uses a custom use tracking through the CaptureTracker interface and therefore needs to be thought explicitly.

Diff Detail

Event Timeline

jdoerfert created this revision.Jul 16 2021, 1:23 PM
jdoerfert requested review of this revision.Jul 16 2021, 1:23 PM
Herald added a reviewer: baziotis. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Herald added subscribers: bbn, sstefan1. · View Herald Transcript
kuter added inline comments.Jul 16 2021, 4:48 PM
llvm/lib/Transforms/IPO/Attributor.cpp
320

Nit: typo

llvm/lib/Transforms/IPO/AttributorAttributes.cpp
3085–3090

From what I can see checkForAllUses can now return uses from different functions.
I am worried about some code not handling this case correctly.

For example, do you think this piece of code can cause a problem ?

jdoerfert added inline comments.Jul 16 2021, 5:48 PM
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
3085–3090

Assuming AAReachability would handle interprocedural queries right (it will assert now) this would be fine.

That said, I find the UserI check above very suspect and I can not remember why this is supposed to be valid without following the user at least.

jdoerfert updated this revision to Diff 360005.Jul 19 2021, 9:01 PM

Fixed spelling

kuter accepted this revision.Jul 20 2021, 9:59 AM

LGTM

This revision is now accepted and ready to land.Jul 20 2021, 9:59 AM
This revision was landed with ongoing or failed builds.Jul 26 2021, 9:34 PM
This revision was automatically updated to reflect the committed changes.