LLVM: lib/Transforms/Instrumentation/SanitizerCoverage.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
39
40using namespace llvm;
41
42#define DEBUG_TYPE "sancov"
43
54const char SanCovLoad1[] = "__sanitizer_cov_load1";
55const char SanCovLoad2[] = "__sanitizer_cov_load2";
56const char SanCovLoad4[] = "__sanitizer_cov_load4";
57const char SanCovLoad8[] = "__sanitizer_cov_load8";
69 "sancov.module_ctor_trace_pc_guard";
71 "sancov.module_ctor_8bit_counters";
74
81
88
92
94 "sanitizer-coverage-level",
95 cl::desc("Sanitizer Coverage. 0: none, 1: entry block, 2: all blocks, "
96 "3: all blocks and critical edges"),
98
101
103 cl::desc("pc tracing with a guard"),
105
106
107
108
109
110
111
113 cl::desc("create a static PC table"),
115
118 cl::desc("increments 8-bit counter for every edge"),
120
123 cl::desc("do not emit module ctors for global counters"),
125
128 cl::desc("sets a boolean flag for every edge"),
130
133 cl::desc("Tracing of CMP and similar instructions"),
135
137 cl::desc("Tracing of DIV instructions"),
139
141 cl::desc("Tracing of load instructions"),
143
145 cl::desc("Tracing of store instructions"),
147
149 cl::desc("Tracing of GEP instructions"),
151
154 cl::desc("Reduce the number of instrumented blocks"),
156
158 cl::desc("max stack depth tracing"),
160
162 "sanitizer-coverage-stack-depth-callback-min",
163 cl::desc("max stack depth tracing should use callback and only when "
164 "stack depth more than specified"),
166
170
172 "sanitizer-coverage-gated-trace-callbacks",
173 cl::desc("Gate the invocation of the tracing callbacks on a global variable"
174 ". Currently only supported for trace-pc-guard and trace-cmp."),
176
177namespace {
178
181 switch (LegacyCoverageLevel) {
182 case 0:
184 break;
185 case 1:
187 break;
188 case 2:
190 break;
191 case 3:
193 break;
194 case 4:
197 break;
198 }
199 return Res;
200}
201
203
217 Options.StackDepthCallbackMin = std::max(Options.StackDepthCallbackMin,
223 .Inline8bitCounters &&
.StackDepth &&
225 Options.TracePCGuard = true;
228}
229
230class ModuleSanitizerCoverage {
231public:
232 using DomTreeCallback = function_ref<const DominatorTree &(Function &F)>;
233 using PostDomTreeCallback =
234 function_ref<const PostDominatorTree &(Function &F)>;
235
236 ModuleSanitizerCoverage(Module &M, DomTreeCallback DTCallback,
237 PostDomTreeCallback PDTCallback,
238 const SanitizerCoverageOptions &Options,
239 const SpecialCaseList *Allowlist,
240 const SpecialCaseList *Blocklist)
241 : M(M), DTCallback(DTCallback), PDTCallback(PDTCallback),
242 Options(Options), Allowlist(Allowlist), Blocklist(Blocklist) {}
243
244 bool instrumentModule();
245
246private:
247 void createFunctionControlFlow(Function &F);
248 void instrumentFunction(Function &F);
249 void InjectCoverageForIndirectCalls(Function &F,
252 Value *&FunctionGateCmp);
253 void InjectTraceForDiv(Function &F,
255 void InjectTraceForGep(Function &F,
259 void InjectTraceForSwitch(Function &F,
261 Value *&FunctionGateCmp);
263 Value *&FunctionGateCmp, bool IsLeafFunc);
264 GlobalVariable *CreateFunctionLocalArrayInSection(size_t NumElements,
266 const char *Section);
269 Instruction *CreateGateBranch(Function &F, Value *&FunctionGateCmp,
270 Instruction *I);
272 void InjectCoverageAtBlock(Function &F, BasicBlock &BB, size_t Idx,
273 Value *&FunctionGateCmp, bool IsLeafFunc);
274 Function *CreateInitCallsForSections(Module &M, const char *CtorName,
275 const char *InitFunctionName, Type *Ty,
276 const char *Section);
277 std::pair<Value *, Value *> CreateSecStartEnd(Module &M, const char *Section,
279
280 std::string getSectionName(const std::string &Section) const;
281 std::string getSectionStart(const std::string &Section) const;
282 std::string getSectionEnd(const std::string &Section) const;
283
285 DomTreeCallback DTCallback;
286 PostDomTreeCallback PDTCallback;
287
288 FunctionCallee SanCovStackDepthCallback;
289 FunctionCallee SanCovTracePCIndir;
290 FunctionCallee SanCovTracePC, SanCovTracePCGuard;
291 std::array<FunctionCallee, 4> SanCovTraceCmpFunction;
292 std::array<FunctionCallee, 4> SanCovTraceConstCmpFunction;
293 std::array<FunctionCallee, 5> SanCovLoadFunction;
294 std::array<FunctionCallee, 5> SanCovStoreFunction;
295 std::array<FunctionCallee, 2> SanCovTraceDivFunction;
296 FunctionCallee SanCovTraceGepFunction;
297 FunctionCallee SanCovTraceSwitchFunction;
298 GlobalVariable *SanCovLowestStack;
299 GlobalVariable *SanCovCallbackGate;
300 Type *PtrTy, *IntptrTy, *Int64Ty, *Int32Ty, *Int16Ty, *Int8Ty, *Int1Ty;
302 Triple TargetTriple;
303 LLVMContext *C;
304 const DataLayout *DL;
305
306 GlobalVariable *FunctionGuardArray;
307 GlobalVariable *Function8bitCounterArray;
308 GlobalVariable *FunctionBoolArray;
309 GlobalVariable *FunctionPCsArray;
310 GlobalVariable *FunctionCFsArray;
313
314 SanitizerCoverageOptions Options;
315
316 const SpecialCaseList *Allowlist;
317 const SpecialCaseList *Blocklist;
318};
319}
320
323 const std::vectorstd::string &AllowlistFiles,
324 const std::vectorstd::string &BlocklistFiles)
325 : Options(std::move(Options)),
326 VFS(VFS ? std::move(VFS) : vfs::getRealFileSystem()) {
327 if (AllowlistFiles.size() > 0)
329 if (BlocklistFiles.size() > 0)
331}
332
338 };
341 };
342 ModuleSanitizerCoverage ModuleSancov(M, DTCallback, PDTCallback,
343 OverrideFromCL(Options), Allowlist.get(),
344 Blocklist.get());
345 if (!ModuleSancov.instrumentModule())
347
349
350
351
353 return PA;
354}
355
356std::pair<Value *, Value *>
357ModuleSanitizerCoverage::CreateSecStartEnd(Module &M, const char *Section,
359
360
361
362
367 getSectionStart(Section));
370 getSectionEnd(Section));
373 if (!TargetTriple.isOSBinFormatCOFF())
374 return std::make_pair(SecStart, SecEnd);
375
376
377
378 auto GEP =
379 IRB.CreatePtrAdd(SecStart, ConstantInt::get(IntptrTy, sizeof(uint64_t)));
380 return std::make_pair(GEP, SecEnd);
381}
382
383Function *ModuleSanitizerCoverage::CreateInitCallsForSections(
384 Module &M, const char *CtorName, const char *InitFunctionName, Type *Ty,
385 const char *Section) {
387 return nullptr;
388 auto SecStartEnd = CreateSecStartEnd(M, Section, Ty);
389 auto SecStart = SecStartEnd.first;
390 auto SecEnd = SecStartEnd.second;
393 M, CtorName, InitFunctionName, {PtrTy, PtrTy}, {SecStart, SecEnd});
395
396 if (TargetTriple.supportsCOMDAT()) {
397
398 CtorFunc->setComdat(M.getOrInsertComdat(CtorName));
400 } else {
402 }
403
404 if (TargetTriple.isOSBinFormatCOFF()) {
405
406
407
408
409
410
412 }
413 return CtorFunc;
414}
415
416bool ModuleSanitizerCoverage::instrumentModule() {
418 return false;
419 if (Allowlist &&
420 !Allowlist->inSection("coverage", "src", M.getSourceFileName()))
421 return false;
422 if (Blocklist &&
423 Blocklist->inSection("coverage", "src", M.getSourceFileName()))
424 return false;
427 CurModule = &M;
428 TargetTriple = M.getTargetTriple();
429 FunctionGuardArray = nullptr;
430 Function8bitCounterArray = nullptr;
431 FunctionBoolArray = nullptr;
432 FunctionPCsArray = nullptr;
433 FunctionCFsArray = nullptr;
438 Int64Ty = IRB.getInt64Ty();
439 Int32Ty = IRB.getInt32Ty();
440 Int16Ty = IRB.getInt16Ty();
441 Int8Ty = IRB.getInt8Ty();
442 Int1Ty = IRB.getInt1Ty();
443
444 SanCovTracePCIndir =
446
447
448 AttributeList SanCovTraceCmpZeroExtAL;
449 SanCovTraceCmpZeroExtAL =
450 SanCovTraceCmpZeroExtAL.addParamAttribute(*C, 0, Attribute::ZExt);
451 SanCovTraceCmpZeroExtAL =
452 SanCovTraceCmpZeroExtAL.addParamAttribute(*C, 1, Attribute::ZExt);
453
454 SanCovTraceCmpFunction[0] =
455 M.getOrInsertFunction(SanCovTraceCmp1, SanCovTraceCmpZeroExtAL, VoidTy,
456 IRB.getInt8Ty(), IRB.getInt8Ty());
457 SanCovTraceCmpFunction[1] =
458 M.getOrInsertFunction(SanCovTraceCmp2, SanCovTraceCmpZeroExtAL, VoidTy,
459 IRB.getInt16Ty(), IRB.getInt16Ty());
460 SanCovTraceCmpFunction[2] =
461 M.getOrInsertFunction(SanCovTraceCmp4, SanCovTraceCmpZeroExtAL, VoidTy,
462 IRB.getInt32Ty(), IRB.getInt32Ty());
463 SanCovTraceCmpFunction[3] =
464 M.getOrInsertFunction(SanCovTraceCmp8, VoidTy, Int64Ty, Int64Ty);
465
466 SanCovTraceConstCmpFunction[0] = M.getOrInsertFunction(
468 SanCovTraceConstCmpFunction[1] = M.getOrInsertFunction(
470 SanCovTraceConstCmpFunction[2] = M.getOrInsertFunction(
472 SanCovTraceConstCmpFunction[3] =
474
475
476 SanCovLoadFunction[0] = M.getOrInsertFunction(SanCovLoad1, VoidTy, PtrTy);
477 SanCovLoadFunction[1] = M.getOrInsertFunction(SanCovLoad2, VoidTy, PtrTy);
478 SanCovLoadFunction[2] = M.getOrInsertFunction(SanCovLoad4, VoidTy, PtrTy);
479 SanCovLoadFunction[3] = M.getOrInsertFunction(SanCovLoad8, VoidTy, PtrTy);
480 SanCovLoadFunction[4] = M.getOrInsertFunction(SanCovLoad16, VoidTy, PtrTy);
481
482 SanCovStoreFunction[0] = M.getOrInsertFunction(SanCovStore1, VoidTy, PtrTy);
483 SanCovStoreFunction[1] = M.getOrInsertFunction(SanCovStore2, VoidTy, PtrTy);
484 SanCovStoreFunction[2] = M.getOrInsertFunction(SanCovStore4, VoidTy, PtrTy);
485 SanCovStoreFunction[3] = M.getOrInsertFunction(SanCovStore8, VoidTy, PtrTy);
486 SanCovStoreFunction[4] = M.getOrInsertFunction(SanCovStore16, VoidTy, PtrTy);
487
488 {
489 AttributeList AL;
490 AL = AL.addParamAttribute(*C, 0, Attribute::ZExt);
491 SanCovTraceDivFunction[0] =
492 M.getOrInsertFunction(SanCovTraceDiv4, AL, VoidTy, IRB.getInt32Ty());
493 }
494 SanCovTraceDivFunction[1] =
496 SanCovTraceGepFunction =
498 SanCovTraceSwitchFunction =
500
502 if (SanCovLowestStack->getValueType() != IntptrTy) {
504 "' should not be declared by the user");
505 return true;
506 }
507 SanCovLowestStack->setThreadLocalMode(
509 if (Options.StackDepth && !SanCovLowestStack->isDeclaration())
511
512 if (Options.GatedCallbacks) {
515 "' is only supported with trace-pc-guard or trace-cmp");
516 return true;
517 }
518
521 SanCovCallbackGate->setSection(
527 }
528
530 SanCovTracePCGuard =
532
533 SanCovStackDepthCallback =
535
536 for (auto &F : M)
537 instrumentFunction(F);
538
540
541 if (FunctionGuardArray)
545 if (Function8bitCounterArray)
549 if (FunctionBoolArray) {
553 }
554 if (Ctor && Options.PCTable) {
559 IRBCtor.CreateCall(InitFunction, {SecStartEnd.first, SecStartEnd.second});
560 }
561
562 if (Ctor && Options.CollectControlFlow) {
567 IRBCtor.CreateCall(InitFunction, {SecStartEnd.first, SecStartEnd.second});
568 }
569
572 return true;
573}
574
575
578 return false;
579
582 });
583}
584
585
589 return false;
590
593 });
594}
595
600
601
602
603
604
606 return false;
607
608
609
611 return false;
612
613 if (Options.NoPrune || &F.getEntryBlock() == BB)
614 return true;
615
617 &F.getEntryBlock() != BB)
618 return false;
619
620
621
624}
625
626
627
628
629
633 return true;
636 return true;
637 return false;
638}
639
640
641
642
643
644
648 if (CMP->hasOneUse())
652 return false;
653 return true;
654}
655
656void ModuleSanitizerCoverage::instrumentFunction(Function &F) {
657 if (F.empty())
658 return;
659 if (F.getName().contains(".module_ctor"))
660 return;
661 if (F.getName().starts_with("__sanitizer_"))
662 return;
663
665 return;
666
667
668 if (F.getName() == "__local_stdio_printf_options" ||
669 F.getName() == "__local_stdio_scanf_options")
670 return;
672 return;
673
674
675
676 if (F.hasPersonalityFn() &&
678 return;
679 if (Allowlist && !Allowlist->inSection("coverage", "fun", F.getName()))
680 return;
681 if (Blocklist && Blocklist->inSection("coverage", "fun", F.getName()))
682 return;
683
684 if (F.hasFnAttribute(Attribute::Naked))
685 return;
686 if (F.hasFnAttribute(Attribute::NoSanitizeCoverage))
687 return;
688 if (F.hasFnAttribute(Attribute::DisableSanitizerInstrumentation))
689 return;
693 }
702
705 bool IsLeafFunc = true;
706
707 for (auto &BB : F) {
709 BlocksToInstrument.push_back(&BB);
710 for (auto &Inst : BB) {
711 if (Options.IndirectCalls) {
715 }
719 CmpTraceTargets.push_back(&Inst);
721 SwitchTraceTargets.push_back(&Inst);
722 }
725 if (BO->getOpcode() == Instruction::SDiv ||
726 BO->getOpcode() == Instruction::UDiv)
740 IsLeafFunc = false;
741 }
742 }
743
744 if (Options.CollectControlFlow)
745 createFunctionControlFlow(F);
746
747 Value *FunctionGateCmp = nullptr;
748 InjectCoverage(F, BlocksToInstrument, FunctionGateCmp, IsLeafFunc);
749 InjectCoverageForIndirectCalls(F, IndirCalls);
750 InjectTraceForCmp(F, CmpTraceTargets, FunctionGateCmp);
751 InjectTraceForSwitch(F, SwitchTraceTargets, FunctionGateCmp);
752 InjectTraceForDiv(F, DivTraceTargets);
753 InjectTraceForGep(F, GepTraceTargets);
754 InjectTraceForLoadsAndStores(F, Loads, Stores);
755}
756
757GlobalVariable *ModuleSanitizerCoverage::CreateFunctionLocalArrayInSection(
758 size_t NumElements, Function &F, Type *Ty, const char *Section) {
763
764 if (TargetTriple.supportsCOMDAT() &&
765 (F.hasComdat() || TargetTriple.isOSBinFormatELF() || .isInterposable()))
769 Array->setAlignment(Align(DL->getTypeStoreSize(Ty).getFixedValue()));
770
771
772
773
774
775
776
777
778
779
780 if (Array->hasComdat())
781 GlobalsToAppendToCompilerUsed.push_back(Array);
782 else
783 GlobalsToAppendToUsed.push_back(Array);
784
786}
787
789ModuleSanitizerCoverage::CreatePCArray(Function &F,
791 size_t N = AllBlocks.size();
794 IRBuilder<> IRB(&*F.getEntryBlock().getFirstInsertionPt());
795 for (size_t i = 0; i < N; i++) {
796 if (&F.getEntryBlock() == AllBlocks[i]) {
799 (Constant *)IRB.CreateIntToPtr(ConstantInt::get(IntptrTy, 1), PtrTy));
800 } else {
804 }
805 }
806 auto *PCArray =
808 PCArray->setInitializer(
810 PCArray->setConstant(true);
811
812 return PCArray;
813}
814
815void ModuleSanitizerCoverage::CreateFunctionLocalArrays(
817 if (Options.TracePCGuard)
818 FunctionGuardArray = CreateFunctionLocalArrayInSection(
820
821 if (Options.Inline8bitCounters)
822 Function8bitCounterArray = CreateFunctionLocalArrayInSection(
824 if (Options.InlineBoolFlag)
825 FunctionBoolArray = CreateFunctionLocalArrayInSection(
827
829 FunctionPCsArray = CreatePCArray(F, AllBlocks);
830}
831
832Value *ModuleSanitizerCoverage::CreateFunctionLocalGateCmp(IRBuilder<> &IRB) {
833 auto Load = IRB.CreateLoad(Int64Ty, SanCovCallbackGate);
834 Load->setNoSanitizeMetadata();
836 Cmp->setName("sancov gate cmp");
837 return Cmp;
838}
839
841 Value *&FunctionGateCmp,
843 if (!FunctionGateCmp) {
844
849 FunctionGateCmp = CreateFunctionLocalGateCmp(EntryIRB);
850 }
851
852
853
856}
857
858bool ModuleSanitizerCoverage::InjectCoverage(Function &F,
860 Value *&FunctionGateCmp,
861 bool IsLeafFunc) {
862 if (AllBlocks.empty())
863 return false;
864 CreateFunctionLocalArrays(F, AllBlocks);
865 for (size_t i = 0, N = AllBlocks.size(); i < N; i++)
866 InjectCoverageAtBlock(F, *AllBlocks[i], i, FunctionGateCmp, IsLeafFunc);
867 return true;
868}
869
870
871
872
873
874
875
876
877void ModuleSanitizerCoverage::InjectCoverageForIndirectCalls(
879 if (IndirCalls.empty())
880 return;
882 Options.Inline8bitCounters || Options.InlineBoolFlag);
883 for (auto *I : IndirCalls) {
888 continue;
890 }
891}
892
893
894
895
896
897void ModuleSanitizerCoverage::InjectTraceForSwitch(
899 Value *&FunctionGateCmp) {
900 for (auto *I : SwitchTraceTargets) {
905 if (Cond->getType()->getScalarSizeInBits() >
906 Int64Ty->getScalarSizeInBits())
907 continue;
908 Initializers.push_back(ConstantInt::get(Int64Ty, SI->getNumCases()));
910 ConstantInt::get(Int64Ty, Cond->getType()->getScalarSizeInBits()));
911 if (Cond->getType()->getScalarSizeInBits() <
912 Int64Ty->getScalarSizeInBits())
914 for (auto It : SI->cases()) {
916 if (C->getType()->getScalarSizeInBits() < 64)
917 C = ConstantInt::get(C->getContext(), C->getValue().zext(64));
919 }
924 });
929 "__sancov_gen_cov_switch_values");
930 if (Options.GatedCallbacks) {
931 auto GateBranch = CreateGateBranch(F, FunctionGateCmp, I);
933 GateIRB.CreateCall(SanCovTraceSwitchFunction, {Cond, GV});
934 } else {
935 IRB.CreateCall(SanCovTraceSwitchFunction, {Cond, GV});
936 }
937 }
938 }
939}
940
941void ModuleSanitizerCoverage::InjectTraceForDiv(
943 for (auto *BO : DivTraceTargets) {
945 Value *A1 = BO->getOperand(1);
947 continue;
949 continue;
951 int CallbackIdx = TypeSize == 32 ? 0 : TypeSize == 64 ? 1 : -1;
952 if (CallbackIdx < 0)
953 continue;
955 IRB.CreateCall(SanCovTraceDivFunction[CallbackIdx],
957 }
958}
959
960void ModuleSanitizerCoverage::InjectTraceForGep(
962 for (auto *GEP : GepTraceTargets) {
964 for (Use &Idx : GEP->indices())
966 IRB.CreateCall(SanCovTraceGepFunction,
968 }
969}
970
971void ModuleSanitizerCoverage::InjectTraceForLoadsAndStores(
973 auto CallbackIdx = [&](Type *ElementTy) -> int {
974 uint64_t TypeSize = DL->getTypeStoreSizeInBits(ElementTy);
980 : -1;
981 };
982 for (auto *LI : Loads) {
984 auto Ptr = LI->getPointerOperand();
985 int Idx = CallbackIdx(LI->getType());
986 if (Idx < 0)
987 continue;
988 IRB.CreateCall(SanCovLoadFunction[Idx], Ptr);
989 }
990 for (auto *SI : Stores) {
992 auto Ptr = SI->getPointerOperand();
993 int Idx = CallbackIdx(SI->getValueOperand()->getType());
994 if (Idx < 0)
995 continue;
996 IRB.CreateCall(SanCovStoreFunction[Idx], Ptr);
997 }
998}
999
1000void ModuleSanitizerCoverage::InjectTraceForCmp(
1002 Value *&FunctionGateCmp) {
1003 for (auto *I : CmpTraceTargets) {
1006 Value *A0 = ICMP->getOperand(0);
1007 Value *A1 = ICMP->getOperand(1);
1009 continue;
1011 int CallbackIdx = TypeSize == 8 ? 0
1015 : -1;
1016 if (CallbackIdx < 0)
1017 continue;
1018
1019 auto CallbackFunc = SanCovTraceCmpFunction[CallbackIdx];
1022
1023 if (FirstIsConst && SecondIsConst)
1024 continue;
1025
1026 if (FirstIsConst || SecondIsConst) {
1027 CallbackFunc = SanCovTraceConstCmpFunction[CallbackIdx];
1028 if (SecondIsConst)
1030 }
1031
1033 if (Options.GatedCallbacks) {
1034 auto GateBranch = CreateGateBranch(F, FunctionGateCmp, I);
1036 GateIRB.CreateCall(CallbackFunc, {GateIRB.CreateIntCast(A0, Ty, true),
1037 GateIRB.CreateIntCast(A1, Ty, true)});
1038 } else {
1041 }
1042 }
1043 }
1044}
1045
1046void ModuleSanitizerCoverage::InjectCoverageAtBlock(Function &F, BasicBlock &BB,
1047 size_t Idx,
1048 Value *&FunctionGateCmp,
1049 bool IsLeafFunc) {
1051 bool IsEntryBB = &BB == &F.getEntryBlock();
1053 if (IsEntryBB) {
1054 if (auto SP = F.getSubprogram())
1055 EntryLoc = DILocation::get(SP->getContext(), SP->getScopeLine(), 0, SP);
1056
1057
1058
1060 }
1061
1063 if (EntryLoc)
1067 ->setCannotMerge();
1068 }
1069 if (Options.TracePCGuard) {
1071 FunctionGuardArray->getValueType(), FunctionGuardArray, 0, Idx);
1072 if (Options.GatedCallbacks) {
1074 auto GateBranch = CreateGateBranch(F, FunctionGateCmp, I);
1076 GateIRB.CreateCall(SanCovTracePCGuard, GuardPtr)->setCannotMerge();
1077 } else {
1079 }
1080 }
1081 if (Options.Inline8bitCounters) {
1082 auto CounterPtr = IRB.CreateGEP(
1083 Function8bitCounterArray->getValueType(), Function8bitCounterArray,
1084 {ConstantInt::get(IntptrTy, 0), ConstantInt::get(IntptrTy, Idx)});
1086 auto Inc = IRB.CreateAdd(Load, ConstantInt::get(Int8Ty, 1));
1088 Load->setNoSanitizeMetadata();
1089 Store->setNoSanitizeMetadata();
1090 }
1091 if (Options.InlineBoolFlag) {
1093 FunctionBoolArray->getValueType(), FunctionBoolArray,
1094 {ConstantInt::get(IntptrTy, 0), ConstantInt::get(IntptrTy, Idx)});
1101 if (EntryLoc)
1102 Store->setDebugLoc(EntryLoc);
1103 Load->setNoSanitizeMetadata();
1104 Store->setNoSanitizeMetadata();
1105 }
1106 if (Options.StackDepth && IsEntryBB && !IsLeafFunc) {
1109
1110 if (Options.StackDepthCallbackMin) {
1111
1112 int EstimatedStackSize = 0;
1113
1114 bool HasDynamicAlloc = false;
1115
1117
1118
1119
1120
1121 for (auto &I : BB) {
1123
1125
1126
1127 if (AI->isStaticAlloca()) {
1128 uint32_t Bytes = DL.getTypeAllocSize(AI->getAllocatedType());
1129 if (AI->isArrayAllocation()) {
1132 Bytes *= arraySize->getZExtValue();
1133 } else {
1134 HasDynamicAlloc = true;
1135 }
1136 }
1137 EstimatedStackSize += Bytes;
1138 } else {
1139 HasDynamicAlloc = true;
1140 }
1141 }
1142 }
1143
1144 if (HasDynamicAlloc ||
1145 EstimatedStackSize >= Options.StackDepthCallbackMin) {
1146 if (InsertBefore)
1148 auto Call = IRB.CreateCall(SanCovStackDepthCallback);
1149 if (EntryLoc)
1152 }
1153 } else {
1154
1156 Intrinsic::frameaddress, IRB.getPtrTy(DL.getAllocaAddrSpace()),
1157 {Constant::getNullValue(Int32Ty)});
1158 auto FrameAddrInt = IRB.CreatePtrToInt(FrameAddrPtr, IntptrTy);
1159 auto LowestStack = IRB.CreateLoad(IntptrTy, SanCovLowestStack);
1160 auto IsStackLower = IRB.CreateICmpULT(FrameAddrInt, LowestStack);
1162 IsStackLower, &*IP, false,
1165 auto Store = ThenIRB.CreateStore(FrameAddrInt, SanCovLowestStack);
1166 if (EntryLoc)
1167 Store->setDebugLoc(EntryLoc);
1168 LowestStack->setNoSanitizeMetadata();
1169 Store->setNoSanitizeMetadata();
1170 }
1171 }
1172}
1173
1174std::string
1175ModuleSanitizerCoverage::getSectionName(const std::string &Section) const {
1176 if (TargetTriple.isOSBinFormatCOFF()) {
1178 return ".SCOV$CM";
1180 return ".SCOV$BM";
1182 return ".SCOVP$M";
1183 return ".SCOV$GM";
1184 }
1185 if (TargetTriple.isOSBinFormatMachO())
1186 return "__DATA,__" + Section;
1188}
1189
1190std::string
1191ModuleSanitizerCoverage::getSectionStart(const std::string &Section) const {
1192 if (TargetTriple.isOSBinFormatMachO())
1193 return "\1section$start$__DATA$__" + Section;
1194 return "__start___" + Section;
1195}
1196
1197std::string
1198ModuleSanitizerCoverage::getSectionEnd(const std::string &Section) const {
1199 if (TargetTriple.isOSBinFormatMachO())
1200 return "\1section$end$__DATA$__" + Section;
1201 return "__stop___" + Section;
1202}
1203
1204void ModuleSanitizerCoverage::createFunctionControlFlow(Function &F) {
1206 IRBuilder<> IRB(&*F.getEntryBlock().getFirstInsertionPt());
1207
1208 for (auto &BB : F) {
1209
1210 if (&BB == &F.getEntryBlock())
1212 else
1215
1216 for (auto SuccBB : successors(&BB)) {
1217 assert(SuccBB != &F.getEntryBlock());
1220 }
1221
1223
1224 for (auto &Inst : BB) {
1227
1229 ConstantInt::get(IntptrTy, -1), PtrTy));
1230 } else {
1232 if (CalledF && !CalledF->isIntrinsic())
1234 }
1235 }
1236 }
1237
1239 }
1240
1241 FunctionCFsArray = CreateFunctionLocalArrayInSection(CFs.size(), F, PtrTy,
1243 FunctionCFsArray->setInitializer(
1245 FunctionCFsArray->setConstant(true);
1246}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This is the interface for a simple mod/ref and alias analysis over globals.
Module.h This file contains the declarations for the Module class.
Machine Check Debug Module
static cl::opt< bool > SplitAllCriticalEdges("phi-elim-split-all-critical-edges", cl::init(false), cl::Hidden, cl::desc("Split all critical edges during " "PHI elimination"))
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
const SmallVectorImpl< MachineOperand > & Cond
static cl::opt< bool > ClLoadTracing("sanitizer-coverage-trace-loads", cl::desc("Tracing of load instructions"), cl::Hidden)
const char SanCovCFsSectionName[]
Definition SanitizerCoverage.cpp:86
static bool isFullPostDominator(const BasicBlock *BB, const PostDominatorTree &PDT)
Definition SanitizerCoverage.cpp:586
static cl::opt< int > ClCoverageLevel("sanitizer-coverage-level", cl::desc("Sanitizer Coverage. 0: none, 1: entry block, 2: all blocks, " "3: all blocks and critical edges"), cl::Hidden)
static cl::opt< bool > ClSancovDropCtors("sanitizer-coverage-drop-ctors", cl::desc("do not emit module ctors for global counters"), cl::Hidden)
static cl::opt< bool > ClStackDepth("sanitizer-coverage-stack-depth", cl::desc("max stack depth tracing"), cl::Hidden)
static cl::opt< bool > ClInlineBoolFlag("sanitizer-coverage-inline-bool-flag", cl::desc("sets a boolean flag for every edge"), cl::Hidden)
const char SanCovTraceConstCmp4[]
Definition SanitizerCoverage.cpp:52
const char SanCovBoolFlagSectionName[]
Definition SanitizerCoverage.cpp:84
const char SanCov8bitCountersInitName[]
Definition SanitizerCoverage.cpp:77
const char SanCovLoad8[]
Definition SanitizerCoverage.cpp:57
const char SanCovTraceSwitchName[]
Definition SanitizerCoverage.cpp:67
const char SanCovTraceCmp1[]
Definition SanitizerCoverage.cpp:46
const char SanCovModuleCtorTracePcGuardName[]
Definition SanitizerCoverage.cpp:68
const char SanCovCountersSectionName[]
Definition SanitizerCoverage.cpp:83
static cl::opt< bool > ClCreatePCTable("sanitizer-coverage-pc-table", cl::desc("create a static PC table"), cl::Hidden)
const char SanCovPCsInitName[]
Definition SanitizerCoverage.cpp:79
const char SanCovTracePCGuardName[]
Definition SanitizerCoverage.cpp:75
static cl::opt< int > ClStackDepthCallbackMin("sanitizer-coverage-stack-depth-callback-min", cl::desc("max stack depth tracing should use callback and only when " "stack depth more than specified"), cl::Hidden)
const char SanCovModuleCtor8bitCountersName[]
Definition SanitizerCoverage.cpp:70
const char SanCovTracePCGuardInitName[]
Definition SanitizerCoverage.cpp:76
static cl::opt< bool > ClCollectCF("sanitizer-coverage-control-flow", cl::desc("collect control flow for each function"), cl::Hidden)
const char SanCovTraceDiv4[]
Definition SanitizerCoverage.cpp:64
static const uint64_t SanCtorAndDtorPriority
Definition SanitizerCoverage.cpp:73
const char SanCovBoolFlagInitName[]
Definition SanitizerCoverage.cpp:78
static cl::opt< bool > ClGatedCallbacks("sanitizer-coverage-gated-trace-callbacks", cl::desc("Gate the invocation of the tracing callbacks on a global variable" ". Currently only supported for trace-pc-guard and trace-cmp."), cl::Hidden, cl::init(false))
const char SanCovTraceGep[]
Definition SanitizerCoverage.cpp:66
const char SanCovLoad16[]
Definition SanitizerCoverage.cpp:58
const char SanCovTraceConstCmp8[]
Definition SanitizerCoverage.cpp:53
const char SanCovGuardsSectionName[]
Definition SanitizerCoverage.cpp:82
const char SanCovStore1[]
Definition SanitizerCoverage.cpp:59
const char SanCovTraceConstCmp2[]
Definition SanitizerCoverage.cpp:51
const char SanCovTraceConstCmp1[]
Definition SanitizerCoverage.cpp:50
static bool IsBackEdge(BasicBlock *From, BasicBlock *To, const DominatorTree &DT)
Definition SanitizerCoverage.cpp:630
static cl::opt< bool > ClStoreTracing("sanitizer-coverage-trace-stores", cl::desc("Tracing of store instructions"), cl::Hidden)
const char SanCovCallbackGateName[]
Definition SanitizerCoverage.cpp:91
static cl::opt< bool > ClTracePCGuard("sanitizer-coverage-trace-pc-guard", cl::desc("pc tracing with a guard"), cl::Hidden)
const char SanCovTraceDiv8[]
Definition SanitizerCoverage.cpp:65
const char SanCovLoad4[]
Definition SanitizerCoverage.cpp:56
static cl::opt< bool > ClGEPTracing("sanitizer-coverage-trace-geps", cl::desc("Tracing of GEP instructions"), cl::Hidden)
const char SanCovStackDepthCallbackName[]
Definition SanitizerCoverage.cpp:89
const char SanCovCFsInitName[]
Definition SanitizerCoverage.cpp:80
static cl::opt< bool > ClTracePC("sanitizer-coverage-trace-pc", cl::desc("Experimental pc tracing"), cl::Hidden)
const char SanCovStore2[]
Definition SanitizerCoverage.cpp:60
static cl::opt< bool > ClPruneBlocks("sanitizer-coverage-prune-blocks", cl::desc("Reduce the number of instrumented blocks"), cl::Hidden, cl::init(true))
const char SanCovPCsSectionName[]
Definition SanitizerCoverage.cpp:85
const char SanCovLoad1[]
Definition SanitizerCoverage.cpp:54
static bool isFullDominator(const BasicBlock *BB, const DominatorTree &DT)
Definition SanitizerCoverage.cpp:576
static cl::opt< bool > ClCMPTracing("sanitizer-coverage-trace-compares", cl::desc("Tracing of CMP and similar instructions"), cl::Hidden)
const char SanCovTraceCmp8[]
Definition SanitizerCoverage.cpp:49
const char SanCovCallbackGateSectionName[]
Definition SanitizerCoverage.cpp:87
const char SanCovStore16[]
Definition SanitizerCoverage.cpp:63
static bool IsInterestingCmp(ICmpInst *CMP, const DominatorTree &DT, const SanitizerCoverageOptions &Options)
Definition SanitizerCoverage.cpp:645
static cl::opt< bool > ClDIVTracing("sanitizer-coverage-trace-divs", cl::desc("Tracing of DIV instructions"), cl::Hidden)
static cl::opt< bool > ClInline8bitCounters("sanitizer-coverage-inline-8bit-counters", cl::desc("increments 8-bit counter for every edge"), cl::Hidden)
static bool shouldInstrumentBlock(const Function &F, const BasicBlock *BB, const DominatorTree &DT, const PostDominatorTree &PDT, const SanitizerCoverageOptions &Options)
Definition SanitizerCoverage.cpp:596
const char SanCovModuleCtorBoolFlagName[]
Definition SanitizerCoverage.cpp:72
const char SanCovTraceCmp2[]
Definition SanitizerCoverage.cpp:47
const char SanCovStore8[]
Definition SanitizerCoverage.cpp:62
const char SanCovTracePCName[]
Definition SanitizerCoverage.cpp:45
const char SanCovStore4[]
Definition SanitizerCoverage.cpp:61
const char SanCovLoad2[]
Definition SanitizerCoverage.cpp:55
const char SanCovTraceCmp4[]
Definition SanitizerCoverage.cpp:48
const char SanCovLowestStackName[]
Definition SanitizerCoverage.cpp:90
const char SanCovTracePCIndirName[]
Definition SanitizerCoverage.cpp:44
This file defines the SmallVector class.
Defines the virtual file system interface vfs::FileSystem.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
Class to represent array types.
static LLVM_ABI ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
LLVM Basic Block Representation.
LLVM_ABI const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
LLVM_ABI const BasicBlock * getUniqueSuccessor() const
Return the successor of this block if it has a unique successor.
LLVM_ABI const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
InstListType::iterator iterator
Instruction iterators...
LLVM_ABI InstListType::const_iterator getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp=true) const
Returns a pointer to the first instruction in this block that is not a PHINode, a debug intrinsic,...
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
static LLVM_ABI BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
LLVM_ABI bool isIndirectCall() const
Return true if the callsite is an indirect call.
Value * getCalledOperand() const
static LLVM_ABI Constant * get(ArrayType *T, ArrayRef< Constant * > V)
This is the shared class of boolean and integer constants.
static LLVM_ABI ConstantInt * getTrue(LLVMContext &Context)
This is an important base class in LLVM.
static LLVM_ABI Constant * getAllOnesValue(Type *Ty)
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
A parsed version of the target data layout string in and methods for querying it.
Analysis pass which computes a DominatorTree.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
LLVM_ABI bool dominates(const BasicBlock *BB, const Use &U) const
Return true if the (end of the) basic block BB dominates the use U.
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
const BasicBlock & getEntryBlock() const
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
LLVM_ABI void setComdat(Comdat *C)
void setLinkage(LinkageTypes LT)
@ HiddenVisibility
The GV is hidden.
void setVisibility(VisibilityTypes V)
LinkageTypes
An enumeration for the kinds of linkage for global values.
@ PrivateLinkage
Like Internal, but omit from symbol table.
@ InternalLinkage
Rename collisions when linking (static functions).
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
@ WeakODRLinkage
Same, but only replaced by something equivalent.
@ ExternalLinkage
Externally visible function.
@ AvailableExternallyLinkage
Available for inspection, not emission.
@ ExternalWeakLinkage
ExternalWeak linkage description.
Analysis pass providing a never-invalidated alias analysis result.
This instruction compares its operands according to the predicate given to the constructor.
Value * CreateICmpULT(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreatePointerCast(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateIntToPtr(Value *V, Type *DestTy, const Twine &Name="")
void SetCurrentDebugLocation(DebugLoc L)
Set location information used by debugging information.
Value * CreateGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="", GEPNoWrapFlags NW=GEPNoWrapFlags::none())
LLVM_ABI CallInst * CreateIntrinsic(Intrinsic::ID ID, ArrayRef< Type * > Types, ArrayRef< Value * > Args, FMFSource FMFSource={}, const Twine &Name="")
Create a call to intrinsic ID with Args, mangled using Types.
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of converting the string to 'bool...
LLVMContext & getContext() const
Value * CreateConstInBoundsGEP2_64(Type *Ty, Value *Ptr, uint64_t Idx0, uint64_t Idx1, const Twine &Name="")
StoreInst * CreateStore(Value *Val, Value *Ptr, bool isVolatile=false)
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Value * CreatePtrToInt(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateIsNotNull(Value *Arg, const Twine &Name="")
Return a boolean value testing if Arg != 0.
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args={}, const Twine &Name="", MDNode *FPMathTag=nullptr)
PointerType * getPtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer.
Value * CreateIntCast(Value *V, Type *DestTy, bool isSigned, const Twine &Name="")
Value * CreateIsNull(Value *Arg, const Twine &Name="")
Return a boolean value testing if Arg == 0.
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
An instruction for reading from memory.
LLVM_ABI MDNode * createBranchWeights(uint32_t TrueWeight, uint32_t FalseWeight, bool IsExpected=false)
Return metadata containing two branch weights.
LLVM_ABI MDNode * createUnlikelyBranchWeights()
Return metadata containing two branch weights, with significant bias towards false destination.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
A Module instance is used to store all the information related to an LLVM module.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Analysis pass which computes a PostDominatorTree.
PostDominatorTree Class - Concrete subclass of DominatorTree that is used to compute the post-dominat...
LLVM_ABI bool dominates(const Instruction *I1, const Instruction *I2) const
Return true if I1 dominates I2.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & abandon()
Mark an analysis as abandoned.
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition SanitizerCoverage.cpp:333
LLVM_ABI SanitizerCoveragePass(SanitizerCoverageOptions Options=SanitizerCoverageOptions(), IntrusiveRefCntPtr< vfs::FileSystem > VFS=nullptr, const std::vector< std::string > &AllowlistFiles={}, const std::vector< std::string > &BlocklistFiles={})
Definition SanitizerCoverage.cpp:321
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static LLVM_ABI std::unique_ptr< SpecialCaseList > createOrDie(const std::vector< std::string > &Paths, llvm::vfs::FileSystem &FS)
Parses the special case list entries from files.
An instruction for storing to memory.
StringRef - Represent a constant reference to a string, i.e.
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
bool isIntegerTy() const
True if this is an instance of IntegerType.
static LLVM_ABI IntegerType * getIntNTy(LLVMContext &C, unsigned N)
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
@ C
The default llvm calling convention, compatible with C.
initializer< Ty > init(const Ty &Val)
static constexpr const StringLiteral & getSectionName(DebugSectionKind SectionKind)
Return the name of the section.
friend class Instruction
Iterator for Instructions in a `BasicBlock.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
FunctionAddr VTableAddr Value
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
bool succ_empty(const Instruction *I)
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
FunctionAddr VTableAddr uintptr_t uintptr_t Int32Ty
auto successors(const MachineBasicBlock *BB)
InnerAnalysisManagerProxy< FunctionAnalysisManager, Module > FunctionAnalysisManagerModuleProxy
Provide the FunctionAnalysisManager to Module proxy.
LLVM_ABI FunctionCallee declareSanitizerInitFunction(Module &M, StringRef InitName, ArrayRef< Type * > InitArgTypes, bool Weak=false)
LLVM_ABI std::pair< Function *, FunctionCallee > createSanitizerCtorAndInitFunctions(Module &M, StringRef CtorName, StringRef InitName, ArrayRef< Type * > InitArgTypes, ArrayRef< Value * > InitArgs, StringRef VersionCheckName=StringRef(), bool Weak=false)
Creates sanitizer constructor function, and calls sanitizer's init function from it.
void sort(IteratorTy Start, IteratorTy End)
LLVM_ABI EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
LLVM_ABI Comdat * getOrCreateFunctionComdat(Function &F, Triple &T)
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
IRBuilder(LLVMContext &, FolderTy, InserterTy, MDNode *, ArrayRef< OperandBundleDef >) -> IRBuilder< FolderTy, InserterTy >
LLVM_ABI void appendToCompilerUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.compiler.used list.
FunctionAddr VTableAddr Next
ArrayRef(const T &OneElt) -> ArrayRef< T >
bool isAsynchronousEHPersonality(EHPersonality Pers)
Returns true if this personality function catches asynchronous exceptions.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI void appendToGlobalCtors(Module &M, Function *F, int Priority, Constant *Data=nullptr)
Append F to the list of global ctors of module M with the given Priority.
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.
auto predecessors(const MachineBasicBlock *BB)
bool pred_empty(const BasicBlock *BB)
LLVM_ABI BasicBlock::iterator PrepareToSplitEntryBlock(BasicBlock &BB, BasicBlock::iterator IP)
Instrumentation passes often insert conditional checks into entry blocks.
LLVM_ABI Instruction * SplitBlockAndInsertIfThen(Value *Cond, BasicBlock::iterator SplitBefore, bool Unreachable, MDNode *BranchWeights=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, BasicBlock *ThenBlock=nullptr)
Split the containing block at the specified instruction - everything before SplitBefore stays in the ...
LLVM_ABI void appendToUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.used list.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Implement std::hash so that hash_code can be used in STL containers.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Option class for critical edge splitting.
enum llvm::SanitizerCoverageOptions::Type CoverageType