[all-commits] [llvm/llvm-project] eca03d: [CSSPGO] Track and use context-sensitive post-opti...

WenleiHe via All-commits all-commits at lists.llvm.org
Wed Aug 18 23:01:35 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: eca03d27684d076b960bac280ef6e4fa37fd8bbd
      https://github.com/llvm/llvm-project/commit/eca03d27684d076b960bac280ef6e4fa37fd8bbd
  Author: Wenlei He <aktoon at gmail.com>
  Date:   2021-08-18 (Wed, 18 Aug 2021)

  Changed paths:
    M llvm/include/llvm/ProfileData/SampleProf.h
    M llvm/include/llvm/Transforms/IPO/SampleContextTracker.h
    M llvm/lib/Transforms/IPO/SampleContextTracker.cpp
    A llvm/test/tools/llvm-profgen/Inputs/cs-preinline-cost.perfbin
    A llvm/test/tools/llvm-profgen/Inputs/cs-preinline-cost.perfscript
    A llvm/test/tools/llvm-profgen/cs-preinline-cost.test
    M llvm/tools/llvm-profgen/CSPreInliner.cpp
    M llvm/tools/llvm-profgen/CSPreInliner.h
    M llvm/tools/llvm-profgen/ProfileGenerator.cpp
    M llvm/tools/llvm-profgen/ProfiledBinary.cpp
    M llvm/tools/llvm-profgen/ProfiledBinary.h

  Log Message:
  -----------
  [CSSPGO] Track and use context-sensitive post-optimization function size to drive global pre-inliner in llvm-profgen

This change enables llvm-profgen to use accurate context-sensitive post-optimization function byte size as a cost proxy to drive global preinline decisions.

To do this, BinarySizeContextTracker is introduced to track function byte size under different inline context during disassembling. In preinliner, we can not query context byte size under switch `context-cost-for-preinliner`. The tracker uses a reverse trie to keep size of functions under different context (callee as parent, caller as child), and it can give best/longest possible matching context size for given input context.

The new size cost is off by default. There're a few TODOs that needs to addressed: 1) avoid dangling string from `Offset2LocStackMap`, which will be addressed in split context work; 2) using inlinee's entry probe to make sure we have correct zero size for inlinee that's completely optimized away after inlining. Some tuning is also needed.

Differential Revision: https://reviews.llvm.org/D108180




More information about the All-commits mailing list