This is an archive of the discontinued LLVM Phabricator instance.

[DSE] Use cached escape info for calls.
AbandonedPublic

Authored by fhahn on Sep 16 2021, 12:09 PM.

Details

Summary

This patch uses the caching added in D109844 to analyze calls. It adds a
variant of callCapturesBefore which should only be called if the object
does not escape before the call. I am happy to adjust the naming and
structure of the changes in CaptureTracking and I'll add a doc-comment
once everything is settled.

Fixes PR50220.

Diff Detail

Event Timeline

fhahn created this revision.Sep 16 2021, 12:09 PM
fhahn requested review of this revision.Sep 16 2021, 12:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 16 2021, 12:09 PM

Please document in detail that callCapturesBefore should only be called if the object does not escape before the call. Even if the public API is not available with this patch, it can be added in the future due to oversight if a comment does not explain this choice.

llvm/lib/Analysis/AliasAnalysis.cpp
741

Define the API only for a CallBase; simplify checks below.

fhahn updated this revision to Diff 373239.Sep 17 2021, 8:51 AM

Please document in detail that callCapturesBefore should only be called if the object does not escape before the call. Even if the public API is not available with this patch, it can be added in the future due to oversight if a comment does not explain this choice.

I added a comment to callCaptures, removed callKnownNoCapture and exposed callCaptures as public function instead. I also removed the redundant DT argument.

fhahn marked an inline comment as done.Sep 17 2021, 8:52 AM
fhahn added inline comments.
llvm/lib/Analysis/AliasAnalysis.cpp
741

I simplified the API here by just exposing callCaptures which only takes a CallBase and an object.

asbirlea accepted this revision.Sep 17 2021, 2:50 PM
This revision is now accepted and ready to land.Sep 17 2021, 2:50 PM
nikic requested changes to this revision.Sep 17 2021, 3:26 PM
nikic added inline comments.
llvm/include/llvm/Analysis/AliasAnalysis.h
812

I'm really confused by this API. My understanding is that it computes the ModRefInfo of the call under the assumption that the object is not captured before *or at* the call. The implementation skips over non-nocapture arguments on the premise that these must have already been checked. It only checks whether there are arguments that may mod/ref the object without capturing. With that in mind, the API name seems to be the opposite of what it actually does.

This revision now requires changes to proceed.Sep 17 2021, 3:26 PM
fhahn updated this revision to Diff 373624.Sep 20 2021, 9:35 AM
fhahn marked an inline comment as done.

Adjust naming callCaptures to callNoCapturesBefore.

fhahn added inline comments.Sep 20 2021, 9:37 AM
llvm/include/llvm/Analysis/AliasAnalysis.h
812

I changed it to callNoCapturesBefore, which should be more in line with callCapturesBefore which runs the capture-before checks. The naming is still not that great, I'd appreciate any suggestions.

nikic added inline comments.Sep 20 2021, 11:42 AM
llvm/include/llvm/Analysis/AliasAnalysis.h
812

It's a mouthful, but maybe getModRefInfoAssumingNoCapture()?

I think it would be good to adjust the comment here to say "does not escape before or at the call".

llvm/lib/Analysis/AliasAnalysis.cpp
748

Just as a side-note, as this is a preexisting issue in this code: This only checks that Object itself is called, but not whether something that aliases Object is called.

Probably doesn't matter much in practice as calling a local object seems like a really weird thing to do.

fhahn updated this revision to Diff 373683.Sep 20 2021, 12:07 PM

Updated to use getModRefInfoAssumingNoCapture.

nikic added a comment.Sep 27 2021, 1:34 PM

This one should no longer be necessary?

fhahn planned changes to this revision.Sep 28 2021, 2:23 AM

This one should no longer be necessary?

Yep, I also closed PR50220

fhahn abandoned this revision.Sep 28 2021, 2:23 AM