This is an archive of the discontinued LLVM Phabricator instance.

Use profile info to set function section prefix to group hot/cold functions.
ClosedPublic

Authored by danielcdh on Sep 27 2016, 2:58 PM.

Details

Summary

The original implementation is in r261607, which was reverted in r269726 to accomendate the ProfileSummaryInfo analysis pass. The new implementation:

  1. add a new metadata for function section prefix
  2. query against ProfileSummaryInfo in CGP to set the correct section prefix for each function
  3. output the section prefix set by CGP

Event Timeline

danielcdh updated this revision to Diff 72716.Sep 27 2016, 2:58 PM
danielcdh retitled this revision from to Use profile info to set function section prefix to group hot/cold functions..
danielcdh updated this object.
danielcdh added reviewers: eraman, davidxl.
danielcdh added a subscriber: llvm-commits.
eraman added inline comments.Sep 27 2016, 5:55 PM
lib/CodeGen/CodeGenPrepare.cpp
124

Option name misspelt: guideded -> guided

246

isHotFunction and isColdFunction do not use the histogram based hotness/coldness information. It's probably fine to use this now and later change their implementation.

lib/CodeGen/TargetLoweringObjectFileImpl.cpp
298–299

Remove the FIXME

test/Transforms/CodeGenPrepare/section.ll
7

You don't need the PROF variable since you don't use it later

danielcdh updated this revision to Diff 72749.Sep 27 2016, 6:08 PM
danielcdh marked an inline comment as done.

update

vsk added a subscriber: vsk.Oct 10 2016, 11:26 AM
vsk added inline comments.
lib/Analysis/ProfileSummaryInfo.cpp
116 ↗(On Diff #72749)

Please spell the method name out to be explicit.

120 ↗(On Diff #72749)

Why aren't the Hot/Cold count thresholds cleared?

139 ↗(On Diff #72749)

How is the call to "resetM" being tested by your test?

lib/CodeGen/TargetLoweringObjectFileImpl.cpp
301

IMO this makes more sense as "auto OptionalPrefix =" or "Optional<StringRef> Prefix =".

test/Transforms/CodeGenPrepare/section.ll
7

Please move your checks closer to the relevant "source" IR. Checks for module-level metadata should go at the end of the test, and checks related to a function should be near its definition.

8

"[0-9]*" should be "[0-9]+" in these tests.

danielcdh updated this revision to Diff 74152.Oct 10 2016, 11:46 AM
danielcdh marked 5 inline comments as done.

rebase and update

danielcdh added inline comments.Oct 10 2016, 11:47 AM
lib/Analysis/ProfileSummaryInfo.cpp
116 ↗(On Diff #72749)

after rebasing, these changes are not necessary.

120 ↗(On Diff #72749)

after rebasing, these changes are not necessary.

139 ↗(On Diff #72749)

after rebasing, these changes are not necessary.

vsk added a comment.Oct 10 2016, 4:12 PM

No objections from me! It'd be better if Easwaran or David sign off on this though.

eraman edited edge metadata.Oct 11 2016, 3:47 PM

I've some minor comments, but otherwise LGTM.

lib/CodeGen/CodeGenPrepare.cpp
216

This is not part of your change, but why are the other analysis passes (LoopInfoWrapper etc) already specified in INITIALIZE_PASS_DEPENDENCY?

lib/IR/Function.cpp
1280

This seems to exceed 80 char limit. Did you run clang-format?

1285

if MD is non nullptr, then you shouldn't have to check for MD->getOperand(0) to be non-null right? Similarly, below, you don't have to check that operand 0 equals "function_section_prefix". Removing the ifs will make this clean. Or may be add asserts?

danielcdh updated this revision to Diff 74387.Oct 12 2016, 8:46 AM
danielcdh marked 2 inline comments as done.
danielcdh edited edge metadata.

update

lib/CodeGen/CodeGenPrepare.cpp
216

In theory, all analysis pass it depends on should be declared here. But other analysis pass it depends on have all been declared as dependency of something initialized by LLVMInitializeXXXXXXTarget, but ProfileSummaryInfo is not such case, thus needs to be explicitly declared here.

eraman accepted this revision.Oct 18 2016, 10:54 AM
eraman edited edge metadata.

LGTM

lib/IR/Function.cpp
1285

Weird formatting here - space between * and MD.

This revision is now accepted and ready to land.Oct 18 2016, 10:54 AM
danielcdh closed this revision.Oct 18 2016, 1:52 PM
danielcdh marked an inline comment as done.Oct 18 2016, 1:58 PM