[all-commits] [llvm/llvm-project] 1757a2: [ctxprof] Make ContextRoot an implementation detai...

Mircea Trofin via All-commits all-commits at lists.llvm.org
Tue Mar 18 22:03:48 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1757a235e386be908d5df01bb736085270d31686
      https://github.com/llvm/llvm-project/commit/1757a235e386be908d5df01bb736085270d31686
  Author: Mircea Trofin <mtrofin at google.com>
  Date:   2025-03-18 (Tue, 18 Mar 2025)

  Changed paths:
    M compiler-rt/lib/ctx_profile/CtxInstrProfiling.cpp
    M compiler-rt/lib/ctx_profile/CtxInstrProfiling.h
    M compiler-rt/lib/ctx_profile/tests/CtxInstrProfilingTest.cpp
    M llvm/lib/Transforms/Instrumentation/PGOCtxProfLowering.cpp
    M llvm/test/Transforms/PGOProfile/ctx-instrumentation.ll

  Log Message:
  -----------
  [ctxprof] Make ContextRoot an implementation detail (#131416)

`ContextRoot` `FunctionData` are currently known by the llvm side, which has to instantiate and zero-initialize them. 

This patch makes `FunctionData` the only global value that needs to be known and instantiated by the compiler. On the compiler-rt side, `ContextRoot`s are hung off `FunctionData`, when applicable.

This is for two reasons. First, it is a step towards root autodetection (in a subsequent patch). An autodetection mechanism would instantiate the `ContextRoot` for the detected roots, and then `__llvm_ctx_profile_get_context` would detect that and route to `__llvm_ctx_profile_start_context`.

The second reason is that we will hang off `ContextRoot` more complex datatypes (next patch), and we want to avoid too deep of a coupling between llvm and compiler-rt. Acting as a place to hang related data, `FunctionData` can stay simple - pointers and an (atomic) int (the mutex).



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list