xref: /aosp_15_r20/external/compiler-rt/lib/stats/stats.h (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot //===-- stats.h -------------------------------------------------*- C++ -*-===//
2*7c3d14c8STreehugger Robot //
3*7c3d14c8STreehugger Robot //                     The LLVM Compiler Infrastructure
4*7c3d14c8STreehugger Robot //
5*7c3d14c8STreehugger Robot // This file is distributed under the University of Illinois Open Source
6*7c3d14c8STreehugger Robot // License. See LICENSE.TXT for details.
7*7c3d14c8STreehugger Robot //
8*7c3d14c8STreehugger Robot //===----------------------------------------------------------------------===//
9*7c3d14c8STreehugger Robot //
10*7c3d14c8STreehugger Robot // Data definitions for sanitizer statistics gathering.
11*7c3d14c8STreehugger Robot //
12*7c3d14c8STreehugger Robot //===----------------------------------------------------------------------===//
13*7c3d14c8STreehugger Robot 
14*7c3d14c8STreehugger Robot #ifndef SANITIZER_STATS_STATS_H
15*7c3d14c8STreehugger Robot #define SANITIZER_STATS_STATS_H
16*7c3d14c8STreehugger Robot 
17*7c3d14c8STreehugger Robot #include "sanitizer_common/sanitizer_internal_defs.h"
18*7c3d14c8STreehugger Robot 
19*7c3d14c8STreehugger Robot namespace __sanitizer {
20*7c3d14c8STreehugger Robot 
21*7c3d14c8STreehugger Robot // Number of bits in data that are used for the sanitizer kind. Needs to match
22*7c3d14c8STreehugger Robot // llvm::kSanitizerStatKindBits in
23*7c3d14c8STreehugger Robot // llvm/include/llvm/Transforms/Utils/SanitizerStats.h
24*7c3d14c8STreehugger Robot enum { kKindBits = 3 };
25*7c3d14c8STreehugger Robot 
26*7c3d14c8STreehugger Robot struct StatInfo {
27*7c3d14c8STreehugger Robot   uptr addr;
28*7c3d14c8STreehugger Robot   uptr data;
29*7c3d14c8STreehugger Robot };
30*7c3d14c8STreehugger Robot 
31*7c3d14c8STreehugger Robot struct StatModule {
32*7c3d14c8STreehugger Robot   StatModule *next;
33*7c3d14c8STreehugger Robot   u32 size;
34*7c3d14c8STreehugger Robot   StatInfo infos[1];
35*7c3d14c8STreehugger Robot };
36*7c3d14c8STreehugger Robot 
CountFromData(uptr data)37*7c3d14c8STreehugger Robot inline uptr CountFromData(uptr data) {
38*7c3d14c8STreehugger Robot   return data & ((1ull << (sizeof(uptr) * 8 - kKindBits)) - 1);
39*7c3d14c8STreehugger Robot }
40*7c3d14c8STreehugger Robot 
41*7c3d14c8STreehugger Robot }
42*7c3d14c8STreehugger Robot 
43*7c3d14c8STreehugger Robot #endif
44