This is an archive of the discontinued LLVM Phabricator instance.

[PGO][PGSO] Handle MBFIWrapper
ClosedPublic

Authored by hjyamauchi on Jan 24 2020, 1:49 PM.

Details

Reviewers
davidxl
Summary

Some code gen passes use MBFIWrapper to keep track of the frequency of new
blocks. This was not taken into account and could lead to incorrect frequencies
as MBFI silently returns zero frequency for unknown/new blocks.

Add a variant for MBFIWrapper in the PGSO query interface.

Depends on D73494.

Event Timeline

hjyamauchi created this revision.Jan 24 2020, 1:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 24 2020, 1:49 PM

The MBFIWrapper change seems NFC, can it be extracted out first?

Split the movement of MBFIWrapper into D73494.

Rebased past D73494. PTAL.

davidxl added inline comments.Jan 29 2020, 10:00 AM
llvm/include/llvm/Transforms/Utils/SizeOpts.h
92

Is this function necessary? It is mostly the same as the previous impl.

hjyamauchi marked an inline comment as done.Jan 29 2020, 10:57 AM
hjyamauchi added inline comments.
llvm/include/llvm/Transforms/Utils/SizeOpts.h
92

This version takes a BlockFrequency rather than a block (BlockT). Since only MBFIWrapper, rather than BFI, has the true frequency for the block, we'd need to either (1) get the frequency out of MBFIWrapper and then pass it here, or (2) pass MBFIWrapper down here. The current approach is (1). Either way, we'd need to take the frequency out of MBFIWrapper somwhere along the way, and it won't likely dedup the code as they both require a new param type that doesn't seem to be amenable to additional templatization on top of this already templatized code.

Do you see a better idea?

davidxl added inline comments.Jan 29 2020, 11:16 AM
llvm/include/llvm/Transforms/Utils/SizeOpts.h
92

How about changing BlockT template parameter into BlockTOrBlockFreq, so that it can be instantiated with BlockFrequency too?

hjyamauchi marked an inline comment as done.

Addressed comment. PTAL.

llvm/include/llvm/Transforms/Utils/SizeOpts.h
92

That just worked out, except for the assert on the BB pointer non-nullness, which I resolved by moving it to the callers. Done.

davidxl accepted this revision.Jan 30 2020, 1:24 PM

lgtm

This revision is now accepted and ready to land.Jan 30 2020, 1:24 PM
hjyamauchi closed this revision.Feb 4 2020, 10:24 AM