This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Don't apply ICP to instructions with unknown control flow
AbandonedPublic

Authored by Amir on Jun 29 2022, 7:14 PM.

Details

Reviewers
rafauler
maksfb
Summary

ICP has two modes: jump table promotion and indirect call promotion.
The selection is based on whether an instruction has a jump table or not.
An instruction with unknown control flow doesn't have a jump table and will
fall under indirect call promotion policy which might be incorrect/unsafe
(if an instruction is not a tail call, i.e. has local jump targets).

Prevent ICP for instructions with unknown control flow by adding a corresponding
check in canPromoteCallsite.

Diff Detail

Event Timeline

Amir created this revision.Jun 29 2022, 7:14 PM
Herald added a reviewer: maksfb. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: ayermolo. · View Herald Transcript
Amir requested review of this revision.Jun 29 2022, 7:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 29 2022, 7:14 PM
Amir updated this revision to Diff 441301.Jun 30 2022, 1:24 AM

Narrow down to non-tailcall indirect jump with no jump table

maksfb accepted this revision.Jul 25 2022, 3:21 PM

Filtering out functions with hasUnknownControlFlow() property in shouldOptimize() sounds more straightforward. But if you feel confident that some call sites could still be optimized, go for it.

This revision is now accepted and ready to land.Jul 25 2022, 3:21 PM
Amir added a comment.Jul 25 2022, 6:00 PM

Filtering out functions with hasUnknownControlFlow() property in shouldOptimize() sounds more straightforward. But if you feel confident that some call sites could still be optimized, go for it.

Good idea to filter on a function basis.

Amir abandoned this revision.Jul 25 2022, 6:00 PM