File indexing completed on 2026-05-10 08:44:38
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_BLOCKCOVERAGEINFERENCE_H
0016 #define LLVM_TRANSFORMS_INSTRUMENTATION_BLOCKCOVERAGEINFERENCE_H
0017
0018 #include "llvm/ADT/ArrayRef.h"
0019 #include "llvm/ADT/DenseMap.h"
0020 #include "llvm/ADT/SetVector.h"
0021 #include "llvm/Support/raw_ostream.h"
0022
0023 namespace llvm {
0024
0025 class Function;
0026 class BasicBlock;
0027 class DotFuncBCIInfo;
0028
0029 class BlockCoverageInference {
0030 friend class DotFuncBCIInfo;
0031
0032 public:
0033 using BlockSet = SmallSetVector<const BasicBlock *, 4>;
0034
0035 BlockCoverageInference(const Function &F, bool ForceInstrumentEntry);
0036
0037
0038 bool shouldInstrumentBlock(const BasicBlock &BB) const;
0039
0040
0041
0042 BlockSet getDependencies(const BasicBlock &BB) const;
0043
0044
0045 uint64_t getInstrumentedBlocksHash() const;
0046
0047
0048 void dump(raw_ostream &OS) const;
0049
0050
0051
0052
0053
0054
0055 void viewBlockCoverageGraph(
0056 const DenseMap<const BasicBlock *, bool> *Coverage = nullptr) const;
0057
0058 private:
0059 const Function &F;
0060 bool ForceInstrumentEntry;
0061
0062
0063
0064 DenseMap<const BasicBlock *, BlockSet> PredecessorDependencies;
0065
0066
0067
0068 DenseMap<const BasicBlock *, BlockSet> SuccessorDependencies;
0069
0070
0071 void findDependencies();
0072
0073
0074
0075 void getReachableAvoiding(const BasicBlock &Start, const BasicBlock &Avoid,
0076 bool IsForward, BlockSet &Reachable) const;
0077
0078 static std::string getBlockNames(ArrayRef<const BasicBlock *> BBs);
0079 static std::string getBlockNames(BlockSet BBs) {
0080 return getBlockNames(ArrayRef<const BasicBlock *>(BBs.begin(), BBs.end()));
0081 }
0082 };
0083
0084 }
0085
0086 #endif