[all-commits] [llvm/llvm-project] 373346: [IR][PGO] Add hot func attribute and use hot/cold ...

xur-llvm via All-commits all-commits at lists.llvm.org
Thu Dec 17 18:59:41 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 3733463dbb58a29892be3872bd32f93cb9af492c
      https://github.com/llvm/llvm-project/commit/3733463dbb58a29892be3872bd32f93cb9af492c
  Author: Rong Xu <xur at google.com>
  Date:   2020-12-17 (Thu, 17 Dec 2020)

  Changed paths:
    M clang/lib/CodeGen/CGCall.cpp
    M clang/lib/CodeGen/CodeGenModule.cpp
    M clang/test/CodeGen/attributes.c
    M llvm/docs/LangRef.rst
    M llvm/include/llvm/Bitcode/LLVMBitCodes.h
    M llvm/include/llvm/IR/Attributes.td
    M llvm/lib/AsmParser/LLParser.cpp
    M llvm/lib/Bitcode/Reader/BitcodeReader.cpp
    M llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
    M llvm/lib/CodeGen/CodeGenPrepare.cpp
    M llvm/lib/IR/Attributes.cpp
    M llvm/lib/IR/Verifier.cpp
    M llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
    M llvm/test/Bitcode/attributes.ll
    A llvm/test/CodeGen/X86/hot-unlikely-section-prefix.ll
    A llvm/test/MC/AsmParser/function_hot_attr.ll

  Log Message:
  -----------
  [IR][PGO] Add hot func attribute and use hot/cold attribute in func section

Clang FE currently has hot/cold function attribute. But we only have
cold function attribute in LLVM IR.

This patch adds support of hot function attribute to LLVM IR.  This
attribute will be used in setting function section prefix/suffix.
Currently .hot and .unlikely suffix only are added in PGO (Sample PGO)
compilation (through isFunctionHotInCallGraph and
isFunctionColdInCallGraph).

This patch changes the behavior. The new behavior is:
(1) If the user annotates a function as hot or isFunctionHotInCallGraph
    is true, this function will be marked as hot. Otherwise,
(2) If the user annotates a function as cold or
    isFunctionColdInCallGraph is true, this function will be marked as
    cold.

The changes are:
(1) user annotated function attribute will used in setting function
    section prefix/suffix.
(2) hot attribute overwrites profile count based hotness.
(3) profile count based hotness overwrite user annotated cold attribute.

The intention for these changes is to provide the user a way to mark
certain function as hot in cases where training input is hard to cover
all the hot functions.

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




More information about the All-commits mailing list