This is an archive of the discontinued LLVM Phabricator instance.

[SampleProfile][Inline] Annotate sample profile inline remarks with link phase (prelink/postlink) information.
ClosedPublic

Authored by mingmingl on Jun 1 2022, 3:23 PM.

Details

Summary

The annotation is gated by a bool option, and off by default.

Diff Detail

Event Timeline

mingmingl created this revision.Jun 1 2022, 3:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2022, 3:23 PM
mingmingl requested review of this revision.Jun 1 2022, 3:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2022, 3:23 PM

This is a strict subset of https://reviews.llvm.org/D125495, to make that patch simpler.

mingmingl updated this revision to Diff 433880.Jun 2 2022, 2:01 PM
  • Fix a bug in InlineAdvisor::getAnnotatedInlinePassName (from https://reviews.llvm.org/D126824). Basically, to compute string only once, make it a constant member of class, and return its c_str() ever since.
  • Let SampleProfileLoader class call llvm::AnnotateInlinePassName to get an annotated name.
mingmingl updated this revision to Diff 433884.Jun 2 2022, 2:05 PM

Revert unnecessary change in llvm/include/llvm/Transforms/IPO/SampleProfile.h

kazu added a comment.Jun 8 2022, 11:20 AM

The patch looks good in general, but I have some nit-picky suggestions.

llvm/include/llvm/Analysis/InlineAdvisor.h
211

Capitalize the variable name like AnnotatedInlinePassName.

llvm/lib/Analysis/InlineAdvisor.cpp
576–577

You should be able to remove this if statement. When IC.hasValue() is false, the constructor sets annotatedInlinePassName to DEBUG_TYPE.

Once the function has been simplified down to:

const char *InlineAdvisor::getAnnotatedInlinePassName() {
  return annotatedInlinePassName.c_str();
}

you might as well move it to InlineAdvisor.h.

llvm/lib/Transforms/IPO/SampleProfile.cpp
503

Capitalize the variable name like AnnotatedPassName.

545

Remove inline unless you absolutely need it.

598

Likewise, remove inline unless you absolutely need it.

599–602

Could you fully compute annotatedPassName in the constructor as you do in InlineAdvisor.cpp? I'm suggesting this partly for consistency with InlineAdvisor.cpp and partly for readability.

Again, you might consider moving the function to the class declaration.

mingmingl updated this revision to Diff 435276.Jun 8 2022, 11:46 AM
mingmingl marked 6 inline comments as done.

Resolve comments, and add Differential Revision: <URL> in commit message.

thanks for reviews! PTAL.

llvm/lib/Analysis/InlineAdvisor.cpp
576–577

Done by 1) simplifying InlineAdvisor::getAnnotatedInlinePassName 2) move it to InlineAdvisor.h.

ormris removed a subscriber: ormris.Jun 8 2022, 3:07 PM
kazu accepted this revision.Jun 22 2022, 2:38 PM

LGTM with a minor change to the constructor of InlineAdvisor. Thank you for your patience.

llvm/lib/Analysis/InlineAdvisor.cpp
512

Replace IC.hasValue() with TC.

513

Replace IC.getValue() with *IC.

This revision is now accepted and ready to land.Jun 22 2022, 2:38 PM
mingmingl updated this revision to Diff 439217.Jun 22 2022, 5:06 PM
mingmingl marked 2 inline comments as done.

Address comments, by using overloaded operator rather than hasValue() / getValue(), since the former is closer to std::optional in terms of style.

This revision was landed with ongoing or failed builds.Jun 22 2022, 5:32 PM
This revision was automatically updated to reflect the committed changes.