///< Only useful when running CodeGen as a
///< subroutine.
CODEGENOPT(EmitVersionIdentMetadata , 1, 1) ///< Emit compiler version metadata.
-CODEGENOPT(EmitGcovArcs , 1, 0) ///< Emit coverage data files, aka. GCDA.
-CODEGENOPT(EmitGcovNotes , 1, 0) ///< Emit coverage "notes" files, aka GCNO.
CODEGENOPT(EmitOpenCLArgMetadata , 1, 0) ///< Emit OpenCL kernel arg metadata.
CODEGENOPT(EmulatedTLS , 1, 0) ///< Set by default or -f[no-]emulated-tls.
/// Embed Bitcode mode (off/all/bitcode/marker).
HelpText<"Disable using instrumentation data for profile-guided optimization">;
def fno_profile_use : Flag<["-"], "fno-profile-use">,
Alias<fno_profile_instr_use>;
-defm profile_arcs : BoolFOption<"profile-arcs",
- CodeGenOpts<"EmitGcovArcs">, DefaultFalse,
- PosFlag<SetTrue, [CC1Option, LinkOption]>, NegFlag<SetFalse>>;
-defm test_coverage : BoolFOption<"test-coverage",
- CodeGenOpts<"EmitGcovNotes">, DefaultFalse,
- PosFlag<SetTrue, [CC1Option]>, NegFlag<SetFalse>>;
+def ftest_coverage : Flag<["-"], "ftest-coverage">, Group<f_Group>,
+ HelpText<"Produce gcov notes files (*.gcno)">;
+def fno_test_coverage : Flag<["-"], "fno-test-coverage">, Group<f_Group>;
+def fprofile_arcs : Flag<["-"], "fprofile-arcs">, Group<f_Group>,
+ HelpText<"Instrument code to produce gcov data files (*.gcda)">;
+def fno_profile_arcs : Flag<["-"], "fno-profile-arcs">, Group<f_Group>;
def fprofile_filter_files_EQ : Joined<["-"], "fprofile-filter-files=">,
Group<f_Group>, Flags<[CC1Option, CoreOption]>,
HelpText<"Instrument only functions from files where names match any regex separated by a semi-colon">,
- MarshallingInfoString<CodeGenOpts<"ProfileFilterFiles">>,
- ShouldParseIf<!strconcat(fprofile_arcs.KeyPath, "||", ftest_coverage.KeyPath)>;
+ MarshallingInfoString<CodeGenOpts<"ProfileFilterFiles">>;
def fprofile_exclude_files_EQ : Joined<["-"], "fprofile-exclude-files=">,
Group<f_Group>, Flags<[CC1Option, CoreOption]>,
HelpText<"Instrument only functions from files where names don't match all the regexes separated by a semi-colon">,
- MarshallingInfoString<CodeGenOpts<"ProfileExcludeFiles">>,
- ShouldParseIf<!strconcat(fprofile_arcs.KeyPath, "||", ftest_coverage.KeyPath)>;
+ MarshallingInfoString<CodeGenOpts<"ProfileExcludeFiles">>;
def fprofile_update_EQ : Joined<["-"], "fprofile-update=">,
Group<f_Group>, Flags<[CC1Option, CoreOption]>, Values<"atomic,prefer-atomic,single">,
MetaVarName<"<method>">, HelpText<"Set update method of profile counters">,
MarshallingInfoFlag<CodeGenOpts<"MergeFunctions">>;
def coverage_data_file : Separate<["-"], "coverage-data-file">,
HelpText<"Emit coverage data to this filename.">,
- MarshallingInfoString<CodeGenOpts<"CoverageDataFile">>,
- ShouldParseIf<!strconcat(fprofile_arcs.KeyPath, "||", ftest_coverage.KeyPath)>;
+ MarshallingInfoString<CodeGenOpts<"CoverageDataFile">>;
def coverage_data_file_EQ : Joined<["-"], "coverage-data-file=">,
Alias<coverage_data_file>;
def coverage_notes_file : Separate<["-"], "coverage-notes-file">,
HelpText<"Emit coverage notes to this filename.">,
- MarshallingInfoString<CodeGenOpts<"CoverageNotesFile">>,
- ShouldParseIf<!strconcat(fprofile_arcs.KeyPath, "||", ftest_coverage.KeyPath)>;
+ MarshallingInfoString<CodeGenOpts<"CoverageNotesFile">>;
def coverage_notes_file_EQ : Joined<["-"], "coverage-notes-file=">,
Alias<coverage_notes_file>;
def coverage_version_EQ : Joined<["-"], "coverage-version=">,
static std::optional<GCOVOptions>
getGCOVOptions(const CodeGenOptions &CodeGenOpts, const LangOptions &LangOpts) {
- if (!CodeGenOpts.EmitGcovArcs && !CodeGenOpts.EmitGcovNotes)
+ if (CodeGenOpts.CoverageNotesFile.empty() &&
+ CodeGenOpts.CoverageDataFile.empty())
return std::nullopt;
// Not using 'GCOVOptions::getDefault' allows us to avoid exiting if
// LLVM's -default-gcov-version flag is set to something invalid.
GCOVOptions Options;
- Options.EmitNotes = CodeGenOpts.EmitGcovNotes;
- Options.EmitData = CodeGenOpts.EmitGcovArcs;
+ Options.EmitNotes = !CodeGenOpts.CoverageNotesFile.empty();
+ Options.EmitData = !CodeGenOpts.CoverageDataFile.empty();
llvm::copy(CodeGenOpts.CoverageVersion, std::begin(Options.Version));
Options.NoRedZone = CodeGenOpts.DisableRedZone;
Options.Filter = CodeGenOpts.ProfileFilterFiles;
// subprogram name, no need to have it at all unless coverage is enabled or
// debug is set to more than just line tables or extra debug info is needed.
if (LinkageName == Name ||
- (!CGM.getCodeGenOpts().EmitGcovArcs &&
- !CGM.getCodeGenOpts().EmitGcovNotes &&
+ (CGM.getCodeGenOpts().CoverageNotesFile.empty() &&
+ CGM.getCodeGenOpts().CoverageDataFile.empty() &&
!CGM.getCodeGenOpts().DebugInfoForProfiling &&
!CGM.getCodeGenOpts().PseudoProbeForProfiling &&
DebugKind <= llvm::codegenoptions::DebugLineTablesOnly))
// If debug info or coverage generation is enabled, create the CGDebugInfo
// object.
if (CodeGenOpts.getDebugInfo() != llvm::codegenoptions::NoDebugInfo ||
- CodeGenOpts.EmitGcovArcs || CodeGenOpts.EmitGcovNotes)
+ CodeGenOpts.CoverageNotesFile.size() ||
+ CodeGenOpts.CoverageDataFile.size())
DebugInfo.reset(new CGDebugInfo(*this));
Block.GlobalUniqueCount = 0;
if (getCodeGenOpts().EmitDeclMetadata)
EmitDeclMetadata();
- if (getCodeGenOpts().EmitGcovArcs || getCodeGenOpts().EmitGcovNotes)
+ if (getCodeGenOpts().CoverageNotesFile.size() ||
+ getCodeGenOpts().CoverageDataFile.size())
EmitCoverageFile();
if (CGDebugInfo *DI = getModuleDebugInfo())
}
void CodeGenModule::EmitCoverageFile() {
- if (getCodeGenOpts().CoverageDataFile.empty() &&
- getCodeGenOpts().CoverageNotesFile.empty())
- return;
-
llvm::NamedMDNode *CUNode = TheModule.getNamedMetadata("llvm.dbg.cu");
if (!CUNode)
return;
options::OPT_fno_test_coverage, false) ||
Args.hasArg(options::OPT_coverage);
bool EmitCovData = TC.needsGCovInstrumentation(Args);
- if (EmitCovNotes)
- CmdArgs.push_back("-ftest-coverage");
- if (EmitCovData)
- CmdArgs.push_back("-fprofile-arcs");
if (Args.hasFlag(options::OPT_fcoverage_mapping,
options::OPT_fno_coverage_mapping, false)) {
Opts.MemoryProfileOutput = MemProfileBasename;
memcpy(Opts.CoverageVersion, "408*", 4);
- if (Opts.EmitGcovArcs || Opts.EmitGcovNotes) {
+ if (Opts.CoverageNotesFile.size() || Opts.CoverageDataFile.size()) {
if (Args.hasArg(OPT_coverage_version_EQ)) {
StringRef CoverageVersion = Args.getLastArgValue(OPT_coverage_version_EQ);
if (CoverageVersion.size() != 4) {
// RUN: -Werror=ignored-attributes -mfunction-return=thunk-extern \
// RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-EXTERN
// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
-// RUN: -mfunction-return=thunk-extern -fprofile-arcs \
+// RUN: -mfunction-return=thunk-extern -coverage-data-file /dev/null \
// RUN: | FileCheck %s --check-prefix=CHECK-GCOV
// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
// RUN: -mfunction-return=thunk-extern -fsanitize=address \
/// -fprofile-update=atomic (implied by -fsanitize=thread) requires the
/// (potentially concurrent) counter updates to be atomic.
-// RUN: %clang_cc1 %s -triple x86_64 -emit-llvm -fprofile-update=atomic -ftest-coverage -fprofile-arcs \
+// RUN: %clang_cc1 %s -triple x86_64 -emit-llvm -fprofile-update=atomic \
// RUN: -coverage-notes-file /dev/null -coverage-data-file /dev/null -o - | FileCheck %s
// CHECK-LABEL: void @foo()
/// 3.4 redesigns the format and changed .da to .gcda
/// 4.7 enables cfg_checksum.
/// 4.8 (default, compatible with gcov 7) emits the exit block the second.
-// RUN: %clang_cc1 -emit-llvm -disable-red-zone -fprofile-arcs -coverage-version='304*' %s -o - | \
+// RUN: %clang_cc1 -emit-llvm -disable-red-zone -coverage-data-file /dev/null -coverage-version='304*' %s -o - | \
// RUN: FileCheck --check-prefixes=CHECK,304 %s
-// RUN: %clang_cc1 -emit-llvm -disable-red-zone -fprofile-arcs -coverage-version='407*' %s -o - | \
+// RUN: %clang_cc1 -emit-llvm -disable-red-zone -coverage-data-file /dev/null -coverage-version='407*' %s -o - | \
// RUN: FileCheck --check-prefixes=CHECK,407 %s
-// RUN: %clang_cc1 -emit-llvm -disable-red-zone -fprofile-arcs %s -o - | \
+// RUN: %clang_cc1 -emit-llvm -disable-red-zone -coverage-data-file /dev/null %s -o - | \
// RUN: FileCheck --check-prefixes=CHECK,408 %s
-// RUN: %clang_cc1 -emit-llvm -disable-red-zone -fprofile-arcs -coverage-notes-file=aaa.gcno -coverage-data-file=bbb.gcda -debug-info-kind=limited -dwarf-version=4 %s -o - | FileCheck %s --check-prefix GCOV_FILE_INFO
+// RUN: %clang_cc1 -emit-llvm -disable-red-zone -coverage-notes-file=aaa.gcno -coverage-data-file=bbb.gcda -debug-info-kind=limited -dwarf-version=4 %s -o - | FileCheck %s --check-prefix GCOV_FILE_INFO
-// RUN: %clang_cc1 -emit-llvm-bc -o /dev/null -fdebug-pass-manager -fprofile-arcs %s 2>&1 | FileCheck --check-prefix=NEWPM %s
-// RUN: %clang_cc1 -emit-llvm-bc -o /dev/null -fdebug-pass-manager -fprofile-arcs -O3 %s 2>&1 | FileCheck --check-prefix=NEWPM-O3 %s
+// RUN: %clang_cc1 -emit-llvm-bc -o /dev/null -fdebug-pass-manager -coverage-data-file=/dev/null %s 2>&1 | FileCheck --check-prefix=NEWPM %s
+// RUN: %clang_cc1 -emit-llvm-bc -o /dev/null -fdebug-pass-manager -coverage-data-file=/dev/null -O3 %s 2>&1 | FileCheck --check-prefix=NEWPM-O3 %s
// NEWPM-NOT: Running pass
// NEWPM: Running pass: GCOVProfilerPass
// RUN: -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -fprofile-instrument=clang -disable-llvm-passes \
// RUN: -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -fprofile-arcs -disable-llvm-passes \
+// RUN: %clang_cc1 -coverage-data-file /dev/null -disable-llvm-passes \
// RUN: -emit-llvm -o - %s | FileCheck %s
int g(int);
// RUN: %clang -### -S -ftest-coverage %s 2>&1 | FileCheck --check-prefix=TEST-COVERAGE %s
// RUN: %clang -### -S -ftest-coverage -fno-test-coverage %s 2>&1 | FileCheck --check-prefix=NO-TEST-COVERAGE %s
-// TEST-COVERAGE: "-ftest-coverage"
// TEST-COVERAGE: "-coverage-notes-file" "coverage.gcno"
// NO-TEST-COVERAGE-NOT: "-coverage-notes-file"
// RUN: %clang -### -S -fprofile-arcs -fno-profile-arcs %s 2>&1 | FileCheck --check-prefix=NO-PROFILE-ARCS %s
// NO-PROFILE-ARCS-NOT: "-coverage-notes-file"
-// PROFILE-ARCS: "-fprofile-arcs"
// PROFILE-ARCS: "-coverage-data-file" "coverage.gcda"
// RUN: %clang -### -S -ftest-coverage %s -o /foo/bar.o 2>&1 | FileCheck --check-prefix=GCNO-LOCATION %s
// CHECK-NOT: "-fprofile{{[^"]*}}"
// CHECK: "-triple" "x86_64-unknown-linux-gnu"
// PROF: "-fprofile{{.*}}"
-// GCOV: "-ftest-coverage"
+// GCOV: "-coverage-notes-file"