From: Justin Bogner Date: Tue, 17 Mar 2015 00:18:51 +0000 (+0000) Subject: llvm-cov: Warn instead of error if a .gcda has arcs from an exit block X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=bdd2212363c440b17b8664c90f67c6f9910ff7c7;p=oota-llvm.git llvm-cov: Warn instead of error if a .gcda has arcs from an exit block Patch by Vanderson M. Rosario. Thanks! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232443 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/IR/GCOV.cpp b/lib/IR/GCOV.cpp index 08f44e079a4..b0a2bae4e06 100644 --- a/lib/IR/GCOV.cpp +++ b/lib/IR/GCOV.cpp @@ -302,10 +302,12 @@ 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()) { 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) { 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 00000000000..3ca483d1f46 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 00000000000..d453566282f Binary files /dev/null and b/test/tools/llvm-cov/Inputs/test_exit_block_arcs.gcno differ diff --git a/test/tools/llvm-cov/llvm-cov.test b/test/tools/llvm-cov/llvm-cov.test index 6a71120c882..ad4ceefbbce 100644 --- a/test/tools/llvm-cov/llvm-cov.test +++ b/test/tools/llvm-cov/llvm-cov.test @@ -111,4 +111,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.c 2>&1 | FileCheck %s -check-prefix=EXIT_BLOCK_ARCS +EXIT_BLOCK_ARCS: (main) has arcs from exit block. + XFAIL: powerpc64-, s390x, mips-, mips64-, sparc