This is an archive of the discontinued LLVM Phabricator instance.

[llvm-profgen] Refactor PerfReader to allow different types of perf scripts
ClosedPublic

Authored by wlei on Jul 28 2021, 4:12 PM.

Details

Summary

In order to support different types of perf scripts, this change tried to refactor PerfReader by adding the base class PerfReaderBase and current HybridPerfReader is derived from it for CS profile generation. Common functions like, passMM2PEvents, extract_lbrs, extract_callstack, etc. can be reused.

Next step is to add LBR only reader(for non-CS profile) and aggregated perf scripts reader(do a pre-aggregation of scripts).

Diff Detail

Event Timeline

wlei created this revision.Jul 28 2021, 4:12 PM
wlei requested review of this revision.Jul 28 2021, 4:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 28 2021, 4:12 PM
wlei updated this revision to Diff 362579.Jul 28 2021, 4:17 PM

fix lint

wlei retitled this revision from [llvm-profgen] Refactor to allow different types of perf scripts to [llvm-profgen] Refactor PerfReader to allow different types of perf scripts.Jul 28 2021, 4:32 PM
wlei edited the summary of this revision. (Show Details)
wlei added reviewers: hoy, wenlei, wmi.
hoy added a comment.Jul 29 2021, 1:03 PM

Thanks for working on this. We can continue from here to support more types of trace files, for non-cs profiles and more .

llvm/tools/llvm-profgen/ProfiledBinary.cpp
55 ↗(On Diff #362579)

The function does more than disassembling, maybe name it LoadBinary and move it out of the ProfiledBinary class?

wlei updated this revision to Diff 363149.Jul 30 2021, 10:48 AM

rename showBinaryDisasmOnly to loadBinaries

hoy accepted this revision.Jul 30 2021, 11:02 AM

LGTM, except for a minor naming issue.

llvm/tools/llvm-profgen/llvm-profgen.cpp
53

Nit: On the second thought, maybe just inlined the function here? PerfReaderBase doesn't seem a good resort for this function either since conceptually we want to by pass the perfreader and exit early.

This revision is now accepted and ready to land.Jul 30 2021, 11:02 AM
wenlei accepted this revision.Jul 30 2021, 12:02 PM

lgtm, thanks.

wlei updated this revision to Diff 363207.Jul 30 2021, 2:46 PM

address Hongtao's feedback.