[compiler-rt] [compiler-rt][ctx_profile] Add the instrumented contextual profiling APIs (PR #89838)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Mon May 6 09:59:25 PDT 2024
================
@@ -13,11 +13,101 @@
#include "sanitizer_common/sanitizer_mutex.h"
#include "sanitizer_common/sanitizer_placement_new.h"
#include "sanitizer_common/sanitizer_thread_safety.h"
+#include "sanitizer_common/sanitizer_vector.h"
#include <assert.h>
using namespace __ctx_profile;
+namespace {
+// Keep track of all the context roots we actually saw, so we can then traverse
+// them when the user asks for the profile in __llvm_ctx_profile_fetch
+__sanitizer::SpinMutex AllContextsMutex;
+SANITIZER_GUARDED_BY(AllContextsMutex)
+__sanitizer::Vector<ContextRoot *> AllContextRoots;
+
+// utility to taint a pointer by setting the LSB. There is an assumption
+// throughout that the addresses of contexts are even (really, they should be
+// align(8), but "even"-ness is the minimum assumption)
+ContextNode *markAsScratch(const ContextNode *Ctx) {
----------------
mtrofin wrote:
Explained in header, re-explaining here, too.
https://github.com/llvm/llvm-project/pull/89838
More information about the llvm-commits
mailing list