Allows llvm-cov to read GCOV data generated by CLANG 3.6
Vanderson Martins do Rosario
vandersonmr2 at gmail.com
Thu Feb 5 15:18:03 PST 2015
I'm sending the test.
That's the first time that I'm sending code for an open source project, so
let me know if I did something wrong ;)
Vanderson M. Rosario
2015-02-05 17:25 GMT-02:00 Justin Bogner <mail at justinbogner.com>:
> Vanderson Martins do Rosario <vandersonmr2 at gmail.com> writes:
> > FIX bug 22436. llvm-cov now allows to continuing reading gcda file if it
> has
> > arcs from exit block, and just showing a message warning about that in
> the
> > same way as GNU gcov.
>
> Can you add a test for this please?
>
> > Vanderson M. Rosario
> >
> >
> > diff --git a/lib/IR/GCOV.cpp b/lib/IR/GCOV.cpp
> > index 245c500..c43cb99 100644
> > --- a/lib/IR/GCOV.cpp
> > +++ b/lib/IR/GCOV.cpp
> > @@ -263,10 +263,13 @@ bool GCOVFunction::readGCDA(GCOVBuffer &Buff,
> GCOV::GCOVVersion Version) {
> > // required to combine the edge counts that are contained in the GCDA
> file.
> > for (uint32_t BlockNo = 0; Count > 0; ++BlockNo) {
> > // The last block is always reserved for exit block
> > - if (BlockNo >= Blocks.size()-1) {
> > + if (BlockNo > Blocks.size()-1) {
> > errs() << "Unexpected number of edges (in " << Name << ").\n";
> > return false;
> > }
> > + if (BlockNo == Blocks.size()-1) {
> > + errs() << "(" << Name << ") has arcs from exit block.\n";
> > + }
> > GCOVBlock &Block = *Blocks[BlockNo];
> > for (size_t EdgeNo = 0, End = Block.getNumDstEdges(); EdgeNo < End;
> > ++EdgeNo) {
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150205/2ac81517/attachment.html>
-------------- next part --------------
diff --git a/test/tools/llvm-cov/Inputs/test_exit_block_arcs.cpp.gcov b/test/tools/llvm-cov/Inputs/test_exit_block_arcs.cpp.gcov
new file mode 100644
index 0000000..d4a8990
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_exit_block_arcs.cpp.gcov
@@ -0,0 +1,79 @@
+ -: 0:Source:test.cpp
+ -: 0:Graph:test_exit_block_arcs.gcno
+ -: 0:Data:test_exit_block_arcs.gcda
+ -: 0:Runs:2
+ -: 0:Programs:1
+ -: 1:#include "test.h"
+ -: 2:#include <cstdlib>
+ -: 3:
+ -: 4:bool on = false;
+ -: 5:int len = 42;
+ -: 6:double grid[10][10] = {0};
+ -: 7:const char * hello = "world";
+ -: 8:const char * world = "hello";
+ -: 9:
+8589934592: 10:void A::B() {}
+ -: 11:
+ #####: 12:void useless() {}
+ -: 13:
+ -: 14:double more_useless() {
+ #####: 15: return 0;
+ -: 16:}
+ -: 17:
+ -: 18:int foo() {
+ 2: 19: on = true;
+ 2: 20: return 3;
+ -: 21:}
+ -: 22:
+ -: 23:int bar() {
+ #####: 24: len--;
+ #####: 25: return foo() + 45;
+ -: 26:}
+ -: 27:
+ -: 28:void assign(int ii, int jj) {
+ 8: 29: grid[ii][jj] = (ii+1) * (jj+1);
+ 8: 30:}
+ -: 31:
+ -: 32:void initialize_grid() {
+ 12: 33: for (int ii = 0; ii < 2; ii++)
+ 24: 34: for (int jj = 0; jj < 2; jj++)
+ 12: 35: assign(ii, jj);
+ 2: 36:}
+ -: 37:
+ -: 38:int main() {
+ 2: 39: initialize_grid();
+ -: 40:
+ 2: 41: int a = 2;
+ 2: 42: on = rand() % 2;
+ 2: 43: if (on) {
+ 2: 44: foo();
+ 2: 45: ++a;
+ 2: 46: } else {
+ #####: 47: bar();
+ #####: 48: a += rand();
+ -: 49: }
+ -: 50:
+ 44: 51: for (int ii = 0; ii < 10; ++ii) {
+ 20: 52: switch (rand() % 5) {
+ -: 53: case 0:
+ 4: 54: a += rand();
+ 4: 55: break;
+ -: 56: case 1:
+ -: 57: case 2:
+ 8: 58: a += rand() / rand();
+ 8: 59: break;
+ -: 60: case 3:
+ 6: 61: a -= rand();
+ 6: 62: break;
+ -: 63: default:
+ 2: 64: a = -1;
+ 2: 65: }
+ 20: 66: }
+ -: 67:
+ 2: 68: A thing;
+17179869188: 69: for (uint64_t ii = 0; ii < 4294967296; ++ii)
+8589934592: 70: thing.B();
+ -: 71:
+ 2: 72: return a + 8 + grid[2][3] + len;
+ -: 73: return more_useless();
+ -: 74:}
diff --git a/test/tools/llvm-cov/Inputs/test_exit_block_arcs.gcda b/test/tools/llvm-cov/Inputs/test_exit_block_arcs.gcda
new file mode 100644
index 0000000..c4592e5
Binary files /dev/null and b/test/tools/llvm-cov/Inputs/test_exit_block_arcs.gcda differ
diff --git a/test/tools/llvm-cov/Inputs/test_exit_block_arcs.gcno b/test/tools/llvm-cov/Inputs/test_exit_block_arcs.gcno
new file mode 100644
index 0000000..874883d
Binary files /dev/null and b/test/tools/llvm-cov/Inputs/test_exit_block_arcs.gcno differ
diff --git a/test/tools/llvm-cov/Inputs/test_exit_block_arcs.output b/test/tools/llvm-cov/Inputs/test_exit_block_arcs.output
new file mode 100644
index 0000000..f7f62f7
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_exit_block_arcs.output
@@ -0,0 +1,17 @@
+(_ZN1A1BEv) has arcs from exit block.
+(_Z7uselessv) has arcs from exit block.
+(_Z12more_uselessv) has arcs from exit block.
+(_Z3foov) has arcs from exit block.
+(_Z3barv) has arcs from exit block.
+(_Z6assignii) has arcs from exit block.
+(_Z15initialize_gridv) has arcs from exit block.
+(main) has arcs from exit block.
+(_ZN1AC2Ev) has arcs from exit block.
+File 'test.cpp'
+Lines executed:83.78% of 37
+test.cpp:creating 'test.cpp.gcov'
+
+File './test.h'
+Lines executed:100.00% of 1
+./test.h:creating 'test.h.gcov'
+
diff --git a/test/tools/llvm-cov/llvm-cov.test b/test/tools/llvm-cov/llvm-cov.test
index 0d3eb6b..9fb6662 100644
--- a/test/tools/llvm-cov/llvm-cov.test
+++ b/test/tools/llvm-cov/llvm-cov.test
@@ -110,4 +110,8 @@ RUN: llvm-cov test.c -gcda=test_file_checksum_fail.gcda
# Bad function checksum on gcda
RUN: llvm-cov test.c -gcda=test_func_checksum_fail.gcda
+# Has arcs from exit blocks
+RUN: llvm-cov test_exit_block_arcs.gcda 2>&1| tail -n17 | diff -u test_exit_block_arcs.output -
+RUN: diff -aub test_exit_block_arcs.cpp.gcov test.cpp.gcov
+
XFAIL: powerpc64-, s390x, mips-, mips64-, sparc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_exit_block_arcs.gcno
Type: application/octet-stream
Size: 3372 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150205/2ac81517/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_exit_block_arcs.gcda
Type: application/octet-stream
Size: 848 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150205/2ac81517/attachment-0001.obj>
More information about the llvm-commits
mailing list