1 //===- Transforms/Instrumentation/MemorySanitizer.h - MSan Pass -----------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the memoy sanitizer pass.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_MEMORYSANITIZER_H
15 #define LLVM_TRANSFORMS_INSTRUMENTATION_MEMORYSANITIZER_H
16 
17 #include "llvm/IR/PassManager.h"
18 #include "llvm/Pass.h"
19 
20 namespace llvm {
21 
22 // Insert MemorySanitizer instrumentation (detection of uninitialized reads)
23 FunctionPass *createMemorySanitizerLegacyPassPass(int TrackOrigins = 0,
24                                         bool Recover = false,
25                                         bool EnableKmsan = false);
26 
27 /// A function pass for msan instrumentation.
28 ///
29 /// Instruments functions to detect unitialized reads. This function pass
30 /// inserts calls to runtime library functions. If the functions aren't declared
31 /// yet, the pass inserts the declarations. Otherwise the existing globals are
32 /// used.
33 struct MemorySanitizerPass : public PassInfoMixin<MemorySanitizerPass> {
34   MemorySanitizerPass(int TrackOrigins = 0, bool Recover = false,
35                       bool EnableKmsan = false)
TrackOriginsMemorySanitizerPass36       : TrackOrigins(TrackOrigins), Recover(Recover), EnableKmsan(EnableKmsan) {
37   }
38 
39   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
40 
41 private:
42   int TrackOrigins;
43   bool Recover;
44   bool EnableKmsan;
45 };
46 }
47 
48 #endif /* LLVM_TRANSFORMS_INSTRUMENTATION_MEMORYSANITIZER_H */
49