Clang usually propagates counter mapping region for conditions of if, while,
for, etc from parent counter. We should do the same for condition of conditional operator.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Nice. I believe there are some integration tests in compiler-rt/test/profile. First, please run them and make sure they pass. Second, @vsk, do you think it's worth adding an integration test for this, seeing as the bug is really only observable when you put all the coverage tools together?
How was the issue spotted? If there was a crash or an incorrect coverage bug that's not triggered by one of the existing frontend tests, it'd be worth adding a regression test. If the problem can't be replicated without involving llvm-cov, this can be an integration test.
The issue was spotted by @pirama. But this doesn't completely solve the problem. When I was investigating the issue, I noticed condition expression of conditional operator was not given a counter. So, I sent this patch.
For the issue reported by @pirama, it is that llvm-cov shows following:
1| |#include <stdlib.h> 2| | 3| 1|int main() { 4| 1| return getenv( 5| 0| "TEST") ? 1 6| 1| : 0; 7| 1|}
Here are the debug dump.
Combined regions: 3:12 -> 7:2 (count=1) 4:10 -> 5:14 (count=1) 5:15 -> 5:17 (count=0) 5:17 -> 5:18 (count=0) 6:17 -> 6:18 (count=1) Segment at 3:12 (count = 1), RegionEntry Segment at 4:10 (count = 1), RegionEntry Segment at 5:14 (count = 1) Segment at 5:15 (count = 0), Gap Segment at 5:17 (count = 0), RegionEntry Segment at 5:18 (count = 1) Segment at 6:17 (count = 1), RegionEntry Segment at 6:18 (count = 1) Segment at 7:2 (count = 0), Skipped
I am working on this.