forked from OSchip/llvm-project
[sanitizer-coverage] implement -fsanitize-coverage=no-prune,... instead of a hidden -mllvm flag. clang part.
llvm-svn: 302320
This commit is contained in:
parent
424bfed693
commit
50fb618b93
|
@ -144,8 +144,9 @@ Use these flags together with ``trace-pc-guard`` or ``trace-pc``,
|
|||
like this: ``-fsanitize-coverage=func,trace-pc-guard``.
|
||||
|
||||
When ``edge`` or ``bb`` is used, some of the edges/blocks may still be left
|
||||
uninstrumented if such instrumentation is considered redundant.
|
||||
**TODO**: add a user-visible option to disable the optimization.
|
||||
uninstrumented (pruned) if such instrumentation is considered redundant.
|
||||
Use ``no-prune`` (e.g. ``-fsanitize-coverage=bb,no-prune,trace-pc-guard``)
|
||||
to disable pruning. This could be useful for better coverage visualization.
|
||||
|
||||
|
||||
Edge coverage
|
||||
|
|
|
@ -297,6 +297,9 @@ def fsanitize_coverage_trace_pc
|
|||
def fsanitize_coverage_trace_pc_guard
|
||||
: Flag<["-"], "fsanitize-coverage-trace-pc-guard">,
|
||||
HelpText<"Enable PC tracing with guard in sanitizer coverage">;
|
||||
def fsanitize_coverage_no_prune
|
||||
: Flag<["-"], "fsanitize-coverage-no-prune">,
|
||||
HelpText<"Disable coverage pruning (i.e. instrument all blocks/edges)">;
|
||||
def fprofile_instrument_EQ : Joined<["-"], "fprofile-instrument=">,
|
||||
HelpText<"Enable PGO instrumentation. The accepted value is clang, llvm, "
|
||||
"or none">;
|
||||
|
|
|
@ -160,6 +160,7 @@ CODEGENOPT(SanitizeCoverageTracePC, 1, 0) ///< Enable PC tracing
|
|||
///< in sanitizer coverage.
|
||||
CODEGENOPT(SanitizeCoverageTracePCGuard, 1, 0) ///< Enable PC tracing with guard
|
||||
///< in sanitizer coverage.
|
||||
CODEGENOPT(SanitizeCoverageNoPrune, 1, 0) ///< Disable coverage pruning.
|
||||
CODEGENOPT(SanitizeStats , 1, 0) ///< Collect statistics for sanitizers.
|
||||
CODEGENOPT(SimplifyLibCalls , 1, 1) ///< Set when -fbuiltin is enabled.
|
||||
CODEGENOPT(SoftFloat , 1, 0) ///< -soft-float.
|
||||
|
|
|
@ -185,6 +185,7 @@ static void addSanitizerCoveragePass(const PassManagerBuilder &Builder,
|
|||
Opts.Use8bitCounters = CGOpts.SanitizeCoverage8bitCounters;
|
||||
Opts.TracePC = CGOpts.SanitizeCoverageTracePC;
|
||||
Opts.TracePCGuard = CGOpts.SanitizeCoverageTracePCGuard;
|
||||
Opts.NoPrune = CGOpts.SanitizeCoverageNoPrune;
|
||||
PM.add(createSanitizerCoverageModulePass(Opts));
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ enum CoverageFeature {
|
|||
Coverage8bitCounters = 1 << 8,
|
||||
CoverageTracePC = 1 << 9,
|
||||
CoverageTracePCGuard = 1 << 10,
|
||||
CoverageNoPrune = 1 << 11,
|
||||
};
|
||||
|
||||
/// Parse a -fsanitize= or -fno-sanitize= argument's values, diagnosing any
|
||||
|
@ -629,7 +630,8 @@ void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
|
|||
std::make_pair(CoverageTraceGep, "-fsanitize-coverage-trace-gep"),
|
||||
std::make_pair(Coverage8bitCounters, "-fsanitize-coverage-8bit-counters"),
|
||||
std::make_pair(CoverageTracePC, "-fsanitize-coverage-trace-pc"),
|
||||
std::make_pair(CoverageTracePCGuard, "-fsanitize-coverage-trace-pc-guard")};
|
||||
std::make_pair(CoverageTracePCGuard, "-fsanitize-coverage-trace-pc-guard"),
|
||||
std::make_pair(CoverageNoPrune, "-fsanitize-coverage-no-prune")};
|
||||
for (auto F : CoverageFlags) {
|
||||
if (CoverageFeatures & F.first)
|
||||
CmdArgs.push_back(Args.MakeArgString(F.second));
|
||||
|
@ -786,6 +788,7 @@ int parseCoverageFeatures(const Driver &D, const llvm::opt::Arg *A) {
|
|||
.Case("8bit-counters", Coverage8bitCounters)
|
||||
.Case("trace-pc", CoverageTracePC)
|
||||
.Case("trace-pc-guard", CoverageTracePCGuard)
|
||||
.Case("no-prune", CoverageNoPrune)
|
||||
.Default(0);
|
||||
if (F == 0)
|
||||
D.Diag(clang::diag::err_drv_unsupported_option_argument)
|
||||
|
|
|
@ -766,6 +766,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
|
|||
Opts.SanitizeCoverageTracePC = Args.hasArg(OPT_fsanitize_coverage_trace_pc);
|
||||
Opts.SanitizeCoverageTracePCGuard =
|
||||
Args.hasArg(OPT_fsanitize_coverage_trace_pc_guard);
|
||||
Opts.SanitizeCoverageNoPrune = Args.hasArg(OPT_fsanitize_coverage_no_prune);
|
||||
Opts.SanitizeMemoryTrackOrigins =
|
||||
getLastArgIntValue(Args, OPT_fsanitize_memory_track_origins_EQ, 0, Diags);
|
||||
Opts.SanitizeMemoryUseAfterDtor =
|
||||
|
|
|
@ -80,6 +80,10 @@
|
|||
// CHECK-EXTEND-LEGACY: -fsanitize-coverage-type=1
|
||||
// CHECK-EXTEND-LEGACY: -fsanitize-coverage-trace-cmp
|
||||
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=no-prune,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_NOPRUNE
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=no-prune,func,trace-pc-guard %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_NOPRUNE
|
||||
// CHECK_NOPRUNE: -fsanitize-coverage-no-prune
|
||||
|
||||
// RUN: %clang_cl --target=i386-pc-win32 -fsanitize=address -fsanitize-coverage=func,trace-pc-guard -c -### -- %s 2>&1 | FileCheck %s -check-prefix=CLANG-CL-COVERAGE
|
||||
// CLANG-CL-COVERAGE-NOT: error:
|
||||
// CLANG-CL-COVERAGE-NOT: warning:
|
||||
|
|
Loading…
Reference in New Issue