This is an archive of the discontinued LLVM Phabricator instance.

[LICM] Make capture check more precise
ClosedPublic

Authored by nikic on Apr 17 2021, 8:07 AM.

Details

Summary

During store promotion, we check whether the pointer was captured to exclude potential reads from other threads. However, we're only interested in captures before or inside the loop. Check this using PointerMayBeCapturedBefore against the loop header.

I'm not seeing any compile-time impact on CTMark for this change.

Diff Detail

Event Timeline

nikic created this revision.Apr 17 2021, 8:07 AM
nikic requested review of this revision.Apr 17 2021, 8:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 17 2021, 8:07 AM
reames accepted this revision.Apr 19 2021, 9:36 AM

LGTM w/one suggested comment.

llvm/lib/Transforms/Scalar/LICM.cpp
1957

I'd suggest inlining this helper into it's sole caller and simply updating the existing block comment. (Optional.)

This revision is now accepted and ready to land.Apr 19 2021, 9:36 AM
nikic added inline comments.Apr 19 2021, 9:38 AM
llvm/lib/Transforms/Scalar/LICM.cpp
1957

There's two callers though :) One in isKnownNonEscaping, and the other in promoteLoopAccessesToScalars.

reames added inline comments.Apr 19 2021, 10:24 AM
llvm/lib/Transforms/Scalar/LICM.cpp
1957

Oops, yep.

Though why I wrote the second caller that way as opposed to calling the same helper is not immediately obvious. Cleanup opportunity?

p.s. LGTM still stands.

This revision was automatically updated to reflect the committed changes.