This is an archive of the discontinued LLVM Phabricator instance.

[Attributor] Cache query results for isPotentiallyReachable in AAReachability
ClosedPublic

Authored by okura on Jul 6 2020, 11:50 AM.

Details

Summary

This is the next patch of D76210.
This patch made a map in InformationCache for caching results.

Diff Detail

Event Timeline

okura created this revision.Jul 6 2020, 11:50 AM
Herald added a reviewer: uenoku. · View Herald Transcript
Herald added a reviewer: homerdin. · View Herald Transcript
Herald added a reviewer: baziotis. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
okura updated this revision to Diff 275779.Jul 6 2020, 11:54 AM

Added a comment

I'm not sold on the liveness check. Do we have users of this function that would even try to call with a dead instruction? Usually, liveness is backed in so deep that all AAs actually see is assumed life.

llvm/include/llvm/Transforms/IPO/Attributor.h
729

Please add documentation and consider taking the instructions as references.

Nit: Move F after the first check to shorten the lifetime (and avoid confusion).

2397

Style: Most our interfaces take the Attributor first (I think).

okura added a comment.Jul 10 2020, 6:17 AM

On second thoughts, I think so too about the licenses check.
Could you tell me where you think we can use the liveness information in this comment?

okura marked an inline comment as done.Jul 10 2020, 7:28 AM
okura added inline comments.
llvm/include/llvm/Transforms/IPO/Attributor.h
729

Do you expect that I change interfaces of AAReachability to take instructions as references too?
Could you tell me the advantage of taking as references compared to taking as pointers? I don't mean I want to stick to pointers, just want to know about it.

On second thoughts, I think so too about the licenses check.
Could you tell me where you think we can use the liveness information in this comment?

Right. What I meant is we should use liveness when computing the entire reachability result, not only the endpoints. We can (reasonably) expect users to do the latter (for now).
If we compute reachability ourselves it is a different story as we can use the liveness of edges (eventually) to improve the result.

llvm/include/llvm/Transforms/IPO/Attributor.h
729

Yes, feel free to change the other interface as well.

There is no(t much) "functional benefit". In the Attributor we usually use references whenever we cannot pass null and pointers when we might (or have to use pointers). At the end of the day it is just a hint for the user that nullptr is not acceptable.

okura updated this revision to Diff 277314.Jul 12 2020, 7:32 PM
okura retitled this revision from [Attributor] use liveness information from AAIsDead in AAReachability and cache query results to [Attributor] Cache query results for isPotentiallyReachable in AAReachability.
okura edited the summary of this revision. (Show Details)

fix according to review comments
change the purpose of this patch to caching query results only.

Now that I look at this again, why don't we move everything into AAReachability, the map and such. It is the place we will eventually also compute things. The code looks good otherwise.

okura added a comment.Jul 21 2020, 2:59 AM

I have difficulty in moving into AAReachability because a member should be const function. If the map move in AAReachability, the function that cache query results cannot be const. That's why I put the cache in InformationCache.

jdoerfert accepted this revision.Jul 22 2020, 10:06 PM

I have difficulty in moving into AAReachability because a member should be const function. If the map move in AAReachability, the function that cache query results cannot be const. That's why I put the cache in InformationCache.

Good point. Let's go with this :)

This revision is now accepted and ready to land.Jul 22 2020, 10:06 PM
This revision was automatically updated to reflect the committed changes.