phosek created this revision. phosek added reviewers: vsk, davidxl, keith. Herald added subscribers: jansvoboda11, dexonsmith, dang. phosek requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
These flags affect coverage mapping (-fcoverage-mapping), not -fprofile-[instr-]generate so it makes more sense to use the -fcoverage-* prefix. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D97434 Files: clang/include/clang/Basic/CodeGenOptions.h clang/include/clang/Driver/Options.td clang/lib/CodeGen/CoverageMappingGen.cpp clang/lib/CodeGen/CoverageMappingGen.h clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/test/CodeGen/coverage-compilation-dir.c clang/test/CodeGen/profile-compilation-dir.c clang/test/Driver/debug-prefix-map.c clang/test/Profile/coverage-prefix-map.c clang/test/Profile/profile-prefix-map.c
Index: clang/test/Profile/profile-prefix-map.c =================================================================== --- clang/test/Profile/profile-prefix-map.c +++ /dev/null @@ -1,21 +0,0 @@ -// %s expands to an absolute path, so to test relative paths we need to create a -// clean directory, put the source there, and cd into it. -// RUN: rm -rf %t -// RUN: mkdir -p %t/root/nested -// RUN: echo "void f1() {}" > %t/root/nested/profile-prefix-map.c -// RUN: cd %t/root - -// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name profile-prefix-map.c %t/root/nested/profile-prefix-map.c -o - | FileCheck --check-prefix=ABSOLUTE %s -// -// ABSOLUTE: @__llvm_coverage_mapping = {{.*"\\02.*root.*nested.*profile-prefix-map\.c}} - -// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name profile-prefix-map.c ../root/nested/profile-prefix-map.c -o - | FileCheck --check-prefix=RELATIVE %s -// -// RELATIVE: @__llvm_coverage_mapping = {{.*"\\02.*}}..{{/|\\+}}root{{/|\\+}}nested{{.*profile-prefix-map\.c}} - -// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name profile-prefix-map.c %t/root/nested/profile-prefix-map.c -fprofile-prefix-map=%/t/root=. -o - | FileCheck --check-prefix=PROFILE-PREFIX-MAP %s -// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name profile-prefix-map.c ../root/nested/profile-prefix-map.c -fprofile-prefix-map=../root=. -o - | FileCheck --check-prefix=PROFILE-PREFIX-MAP %s -// PROFILE-PREFIX-MAP: @__llvm_coverage_mapping = {{.*"\\02.*}}.{{/|\\+}}nested{{.*profile-prefix-map\.c}} - -// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name profile-prefix-map.c %t/root/nested/profile-prefix-map.c -fprofile-compilation-dir=/custom -fprofile-prefix-map=/custom=/nonsense -o - | FileCheck --check-prefix=PROFILE-COMPILATION-DIR %s -// PROFILE-COMPILATION-DIR: @__llvm_coverage_mapping = {{.*"\\02.*}}nonsense Index: clang/test/Profile/coverage-prefix-map.c =================================================================== --- /dev/null +++ clang/test/Profile/coverage-prefix-map.c @@ -0,0 +1,21 @@ +// %s expands to an absolute path, so to test relative paths we need to create a +// clean directory, put the source there, and cd into it. +// RUN: rm -rf %t +// RUN: mkdir -p %t/root/nested +// RUN: echo "void f1() {}" > %t/root/nested/coverage-prefix-map.c +// RUN: cd %t/root + +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c %t/root/nested/coverage-prefix-map.c -o - | FileCheck --check-prefix=ABSOLUTE %s +// +// ABSOLUTE: @__llvm_coverage_mapping = {{.*"\\02.*root.*nested.*coverage-prefix-map\.c}} + +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c ../root/nested/coverage-prefix-map.c -o - | FileCheck --check-prefix=RELATIVE %s +// +// RELATIVE: @__llvm_coverage_mapping = {{.*"\\02.*}}..{{/|\\+}}root{{/|\\+}}nested{{.*coverage-prefix-map\.c}} + +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c %t/root/nested/coverage-prefix-map.c -fcoverage-prefix-map=%/t/root=. -o - | FileCheck --check-prefix=COVERAGE-PREFIX-MAP %s +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c ../root/nested/coverage-prefix-map.c -fcoverage-prefix-map=../root=. -o - | FileCheck --check-prefix=COVERAGE-PREFIX-MAP %s +// COVERAGE-PREFIX-MAP: @__llvm_coverage_mapping = {{.*"\\02.*}}.{{/|\\+}}nested{{.*coverage-prefix-map\.c}} + +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c %t/root/nested/coverage-prefix-map.c -fcoverage-compilation-dir=/custom -fcoverage-prefix-map=/custom=/nonsense -o - | FileCheck --check-prefix=COVERAGE-COMPILATION-DIR %s +// COVERAGE-COMPILATION-DIR: @__llvm_coverage_mapping = {{.*"\\02.*}}nonsense Index: clang/test/Driver/debug-prefix-map.c =================================================================== --- clang/test/Driver/debug-prefix-map.c +++ clang/test/Driver/debug-prefix-map.c @@ -1,39 +1,39 @@ // RUN: %clang -### -fdebug-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-INVALID // RUN: %clang -### -fmacro-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-INVALID -// RUN: %clang -### -fprofile-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-PROFILE-INVALID +// RUN: %clang -### -fcoverage-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-COVERAGE-INVALID // RUN: %clang -### -ffile-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-FILE-INVALID // RUN: %clang -### -fdebug-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-SIMPLE // RUN: %clang -### -fmacro-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-SIMPLE -// RUN: %clang -### -fprofile-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-PROFILE-SIMPLE +// RUN: %clang -### -fcoverage-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-COVERAGE-SIMPLE // RUN: %clang -### -ffile-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-SIMPLE // RUN: %clang -### -ffile-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-SIMPLE -// RUN: %clang -### -ffile-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-PROFILE-SIMPLE +// RUN: %clang -### -ffile-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-COVERAGE-SIMPLE // RUN: %clang -### -fdebug-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-COMPLEX // RUN: %clang -### -fmacro-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-COMPLEX -// RUN: %clang -### -fprofile-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-PROFILE-COMPLEX +// RUN: %clang -### -fcoverage-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-COVERAGE-COMPLEX // RUN: %clang -### -ffile-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-COMPLEX // RUN: %clang -### -ffile-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-COMPLEX -// RUN: %clang -### -ffile-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-PROFILE-COMPLEX +// RUN: %clang -### -ffile-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-COVERAGE-COMPLEX // RUN: %clang -### -fdebug-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-EMPTY // RUN: %clang -### -fmacro-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-EMPTY -// RUN: %clang -### -fprofile-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-PROFILE-EMPTY +// RUN: %clang -### -fcoverage-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-COVERAGE-EMPTY // RUN: %clang -### -ffile-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-EMPTY // RUN: %clang -### -ffile-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-EMPTY -// RUN: %clang -### -ffile-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-PROFILE-EMPTY +// RUN: %clang -### -ffile-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-COVERAGE-EMPTY // CHECK-DEBUG-INVALID: error: invalid argument 'old' to -fdebug-prefix-map // CHECK-MACRO-INVALID: error: invalid argument 'old' to -fmacro-prefix-map -// CHECK-PROFILE-INVALID: error: invalid argument 'old' to -fprofile-prefix-map +// CHECK-COVERAGE-INVALID: error: invalid argument 'old' to -fcoverage-prefix-map // CHECK-FILE-INVALID: error: invalid argument 'old' to -ffile-prefix-map // CHECK-DEBUG-SIMPLE: fdebug-prefix-map=old=new // CHECK-MACRO-SIMPLE: fmacro-prefix-map=old=new -// CHECK-PROFILE-SIMPLE: fprofile-prefix-map=old=new +// CHECK-COVERAGE-SIMPLE: fcoverage-prefix-map=old=new // CHECK-DEBUG-COMPLEX: fdebug-prefix-map=old=n=ew // CHECK-MACRO-COMPLEX: fmacro-prefix-map=old=n=ew -// CHECK-PROFILE-COMPLEX: fprofile-prefix-map=old=n=ew +// CHECK-COVERAGE-COMPLEX: fcoverage-prefix-map=old=n=ew // CHECK-DEBUG-EMPTY: fdebug-prefix-map=old= // CHECK-MACRO-EMPTY: fmacro-prefix-map=old= -// CHECK-PROFILE-EMPTY: fprofile-prefix-map=old= +// CHECK-COVERAGE-EMPTY: fcoverage-prefix-map=old= Index: clang/test/CodeGen/coverage-compilation-dir.c =================================================================== --- clang/test/CodeGen/coverage-compilation-dir.c +++ clang/test/CodeGen/coverage-compilation-dir.c @@ -1,6 +1,6 @@ // RUN: mkdir -p %t.dir && cd %t.dir // RUN: cp %s rel.c -// RUN: %clang_cc1 -fprofile-instrument=clang -fprofile-compilation-dir=/nonsense -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false rel.c -o - | FileCheck -check-prefix=CHECK-NONSENSE %s +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-compilation-dir=/nonsense -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false rel.c -o - | FileCheck -check-prefix=CHECK-NONSENSE %s // RUN: %clang_cc1 -fprofile-instrument=clang -ffile-compilation-dir=/nonsense -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false rel.c -o - | FileCheck -check-prefix=CHECK-NONSENSE %s // CHECK-NONSENSE: nonsense Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -1340,8 +1340,8 @@ GenerateArg(Args, OPT_fdebug_prefix_map_EQ, Prefix.first + "=" + Prefix.second, SA); - for (const auto &Prefix : Opts.ProfilePrefixMap) - GenerateArg(Args, OPT_fprofile_prefix_map_EQ, + for (const auto &Prefix : Opts.CoveragePrefixMap) + GenerateArg(Args, OPT_fcoverage_prefix_map_EQ, Prefix.first + "=" + Prefix.second, SA); if (Opts.NewStructPathTBAA) @@ -1619,9 +1619,9 @@ {std::string(Split.first), std::string(Split.second)}); } - for (const auto &Arg : Args.getAllArgValues(OPT_fprofile_prefix_map_EQ)) { + for (const auto &Arg : Args.getAllArgValues(OPT_fcoverage_prefix_map_EQ)) { auto Split = StringRef(Arg).split('='); - Opts.ProfilePrefixMap.insert( + Opts.CoveragePrefixMap.insert( {std::string(Split.first), std::string(Split.second)}); } Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -657,16 +657,16 @@ } /// Add a CC1 and CC1AS option to specify the coverage file path prefix map. -static void addProfilePrefixMapArg(const Driver &D, const ArgList &Args, +static void addCoveragePrefixMapArg(const Driver &D, const ArgList &Args, ArgStringList &CmdArgs) { for (const Arg *A : Args.filtered(options::OPT_ffile_prefix_map_EQ, - options::OPT_fprofile_prefix_map_EQ)) { + options::OPT_fcoverage_prefix_map_EQ)) { StringRef Map = A->getValue(); if (Map.find('=') == StringRef::npos) D.Diag(diag::err_drv_invalid_argument_to_option) << Map << A->getOption().getName(); else - CmdArgs.push_back(Args.MakeArgString("-fprofile-prefix-map=" + Map)); + CmdArgs.push_back(Args.MakeArgString("-fcoverage-prefix-map=" + Map)); A->claim(); } } @@ -861,11 +861,11 @@ } if (Arg *A = Args.getLastArg(options::OPT_ffile_compilation_dir_EQ, - options::OPT_fprofile_compilation_dir_EQ)) { + options::OPT_fcoverage_compilation_dir_EQ)) { A->render(Args, CmdArgs); } else if (llvm::ErrorOr<std::string> CWD = D.getVFS().getCurrentWorkingDirectory()) { - Args.MakeArgString("-fprofile-compilation-dir=" + *CWD); + Args.MakeArgString("-fcoverage-compilation-dir=" + *CWD); } if (Args.hasArg(options::OPT_fprofile_exclude_files_EQ)) { @@ -1391,7 +1391,7 @@ } addMacroPrefixMapArg(D, Args, CmdArgs); - addProfilePrefixMapArg(D, Args, CmdArgs); + addCoveragePrefixMapArg(D, Args, CmdArgs); } // FIXME: Move to target hook. Index: clang/lib/CodeGen/CoverageMappingGen.h =================================================================== --- clang/lib/CodeGen/CoverageMappingGen.h +++ clang/lib/CodeGen/CoverageMappingGen.h @@ -93,7 +93,7 @@ llvm::SmallDenseMap<const FileEntry *, unsigned, 8> FileEntries; std::vector<llvm::Constant *> FunctionNames; std::vector<FunctionInfo> FunctionRecords; - std::map<std::string, std::string> ProfilePrefixMap; + std::map<std::string, std::string> CoveragePrefixMap; std::string getCurrentDirname(); std::string normalizeFilename(StringRef Filename); Index: clang/lib/CodeGen/CoverageMappingGen.cpp =================================================================== --- clang/lib/CodeGen/CoverageMappingGen.cpp +++ clang/lib/CodeGen/CoverageMappingGen.cpp @@ -1603,12 +1603,12 @@ CoverageMappingModuleGen::CoverageMappingModuleGen( CodeGenModule &CGM, CoverageSourceInfo &SourceInfo) : CGM(CGM), SourceInfo(SourceInfo) { - ProfilePrefixMap = CGM.getCodeGenOpts().ProfilePrefixMap; + CoveragePrefixMap = CGM.getCodeGenOpts().CoveragePrefixMap; } std::string CoverageMappingModuleGen::getCurrentDirname() { - if (!CGM.getCodeGenOpts().ProfileCompilationDir.empty()) - return CGM.getCodeGenOpts().ProfileCompilationDir; + if (!CGM.getCodeGenOpts().CoverageCompilationDir.empty()) + return CGM.getCodeGenOpts().CoverageCompilationDir; SmallString<256> CWD; llvm::sys::fs::current_path(CWD); @@ -1618,7 +1618,7 @@ std::string CoverageMappingModuleGen::normalizeFilename(StringRef Filename) { llvm::SmallString<256> Path(Filename); llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true); - for (const auto &Entry : ProfilePrefixMap) { + for (const auto &Entry : CoveragePrefixMap) { if (llvm::sys::path::replace_path_prefix(Path, Entry.first, Entry.second)) break; } Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -1108,10 +1108,10 @@ def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">, Group<f_Group>, Flags<[CC1Option, CC1AsOption, CoreOption]>, Alias<fdebug_compilation_dir_EQ>; -def fprofile_compilation_dir_EQ : Joined<["-"], "fprofile-compilation-dir=">, +def fcoverage_compilation_dir_EQ : Joined<["-"], "fcoverage-compilation-dir=">, Group<f_Group>, Flags<[CC1Option, CC1AsOption, CoreOption]>, HelpText<"The compilation directory to embed in the coverage mapping.">, - MarshallingInfoString<CodeGenOpts<"ProfileCompilationDir">>; + MarshallingInfoString<CodeGenOpts<"CoverageCompilationDir">>; def ffile_compilation_dir_EQ : Joined<["-"], "ffile-compilation-dir=">, Group<f_Group>, HelpText<"The compilation directory to embed in the debug info and coverage mapping.">; defm debug_info_for_profiling : BoolFOption<"debug-info-for-profiling", @@ -2632,10 +2632,10 @@ : Joined<["-"], "fdebug-prefix-map=">, Group<f_Group>, Flags<[CC1Option,CC1AsOption]>, HelpText<"remap file source paths in debug info">; -def fprofile_prefix_map_EQ - : Joined<["-"], "fprofile-prefix-map=">, Group<f_Group>, +def fcoverage_prefix_map_EQ + : Joined<["-"], "fcoverage-prefix-map=">, Group<f_Group>, Flags<[CC1Option]>, - HelpText<"remap file source paths in coverage info">; + HelpText<"remap file source paths in coverage mapping">; def ffile_prefix_map_EQ : Joined<["-"], "ffile-prefix-map=">, Group<f_Group>, HelpText<"remap file source paths in debug info and predefined preprocessor macros">; Index: clang/include/clang/Basic/CodeGenOptions.h =================================================================== --- clang/include/clang/Basic/CodeGenOptions.h +++ clang/include/clang/Basic/CodeGenOptions.h @@ -173,7 +173,7 @@ std::string DebugCompilationDir; /// The string to embed in coverage mapping as the current working directory. - std::string ProfileCompilationDir; + std::string CoverageCompilationDir; /// The string to embed in the debug information for the compile unit, if /// non-empty. @@ -184,7 +184,7 @@ std::string RecordCommandLine; std::map<std::string, std::string> DebugPrefixMap; - std::map<std::string, std::string> ProfilePrefixMap; + std::map<std::string, std::string> CoveragePrefixMap; /// The ABI to use for passing floating point arguments. std::string FloatABI;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits