I previously upstreamed work to enable Branch Coverage (https://reviews.llvm.org/D84467), which was pushed in early 2021. MC/DC (Modified Condition/Decision Coverage) is a planned enhancement to Source-based Code Coverage. Implementation was completed in May for our downstream Arm compiler, and in general use it has not yielded any issues. Our downstream implementation does not use most of the compiler-rt profile functionality, and so that is relatively new to this patch.
See attached file for Background, Motivation, Design, and Implementation Concepts:
I am also available at Discord @alanphipps
Recommended order for the review. Start with the front-end changes:
- New Option and common parameters
- CodeGenOptions.def
- Options.td
- Clang.cpp
- Bitmask Coverage Object Allocation:
- CodeGenPGO.h, CodeGenPGO.cpp
- Source Region Mapping:
- CoverageMappingGen.h, CoverageMappingGen.cpp
- Instrumentation (during IR lowering):
- CGExprScalar.cpp
- CGStmt.cpp
- CodeGenFunction.h, CodeGenFunction.cpp
LLVM back-end processing and profile reading/writing:
- Instrumentation intrinsic lowering and section allocation:
- IntrinsicInst.h
- Intrinsics.td
- IntrinsicInst.cpp
- InstrProfiling.h, InstrProfiling.cpp
- Profiling format read/write:
- CoverageMappingWriter.cpp
- CoverageMappingReader.cpp
- Profile read/write:
- InstrProf.h, InstrProf.cpp
- InstrProfWriter.h, InstrProfWriter.cpp
- InstrProfReader.h, InstrProfReader.cpp
- Runtime profiling aids:
- InstrProfiling.h
- InstrProfilingFilebaremetal.c
- InstrProfilingPlatformBaremetal.c
- compiler-rt
Visualization and Evaluation:
- Bitmask evaluation and MC/DC Region Analysis:
- CoverageMapping.h, CoverageMapping.cpp
- Creation of MC/DC Views with Records:
- CodeCoverage.cpp
- CoverageViewOptions.h
- Text, HTML Visualization:
- SourceCoverageView.h, SourceCoverageView.cpp
- SourceCoverageViewHTML.h, SourceCoverageViewHTML.cpp
- SourceCoverageViewText.h, SourceCoverageViewText.cpp
- Summary Report Generation:
- CoverageSummaryInfo.h, CoverageSummaryInfo.cpp
- CoverageReport.cpp
- JSON exporting:
- CoverageExporterJson.cpp
This patch has been tested on windows (stage1) and linux/mac (stage1 and stage2)
Unsupported at the moment (please consider enabling in a future patch!):
- Fuchsia
- Debug Correlation
Would MCDCTrackingStateAddr be more appropriate? It could save people some time tracking back up to the comment to work out what Temp is being used for.