MemorySanitizer.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- Transforms/Instrumentation/MemorySanitizer.h - MSan Pass -----------===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file defines the memoy sanitizer pass.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_MEMORYSANITIZER_H
  18. #define LLVM_TRANSFORMS_INSTRUMENTATION_MEMORYSANITIZER_H
  19. #include "llvm/ADT/STLFunctionalExtras.h"
  20. #include "llvm/IR/PassManager.h"
  21. namespace llvm {
  22. class Module;
  23. class StringRef;
  24. class raw_ostream;
  25. struct MemorySanitizerOptions {
  26. MemorySanitizerOptions() : MemorySanitizerOptions(0, false, false, false){};
  27. MemorySanitizerOptions(int TrackOrigins, bool Recover, bool Kernel)
  28. : MemorySanitizerOptions(TrackOrigins, Recover, Kernel, false) {}
  29. MemorySanitizerOptions(int TrackOrigins, bool Recover, bool Kernel,
  30. bool EagerChecks);
  31. bool Kernel;
  32. int TrackOrigins;
  33. bool Recover;
  34. bool EagerChecks;
  35. };
  36. /// A module pass for msan instrumentation.
  37. ///
  38. /// Instruments functions to detect unitialized reads. This function pass
  39. /// inserts calls to runtime library functions. If the functions aren't declared
  40. /// yet, the pass inserts the declarations. Otherwise the existing globals are
  41. /// used.
  42. struct MemorySanitizerPass : public PassInfoMixin<MemorySanitizerPass> {
  43. MemorySanitizerPass(MemorySanitizerOptions Options) : Options(Options) {}
  44. PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
  45. void printPipeline(raw_ostream &OS,
  46. function_ref<StringRef(StringRef)> MapClassName2PassName);
  47. static bool isRequired() { return true; }
  48. private:
  49. MemorySanitizerOptions Options;
  50. };
  51. }
  52. #endif /* LLVM_TRANSFORMS_INSTRUMENTATION_MEMORYSANITIZER_H */
  53. #ifdef __GNUC__
  54. #pragma GCC diagnostic pop
  55. #endif