mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[gcov] Default coverage version to '408*' and delete CC1 option -coverage-exit-block-before-body
gcov 4.8 (r189778) moved the exit block from the last to the second. The .gcda format is compatible with 4.7 but * decoding libgcov 4.7 produced .gcda with gcov [4.7,8) can mistake the exit block, emit bogus `%s:'%s' has arcs from exit block\n` warnings, and print wrong `" returned %s` for branch statistics (-b). * decoding libgcov 4.8 produced .gcda with gcov 4.7 has similar issues. Also, rename "return block" to "exit block" because the latter is the appropriate term.
This commit is contained in:
parent
be614d055d
commit
595401e441
@ -41,7 +41,7 @@ class FileInfo;
|
||||
|
||||
namespace GCOV {
|
||||
|
||||
enum GCOVVersion { V402, V407, V800, V900 };
|
||||
enum GCOVVersion { V402, V407, V408, V800, V900 };
|
||||
|
||||
/// A struct for passing gcov options between functions.
|
||||
struct Options {
|
||||
@ -108,8 +108,12 @@ public:
|
||||
// PR gcov-profile/48463
|
||||
Version = GCOV::V800;
|
||||
return true;
|
||||
} else if (Major > 4 || (Major == 4 && Minor >= 7)) {
|
||||
// r173147
|
||||
} else if (Major > 4 || (Major == 4 && Minor >= 8)) {
|
||||
// r189778: the exit block moved from the last to the second.
|
||||
Version = GCOV::V408;
|
||||
return true;
|
||||
} else if (Major == 4 && Minor >= 7) {
|
||||
// r173147: split checksum into cfg checksum and line checksum.
|
||||
Version = GCOV::V407;
|
||||
return true;
|
||||
} else {
|
||||
|
@ -66,10 +66,6 @@ struct GCOVOptions {
|
||||
// Add the 'noredzone' attribute to added runtime library calls.
|
||||
bool NoRedZone;
|
||||
|
||||
// Emit the exit block immediately after the start block, rather than after
|
||||
// all of the function body's blocks.
|
||||
bool ExitBlockBeforeBody;
|
||||
|
||||
// Regexes separated by a semi-colon to filter the files to instrument.
|
||||
std::string Filter;
|
||||
|
||||
|
@ -50,17 +50,14 @@ using namespace llvm;
|
||||
#define DEBUG_TYPE "insert-gcov-profiling"
|
||||
|
||||
static cl::opt<std::string> DefaultGCOVVersion("default-gcov-version",
|
||||
cl::init("407*"), cl::Hidden,
|
||||
cl::init("408*"), cl::Hidden,
|
||||
cl::ValueRequired);
|
||||
static cl::opt<bool> DefaultExitBlockBeforeBody("gcov-exit-block-before-body",
|
||||
cl::init(false), cl::Hidden);
|
||||
|
||||
GCOVOptions GCOVOptions::getDefault() {
|
||||
GCOVOptions Options;
|
||||
Options.EmitNotes = true;
|
||||
Options.EmitData = true;
|
||||
Options.NoRedZone = false;
|
||||
Options.ExitBlockBeforeBody = DefaultExitBlockBeforeBody;
|
||||
|
||||
if (DefaultGCOVVersion.size() != 4) {
|
||||
llvm::report_fatal_error(std::string("Invalid -default-gcov-version: ") +
|
||||
@ -747,9 +744,9 @@ void GCOVProfiler::emitProfileNotes() {
|
||||
EntryBlock.splitBasicBlock(It);
|
||||
|
||||
bool UseCfgChecksum = strncmp(Options.Version, "407", 3) >= 0;
|
||||
bool ExitBlockBeforeBody = strncmp(Options.Version, "408", 3) >= 0;
|
||||
Funcs.push_back(std::make_unique<GCOVFunction>(
|
||||
SP, &F, &out, FunctionIdent++, UseCfgChecksum,
|
||||
Options.ExitBlockBeforeBody));
|
||||
SP, &F, &out, FunctionIdent++, UseCfgChecksum, ExitBlockBeforeBody));
|
||||
GCOVFunction &Func = *Funcs.back();
|
||||
|
||||
// Add the function line number to the lines of the entry block
|
||||
|
@ -1,24 +1,24 @@
|
||||
; Inject metadata to set the .gcno file location
|
||||
; RUN: rm -rf %t && mkdir -p %t
|
||||
; RUN: echo '!19 = !{!"%/t/return-block.ll", !0}' > %t/1
|
||||
; RUN: echo '!19 = !{!"%/t/exit-block.ll", !0}' > %t/1
|
||||
; RUN: cat %s %t/1 > %t/2
|
||||
|
||||
; By default, the return block is last.
|
||||
; By default, the exit block is the second.
|
||||
; RUN: opt -insert-gcov-profiling -disable-output %t/2
|
||||
; RUN: llvm-cov gcov -n -dump %t/return-block.gcno 2>&1 | FileCheck -check-prefix=CHECK -check-prefix=RETURN-LAST %s
|
||||
; RUN: llvm-cov gcov -n -dump %t/exit-block.gcno 2>&1 | FileCheck --check-prefixes=CHECK,EXIT-SECOND %s
|
||||
|
||||
; But we can optionally emit it second, to match newer gcc versions.
|
||||
; RUN: opt -insert-gcov-profiling -gcov-exit-block-before-body -disable-output %t/2
|
||||
; RUN: llvm-cov gcov -n -dump %t/return-block.gcno 2>&1 | FileCheck -check-prefix=CHECK -check-prefix=RETURN-SECOND %s
|
||||
; RUN: rm %t/return-block.gcno
|
||||
; But we can optionally emit it last, to match GCC<4.8 (r189778).
|
||||
; RUN: opt -insert-gcov-profiling -default-gcov-version='407*' -disable-output %t/2
|
||||
; RUN: llvm-cov gcov -n -dump %t/exit-block.gcno 2>&1 | FileCheck --check-prefixes=CHECK,EXIT-LAST %s
|
||||
; RUN: rm %t/exit-block.gcno
|
||||
|
||||
; By default, the return block is last.
|
||||
; By default, the exit block is the second.
|
||||
; RUN: opt -passes=insert-gcov-profiling -disable-output %t/2
|
||||
; RUN: llvm-cov gcov -n -dump %t/return-block.gcno 2>&1 | FileCheck -check-prefix=CHECK -check-prefix=RETURN-LAST %s
|
||||
; RUN: llvm-cov gcov -n -dump %t/exit-block.gcno 2>&1 | FileCheck --check-prefixes=CHECK,EXIT-SECOND %s
|
||||
|
||||
; But we can optionally emit it second, to match newer gcc versions.
|
||||
; RUN: opt -passes=insert-gcov-profiling -gcov-exit-block-before-body -disable-output %t/2
|
||||
; RUN: llvm-cov gcov -n -dump %t/return-block.gcno 2>&1 | FileCheck -check-prefix=CHECK -check-prefix=RETURN-SECOND %s
|
||||
; But we can optionally emit it last, to match GCC<4.8 (r189778).
|
||||
; RUN: opt -passes=insert-gcov-profiling -default-gcov-version='407*' -disable-output %t/2
|
||||
; RUN: llvm-cov gcov -n -dump %t/exit-block.gcno 2>&1 | FileCheck --check-prefixes=CHECK,EXIT-LAST %s
|
||||
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
@ -55,10 +55,10 @@ attributes #2 = { nounwind }
|
||||
!llvm.ident = !{!13}
|
||||
|
||||
!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.6.0 (trunk 223182)", isOptimized: true, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !8, imports: !2)
|
||||
!1 = !DIFile(filename: ".../llvm/test/Transforms/GCOVProfiling/return-block.ll", directory: "")
|
||||
!1 = !DIFile(filename: ".../llvm/test/Transforms/GCOVProfiling/exit-block.ll", directory: "")
|
||||
!2 = !{}
|
||||
!4 = distinct !DISubprogram(name: "test", line: 5, isLocal: false, isDefinition: true, isOptimized: true, unit: !0, scopeLine: 5, file: !1, scope: !5, type: !6, retainedNodes: !2)
|
||||
!5 = !DIFile(filename: ".../llvm/test/Transforms/GCOVProfiling/return-block.ll", directory: "")
|
||||
!5 = !DIFile(filename: ".../llvm/test/Transforms/GCOVProfiling/exit-block.ll", directory: "")
|
||||
!6 = !DISubroutineType(types: !7)
|
||||
!7 = !{null}
|
||||
!8 = !{!9}
|
||||
@ -75,10 +75,10 @@ attributes #2 = { nounwind }
|
||||
|
||||
; There should be no destination edges for the exit block.
|
||||
; CHECK: Block : 1 Counter : 0
|
||||
; RETURN-LAST: Destination Edges
|
||||
; RETURN-SECOND-NOT: Destination Edges
|
||||
; EXIT-LAST: Destination Edges
|
||||
; EXIT-SECOND-NOT: Destination Edges
|
||||
; CHECK: Block : 2 Counter : 0
|
||||
; CHECK: Block : 4 Counter : 0
|
||||
; RETURN-LAST-NOT: Destination Edges
|
||||
; RETURN-SECOND: Destination Edges
|
||||
; EXIT-LAST-NOT: Destination Edges
|
||||
; EXIT-SECOND: Destination Edges
|
||||
; CHECK-NOT: Block :
|
@ -2,7 +2,7 @@
|
||||
; RUN: echo '!9 = !{!"%/t/version.ll", !0}' > %t/1
|
||||
; RUN: cat %s %t/1 > %t/2
|
||||
; RUN: opt -insert-gcov-profiling -disable-output < %t/2
|
||||
; RUN: head -c8 %t/version.gcno | grep '^oncg.704'
|
||||
; RUN: head -c8 %t/version.gcno | grep '^oncg.804'
|
||||
; RUN: rm %t/version.gcno
|
||||
; RUN: not --crash opt -insert-gcov-profiling -default-gcov-version=asdfasdf -disable-output < %t/2
|
||||
; RUN: opt -insert-gcov-profiling -default-gcov-version='402*' -disable-output < %t/2
|
||||
@ -10,7 +10,7 @@
|
||||
; RUN: rm %t/version.gcno
|
||||
|
||||
; RUN: opt -passes=insert-gcov-profiling -disable-output < %t/2
|
||||
; RUN: head -c8 %t/version.gcno | grep '^oncg.704'
|
||||
; RUN: head -c8 %t/version.gcno | grep '^oncg.804'
|
||||
; RUN: rm %t/version.gcno
|
||||
; RUN: not --crash opt -passes=insert-gcov-profiling -default-gcov-version=asdfasdf -disable-output < %t/2
|
||||
; RUN: opt -passes=insert-gcov-profiling -default-gcov-version='402*' -disable-output < %t/2
|
||||
|
Loading…
x
Reference in New Issue
Block a user