1 //===- LowerAllowCheckPass.h ------------------------------------*- 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 /// \file 9 /// This file provides the interface for the pass responsible for removing 10 /// expensive ubsan checks. 11 /// 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_LOWERALLOWCHECKPASS_H 15 #define LLVM_TRANSFORMS_INSTRUMENTATION_LOWERALLOWCHECKPASS_H 16 17 #include "llvm/IR/Function.h" 18 #include "llvm/IR/PassManager.h" 19 #include "llvm/Pass.h" 20 #include "llvm/Support/Compiler.h" 21 22 namespace llvm { 23 24 // This pass is responsible for removing optional traps, like llvm.ubsantrap 25 // from the hot code. 26 class LowerAllowCheckPass : public PassInfoMixin<LowerAllowCheckPass> { 27 public: 28 struct Options { 29 std::vector<unsigned int> cutoffs; 30 unsigned int runtime_check = 0; 31 }; 32 LowerAllowCheckPass(LowerAllowCheckPass::Options Opts)33 explicit LowerAllowCheckPass(LowerAllowCheckPass::Options Opts) 34 : Opts(std::move(Opts)) {}; 35 LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); 36 37 LLVM_ABI static bool IsRequested(); 38 LLVM_ABI void 39 printPipeline(raw_ostream &OS, 40 function_ref<StringRef(StringRef)> MapClassName2PassName); 41 42 private: 43 LowerAllowCheckPass::Options Opts; 44 }; 45 46 } // namespace llvm 47 48 #endif 49