This is an archive of the discontinued LLVM Phabricator instance.

[funcattrs] Consistently treat calling a function pointer as a non-capturing read
ClosedPublic

Authored by reames on Dec 16 2021, 4:55 PM.

Details

Summary

We were being wildly inconsistent about what memory access was implied by an indirect function call. Depending on the call site attributes, you could get anything from a read, to unknown, to none at all. (The last was a miscompile.)

We were also always traversing the uses of a readonly indirect call. This is entirely unneeded as the indirect call does not capture. The callee might capture itself internally, but that has no implications for this caller. (See the nice explanation in the CaptureTracking comments if that case is confusing.)

Note that elsewhere in the same file, we were correctly computing the nocapture attribute for indirect calls. The changed case only resulted in conservatism when computing memory attributes if say the return value was written to.

Diff Detail

Event Timeline

reames created this revision.Dec 16 2021, 4:55 PM
reames requested review of this revision.Dec 16 2021, 4:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 16 2021, 4:55 PM
nikic accepted this revision.Dec 17 2021, 12:02 AM
nikic added a subscriber: nikic.

LGTM

This revision is now accepted and ready to land.Dec 17 2021, 12:02 AM
This revision was landed with ongoing or failed builds.Dec 17 2021, 9:02 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptDec 17 2021, 9:02 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript