This is an archive of the discontinued LLVM Phabricator instance.

[llvm-profgen] Refactor and better diagnostics
ClosedPublic

Authored by wenlei on Sep 29 2021, 9:38 AM.

Details

Summary

This change contains diagnostics improvments, refactoring and preparation for consuming perf data directly.

Diagnostics:

  • We now have more detailed diagnostics when no mmap is found.
  • We also print warning for abnormal transition to external code.

Refactoring:

  • Simplify input perf trace processing to only allow a single input file. This is because 1) using multiple input perf trace (perf script) is error prone because we may miss key mmap events. 2) the functionality is not really being used anyways.
  • Make more functions private for Readers, move non-trivial definitions out of header. Cleanup some inconsistency.
  • Prepare for consuming perf data as input directly.

Diff Detail

Event Timeline

wenlei created this revision.Sep 29 2021, 9:38 AM
wenlei requested review of this revision.Sep 29 2021, 9:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 29 2021, 9:38 AM
wenlei added inline comments.Sep 29 2021, 9:43 AM
llvm/tools/llvm-profgen/PerfReader.cpp
859

Remove the file name parameter because we have check perf script type in create. Providing file name here opens up the possibility of checking perf script type on one file, but parsePerfTraces on a different file. Now file name is passed in through ctor and stored as a member.

llvm/tools/llvm-profgen/llvm-profgen.cpp
51–66

We were accessing cl option ShowDisassemblyOnly and ShowSourceLocations directly, but passing BinaryPath and PerfTraceFilenames through parameters. Fix to always access cl option directly to be consistent.

hoy accepted this revision.Sep 29 2021, 12:01 PM

LGTM.

llvm/tools/llvm-profgen/PerfReader.cpp
440

Nit: "Invalid transfer" -> "Unpaired transfer"? The incoming jump may not be captured by the current trace.

This revision is now accepted and ready to land.Sep 29 2021, 12:01 PM
wenlei added inline comments.Sep 29 2021, 12:28 PM
llvm/tools/llvm-profgen/PerfReader.cpp
440

This is actually meant to capture cases like "internal/internal external/external" where we do see internal branches, but there's no transition. So it's different from the unpaired case below. This is implicitly guaranteed because if leaf is external, we would ignore the stack trace and throw away the entire stack+lbr. But let make add a check for Index to be explicit.

wenlei updated this revision to Diff 376107.Sep 29 2021, 10:51 PM

update, address comment.

This revision was landed with ongoing or failed builds.Sep 29 2021, 10:56 PM
This revision was automatically updated to reflect the committed changes.