Skip to content

[Coverage][Single] Enable Branch coverage for SwitchStmt #113112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 57 commits into
base: users/chapuni/cov/single/nextcount
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
178b57c
[Coverage] Move SingleByteCoverage out of CountedRegion
chapuni Oct 2, 2024
aacb50d
[Coverage] Make SingleByteCoverage work consistent to merging
chapuni Oct 2, 2024
b9bbc7c
Rework. (Also reverts "[Coverage] Move SingleByteCoverage out of Cou…
chapuni Oct 5, 2024
52f072e
clang/test/CoverageMapping/single-byte-counters.cpp: Rewrite counter …
chapuni Oct 17, 2024
78e33ba
Merge branches 'users/chapuni/cov/single/test' and 'users/chapuni/cov…
chapuni Oct 21, 2024
ec05cc3
[Coverage][Single] Enable Branch coverage for SwitchStmt
chapuni Oct 20, 2024
4b87f26
Merge branch 'users/chapuni/cov/single/nextcount' into users/chapuni/…
chapuni Oct 27, 2024
bfc4b4d
Merge branch 'users/chapuni/cov/single/base' into users/chapuni/cov/s…
chapuni Oct 27, 2024
bc708d5
Merge branch 'users/chapuni/cov/single/nextcount' into users/chapuni/…
chapuni Oct 27, 2024
5c7f06f
Merge branch 'users/chapuni/cov/single/base' into users/chapuni/cov/s…
chapuni Oct 27, 2024
97a4a8f
test/llvm-cov: Transform %.c* tests to {%.test, Inputs/%.c*}
chapuni Nov 20, 2024
c50c492
Introduce test/llvm-cov/Inputs/yaml.makefile for convenience.
chapuni Nov 20, 2024
d7c5b44
Add tests for SingleByteCoverage
chapuni Nov 20, 2024
6675226
Merge branch 'users/chapuni/cov/single/test' into users/chapuni/cov/s…
chapuni Nov 20, 2024
5fc3408
Fix a test to fix linecount=1
chapuni Nov 20, 2024
d086491
Merge branch 'users/chapuni/cov/single/merge' into users/chapuni/cov/…
chapuni Nov 20, 2024
b1491b8
Merge branch 'users/chapuni/cov/single/merge' into users/chapuni/cov/…
chapuni Nov 20, 2024
cce771f
Update test
chapuni Nov 20, 2024
c81e7d4
Merge branch 'users/chapuni/cov/single/base' into users/chapuni/cov/s…
chapuni Nov 20, 2024
eb7fff9
threads.c: Fixup on the clean testdir
chapuni Nov 20, 2024
7543095
Rename threads.c to threads.test since it is no longer C source file.
chapuni Nov 21, 2024
00ac90d
llvm/test/tools/llvm-cov/Inputs: Avoid wildcards `rm -rf %t*.dir`
chapuni Nov 21, 2024
fcb3ee8
Merge branch 'main' into users/chapuni/cov/single/test
chapuni Dec 21, 2024
5fa862a
Use `[[#min(C,n)]]` for tests
chapuni Dec 21, 2024
805e9a9
llvm-cov: Introduce `--binary-counters`
chapuni Dec 21, 2024
68d7b3b
Merge branch 'users/chapuni/cov/single/test' into users/chapuni/cov/s…
chapuni Dec 21, 2024
24457a7
Update tests
chapuni Dec 21, 2024
805dbd9
Merge branches 'users/chapuni/cov/single/merge' and 'users/chapuni/co…
chapuni Dec 21, 2024
f96b435
New SingleByteCoverage
chapuni Dec 21, 2024
2968ea6
Merge branch 'users/chapuni/cov/single/refactor' into users/chapuni/c…
chapuni Dec 21, 2024
cb3f959
Merge branch 'users/chapuni/cov/single/nextcount' into users/chapuni/…
chapuni Dec 21, 2024
cb3ff1f
Merge branch 'users/chapuni/cov/single/base' into users/chapuni/cov/s…
chapuni Dec 21, 2024
47550d1
threads.c => threads.test (following #113114)
chapuni Dec 22, 2024
42c0c26
clang/test: Add tests that we missed while I was updating.
chapuni Dec 23, 2024
c0a93e2
Merge branches 'users/chapuni/cov/single/test' and 'users/chapuni/cov…
chapuni Dec 23, 2024
f4dc4eb
s/Count1/BinaryCount/
chapuni Dec 23, 2024
822620b
Update desc
chapuni Dec 23, 2024
658bd48
Merge branch 'main' into users/chapuni/cov/binary
chapuni Dec 24, 2024
0780993
Merge branch 'users/chapuni/cov/binary' into users/chapuni/cov/single…
chapuni Dec 24, 2024
5dfe3e7
Merge branch 'users/chapuni/cov/single/nextcount' into users/chapuni/…
chapuni Dec 24, 2024
1adf497
Eliminate (rewind) "refactor" changes
chapuni Dec 24, 2024
b1ec9e5
Merge branch 'users/chapuni/cov/single/base' into users/chapuni/cov/s…
chapuni Dec 24, 2024
dfc99ba
Fix wrong merge resolutions
chapuni Dec 24, 2024
f3c9593
Reorganize CoverageMapping::SingleByteCoverage
chapuni Dec 24, 2024
3780e07
Prune commented-out line
chapuni Dec 24, 2024
894c383
Merge branch 'main' into users/chapuni/cov/single/refactor
chapuni Dec 27, 2024
7c26a2a
Merge branch 'main' into users/chapuni/cov/single/refactor
chapuni Dec 27, 2024
e11930a
Merge branch 'users/chapuni/cov/single/refactor' into users/chapuni/c…
chapuni Dec 27, 2024
ad7b753
Merge branch 'users/chapuni/cov/single/nextcount' into users/chapuni/…
chapuni Dec 27, 2024
3069477
Merge branch 'main' into users/chapuni/cov/single/base
chapuni Dec 28, 2024
360bed8
Merge branch 'users/chapuni/cov/single/base' into users/chapuni/cov/s…
chapuni Dec 28, 2024
e7fd5cd
Merge branch 'users/chapuni/cov/single/nextcount' into users/chapuni/…
chapuni Jan 8, 2025
b3cdf25
Merge branch 'users/chapuni/cov/single/base' into users/chapuni/cov/s…
chapuni Jan 8, 2025
af75972
Revert "Rewind switch DefaultCase. (to #113112)"
chapuni Jan 8, 2025
fa04eb4
Resurrect merge conflict
chapuni Jan 8, 2025
bdcf47e
Merge branch 'users/chapuni/cov/single/nextcount' into users/chapuni/…
chapuni Jan 9, 2025
e2810c9
Merge branch 'users/chapuni/cov/single/base' into users/chapuni/cov/s…
chapuni Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions clang/lib/CodeGen/CGStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2286,6 +2286,18 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) {

ConditionScope.ForceCleanup();

// Close the last case (or DefaultBlock).
EmitBranch(SwitchExit.getBlock());

// Insert a False Counter if SwitchStmt doesn't have DefaultStmt.
if (getIsCounterPair(S.getCond()).second) {
auto *ImplicitDefaultBlock = createBasicBlock("sw.false");
EmitBlock(ImplicitDefaultBlock);
incrementProfileCounter(UseSkipPath, S.getCond());
Builder.CreateBr(SwitchInsn->getDefaultDest());
SwitchInsn->setDefaultDest(ImplicitDefaultBlock);
}

// Emit continuation.
EmitBlock(SwitchExit.getBlock(), true);
incrementProfileCounter(&S);
Expand Down
42 changes: 24 additions & 18 deletions clang/lib/CodeGen/CoverageMappingGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,25 @@ struct CounterCoverageMappingBuilder
return Counters;
}

/// Returns {TrueCnt,FalseCnt} for "implicit default".
/// FalseCnt is considered as the False count on SwitchStmt.
std::pair<Counter, Counter>
getSwitchImplicitDefaultCounterPair(const Stmt *Cond, Counter ParentCount,
Counter CaseCountSum) {
if (llvm::EnableSingleByteCoverage)
// Allocate the new Counter since `subtract(Parent - Sum)` is unavailable.
return {Counter::getZero(), // Folded
Counter::getCounter(CounterMap[Cond].Skipped = NextCounterNum++)};

// Simplify is skipped while building the counters above: it can get
// really slow on top of switches with thousands of cases. Instead,
// trigger simplification by adding zero to the last counter.
CaseCountSum =
addCounters(CaseCountSum, Counter::getZero(), /*Simplify=*/true);

return {CaseCountSum, Builder.subtract(ParentCount, CaseCountSum)};
}

bool IsCounterEqual(Counter OutCount, Counter ParentCount) {
if (OutCount == ParentCount)
return true;
Expand Down Expand Up @@ -1922,7 +1941,7 @@ struct CounterCoverageMappingBuilder
propagateCounts(Counter::getZero(), Body);
BreakContinue BC = BreakContinueStack.pop_back_val();

if (!BreakContinueStack.empty() && !llvm::EnableSingleByteCoverage)
if (!BreakContinueStack.empty())
BreakContinueStack.back().ContinueCount = addCounters(
BreakContinueStack.back().ContinueCount, BC.ContinueCount);

Expand All @@ -1937,11 +1956,6 @@ struct CounterCoverageMappingBuilder
MostRecentLocation = getStart(S);
handleFileExit(ExitLoc);

// When single byte coverage mode is enabled, do not create branch region by
// early returning.
if (llvm::EnableSingleByteCoverage)
return;

// Create a Branch Region around each Case. Subtract the case's
// counter from the Parent counter to track the "False" branch count.
Counter CaseCountSum;
Expand All @@ -1956,25 +1970,17 @@ struct CounterCoverageMappingBuilder
// the hidden branch, which will be added later by the CodeGen. This region
// will be associated with the switch statement's condition.
if (!HasDefaultCase) {
// Simplify is skipped while building the counters above: it can get
// really slow on top of switches with thousands of cases. Instead,
// trigger simplification by adding zero to the last counter.
CaseCountSum =
addCounters(CaseCountSum, Counter::getZero(), /*Simplify=*/true);

// This is considered as the False count on SwitchStmt.
Counter SwitchFalse = subtractCounters(ParentCount, CaseCountSum);
createBranchRegion(S->getCond(), CaseCountSum, SwitchFalse);
auto Counters = getSwitchImplicitDefaultCounterPair(
S->getCond(), ParentCount, CaseCountSum);
createBranchRegion(S->getCond(), Counters.first, Counters.second);
}
}

void VisitSwitchCase(const SwitchCase *S) {
extendRegion(S);

SourceMappingRegion &Parent = getRegion();
Counter Count = llvm::EnableSingleByteCoverage
? getRegionCounter(S)
: addCounters(Parent.getCounter(), getRegionCounter(S));
Counter Count = addCounters(Parent.getCounter(), getRegionCounter(S));

// Reuse the existing region if it starts at our label. This is typical of
// the first case in a switch.
Expand Down
6 changes: 3 additions & 3 deletions clang/test/CoverageMapping/single-byte-counters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ int testSwitch(int x) { // CHECK-NEXT: File 0, [[@LINE]]:23 -> [[@LINE+20]]:2 =
switch (x) {
// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE+13]]:15 = 0
case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = [[C31:#2]]

// CHECK-NEXT: Branch,File 0, [[@LINE-1]]:3 -> [[@LINE-1]]:9 = [[C31]], 0
result = 1;
break;
// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:11 -> [[@LINE+1]]:3 = 0
case 2: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = [[C32:#3]]

// CHECK-NEXT: Branch,File 0, [[@LINE-1]]:3 -> [[@LINE-1]]:9 = [[C32]], 0
result = 2;
break;
// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:11 -> [[@LINE+1]]:3 = 0
default: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:15 = [[C3D:#4]]

// CHECK-NEXT: Branch,File 0, [[@LINE-1]]:3 -> [[@LINE-1]]:10 = [[C3D]], 0
result = 0;
}
// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE+1]]:3 = [[C3E:#1]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ jumps
# Func Hash:
15051420506203462683
# Num Counters:
38
39
# Counter Values:
1
1
Expand Down Expand Up @@ -232,6 +232,7 @@ jumps
1
1
1
0

main
# Func Hash:
Expand Down Expand Up @@ -263,7 +264,7 @@ switches
# Func Hash:
43242458792028222
# Num Counters:
29
30
# Counter Values:
1
1
Expand Down Expand Up @@ -294,4 +295,5 @@ switches
1
0
0
0

12 changes: 6 additions & 6 deletions llvm/test/tools/llvm-cov/Inputs/branch-c-general-single.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ Sections:
Type: SHT_PROGBITS
Flags: [ SHF_GNU_RETAIN ]
AddressAlign: 0x8
Content: 55947829059F255EB80100001B9C495D3463E1D04C551E9517F40F4F01010046013B0E2F02100201000105010F001409001600190D001A009B808080080D001B040400011402858080800810010100230001050104000009000A15000B008C8080800815000C000E11010402818080800810010100011D010126021D01070008210009008A8080800821000A000C1001010001250103000D25000E0283808080081001010001000103210229000A000B2D000C008D808080082D000D03043501030204350109000A39000B008C8080800839000C000E1002010001310103000D31000E0181808080084101011B024501011A024901011902490207000C4D000D0185808080084D0105000F5100100283808080081001010001510103140255000A000F5900100091808080085900110A04610103090400011006918080800869010501110001120185808080086D0105011200011301858080800871010501115D030402838080800810010100015D0103080275000F0015790017001A7D001B009C808080087D001C0604000115028580808008100101003F0001050304000009000A8501000B008C808080088501000C000E8D01010302048D010109000A9101000B008C808080089101000C000E1002010001
Content: 55947829059F255ED50100001B9C495D3463E1D04C551E9517F40F4F0101004A013B0E2F02100201000105010F001409001600190D001A009B808080080D001B040400011402858080800810010100230001050104000009000A15000B008C8080800815000C000E11010402818080800810010100011D010126021D01070008210009008A8080800821000A000C1001010001250103000D25000E0283808080081001010001000103210229000A000B2D000C008D808080082D000D03043501030204350109000A39000B008C8080800839000C000E1002010001310103000D31000E0181808080084101011B024501011A024901011902490207000C4D000D0185808080084D0105000F5100100283808080081001010001510103140255000A000F5900100091808080085900110A04610103090420009901010D000E00001006918080800869010501112069000005000B0001120185808080086D01050112206D000005000B00011301858080800871010501112071000005000B5D030402838080800810010100015D0103080275000F0015790017001A7D001B009C808080087D001C0604000115028580808008100101003F0001050304000009000A8501000B008C808080088501000C000E8D01010302048D010109000A9101000B008C808080089101000C000E1002010001
- Name: '__llvm_covfun (4)'
Type: SHT_PROGBITS
Flags: [ SHF_GNU_RETAIN ]
AddressAlign: 0x8
Content: 7129CA3C268292BF4D0100003E688383C9A099004C551E9517F40F4F01010035016C112502100201011C000217028A80808008090103010A05020402838080800810010100620501031C020D003F0046110048004B15004C00CD8080800815004D1704000119148F80808008210105130F21010B000C25000D008E8080800825000E001010010100152D0105100F2D010B000C31000D008E8080800831000E0010350107000C35000D0185808080083901050D0F39010B000C3D000D008E808080083D000E0010410107000F4100100185808080084501050A0F45010B000C49000D008E8080800849000E00104D0107080F000012039180808008550107021155010D000E59000F00908080800859001000125D010900115101080285808080081001010001610105020F61010B0017650018018980808008650109000F1902040383808080081001010121190203020219000700116D00120093808080086D001300151001010001
Content: 7129CA3C268292BF8B0100003E688383C9A099004C551E9517F40F4F010103292D516151613D016C112502100201011C000217028A80808008090103010A2009000003000A05020402838080800810010100620501031C020D003F0046110048004B15004C00CD8080800815004D1704000119148F80808008210105130F2021000005000B21010B000C25000D008E8080800825000E00101001010015030105100F202D000005000B03010B000C31000D008E8080800831000E0010350107000C35000D0185808080083901050D0F2039000005000B39010B000C3D000D008E808080083D000E0010410107000F4100100185808080084501050A0F2045000005000B45010B000C49000D008E8080800849000E00104D0107080F200075000F001000001203918080800855010702112055000007001355010D000E59000F00908080800859001000125D0109001151010802858080800810010100010B0105020F2061000005000C0B010B0017650018018980808008650109000F1902040383808080081001010121190203020219000700116D00120093808080086D001300151001010001
- Name: '__llvm_covfun (5)'
Type: SHT_PROGBITS
Flags: [ SHF_GNU_RETAIN ]
AddressAlign: 0x8
Content: 3F4D1C6E6087417B32010000D6FF56B8865A69B64C551E9517F40F4F01010031019301131F02050113001909001B001E0D001F00A0808080080D00201C04000115198C80808008190105180C19010B000C1D000D008E808080081D000E00101001010015250105150C25010B000C29000D008E8080800829000E00102D0107000C2D000D018580808008310105120C31010B000C35000D008E8080800835000E0010390107000C39000D03858080800810010101013D02050D0C3D010B000C41000D008E8080800841000E0010450107000C45000D0185808080084901050A0C49010B000C4D000D008E808080084D000E0010510107000C51000D0385808080081001010101550205050C55010B000C59000D008E8080800859000E00105D0107000C5D000D018580808008610105020C61010B000C65000D008E8080800865000E0010690107000C1003010001
Content: 3F4D1C6E6087417B65010000D6FF56B8865A69B64C551E9517F40F4F010101212538019301131F02050113001909001B001E0D001F00A0808080080D00201C04000115198C80808008190105180C2019000005001219010B000C1D000D008E808080081D000E00101001010015030105150C2025000005001203010B000C29000D008E8080800829000E00102D0107000C2D000D018580808008310105120C2031000005002031010B000C35000D008E8080800835000E0010390107000C39000D03858080800810010101013D02050D0C203D00000500133D010B000C41000D008E8080800841000E0010450107000C45000D0185808080084901050A0C2049000005002149010B000C4D000D008E808080084D000E0010510107000C51000D0385808080081001010101550205050C2055000005002755010B000C59000D008E8080800859000E00105D0107000C5D000D018580808008610105020C2061000005000C61010B000C65000D008E8080800865000E0010690107000C1003010001
- Name: '__llvm_covfun (6)'
Type: SHT_PROGBITS
Flags: [ SHF_GNU_RETAIN ]
Expand Down Expand Up @@ -124,19 +124,19 @@ Symbols:
Type: STT_OBJECT
Section: '__llvm_covfun (3)'
Binding: STB_WEAK
Size: 0x1D4
Size: 0x1F1
Other: [ STV_HIDDEN ]
- Name: __covrec_BF9282263CCA2971u
Type: STT_OBJECT
Section: '__llvm_covfun (4)'
Binding: STB_WEAK
Size: 0x169
Size: 0x1A7
Other: [ STV_HIDDEN ]
- Name: __covrec_7B4187606E1C4D3Fu
Type: STT_OBJECT
Section: '__llvm_covfun (5)'
Binding: STB_WEAK
Size: 0x14E
Size: 0x181
Other: [ STV_HIDDEN ]
- Name: __covrec_58A39A89A88AA459u
Type: STT_OBJECT
Expand Down
32 changes: 16 additions & 16 deletions llvm/test/tools/llvm-cov/Inputs/branch-c-general.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ void jumps() { // CHECK: @LINE|{{.*}}jumps()
while (i < 3) { // BRCOV: Branch ([[@LINE]]:10): [True: 0, False: 1]
loop2:
switch (i) {
case 0: // BRCOV: Branch ([[@LINE]]:5): [True: 1, Folded]
case 0: // CHECK: Branch ([[@LINE]]:5): [True: 1, Folded]
goto first;
case 1: // BRCOV: Branch ([[@LINE]]:5): [True: 1, Folded]
case 1: // CHECK: Branch ([[@LINE]]:5): [True: 1, Folded]
goto second;
case 2: // BRCOV: Branch ([[@LINE]]:5): [True: 1, Folded]
case 2: // CHECK: Branch ([[@LINE]]:5): [True: 1, Folded]
goto third;
}
}
Expand All @@ -110,30 +110,30 @@ void switches() { // CHECK: @LINE|{{.*}}switches()

// No cases -> no weights
switch (weights[0]) {
default: // BRCOV: Branch ([[@LINE]]:3): [True: 1, Folded]
default: // CHECK: Branch ([[@LINE]]:3): [True: 1, Folded]
break;
}
// BRCOV: Branch ([[@LINE+1]]:63): [True: [[#min(C,15)]], False: 0]
for (int i = 0, len = sizeof(weights) / sizeof(weights[0]); i < len; ++i) {
switch (i[weights]) {
case 1: // BRCOV: Branch ([[@LINE]]:5): [True: 1, Folded]
case 1: // CHECK: Branch ([[@LINE]]:5): [True: 1, Folded]
if (i) {} // BRCOV: Branch ([[@LINE]]:11): [True: 0, False: 1]
// fallthrough
case 2: // BRCOV: Branch ([[@LINE]]:5): [True: [[#min(C,2)]], Folded]
case 2: // CHECK: Branch ([[@LINE]]:5): [True: [[#min(C,2)]], Folded]
if (i) {} // BRCOV: Branch ([[@LINE]]:11): [True: [[#min(C,2)]], False: 1]
break;
case 3: // BRCOV: Branch ([[@LINE]]:5): [True: [[#min(C,3)]], Folded]
case 3: // CHECK: Branch ([[@LINE]]:5): [True: [[#min(C,3)]], Folded]
if (i) {} // BRCOV: Branch ([[@LINE]]:11): [True: [[#min(C,3)]], False: 0]
continue;
case 4: // BRCOV: Branch ([[@LINE]]:5): [True: [[#min(C,4)]], Folded]
case 4: // CHECK: Branch ([[@LINE]]:5): [True: [[#min(C,4)]], Folded]
if (i) {} // BRCOV: Branch ([[@LINE]]:11): [True: [[#min(C,4)]], False: 0]
switch (i) {
case 6 ... 9: // BRCOV: Branch ([[@LINE]]:7): [True: [[#min(C,4)]], Folded]
case 6 ... 9: // CHECK: Branch ([[@LINE]]:7): [True: [[#min(C,4)]], Folded]
if (i) {} // BRCOV: Branch ([[@LINE]]:13): [True: [[#min(C,4)]], False: 0]
continue;
}

default: // BRCOV: Branch ([[@LINE]]:5): [True: [[#min(C,5)]], Folded]
default: // CHECK: Branch ([[@LINE]]:5): [True: [[#min(C,5)]], Folded]
if (i == len - 1) // BRCOV: Branch ([[@LINE]]:11): [True: 1, False: [[#min(C,4)]]]
return;
}
Expand All @@ -147,29 +147,29 @@ void switches() { // CHECK: @LINE|{{.*}}switches()
void big_switch() { // CHECK: @LINE|{{.*}}big_switch()
for (int i = 0; i < 32; ++i) {// BRCOV: Branch ([[@LINE]]:19): [True: [[#min(C,32)]], False: 1]
switch (1 << i) {
case (1 << 0): // BRCOV: Branch ([[@LINE]]:5): [True: 1, Folded]
case (1 << 0): // CHECK: Branch ([[@LINE]]:5): [True: 1, Folded]
if (i) {} // BRCOV: Branch ([[@LINE]]:11): [True: 0, False: 1]
// fallthrough
case (1 << 1): // BRCOV: Branch ([[@LINE]]:5): [True: 1, Folded]
case (1 << 1): // CHECK: Branch ([[@LINE]]:5): [True: 1, Folded]
if (i) {} // BRCOV: Branch ([[@LINE]]:11): [True: 1, False: 1]
break;
case (1 << 2) ... (1 << 12):// BRCOV: Branch ([[@LINE]]:5): [True: [[#min(C,11)]], Folded]
case (1 << 2) ... (1 << 12):// CHECK: Branch ([[@LINE]]:5): [True: [[#min(C,11)]], Folded]
if (i) {} // BRCOV: Branch ([[@LINE]]:11): [True: [[#min(C,11)]], False: 0]
break;
// The branch for the large case range above appears after the case body.

case (1 << 13): // BRCOV: Branch ([[@LINE]]:5): [True: 1, Folded]
case (1 << 13): // CHECK: Branch ([[@LINE]]:5): [True: 1, Folded]
if (i) {} // BRCOV: Branch ([[@LINE]]:11): [True: 1, False: 0]
break;
case (1 << 14) ... (1 << 28)://BRCOV: Branch ([[@LINE]]:5): [True: [[#min(C,15)]], Folded]
case (1 << 14) ... (1 << 28)://CHECK: Branch ([[@LINE]]:5): [True: [[#min(C,15)]], Folded]
if (i) {} // BRCOV: Branch ([[@LINE]]:11): [True: [[#min(C,15)]], False: 0]
break;
// The branch for the large case range above appears after the case body.

case (1 << 29) ... ((1 << 29) + 1):
if (i) {} // BRCOV: Branch ([[@LINE]]:11): [True: 1, False: 0]
break;
default: // BRCOV: Branch ([[@LINE]]:5): [True: [[#min(C,2)]], Folded]
default: // CHECK: Branch ([[@LINE]]:5): [True: [[#min(C,2)]], Folded]
if (i) {} // BRCOV: Branch ([[@LINE]]:11): [True: [[#min(C,2)]], False: 0]
break;
}
Expand Down
Loading