[all-commits] [llvm/llvm-project] 176889: [MemProf] Control availability of hot/cold operato...

Teresa Johnson via All-commits all-commits at lists.llvm.org
Mon May 8 08:02:41 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 176889868024d98db032842bc47b416997d9e349
      https://github.com/llvm/llvm-project/commit/176889868024d98db032842bc47b416997d9e349
  Author: Teresa Johnson <tejohnson at google.com>
  Date:   2023-05-08 (Mon, 08 May 2023)

  Changed paths:
    A clang/test/CodeGen/thinlto-distributed-supports-hot-cold-new.ll
    M llvm/include/llvm/IR/ModuleSummaryIndex.h
    M llvm/include/llvm/LTO/LTO.h
    M llvm/lib/Bitcode/Reader/BitcodeReader.cpp
    M llvm/lib/IR/ModuleSummaryIndex.cpp
    M llvm/lib/LTO/LTO.cpp
    M llvm/lib/LTO/LTOBackend.cpp
    M llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
    A llvm/test/LTO/X86/memprof-supports-hot-cold-new.ll
    M llvm/test/ThinLTO/X86/memprof-basic.ll
    M llvm/test/ThinLTO/X86/memprof-duplicate-context-ids.ll
    M llvm/test/ThinLTO/X86/memprof-duplicate-context-ids2.ll
    M llvm/test/ThinLTO/X86/memprof-funcassigncloning.ll
    M llvm/test/ThinLTO/X86/memprof-indirectcall.ll
    M llvm/test/ThinLTO/X86/memprof-inlined.ll
    M llvm/test/ThinLTO/X86/memprof-inlined2.ll
    A llvm/test/ThinLTO/X86/memprof-supports-hot-cold-new.ll
    M llvm/test/Transforms/MemProfContextDisambiguation/basic.ll
    M llvm/test/Transforms/MemProfContextDisambiguation/duplicate-context-ids.ll
    M llvm/test/Transforms/MemProfContextDisambiguation/duplicate-context-ids2.ll
    M llvm/test/Transforms/MemProfContextDisambiguation/funcassigncloning.ll
    M llvm/test/Transforms/MemProfContextDisambiguation/indirectcall.ll
    M llvm/test/Transforms/MemProfContextDisambiguation/inlined.ll
    M llvm/test/Transforms/MemProfContextDisambiguation/inlined2.ll

  Log Message:
  -----------
  [MemProf] Control availability of hot/cold operator new from LTO link

Adds an LTO option to indicate that whether we are linking with an
allocator that supports hot/cold operator new interfaces. If not,
at the start of the LTO backends any existing memprof hot/cold
attributes are removed from the IR, and we also remove memprof metadata
so that post-LTO inlining doesn't add any new attributes.

This is done via setting a new flag in the module summary index. It is
important to communicate via the index to the LTO backends so that
distributed ThinLTO handles this correctly, as they are invoked by
separate clang processes and the combined index is how we communicate
information from the LTO link. Specifically, for distributed ThinLTO the
LTO related processes look like:
```
   # Thin link:
   $ lld --thinlto-index-only obj1.o ... objN.o -llib ...
   # ThinLTO backends:
   $ clang -x ir obj1.o -fthinlto-index=obj1.o.thinlto.bc -c -O2
   ...
   $ clang -x ir objN.o -fthinlto-index=objN.o.thinlto.bc -c -O2
```

It is during the thin link (lld --thinlto-index-only) that we have
visibility into linker dependences and want to be able to pass the new
option via -Wl,-supports-hot-cold-new. This will be recorded in the
summary indexes created for the distributed backend processes
(*.thinlto.bc) and queried from there, so that we don't need to know
during those individual clang backends what allocation library was
linked. Since in-process ThinLTO and regular LTO also use a combined
index, for consistency we query the flag out of the index in all LTO
backends.

Additionally, when the LTO option is disabled, exit early from the
MemProfContextDisambiguation handling performed during LTO, as this is
unnecessary.

Depends on D149117 and D149192.

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




More information about the All-commits mailing list