[Alignment][NFC] Use Align with TargetLowering::setMinFunctionAlignment
[llvm-core.git] / include / llvm / Transforms / Utils / SanitizerStats.h
blob14e8ae045cddd168247350d79b25935f780e4b48
1 //===- SanitizerStats.h - Sanitizer statistics gathering -------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Declares functions and data structures for sanitizer statistics gathering.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_TRANSFORMS_UTILS_SANITIZERSTATS_H
14 #define LLVM_TRANSFORMS_UTILS_SANITIZERSTATS_H
16 #include "llvm/IR/IRBuilder.h"
18 namespace llvm {
20 // Number of bits in data that are used for the sanitizer kind. Needs to match
21 // __sanitizer::kKindBits in compiler-rt/lib/stats/stats.h
22 enum { kSanitizerStatKindBits = 3 };
24 enum SanitizerStatKind {
25 SanStat_CFI_VCall,
26 SanStat_CFI_NVCall,
27 SanStat_CFI_DerivedCast,
28 SanStat_CFI_UnrelatedCast,
29 SanStat_CFI_ICall,
32 struct SanitizerStatReport {
33 SanitizerStatReport(Module *M);
35 /// Generates code into B that increments a location-specific counter tagged
36 /// with the given sanitizer kind SK.
37 void create(IRBuilder<> &B, SanitizerStatKind SK);
39 /// Finalize module stats array and add global constructor to register it.
40 void finish();
42 private:
43 Module *M;
44 GlobalVariable *ModuleStatsGV;
45 ArrayType *StatTy;
46 StructType *EmptyModuleStatsTy;
48 std::vector<Constant *> Inits;
49 ArrayType *makeModuleStatsArrayTy();
50 StructType *makeModuleStatsTy();
55 #endif