summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/compiler-rt/lib/xray/xray_init.cpp
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2021-01-02 17:10:07 +0000
committerpatrick <patrick@openbsd.org>2021-01-02 17:10:07 +0000
commit1f9cb04fc6f537ca6cf5a53c28927340cba218a2 (patch)
treeb7ed93e9425eb3b3592edb1eedf5dd5ca8a1b515 /gnu/llvm/compiler-rt/lib/xray/xray_init.cpp
parentAdd missing .Cm macros to the Address Family table. (diff)
downloadwireguard-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.cpp20
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);