diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-10 19:24:41 +0900 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-10 19:24:41 +0900 |
commit | 0350c1eba1c1a6b73a8d9c271a7f3c8b33202579 (patch) | |
tree | 8a95b96f4b22be54786dd55e66615ab5e517a2eb | |
parent | 8afb2ffcd828ae9563293f51780a2e636c3ba132 (diff) | |
download | llvm-users/chapuni/cov/merge/region_segment.zip llvm-users/chapuni/cov/merge/region_segment.tar.gz llvm-users/chapuni/cov/merge/region_segment.tar.bz2 |
Move mcdc-templates-merge.test from #121194users/chapuni/cov/merge/region_segment
5 files changed, 264 insertions, 0 deletions
diff --git a/llvm/test/tools/llvm-cov/Inputs/mcdc-templates-merge.cpp b/llvm/test/tools/llvm-cov/Inputs/mcdc-templates-merge.cpp new file mode 100644 index 0000000..0abb308 --- /dev/null +++ b/llvm/test/tools/llvm-cov/Inputs/mcdc-templates-merge.cpp @@ -0,0 +1,51 @@ +#include <cstdio> + +template <typename Ty> +bool ab(Ty a, Ty b) { + return (a && b); +} +// CHECK: [[@LINE-2]]| 4| return + +// CHECK: MC/DC Coverage for Decision{{[:]}} 50.00% +// CHECK: MC/DC Coverage for Decision{{[:]}} 50.00% +// CHECK: MC/DC Coverage for Decision{{[:]}} 0.00% +// CHECK-NOT: MC/DC Coverage for Decision{{[:]}} + +// CHECK: _Z2abIbEbT_S0_{{[:]}} +// CHECK: | | MC/DC Coverage for Decision{{[:]}} 50.00% + +// CHECK: _Z2abIxEbT_S0_{{[:]}} +// CHECK: | | MC/DC Coverage for Decision{{[:]}} 50.00% + +// CHECK: Unexecuted instantiation{{[:]}} _Z2abIdEbT_S0_ + +template <bool C> +bool Cab(bool a, bool b) { + return (a && b && C); +} +// CHECK: [[@LINE-2]]| 4| return + +// CHECK: MC/DC Coverage for Decision{{[:]}} 0.00% +// CHECK: MC/DC Coverage for Decision{{[:]}} 50.00% +// CHECK-NOT: MC/DC Coverage for Decision{{[:]}} + +// CHECK: _Z3CabILb0EEbbb{{[:]}} +// CHECK: | | MC/DC Coverage for Decision{{[:]}} 0.00% + +// CHECK: _Z3CabILb1EEbbb{{[:]}} +// CHECK: | | MC/DC Coverage for Decision{{[:]}} 50.00% + +// CHECK: [[@LINE+1]]| 1|int main +int main(int argc, char **argv) { + printf("%d\n", Cab<false>(false, false)); + printf("%d\n", Cab<false>(true, true)); + printf("%d\n", Cab<true>(true, false)); + printf("%d\n", Cab<true>(true, true)); + printf("%d\n", ab(false, false)); + printf("%d\n", ab(true, true)); + printf("%d\n", ab(1LL, 0LL)); + printf("%d\n", ab(1LL, 1LL)); + if (argc == 2) + printf("%d\n", ab(0.0, 0.0)); + return 0; +} diff --git a/llvm/test/tools/llvm-cov/Inputs/mcdc-templates-merge.proftext b/llvm/test/tools/llvm-cov/Inputs/mcdc-templates-merge.proftext new file mode 100644 index 0000000..6136946 --- /dev/null +++ b/llvm/test/tools/llvm-cov/Inputs/mcdc-templates-merge.proftext @@ -0,0 +1,73 @@ +_Z2abIbEbT_S0_ +# Func Hash: +1550 +# Num Counters: +3 +# Counter Values: +2 +1 +1 +# Num Bitmap Bytes: +$1 +# Bitmap Byte Values: +0x5 + + +_Z2abIxEbT_S0_ +# Func Hash: +1550 +# Num Counters: +3 +# Counter Values: +2 +2 +1 +# Num Bitmap Bytes: +$1 +# Bitmap Byte Values: +0x6 + + +_Z3CabILb0EEbbb +# Func Hash: +99214 +# Num Counters: +5 +# Counter Values: +2 +1 +0 +1 +1 +# Num Bitmap Bytes: +$1 +# Bitmap Byte Values: +0x5 + + +_Z3CabILb1EEbbb +# Func Hash: +99214 +# Num Counters: +5 +# Counter Values: +2 +1 +1 +2 +1 +# Num Bitmap Bytes: +$1 +# Bitmap Byte Values: +0xa + + +main +# Func Hash: +175973464 +# Num Counters: +2 +# Counter Values: +1 +0 + diff --git a/llvm/test/tools/llvm-cov/Inputs/mcdc-templates-merge.yaml b/llvm/test/tools/llvm-cov/Inputs/mcdc-templates-merge.yaml new file mode 100644 index 0000000..ba46319 --- /dev/null +++ b/llvm/test/tools/llvm-cov/Inputs/mcdc-templates-merge.yaml @@ -0,0 +1,105 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + OSABI: ELFOSABI_GNU + Type: ET_REL + Machine: EM_X86_64 + SectionHeaderStringTable: .strtab +Sections: + - Name: __llvm_covfun + Type: SHT_PROGBITS + Flags: [ SHF_GNU_RETAIN ] + AddressAlign: 0x8 + Content: FAD58DE7366495DB2500000058247D0A00000000249EC986A505B62F0101010105050127210C020109070010200502000700100500110185808080080501050021 + - Name: '__llvm_covfun (1)' + Type: SHT_PROGBITS + Flags: [ SHF_GNU_RETAIN ] + AddressAlign: 0x8 + Content: 9CC3B348501DBFE8480000008E83010000000000249EC986A505B62F010103010D0D1105090901171A020201010B000C01000B0011280403000B0016300D02010300000B000C0D0010001130110603020000100011050015001630000A02000000150016 + - Name: '__llvm_covfun (2)' + Type: SHT_PROGBITS + Flags: [ SHF_GNU_RETAIN ] + AddressAlign: 0x8 + Content: 9873627177A03F8E460000008E83010000000000249EC986A505B62F010102010D0D110901171A020201010B000C01000B0011280403000B0016300D02010300000B000C0D0010001130110603020000100011050015001630090002000000150016 + - Name: '__llvm_covfun (3)' + Type: SHT_PROGBITS + Flags: [ SHF_GNU_RETAIN ] + AddressAlign: 0x8 + Content: BF407A207503B266320000000E06000000000000249EC986A505B62F0101020105050906010415020201010B000C280302000B0011300502010200000B000C050010001130090602000000100011 + - Name: '__llvm_covfun (4)' + Type: SHT_PROGBITS + Flags: [ SHF_GNU_RETAIN ] + AddressAlign: 0x8 + Content: 8A05A22CB467C37D320000000E06000000000000249EC986A505B62F0101020105050906010415020201010B000C280302000B0011300502010200000B000C050010001130090602000000100011 + - Name: '__llvm_covfun (5)' + Type: SHT_PROGBITS + Flags: [ SHF_GNU_RETAIN ] + AddressAlign: 0x8 + Content: 1700192CAC8F3F26320000000E06000000000000249EC986A505B62F0101020105050906010415020201010B000C280302000B0011300502010200000B000C050010001130090602000000100011 + - Name: __llvm_covmap + Type: SHT_PROGBITS + Flags: [ SHF_GNU_RETAIN ] + AddressAlign: 0x8 + Content: 000000001D0000000000000006000000021A0000186D6364632D74656D706C617465732D6D657267652E637070000000 + - Name: __llvm_prf_names + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_GNU_RETAIN ] + AddressAlign: 0x1 + Content: 51006D61696E015F5A33436162494C62304545626262015F5A33436162494C62314545626262015F5A32616249624562545F53305F015F5A32616249784562545F53305F015F5A32616249644562545F53305F + - Type: SectionHeaderTable + Sections: + - Name: .strtab + - Name: __llvm_covfun + - Name: '__llvm_covfun (1)' + - Name: '__llvm_covfun (2)' + - Name: '__llvm_covfun (3)' + - Name: '__llvm_covfun (4)' + - Name: '__llvm_covfun (5)' + - Name: __llvm_covmap + - Name: __llvm_prf_names + - Name: .symtab +Symbols: + - Name: __llvm_covmap + Type: STT_SECTION + Section: __llvm_covmap + - Name: __llvm_prf_names + Type: STT_SECTION + Section: __llvm_prf_names + - Name: __covrec_DB956436E78DD5FAu + Type: STT_OBJECT + Section: __llvm_covfun + Binding: STB_WEAK + Size: 0x41 + Other: [ STV_HIDDEN ] + - Name: __covrec_E8BF1D5048B3C39Cu + Type: STT_OBJECT + Section: '__llvm_covfun (1)' + Binding: STB_WEAK + Size: 0x64 + Other: [ STV_HIDDEN ] + - Name: __covrec_8E3FA07771627398u + Type: STT_OBJECT + Section: '__llvm_covfun (2)' + Binding: STB_WEAK + Size: 0x62 + Other: [ STV_HIDDEN ] + - Name: __covrec_66B20375207A40BFu + Type: STT_OBJECT + Section: '__llvm_covfun (3)' + Binding: STB_WEAK + Size: 0x4E + Other: [ STV_HIDDEN ] + - Name: __covrec_7DC367B42CA2058Au + Type: STT_OBJECT + Section: '__llvm_covfun (4)' + Binding: STB_WEAK + Size: 0x4E + Other: [ STV_HIDDEN ] + - Name: __covrec_263F8FAC2C190017u + Type: STT_OBJECT + Section: '__llvm_covfun (5)' + Binding: STB_WEAK + Size: 0x4E + Other: [ STV_HIDDEN ] +... diff --git a/llvm/test/tools/llvm-cov/branch-macros.test b/llvm/test/tools/llvm-cov/branch-macros.test index 2ff4355..b60da15 100644 --- a/llvm/test/tools/llvm-cov/branch-macros.test +++ b/llvm/test/tools/llvm-cov/branch-macros.test @@ -1,5 +1,7 @@ // RUN: llvm-profdata merge %S/Inputs/branch-macros.proftext -o %t.profdata // RUN: llvm-cov show --show-expansions --show-branches=count %S/Inputs/branch-macros.o32l -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs | FileCheck %S/Inputs/branch-macros.cpp -check-prefixes=CHECK,BRCOV -D#C=999 +// RUN: llvm-cov report --show-branch-summary %S/Inputs/branch-macros.o32l -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs %S/Inputs/branch-macros.cpp | FileCheck %s -check-prefix=FILE + // RUN: llvm-cov show --binary-counters --show-expansions --show-branches=count %S/Inputs/branch-macros.o32l -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs | FileCheck %S/Inputs/branch-macros.cpp -check-prefixes=CHECK,BRCOV -D#C=1 // RUN: llvm-cov report --show-branch-summary %S/Inputs/branch-macros.o32l -instr-profile %t.profdata -show-functions -path-equivalence=/tmp,%S/Inputs %S/Inputs/branch-macros.cpp | FileCheck %s -check-prefix=REPORT @@ -14,3 +16,9 @@ // REPORT-NEXT: main 1 0 100.00% 6 0 100.00% 0 0 0.00% // REPORT-NEXT: --- // REPORT-NEXT: TOTAL 16 4 75.00% 32 0 100.00% 40 16 60.00% + +// FILE: Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover Branches Missed Branches Cover +// FILE-NEXT: --- +// FILE-NEXT: branch-macros.cpp 16 4 75.00% 3 0 100.00% 32 0 100.00% 40 16 60.00% +// FILE-NEXT: --- +// FILE-NEXT: TOTAL 16 4 75.00% 3 0 100.00% 32 0 100.00% 40 16 60.00% diff --git a/llvm/test/tools/llvm-cov/mcdc-templates-merge.test b/llvm/test/tools/llvm-cov/mcdc-templates-merge.test new file mode 100644 index 0000000..cacd3b6b --- /dev/null +++ b/llvm/test/tools/llvm-cov/mcdc-templates-merge.test @@ -0,0 +1,27 @@ +# Test `merge-instantiations=merge/any/all` + +RUN: yaml2obj %S/Inputs/mcdc-templates-merge.yaml -o %t.o +RUN: llvm-profdata merge %S/Inputs/mcdc-templates-merge.proftext -o %t.profdata + +RUN: llvm-cov show --show-mcdc -show-instantiations=true %t.o -instr-profile %t.profdata -path-equivalence=.,%S/Inputs | FileCheck %S/Inputs/mcdc-templates-merge.cpp + +RUN: llvm-cov report --show-mcdc-summary %t.o -instr-profile %t.profdata -path-equivalence=.,%S/Inputs | FileCheck %s + +REPORT: mcdc-templates-merge.cpp + +# Regions +CHECK: 10 1 90.00% + +# Functions +CHECK: 3 0 100.00% + +# Lines +CHECK: 19 1 94.74% + +# Branches +CHECK: 11 3 72.73% + +# MC/DC Conditions +CHECK: 4 2 50.00% + +REPORT: TOTAL |