Index: include/llvm/Support/CodeGenCoverage.h =================================================================== --- include/llvm/Support/CodeGenCoverage.h +++ include/llvm/Support/CodeGenCoverage.h @@ -23,15 +23,18 @@ BitVector RuleCoverage; public: + using const_covered_iterator = BitVector::const_set_bits_iterator; + CodeGenCoverage(); void setCovered(uint64_t RuleID); - bool isCovered(uint64_t RuleID); + bool isCovered(uint64_t RuleID) const; + iterator_range covered() const; bool parse(MemoryBuffer &Buffer, StringRef BackendName); bool emit(StringRef FilePrefix, StringRef BackendName) const; void reset(); }; -} // end namespace llvm +} // namespace llvm #endif // ifndef LLVM_SUPPORT_CODEGENCOVERAGE_H Index: lib/CodeGen/GlobalISel/InstructionSelect.cpp =================================================================== --- lib/CodeGen/GlobalISel/InstructionSelect.cpp +++ lib/CodeGen/GlobalISel/InstructionSelect.cpp @@ -218,6 +218,12 @@ auto &TLI = *MF.getSubtarget().getTargetLowering(); TLI.finalizeLowering(MF); + DEBUG({ + dbgs() << "Rules covered by selecting function: " << MF.getName() << ":"; + for (auto RuleID : CoverageInfo.covered()) + dbgs() << " id" << RuleID; + dbgs() << "\n\n"; + }); CoverageInfo.emit(CoveragePrefix, MF.getSubtarget() .getTargetLowering() Index: lib/Support/CodeGenCoverage.cpp =================================================================== --- lib/Support/CodeGenCoverage.cpp +++ lib/Support/CodeGenCoverage.cpp @@ -38,12 +38,17 @@ RuleCoverage[RuleID] = true; } -bool CodeGenCoverage::isCovered(uint64_t RuleID) { +bool CodeGenCoverage::isCovered(uint64_t RuleID) const { if (RuleCoverage.size() <= RuleID) return false; return RuleCoverage[RuleID]; } +iterator_range +CodeGenCoverage::covered() const { + return RuleCoverage.set_bits(); +} + bool CodeGenCoverage::parse(MemoryBuffer &Buffer, StringRef BackendName) { const char *CurPtr = Buffer.getBufferStart();