[compiler-rt] [compiler-rt][ctx_instr] Add `ctx_profile` component (PR #89304)

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 19 14:12:46 PDT 2024


================
@@ -0,0 +1,55 @@
+/*===- CtxInstrProfiling.h- Contextual instrumentation-based PGO  ---------===*\
+|*
+|* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+|* See https://llvm.org/LICENSE.txt for license information.
+|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+|*
+\*===----------------------------------------------------------------------===*/
+
+#ifndef CTX_PROFILE_CTXINSTRPROFILING_H_
+#define CTX_PROFILE_CTXINSTRPROFILING_H_
+
+#include <sanitizer/common_interface_defs.h>
+
+namespace __ctx_profile {
+
+/// Arena (bump allocator) forming a linked list. Intentionally not thread safe.
+/// Allocation and de-allocation happen using sanitizer APIs. We make that
+/// explicit.
+class Arena final {
----------------
vitalybuka wrote:

> Try to avoid dependency on sanitizer_common if it's for prod.
I guess it's not requirement.

> LowLevelAllocator
all those linker initialized stuff just expect zero intialized storage.
you can do memset, or we can modernize LowLevelAllocator. Relevant C++ standards allow to write classes usable as local vars, and as globals without dynamic initialization.

Note, there is a plan to improve LowLevelAllocator to make it thread safe and lock free.



https://github.com/llvm/llvm-project/pull/89304


More information about the llvm-commits mailing list