Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 1 | //===-- SanitizerCoverage.cpp - coverage instrumentation for sanitizers ---===// |
| 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 | // Coverage instrumentation that works with AddressSanitizer |
| 11 | // and potentially with other Sanitizers. |
| 12 | // |
Kostya Serebryany | 9fdeb37 | 2014-12-23 22:32:17 +0000 | [diff] [blame] | 13 | // We create a Guard variable with the same linkage |
Alexey Samsonov | 3514f27 | 2015-05-07 01:00:31 +0000 | [diff] [blame] | 14 | // as the function and inject this code into the entry block (SCK_Function) |
| 15 | // or all blocks (SCK_BB): |
Kostya Serebryany | 9fdeb37 | 2014-12-23 22:32:17 +0000 | [diff] [blame] | 16 | // if (Guard < 0) { |
Kostya Serebryany | 4cadd4a | 2014-11-24 18:49:53 +0000 | [diff] [blame] | 17 | // __sanitizer_cov(&Guard); |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 18 | // } |
| 19 | // The accesses to Guard are atomic. The rest of the logic is |
| 20 | // in __sanitizer_cov (it's fine to call it more than once). |
| 21 | // |
Alexey Samsonov | 3514f27 | 2015-05-07 01:00:31 +0000 | [diff] [blame] | 22 | // With SCK_Edge we also split critical edges this effectively |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 23 | // instrumenting all edges. |
| 24 | // |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 25 | // This coverage implementation provides very limited data: |
| 26 | // it only tells if a given function (block) was ever executed. No counters. |
| 27 | // But for many use cases this is what we need and the added slowdown small. |
| 28 | // |
| 29 | //===----------------------------------------------------------------------===// |
| 30 | |
| 31 | #include "llvm/Transforms/Instrumentation.h" |
| 32 | #include "llvm/ADT/ArrayRef.h" |
| 33 | #include "llvm/ADT/SmallVector.h" |
David Majnemer | 70497c6 | 2015-12-02 23:06:39 +0000 | [diff] [blame] | 34 | #include "llvm/Analysis/EHPersonalities.h" |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 35 | #include "llvm/IR/CallSite.h" |
| 36 | #include "llvm/IR/DataLayout.h" |
Alexey Samsonov | 201733b | 2015-06-12 01:48:47 +0000 | [diff] [blame] | 37 | #include "llvm/IR/DebugInfo.h" |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 38 | #include "llvm/IR/Function.h" |
| 39 | #include "llvm/IR/IRBuilder.h" |
Kostya Serebryany | 7376294 | 2014-12-16 21:24:15 +0000 | [diff] [blame] | 40 | #include "llvm/IR/InlineAsm.h" |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 41 | #include "llvm/IR/LLVMContext.h" |
| 42 | #include "llvm/IR/MDBuilder.h" |
| 43 | #include "llvm/IR/Module.h" |
| 44 | #include "llvm/IR/Type.h" |
| 45 | #include "llvm/Support/CommandLine.h" |
| 46 | #include "llvm/Support/Debug.h" |
| 47 | #include "llvm/Support/raw_ostream.h" |
| 48 | #include "llvm/Transforms/Scalar.h" |
| 49 | #include "llvm/Transforms/Utils/BasicBlockUtils.h" |
| 50 | #include "llvm/Transforms/Utils/ModuleUtils.h" |
| 51 | |
| 52 | using namespace llvm; |
| 53 | |
| 54 | #define DEBUG_TYPE "sancov" |
| 55 | |
| 56 | static const char *const kSanCovModuleInitName = "__sanitizer_cov_module_init"; |
| 57 | static const char *const kSanCovName = "__sanitizer_cov"; |
Kostya Serebryany | 77cc729 | 2015-02-04 01:21:45 +0000 | [diff] [blame] | 58 | static const char *const kSanCovWithCheckName = "__sanitizer_cov_with_check"; |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 59 | static const char *const kSanCovIndirCallName = "__sanitizer_cov_indir_call16"; |
Kostya Serebryany | cb45b12 | 2014-11-19 00:22:58 +0000 | [diff] [blame] | 60 | static const char *const kSanCovTraceEnter = "__sanitizer_cov_trace_func_enter"; |
| 61 | static const char *const kSanCovTraceBB = "__sanitizer_cov_trace_basic_block"; |
Kostya Serebryany | f4e35cc | 2015-03-21 01:29:36 +0000 | [diff] [blame] | 62 | static const char *const kSanCovTraceCmp = "__sanitizer_cov_trace_cmp"; |
Kostya Serebryany | fb7d8d9 | 2015-07-31 01:33:06 +0000 | [diff] [blame] | 63 | static const char *const kSanCovTraceSwitch = "__sanitizer_cov_trace_switch"; |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 64 | static const char *const kSanCovModuleCtorName = "sancov.module_ctor"; |
Evgeniy Stepanov | 3fdfc7b | 2015-01-27 15:01:22 +0000 | [diff] [blame] | 65 | static const uint64_t kSanCtorAndDtorPriority = 2; |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 66 | |
| 67 | static cl::opt<int> ClCoverageLevel("sanitizer-coverage-level", |
| 68 | cl::desc("Sanitizer Coverage. 0: none, 1: entry block, 2: all blocks, " |
| 69 | "3: all blocks and critical edges, " |
| 70 | "4: above plus indirect calls"), |
| 71 | cl::Hidden, cl::init(0)); |
| 72 | |
Kostya Serebryany | 77cc729 | 2015-02-04 01:21:45 +0000 | [diff] [blame] | 73 | static cl::opt<unsigned> ClCoverageBlockThreshold( |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 74 | "sanitizer-coverage-block-threshold", |
Kostya Serebryany | 77cc729 | 2015-02-04 01:21:45 +0000 | [diff] [blame] | 75 | cl::desc("Use a callback with a guard check inside it if there are" |
| 76 | " more than this number of blocks."), |
Kostya Serebryany | 8fb05ac | 2015-03-10 01:11:53 +0000 | [diff] [blame] | 77 | cl::Hidden, cl::init(500)); |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 78 | |
Kostya Serebryany | cb45b12 | 2014-11-19 00:22:58 +0000 | [diff] [blame] | 79 | static cl::opt<bool> |
| 80 | ClExperimentalTracing("sanitizer-coverage-experimental-tracing", |
| 81 | cl::desc("Experimental basic-block tracing: insert " |
| 82 | "callbacks at every basic block"), |
| 83 | cl::Hidden, cl::init(false)); |
| 84 | |
Kostya Serebryany | f4e35cc | 2015-03-21 01:29:36 +0000 | [diff] [blame] | 85 | static cl::opt<bool> |
| 86 | ClExperimentalCMPTracing("sanitizer-coverage-experimental-trace-compares", |
| 87 | cl::desc("Experimental tracing of CMP and similar " |
| 88 | "instructions"), |
| 89 | cl::Hidden, cl::init(false)); |
| 90 | |
Kostya Serebryany | be5e0ed | 2015-03-03 23:27:02 +0000 | [diff] [blame] | 91 | // Experimental 8-bit counters used as an additional search heuristic during |
| 92 | // coverage-guided fuzzing. |
| 93 | // The counters are not thread-friendly: |
| 94 | // - contention on these counters may cause significant slowdown; |
| 95 | // - the counter updates are racy and the results may be inaccurate. |
| 96 | // They are also inaccurate due to 8-bit integer overflow. |
| 97 | static cl::opt<bool> ClUse8bitCounters("sanitizer-coverage-8bit-counters", |
| 98 | cl::desc("Experimental 8-bit counters"), |
| 99 | cl::Hidden, cl::init(false)); |
| 100 | |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 101 | namespace { |
| 102 | |
Alexey Samsonov | 3514f27 | 2015-05-07 01:00:31 +0000 | [diff] [blame] | 103 | SanitizerCoverageOptions getOptions(int LegacyCoverageLevel) { |
| 104 | SanitizerCoverageOptions Res; |
| 105 | switch (LegacyCoverageLevel) { |
| 106 | case 0: |
| 107 | Res.CoverageType = SanitizerCoverageOptions::SCK_None; |
| 108 | break; |
| 109 | case 1: |
| 110 | Res.CoverageType = SanitizerCoverageOptions::SCK_Function; |
| 111 | break; |
| 112 | case 2: |
| 113 | Res.CoverageType = SanitizerCoverageOptions::SCK_BB; |
| 114 | break; |
| 115 | case 3: |
| 116 | Res.CoverageType = SanitizerCoverageOptions::SCK_Edge; |
| 117 | break; |
| 118 | case 4: |
| 119 | Res.CoverageType = SanitizerCoverageOptions::SCK_Edge; |
| 120 | Res.IndirectCalls = true; |
| 121 | break; |
| 122 | } |
| 123 | return Res; |
| 124 | } |
| 125 | |
| 126 | SanitizerCoverageOptions OverrideFromCL(SanitizerCoverageOptions Options) { |
| 127 | // Sets CoverageType and IndirectCalls. |
| 128 | SanitizerCoverageOptions CLOpts = getOptions(ClCoverageLevel); |
| 129 | Options.CoverageType = std::max(Options.CoverageType, CLOpts.CoverageType); |
| 130 | Options.IndirectCalls |= CLOpts.IndirectCalls; |
| 131 | Options.TraceBB |= ClExperimentalTracing; |
| 132 | Options.TraceCmp |= ClExperimentalCMPTracing; |
| 133 | Options.Use8bitCounters |= ClUse8bitCounters; |
| 134 | return Options; |
| 135 | } |
| 136 | |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 137 | class SanitizerCoverageModule : public ModulePass { |
| 138 | public: |
Alexey Samsonov | 3514f27 | 2015-05-07 01:00:31 +0000 | [diff] [blame] | 139 | SanitizerCoverageModule( |
| 140 | const SanitizerCoverageOptions &Options = SanitizerCoverageOptions()) |
| 141 | : ModulePass(ID), Options(OverrideFromCL(Options)) {} |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 142 | bool runOnModule(Module &M) override; |
| 143 | bool runOnFunction(Function &F); |
| 144 | static char ID; // Pass identification, replacement for typeid |
| 145 | const char *getPassName() const override { |
| 146 | return "SanitizerCoverageModule"; |
| 147 | } |
| 148 | |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 149 | private: |
| 150 | void InjectCoverageForIndirectCalls(Function &F, |
| 151 | ArrayRef<Instruction *> IndirCalls); |
Kostya Serebryany | f4e35cc | 2015-03-21 01:29:36 +0000 | [diff] [blame] | 152 | void InjectTraceForCmp(Function &F, ArrayRef<Instruction *> CmpTraceTargets); |
Kostya Serebryany | fb7d8d9 | 2015-07-31 01:33:06 +0000 | [diff] [blame] | 153 | void InjectTraceForSwitch(Function &F, |
| 154 | ArrayRef<Instruction *> SwitchTraceTargets); |
Kostya Serebryany | f4e35cc | 2015-03-21 01:29:36 +0000 | [diff] [blame] | 155 | bool InjectCoverage(Function &F, ArrayRef<BasicBlock *> AllBlocks); |
Alexey Samsonov | 0a648a4 | 2015-05-06 21:35:25 +0000 | [diff] [blame] | 156 | void SetNoSanitizeMetadata(Instruction *I); |
Kostya Serebryany | 77cc729 | 2015-02-04 01:21:45 +0000 | [diff] [blame] | 157 | void InjectCoverageAtBlock(Function &F, BasicBlock &BB, bool UseCalls); |
Kostya Serebryany | 48a4023 | 2015-03-10 01:58:27 +0000 | [diff] [blame] | 158 | unsigned NumberOfInstrumentedBlocks() { |
Kostya Serebryany | a3c5347 | 2015-12-02 02:37:13 +0000 | [diff] [blame] | 159 | return SanCovFunction->getNumUses() + |
| 160 | SanCovWithCheckFunction->getNumUses() + SanCovTraceBB->getNumUses() + |
| 161 | SanCovTraceEnter->getNumUses(); |
Kostya Serebryany | 48a4023 | 2015-03-10 01:58:27 +0000 | [diff] [blame] | 162 | } |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 163 | Function *SanCovFunction; |
Kostya Serebryany | 77cc729 | 2015-02-04 01:21:45 +0000 | [diff] [blame] | 164 | Function *SanCovWithCheckFunction; |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 165 | Function *SanCovIndirCallFunction; |
Kostya Serebryany | cb45b12 | 2014-11-19 00:22:58 +0000 | [diff] [blame] | 166 | Function *SanCovTraceEnter, *SanCovTraceBB; |
Kostya Serebryany | f4e35cc | 2015-03-21 01:29:36 +0000 | [diff] [blame] | 167 | Function *SanCovTraceCmpFunction; |
Kostya Serebryany | fb7d8d9 | 2015-07-31 01:33:06 +0000 | [diff] [blame] | 168 | Function *SanCovTraceSwitchFunction; |
Kostya Serebryany | 7376294 | 2014-12-16 21:24:15 +0000 | [diff] [blame] | 169 | InlineAsm *EmptyAsm; |
Kostya Serebryany | fb7d8d9 | 2015-07-31 01:33:06 +0000 | [diff] [blame] | 170 | Type *IntptrTy, *Int64Ty, *Int64PtrTy; |
| 171 | Module *CurModule; |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 172 | LLVMContext *C; |
Kostya Serebryany | f4e35cc | 2015-03-21 01:29:36 +0000 | [diff] [blame] | 173 | const DataLayout *DL; |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 174 | |
Kostya Serebryany | aa185bf | 2014-12-30 19:29:28 +0000 | [diff] [blame] | 175 | GlobalVariable *GuardArray; |
Kostya Serebryany | be5e0ed | 2015-03-03 23:27:02 +0000 | [diff] [blame] | 176 | GlobalVariable *EightBitCounterArray; |
Kostya Serebryany | 9fdeb37 | 2014-12-23 22:32:17 +0000 | [diff] [blame] | 177 | |
Alexey Samsonov | 3514f27 | 2015-05-07 01:00:31 +0000 | [diff] [blame] | 178 | SanitizerCoverageOptions Options; |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 179 | }; |
| 180 | |
| 181 | } // namespace |
| 182 | |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 183 | bool SanitizerCoverageModule::runOnModule(Module &M) { |
Alexey Samsonov | 3514f27 | 2015-05-07 01:00:31 +0000 | [diff] [blame] | 184 | if (Options.CoverageType == SanitizerCoverageOptions::SCK_None) |
| 185 | return false; |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 186 | C = &(M.getContext()); |
Kostya Serebryany | f4e35cc | 2015-03-21 01:29:36 +0000 | [diff] [blame] | 187 | DL = &M.getDataLayout(); |
Kostya Serebryany | fb7d8d9 | 2015-07-31 01:33:06 +0000 | [diff] [blame] | 188 | CurModule = &M; |
Kostya Serebryany | f4e35cc | 2015-03-21 01:29:36 +0000 | [diff] [blame] | 189 | IntptrTy = Type::getIntNTy(*C, DL->getPointerSizeInBits()); |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 190 | Type *VoidTy = Type::getVoidTy(*C); |
Kostya Serebryany | 4cadd4a | 2014-11-24 18:49:53 +0000 | [diff] [blame] | 191 | IRBuilder<> IRB(*C); |
Kostya Serebryany | 8859946 | 2015-02-20 00:30:44 +0000 | [diff] [blame] | 192 | Type *Int8PtrTy = PointerType::getUnqual(IRB.getInt8Ty()); |
Kostya Serebryany | 9fdeb37 | 2014-12-23 22:32:17 +0000 | [diff] [blame] | 193 | Type *Int32PtrTy = PointerType::getUnqual(IRB.getInt32Ty()); |
Kostya Serebryany | fb7d8d9 | 2015-07-31 01:33:06 +0000 | [diff] [blame] | 194 | Int64PtrTy = PointerType::getUnqual(IRB.getInt64Ty()); |
Kostya Serebryany | f4e35cc | 2015-03-21 01:29:36 +0000 | [diff] [blame] | 195 | Int64Ty = IRB.getInt64Ty(); |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 196 | |
Ismail Pazarbasi | 198d6d5 | 2015-04-06 21:09:08 +0000 | [diff] [blame] | 197 | SanCovFunction = checkSanitizerInterfaceFunction( |
Kostya Serebryany | 9fdeb37 | 2014-12-23 22:32:17 +0000 | [diff] [blame] | 198 | M.getOrInsertFunction(kSanCovName, VoidTy, Int32PtrTy, nullptr)); |
Ismail Pazarbasi | 198d6d5 | 2015-04-06 21:09:08 +0000 | [diff] [blame] | 199 | SanCovWithCheckFunction = checkSanitizerInterfaceFunction( |
Kostya Serebryany | 77cc729 | 2015-02-04 01:21:45 +0000 | [diff] [blame] | 200 | M.getOrInsertFunction(kSanCovWithCheckName, VoidTy, Int32PtrTy, nullptr)); |
Ismail Pazarbasi | 198d6d5 | 2015-04-06 21:09:08 +0000 | [diff] [blame] | 201 | SanCovIndirCallFunction = |
| 202 | checkSanitizerInterfaceFunction(M.getOrInsertFunction( |
| 203 | kSanCovIndirCallName, VoidTy, IntptrTy, IntptrTy, nullptr)); |
| 204 | SanCovTraceCmpFunction = |
| 205 | checkSanitizerInterfaceFunction(M.getOrInsertFunction( |
| 206 | kSanCovTraceCmp, VoidTy, Int64Ty, Int64Ty, Int64Ty, nullptr)); |
Kostya Serebryany | fb7d8d9 | 2015-07-31 01:33:06 +0000 | [diff] [blame] | 207 | SanCovTraceSwitchFunction = |
| 208 | checkSanitizerInterfaceFunction(M.getOrInsertFunction( |
| 209 | kSanCovTraceSwitch, VoidTy, Int64Ty, Int64PtrTy, nullptr)); |
Kostya Serebryany | f4e35cc | 2015-03-21 01:29:36 +0000 | [diff] [blame] | 210 | |
Kostya Serebryany | 7376294 | 2014-12-16 21:24:15 +0000 | [diff] [blame] | 211 | // We insert an empty inline asm after cov callbacks to avoid callback merge. |
| 212 | EmptyAsm = InlineAsm::get(FunctionType::get(IRB.getVoidTy(), false), |
| 213 | StringRef(""), StringRef(""), |
| 214 | /*hasSideEffects=*/true); |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 215 | |
Kostya Serebryany | a3c5347 | 2015-12-02 02:37:13 +0000 | [diff] [blame] | 216 | SanCovTraceEnter = checkSanitizerInterfaceFunction( |
| 217 | M.getOrInsertFunction(kSanCovTraceEnter, VoidTy, Int32PtrTy, nullptr)); |
| 218 | SanCovTraceBB = checkSanitizerInterfaceFunction( |
| 219 | M.getOrInsertFunction(kSanCovTraceBB, VoidTy, Int32PtrTy, nullptr)); |
Kostya Serebryany | cb45b12 | 2014-11-19 00:22:58 +0000 | [diff] [blame] | 220 | |
Kostya Serebryany | aa185bf | 2014-12-30 19:29:28 +0000 | [diff] [blame] | 221 | // At this point we create a dummy array of guards because we don't |
| 222 | // know how many elements we will need. |
| 223 | Type *Int32Ty = IRB.getInt32Ty(); |
Kostya Serebryany | be5e0ed | 2015-03-03 23:27:02 +0000 | [diff] [blame] | 224 | Type *Int8Ty = IRB.getInt8Ty(); |
| 225 | |
Kostya Serebryany | aa185bf | 2014-12-30 19:29:28 +0000 | [diff] [blame] | 226 | GuardArray = |
| 227 | new GlobalVariable(M, Int32Ty, false, GlobalValue::ExternalLinkage, |
| 228 | nullptr, "__sancov_gen_cov_tmp"); |
Alexey Samsonov | 3514f27 | 2015-05-07 01:00:31 +0000 | [diff] [blame] | 229 | if (Options.Use8bitCounters) |
Kostya Serebryany | be5e0ed | 2015-03-03 23:27:02 +0000 | [diff] [blame] | 230 | EightBitCounterArray = |
| 231 | new GlobalVariable(M, Int8Ty, false, GlobalVariable::ExternalLinkage, |
| 232 | nullptr, "__sancov_gen_cov_tmp"); |
Kostya Serebryany | aa185bf | 2014-12-30 19:29:28 +0000 | [diff] [blame] | 233 | |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 234 | for (auto &F : M) |
| 235 | runOnFunction(F); |
| 236 | |
Kostya Serebryany | 48a4023 | 2015-03-10 01:58:27 +0000 | [diff] [blame] | 237 | auto N = NumberOfInstrumentedBlocks(); |
| 238 | |
Kostya Serebryany | aa185bf | 2014-12-30 19:29:28 +0000 | [diff] [blame] | 239 | // Now we know how many elements we need. Create an array of guards |
| 240 | // with one extra element at the beginning for the size. |
Kostya Serebryany | 48a4023 | 2015-03-10 01:58:27 +0000 | [diff] [blame] | 241 | Type *Int32ArrayNTy = ArrayType::get(Int32Ty, N + 1); |
Kostya Serebryany | aa185bf | 2014-12-30 19:29:28 +0000 | [diff] [blame] | 242 | GlobalVariable *RealGuardArray = new GlobalVariable( |
| 243 | M, Int32ArrayNTy, false, GlobalValue::PrivateLinkage, |
| 244 | Constant::getNullValue(Int32ArrayNTy), "__sancov_gen_cov"); |
| 245 | |
Kostya Serebryany | be5e0ed | 2015-03-03 23:27:02 +0000 | [diff] [blame] | 246 | |
Kostya Serebryany | aa185bf | 2014-12-30 19:29:28 +0000 | [diff] [blame] | 247 | // Replace the dummy array with the real one. |
| 248 | GuardArray->replaceAllUsesWith( |
| 249 | IRB.CreatePointerCast(RealGuardArray, Int32PtrTy)); |
| 250 | GuardArray->eraseFromParent(); |
| 251 | |
Kostya Serebryany | be5e0ed | 2015-03-03 23:27:02 +0000 | [diff] [blame] | 252 | GlobalVariable *RealEightBitCounterArray; |
Alexey Samsonov | 3514f27 | 2015-05-07 01:00:31 +0000 | [diff] [blame] | 253 | if (Options.Use8bitCounters) { |
Kostya Serebryany | be5e0ed | 2015-03-03 23:27:02 +0000 | [diff] [blame] | 254 | // Make sure the array is 16-aligned. |
| 255 | static const int kCounterAlignment = 16; |
Rui Ueyama | da00f2f | 2016-01-14 21:06:47 +0000 | [diff] [blame] | 256 | Type *Int8ArrayNTy = ArrayType::get(Int8Ty, alignTo(N, kCounterAlignment)); |
Kostya Serebryany | be5e0ed | 2015-03-03 23:27:02 +0000 | [diff] [blame] | 257 | RealEightBitCounterArray = new GlobalVariable( |
| 258 | M, Int8ArrayNTy, false, GlobalValue::PrivateLinkage, |
| 259 | Constant::getNullValue(Int8ArrayNTy), "__sancov_gen_cov_counter"); |
| 260 | RealEightBitCounterArray->setAlignment(kCounterAlignment); |
| 261 | EightBitCounterArray->replaceAllUsesWith( |
| 262 | IRB.CreatePointerCast(RealEightBitCounterArray, Int8PtrTy)); |
| 263 | EightBitCounterArray->eraseFromParent(); |
| 264 | } |
| 265 | |
Kostya Serebryany | 8859946 | 2015-02-20 00:30:44 +0000 | [diff] [blame] | 266 | // Create variable for module (compilation unit) name |
| 267 | Constant *ModNameStrConst = |
| 268 | ConstantDataArray::getString(M.getContext(), M.getName(), true); |
| 269 | GlobalVariable *ModuleName = |
| 270 | new GlobalVariable(M, ModNameStrConst->getType(), true, |
| 271 | GlobalValue::PrivateLinkage, ModNameStrConst); |
| 272 | |
Ismail Pazarbasi | d02ce13 | 2015-05-10 13:45:05 +0000 | [diff] [blame] | 273 | Function *CtorFunc; |
| 274 | std::tie(CtorFunc, std::ignore) = createSanitizerCtorAndInitFunctions( |
| 275 | M, kSanCovModuleCtorName, kSanCovModuleInitName, |
| 276 | {Int32PtrTy, IntptrTy, Int8PtrTy, Int8PtrTy}, |
| 277 | {IRB.CreatePointerCast(RealGuardArray, Int32PtrTy), |
| 278 | ConstantInt::get(IntptrTy, N), |
| 279 | Options.Use8bitCounters |
| 280 | ? IRB.CreatePointerCast(RealEightBitCounterArray, Int8PtrTy) |
| 281 | : Constant::getNullValue(Int8PtrTy), |
| 282 | IRB.CreatePointerCast(ModuleName, Int8PtrTy)}); |
| 283 | |
| 284 | appendToGlobalCtors(M, CtorFunc, kSanCtorAndDtorPriority); |
| 285 | |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 286 | return true; |
| 287 | } |
| 288 | |
| 289 | bool SanitizerCoverageModule::runOnFunction(Function &F) { |
| 290 | if (F.empty()) return false; |
Kostya Serebryany | fea4fb4 | 2014-12-17 21:50:04 +0000 | [diff] [blame] | 291 | if (F.getName().find(".module_ctor") != std::string::npos) |
| 292 | return false; // Should not instrument sanitizer init functions. |
Reid Kleckner | df52337 | 2015-09-03 20:18:29 +0000 | [diff] [blame] | 293 | // Don't instrument functions using SEH for now. Splitting basic blocks like |
| 294 | // we do for coverage breaks WinEHPrepare. |
| 295 | // FIXME: Remove this when SEH no longer uses landingpad pattern matching. |
| 296 | if (F.hasPersonalityFn() && |
| 297 | isAsynchronousEHPersonality(classifyEHPersonality(F.getPersonalityFn()))) |
| 298 | return false; |
Alexey Samsonov | 3514f27 | 2015-05-07 01:00:31 +0000 | [diff] [blame] | 299 | if (Options.CoverageType >= SanitizerCoverageOptions::SCK_Edge) |
Chandler Carruth | 37df2cf | 2015-01-19 12:09:11 +0000 | [diff] [blame] | 300 | SplitAllCriticalEdges(F); |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 301 | SmallVector<Instruction*, 8> IndirCalls; |
| 302 | SmallVector<BasicBlock*, 16> AllBlocks; |
Kostya Serebryany | f4e35cc | 2015-03-21 01:29:36 +0000 | [diff] [blame] | 303 | SmallVector<Instruction*, 8> CmpTraceTargets; |
Kostya Serebryany | fb7d8d9 | 2015-07-31 01:33:06 +0000 | [diff] [blame] | 304 | SmallVector<Instruction*, 8> SwitchTraceTargets; |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 305 | for (auto &BB : F) { |
| 306 | AllBlocks.push_back(&BB); |
Kostya Serebryany | f4e35cc | 2015-03-21 01:29:36 +0000 | [diff] [blame] | 307 | for (auto &Inst : BB) { |
Alexey Samsonov | 3514f27 | 2015-05-07 01:00:31 +0000 | [diff] [blame] | 308 | if (Options.IndirectCalls) { |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 309 | CallSite CS(&Inst); |
| 310 | if (CS && !CS.getCalledFunction()) |
| 311 | IndirCalls.push_back(&Inst); |
| 312 | } |
Kostya Serebryany | fb7d8d9 | 2015-07-31 01:33:06 +0000 | [diff] [blame] | 313 | if (Options.TraceCmp) { |
| 314 | if (isa<ICmpInst>(&Inst)) |
| 315 | CmpTraceTargets.push_back(&Inst); |
| 316 | if (isa<SwitchInst>(&Inst)) |
| 317 | SwitchTraceTargets.push_back(&Inst); |
| 318 | } |
Kostya Serebryany | f4e35cc | 2015-03-21 01:29:36 +0000 | [diff] [blame] | 319 | } |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 320 | } |
Kostya Serebryany | f4e35cc | 2015-03-21 01:29:36 +0000 | [diff] [blame] | 321 | InjectCoverage(F, AllBlocks); |
| 322 | InjectCoverageForIndirectCalls(F, IndirCalls); |
| 323 | InjectTraceForCmp(F, CmpTraceTargets); |
Kostya Serebryany | fb7d8d9 | 2015-07-31 01:33:06 +0000 | [diff] [blame] | 324 | InjectTraceForSwitch(F, SwitchTraceTargets); |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 325 | return true; |
| 326 | } |
| 327 | |
Kostya Serebryany | f4e35cc | 2015-03-21 01:29:36 +0000 | [diff] [blame] | 328 | bool SanitizerCoverageModule::InjectCoverage(Function &F, |
| 329 | ArrayRef<BasicBlock *> AllBlocks) { |
Alexey Samsonov | 3514f27 | 2015-05-07 01:00:31 +0000 | [diff] [blame] | 330 | switch (Options.CoverageType) { |
| 331 | case SanitizerCoverageOptions::SCK_None: |
| 332 | return false; |
| 333 | case SanitizerCoverageOptions::SCK_Function: |
Kostya Serebryany | 77cc729 | 2015-02-04 01:21:45 +0000 | [diff] [blame] | 334 | InjectCoverageAtBlock(F, F.getEntryBlock(), false); |
Alexey Samsonov | 3514f27 | 2015-05-07 01:00:31 +0000 | [diff] [blame] | 335 | return true; |
| 336 | default: { |
| 337 | bool UseCalls = ClCoverageBlockThreshold < AllBlocks.size(); |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 338 | for (auto BB : AllBlocks) |
Alexey Samsonov | 3514f27 | 2015-05-07 01:00:31 +0000 | [diff] [blame] | 339 | InjectCoverageAtBlock(F, *BB, UseCalls); |
| 340 | return true; |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 341 | } |
Alexey Samsonov | 3514f27 | 2015-05-07 01:00:31 +0000 | [diff] [blame] | 342 | } |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | // On every indirect call we call a run-time function |
| 346 | // __sanitizer_cov_indir_call* with two parameters: |
| 347 | // - callee address, |
| 348 | // - global cache array that contains kCacheSize pointers (zero-initialized). |
| 349 | // The cache is used to speed up recording the caller-callee pairs. |
| 350 | // The address of the caller is passed implicitly via caller PC. |
| 351 | // kCacheSize is encoded in the name of the run-time function. |
| 352 | void SanitizerCoverageModule::InjectCoverageForIndirectCalls( |
| 353 | Function &F, ArrayRef<Instruction *> IndirCalls) { |
| 354 | if (IndirCalls.empty()) return; |
| 355 | const int kCacheSize = 16; |
| 356 | const int kCacheAlignment = 64; // Align for better performance. |
| 357 | Type *Ty = ArrayType::get(IntptrTy, kCacheSize); |
| 358 | for (auto I : IndirCalls) { |
| 359 | IRBuilder<> IRB(I); |
| 360 | CallSite CS(I); |
| 361 | Value *Callee = CS.getCalledValue(); |
Benjamin Kramer | 619c4e5 | 2015-04-10 11:24:51 +0000 | [diff] [blame] | 362 | if (isa<InlineAsm>(Callee)) continue; |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 363 | GlobalVariable *CalleeCache = new GlobalVariable( |
| 364 | *F.getParent(), Ty, false, GlobalValue::PrivateLinkage, |
| 365 | Constant::getNullValue(Ty), "__sancov_gen_callee_cache"); |
| 366 | CalleeCache->setAlignment(kCacheAlignment); |
David Blaikie | ff6409d | 2015-05-18 22:13:54 +0000 | [diff] [blame] | 367 | IRB.CreateCall(SanCovIndirCallFunction, |
| 368 | {IRB.CreatePointerCast(Callee, IntptrTy), |
| 369 | IRB.CreatePointerCast(CalleeCache, IntptrTy)}); |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 370 | } |
| 371 | } |
| 372 | |
Kostya Serebryany | fb7d8d9 | 2015-07-31 01:33:06 +0000 | [diff] [blame] | 373 | // For every switch statement we insert a call: |
| 374 | // __sanitizer_cov_trace_switch(CondValue, |
| 375 | // {NumCases, ValueSizeInBits, Case0Value, Case1Value, Case2Value, ... }) |
| 376 | |
| 377 | void SanitizerCoverageModule::InjectTraceForSwitch( |
| 378 | Function &F, ArrayRef<Instruction *> SwitchTraceTargets) { |
| 379 | for (auto I : SwitchTraceTargets) { |
| 380 | if (SwitchInst *SI = dyn_cast<SwitchInst>(I)) { |
| 381 | IRBuilder<> IRB(I); |
| 382 | SmallVector<Constant *, 16> Initializers; |
| 383 | Value *Cond = SI->getCondition(); |
Kostya Serebryany | 2569118 | 2015-08-11 00:24:39 +0000 | [diff] [blame] | 384 | if (Cond->getType()->getScalarSizeInBits() > |
| 385 | Int64Ty->getScalarSizeInBits()) |
| 386 | continue; |
Kostya Serebryany | fb7d8d9 | 2015-07-31 01:33:06 +0000 | [diff] [blame] | 387 | Initializers.push_back(ConstantInt::get(Int64Ty, SI->getNumCases())); |
| 388 | Initializers.push_back( |
| 389 | ConstantInt::get(Int64Ty, Cond->getType()->getScalarSizeInBits())); |
| 390 | if (Cond->getType()->getScalarSizeInBits() < |
| 391 | Int64Ty->getScalarSizeInBits()) |
| 392 | Cond = IRB.CreateIntCast(Cond, Int64Ty, false); |
| 393 | for (auto It: SI->cases()) { |
| 394 | Constant *C = It.getCaseValue(); |
| 395 | if (C->getType()->getScalarSizeInBits() < |
| 396 | Int64Ty->getScalarSizeInBits()) |
| 397 | C = ConstantExpr::getCast(CastInst::ZExt, It.getCaseValue(), Int64Ty); |
| 398 | Initializers.push_back(C); |
| 399 | } |
| 400 | ArrayType *ArrayOfInt64Ty = ArrayType::get(Int64Ty, Initializers.size()); |
| 401 | GlobalVariable *GV = new GlobalVariable( |
| 402 | *CurModule, ArrayOfInt64Ty, false, GlobalVariable::InternalLinkage, |
| 403 | ConstantArray::get(ArrayOfInt64Ty, Initializers), |
| 404 | "__sancov_gen_cov_switch_values"); |
| 405 | IRB.CreateCall(SanCovTraceSwitchFunction, |
| 406 | {Cond, IRB.CreatePointerCast(GV, Int64PtrTy)}); |
| 407 | } |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | |
Kostya Serebryany | f4e35cc | 2015-03-21 01:29:36 +0000 | [diff] [blame] | 412 | void SanitizerCoverageModule::InjectTraceForCmp( |
| 413 | Function &F, ArrayRef<Instruction *> CmpTraceTargets) { |
Kostya Serebryany | f4e35cc | 2015-03-21 01:29:36 +0000 | [diff] [blame] | 414 | for (auto I : CmpTraceTargets) { |
| 415 | if (ICmpInst *ICMP = dyn_cast<ICmpInst>(I)) { |
| 416 | IRBuilder<> IRB(ICMP); |
| 417 | Value *A0 = ICMP->getOperand(0); |
| 418 | Value *A1 = ICMP->getOperand(1); |
| 419 | if (!A0->getType()->isIntegerTy()) continue; |
| 420 | uint64_t TypeSize = DL->getTypeStoreSizeInBits(A0->getType()); |
Alexey Samsonov | 0a648a4 | 2015-05-06 21:35:25 +0000 | [diff] [blame] | 421 | // __sanitizer_cov_trace_cmp((type_size << 32) | predicate, A0, A1); |
David Blaikie | ff6409d | 2015-05-18 22:13:54 +0000 | [diff] [blame] | 422 | IRB.CreateCall( |
Kostya Serebryany | f4e35cc | 2015-03-21 01:29:36 +0000 | [diff] [blame] | 423 | SanCovTraceCmpFunction, |
David Blaikie | ff6409d | 2015-05-18 22:13:54 +0000 | [diff] [blame] | 424 | {ConstantInt::get(Int64Ty, (TypeSize << 32) | ICMP->getPredicate()), |
| 425 | IRB.CreateIntCast(A0, Int64Ty, true), |
| 426 | IRB.CreateIntCast(A1, Int64Ty, true)}); |
Kostya Serebryany | f4e35cc | 2015-03-21 01:29:36 +0000 | [diff] [blame] | 427 | } |
| 428 | } |
| 429 | } |
| 430 | |
Alexey Samsonov | 0a648a4 | 2015-05-06 21:35:25 +0000 | [diff] [blame] | 431 | void SanitizerCoverageModule::SetNoSanitizeMetadata(Instruction *I) { |
Kostya Serebryany | 83ce877 | 2015-03-05 01:20:05 +0000 | [diff] [blame] | 432 | I->setMetadata( |
Sanjay Patel | af674fb | 2015-12-14 17:24:23 +0000 | [diff] [blame] | 433 | I->getModule()->getMDKindID("nosanitize"), MDNode::get(*C, None)); |
Kostya Serebryany | 83ce877 | 2015-03-05 01:20:05 +0000 | [diff] [blame] | 434 | } |
| 435 | |
Kostya Serebryany | 77cc729 | 2015-02-04 01:21:45 +0000 | [diff] [blame] | 436 | void SanitizerCoverageModule::InjectCoverageAtBlock(Function &F, BasicBlock &BB, |
| 437 | bool UseCalls) { |
Alexey Samsonov | 342b1e8 | 2015-06-30 23:11:45 +0000 | [diff] [blame] | 438 | // Don't insert coverage for unreachable blocks: we will never call |
| 439 | // __sanitizer_cov() for them, so counting them in |
| 440 | // NumberOfInstrumentedBlocks() might complicate calculation of code coverage |
| 441 | // percentage. Also, unreachable instructions frequently have no debug |
| 442 | // locations. |
| 443 | if (isa<UnreachableInst>(BB.getTerminator())) |
| 444 | return; |
Justin Bogner | 7ae63aa | 2015-08-14 17:03:45 +0000 | [diff] [blame] | 445 | BasicBlock::iterator IP = BB.getFirstInsertionPt(); |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 446 | |
Kostya Serebryany | d421db0 | 2015-01-03 00:54:43 +0000 | [diff] [blame] | 447 | bool IsEntryBB = &BB == &F.getEntryBlock(); |
Alexey Samsonov | 201733b | 2015-06-12 01:48:47 +0000 | [diff] [blame] | 448 | DebugLoc EntryLoc; |
| 449 | if (IsEntryBB) { |
| 450 | if (auto SP = getDISubprogram(&F)) |
| 451 | EntryLoc = DebugLoc::get(SP->getScopeLine(), 0, SP); |
Reid Kleckner | a57d015 | 2015-08-14 16:45:42 +0000 | [diff] [blame] | 452 | // Keep static allocas and llvm.localescape calls in the entry block. Even |
| 453 | // if we aren't splitting the block, it's nice for allocas to be before |
| 454 | // calls. |
| 455 | IP = PrepareToSplitEntryBlock(BB, IP); |
Alexey Samsonov | 201733b | 2015-06-12 01:48:47 +0000 | [diff] [blame] | 456 | } else { |
| 457 | EntryLoc = IP->getDebugLoc(); |
| 458 | } |
| 459 | |
Duncan P. N. Exon Smith | e82c286 | 2015-10-13 17:39:10 +0000 | [diff] [blame] | 460 | IRBuilder<> IRB(&*IP); |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 461 | IRB.SetCurrentDebugLocation(EntryLoc); |
Kostya Serebryany | aa185bf | 2014-12-30 19:29:28 +0000 | [diff] [blame] | 462 | Value *GuardP = IRB.CreateAdd( |
| 463 | IRB.CreatePointerCast(GuardArray, IntptrTy), |
Kostya Serebryany | 48a4023 | 2015-03-10 01:58:27 +0000 | [diff] [blame] | 464 | ConstantInt::get(IntptrTy, (1 + NumberOfInstrumentedBlocks()) * 4)); |
Kostya Serebryany | aa185bf | 2014-12-30 19:29:28 +0000 | [diff] [blame] | 465 | Type *Int32PtrTy = PointerType::getUnqual(IRB.getInt32Ty()); |
| 466 | GuardP = IRB.CreateIntToPtr(GuardP, Int32PtrTy); |
Kostya Serebryany | a3c5347 | 2015-12-02 02:37:13 +0000 | [diff] [blame] | 467 | if (Options.TraceBB) { |
| 468 | IRB.CreateCall(IsEntryBB ? SanCovTraceEnter : SanCovTraceBB, GuardP); |
| 469 | } else if (UseCalls) { |
Kostya Serebryany | 77cc729 | 2015-02-04 01:21:45 +0000 | [diff] [blame] | 470 | IRB.CreateCall(SanCovWithCheckFunction, GuardP); |
| 471 | } else { |
| 472 | LoadInst *Load = IRB.CreateLoad(GuardP); |
| 473 | Load->setAtomic(Monotonic); |
| 474 | Load->setAlignment(4); |
Alexey Samsonov | 0a648a4 | 2015-05-06 21:35:25 +0000 | [diff] [blame] | 475 | SetNoSanitizeMetadata(Load); |
Kostya Serebryany | 77cc729 | 2015-02-04 01:21:45 +0000 | [diff] [blame] | 476 | Value *Cmp = IRB.CreateICmpSGE(Constant::getNullValue(Load->getType()), Load); |
| 477 | Instruction *Ins = SplitBlockAndInsertIfThen( |
Duncan P. N. Exon Smith | e82c286 | 2015-10-13 17:39:10 +0000 | [diff] [blame] | 478 | Cmp, &*IP, false, MDBuilder(*C).createBranchWeights(1, 100000)); |
Kostya Serebryany | 77cc729 | 2015-02-04 01:21:45 +0000 | [diff] [blame] | 479 | IRB.SetInsertPoint(Ins); |
| 480 | IRB.SetCurrentDebugLocation(EntryLoc); |
| 481 | // __sanitizer_cov gets the PC of the instruction using GET_CALLER_PC. |
| 482 | IRB.CreateCall(SanCovFunction, GuardP); |
David Blaikie | ff6409d | 2015-05-18 22:13:54 +0000 | [diff] [blame] | 483 | IRB.CreateCall(EmptyAsm, {}); // Avoids callback merge. |
Kostya Serebryany | 77cc729 | 2015-02-04 01:21:45 +0000 | [diff] [blame] | 484 | } |
Kostya Serebryany | d421db0 | 2015-01-03 00:54:43 +0000 | [diff] [blame] | 485 | |
Alexey Samsonov | 3514f27 | 2015-05-07 01:00:31 +0000 | [diff] [blame] | 486 | if (Options.Use8bitCounters) { |
Duncan P. N. Exon Smith | e82c286 | 2015-10-13 17:39:10 +0000 | [diff] [blame] | 487 | IRB.SetInsertPoint(&*IP); |
Kostya Serebryany | be5e0ed | 2015-03-03 23:27:02 +0000 | [diff] [blame] | 488 | Value *P = IRB.CreateAdd( |
| 489 | IRB.CreatePointerCast(EightBitCounterArray, IntptrTy), |
Kostya Serebryany | 48a4023 | 2015-03-10 01:58:27 +0000 | [diff] [blame] | 490 | ConstantInt::get(IntptrTy, NumberOfInstrumentedBlocks() - 1)); |
Kostya Serebryany | be5e0ed | 2015-03-03 23:27:02 +0000 | [diff] [blame] | 491 | P = IRB.CreateIntToPtr(P, IRB.getInt8PtrTy()); |
Kostya Serebryany | 83ce877 | 2015-03-05 01:20:05 +0000 | [diff] [blame] | 492 | LoadInst *LI = IRB.CreateLoad(P); |
Kostya Serebryany | be5e0ed | 2015-03-03 23:27:02 +0000 | [diff] [blame] | 493 | Value *Inc = IRB.CreateAdd(LI, ConstantInt::get(IRB.getInt8Ty(), 1)); |
Kostya Serebryany | 83ce877 | 2015-03-05 01:20:05 +0000 | [diff] [blame] | 494 | StoreInst *SI = IRB.CreateStore(Inc, P); |
Alexey Samsonov | 0a648a4 | 2015-05-06 21:35:25 +0000 | [diff] [blame] | 495 | SetNoSanitizeMetadata(LI); |
| 496 | SetNoSanitizeMetadata(SI); |
Kostya Serebryany | be5e0ed | 2015-03-03 23:27:02 +0000 | [diff] [blame] | 497 | } |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | char SanitizerCoverageModule::ID = 0; |
| 501 | INITIALIZE_PASS(SanitizerCoverageModule, "sancov", |
| 502 | "SanitizerCoverage: TODO." |
| 503 | "ModulePass", false, false) |
Alexey Samsonov | 3514f27 | 2015-05-07 01:00:31 +0000 | [diff] [blame] | 504 | ModulePass *llvm::createSanitizerCoverageModulePass( |
| 505 | const SanitizerCoverageOptions &Options) { |
| 506 | return new SanitizerCoverageModule(Options); |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 507 | } |