diff options
author | 2021-01-02 17:10:07 +0000 | |
---|---|---|
committer | 2021-01-02 17:10:07 +0000 | |
commit | 1f9cb04fc6f537ca6cf5a53c28927340cba218a2 (patch) | |
tree | b7ed93e9425eb3b3592edb1eedf5dd5ca8a1b515 /gnu/llvm/compiler-rt/lib/xray/xray_init.cpp | |
parent | Add missing .Cm macros to the Address Family table. (diff) | |
download | wireguard-openbsd-1f9cb04fc6f537ca6cf5a53c28927340cba218a2.tar.xz wireguard-openbsd-1f9cb04fc6f537ca6cf5a53c28927340cba218a2.zip |
Import compiler-rt 11.0.0 release.
ok kettenis@
Diffstat (limited to 'gnu/llvm/compiler-rt/lib/xray/xray_init.cpp')
-rw-r--r-- | gnu/llvm/compiler-rt/lib/xray/xray_init.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/gnu/llvm/compiler-rt/lib/xray/xray_init.cpp b/gnu/llvm/compiler-rt/lib/xray/xray_init.cpp index 40839647797..00ba5fe4a52 100644 --- a/gnu/llvm/compiler-rt/lib/xray/xray_init.cpp +++ b/gnu/llvm/compiler-rt/lib/xray/xray_init.cpp @@ -84,8 +84,24 @@ void __xray_init() XRAY_NEVER_INSTRUMENT { SpinMutexLock Guard(&XRayInstrMapMutex); XRayInstrMap.Sleds = __start_xray_instr_map; XRayInstrMap.Entries = __stop_xray_instr_map - __start_xray_instr_map; - XRayInstrMap.SledsIndex = __start_xray_fn_idx; - XRayInstrMap.Functions = __stop_xray_fn_idx - __start_xray_fn_idx; + if (__start_xray_fn_idx != nullptr) { + XRayInstrMap.SledsIndex = __start_xray_fn_idx; + XRayInstrMap.Functions = __stop_xray_fn_idx - __start_xray_fn_idx; + } else { + size_t CountFunctions = 0; + uint64_t LastFnAddr = 0; + + for (std::size_t I = 0; I < XRayInstrMap.Entries; I++) { + const auto &Sled = XRayInstrMap.Sleds[I]; + const auto Function = Sled.function(); + if (Function != LastFnAddr) { + CountFunctions++; + LastFnAddr = Function; + } + } + + XRayInstrMap.Functions = CountFunctions; + } } atomic_store(&XRayInitialized, true, memory_order_release); |