Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 pmbaty 1
//===------- Definition of the SanitizerBinaryMetadata class ----*- 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
// This file declares the SanitizerBinaryMetadata pass.
10
//
11
//===----------------------------------------------------------------------===//
12
#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_SANITIZERBINARYMETADATA_H
13
#define LLVM_TRANSFORMS_INSTRUMENTATION_SANITIZERBINARYMETADATA_H
14
 
15
#include "llvm/IR/Function.h"
16
#include "llvm/IR/Module.h"
17
#include "llvm/IR/PassManager.h"
18
#include "llvm/Transforms/Instrumentation.h"
19
 
20
namespace llvm {
21
 
22
struct SanitizerBinaryMetadataOptions {
23
  bool Covered = false;
24
  bool Atomics = false;
25
  bool UAR = false;
26
  SanitizerBinaryMetadataOptions() = default;
27
};
28
 
29
inline constexpr int kSanitizerBinaryMetadataAtomicsBit = 0;
30
inline constexpr int kSanitizerBinaryMetadataUARBit = 1;
31
 
32
inline constexpr uint32_t kSanitizerBinaryMetadataNone = 0;
33
inline constexpr uint32_t kSanitizerBinaryMetadataAtomics =
34
    1 << kSanitizerBinaryMetadataAtomicsBit;
35
inline constexpr uint32_t kSanitizerBinaryMetadataUAR =
36
    1 << kSanitizerBinaryMetadataUARBit;
37
 
38
inline constexpr char kSanitizerBinaryMetadataCoveredSection[] =
39
    "sanmd_covered";
40
inline constexpr char kSanitizerBinaryMetadataAtomicsSection[] =
41
    "sanmd_atomics";
42
 
43
/// Public interface to the SanitizerBinaryMetadata module pass for emitting
44
/// metadata for binary analysis sanitizers.
45
//
46
/// The pass should be inserted after optimizations.
47
class SanitizerBinaryMetadataPass
48
    : public PassInfoMixin<SanitizerBinaryMetadataPass> {
49
public:
50
  explicit SanitizerBinaryMetadataPass(
51
      SanitizerBinaryMetadataOptions Opts = {});
52
  PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
53
  static bool isRequired() { return true; }
54
 
55
private:
56
  const SanitizerBinaryMetadataOptions Options;
57
};
58
 
59
} // namespace llvm
60
 
61
#endif