Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:38

0001 //===- BoundsChecking.h - Bounds checking instrumentation -------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_BOUNDSCHECKING_H
0010 #define LLVM_TRANSFORMS_INSTRUMENTATION_BOUNDSCHECKING_H
0011 
0012 #include "llvm/IR/PassManager.h"
0013 #include <optional>
0014 
0015 namespace llvm {
0016 class Function;
0017 
0018 /// A pass to instrument code and perform run-time bounds checking on loads,
0019 /// stores, and other memory intrinsics.
0020 class BoundsCheckingPass : public PassInfoMixin<BoundsCheckingPass> {
0021 
0022 public:
0023   struct Options {
0024     struct Runtime {
0025       Runtime(bool MinRuntime, bool MayReturn)
0026           : MinRuntime(MinRuntime), MayReturn(MayReturn) {}
0027       bool MinRuntime;
0028       bool MayReturn;
0029     };
0030     std::optional<Runtime> Rt; // Trap if empty.
0031     bool Merge = false;
0032     std::optional<int8_t> GuardKind; // `allow_ubsan_check` argument.
0033   };
0034 
0035   BoundsCheckingPass(Options Opts) : Opts(Opts) {}
0036   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
0037   static bool isRequired() { return true; }
0038   void printPipeline(raw_ostream &OS,
0039                      function_ref<StringRef(StringRef)> MapClassName2PassName);
0040 
0041 private:
0042   Options Opts;
0043 };
0044 
0045 } // end namespace llvm
0046 
0047 #endif // LLVM_TRANSFORMS_INSTRUMENTATION_BOUNDSCHECKING_H