As described in , this extends IRPGO to support Temporal Profiling.
When -pgo-temporal-instrumentation is used we add the llvm.instrprof.timestamp() intrinsic to the entry of functions which in turn gets lowered to a call to the compiler-rt function INSTR_PROF_PROFILE_SET_TIMESTAMP(). A new field in the llvm_prf_cnts section stores each function's timestamp. Then in llvm-profdata merge we convert these function timestamps into a trace and add it to the indexed profile.
Since these traces could significantly increase the profile size, we've added -max-temporal-profile-trace-length and -temporal-profile-trace-reservoir-size to limit the length of a trace and the number of traces in a profile, respectively.
In a future diff we plan to use these traces to construct an optimized function order to reduce the number of page faults during startup.
Special thanks to Julian Mestre for helping with reservoir sampling.