Skip to content

Commit caa4964

Browse files
committed
Rename -fno-sanitize-top-hot to -fsanitize-skip-hot-cutoff
Rename a few internal variables as well
1 parent b43d513 commit caa4964

File tree

6 files changed

+48
-48
lines changed

6 files changed

+48
-48
lines changed

clang/include/clang/Basic/CodeGenOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ class CodeGenOptions : public CodeGenOptionsBase {
387387
/// Set of thresholds in a range [0.0, 1.0]: the top hottest code responsible
388388
/// for the given fraction of PGO counters will be excluded from sanitization
389389
/// (0.0 [default] to skip none, 1.0 to skip all).
390-
SanitizerMaskCutoffs NoSanitizeTopHotCutoffs;
390+
SanitizerMaskCutoffs SanitizeSkipHotCutoffs;
391391

392392
/// List of backend command-line options for -fembed-bitcode.
393393
std::vector<uint8_t> CmdArgs;

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2649,8 +2649,8 @@ def fsanitize_undefined_strip_path_components_EQ : Joined<["-"], "fsanitize-unde
26492649
HelpText<"Strip (or keep only, if negative) a given number of path components "
26502650
"when emitting check metadata.">,
26512651
MarshallingInfoInt<CodeGenOpts<"EmitCheckPathComponentsToStrip">, "0", "int">;
2652-
def fno_sanitize_top_hot_EQ
2653-
: CommaJoined<["-"], "fno-sanitize-top-hot=">,
2652+
def fsanitize_skip_hot_cutoff_EQ
2653+
: CommaJoined<["-"], "fsanitize-skip-hot-cutoff=">,
26542654
Group<f_clang_Group>,
26552655
HelpText<
26562656
"Exclude sanitization for the top hottest code responsible for "

clang/include/clang/Driver/SanitizerArgs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class SanitizerArgs {
2626
SanitizerSet RecoverableSanitizers;
2727
SanitizerSet TrapSanitizers;
2828
SanitizerSet MergeHandlers;
29-
SanitizerMaskCutoffs TopHotCutoffs;
29+
SanitizerMaskCutoffs SkipHotCutoffs;
3030

3131
std::vector<std::string> UserIgnorelistFiles;
3232
std::vector<std::string> SystemIgnorelistFiles;

clang/lib/Driver/SanitizerArgs.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,11 @@ static SanitizerMask parseSanitizeTrapArgs(const Driver &D,
331331
}
332332

333333
static SanitizerMaskCutoffs
334-
parseNoSanitizeHotArgs(const Driver &D, const llvm::opt::ArgList &Args,
334+
parseSanitizeSkipHotCutoffArgs(const Driver &D, const llvm::opt::ArgList &Args,
335335
bool DiagnoseErrors) {
336336
SanitizerMaskCutoffs Cutoffs;
337337
for (const auto *Arg : Args)
338-
if (Arg->getOption().matches(options::OPT_fno_sanitize_top_hot_EQ)) {
338+
if (Arg->getOption().matches(options::OPT_fsanitize_skip_hot_cutoff_EQ)) {
339339
Arg->claim();
340340
parseArgCutoffs(D, Arg, DiagnoseErrors, Cutoffs);
341341
}
@@ -734,7 +734,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
734734
MergeKinds &= Kinds;
735735

736736
// Parse -fno-sanitize-top-hot flags
737-
TopHotCutoffs = parseNoSanitizeHotArgs(D, Args, DiagnoseErrors);
737+
SkipHotCutoffs = parseSanitizeSkipHotCutoffArgs(D, Args, DiagnoseErrors);
738738

739739
// Setup ignorelist files.
740740
// Add default ignorelist from resource directory for activated sanitizers,
@@ -1156,8 +1156,8 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
11561156

11571157
MergeHandlers.Mask |= MergeKinds;
11581158

1159-
// Zero out TopHotCutoffs for unused sanitizers
1160-
TopHotCutoffs.clear(~Sanitizers.Mask);
1159+
// Zero out SkipHotCutoffs for unused sanitizers
1160+
SkipHotCutoffs.clear(~Sanitizers.Mask);
11611161
}
11621162

11631163
static std::string toString(const clang::SanitizerSet &Sanitizers) {
@@ -1329,10 +1329,10 @@ void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
13291329
CmdArgs.push_back(
13301330
Args.MakeArgString("-fsanitize-merge=" + toString(MergeHandlers)));
13311331

1332-
std::string TopHotCutoffsStr = toString(TopHotCutoffs);
1333-
if (!TopHotCutoffsStr.empty())
1332+
std::string SkipHotCutoffsStr = toString(SkipHotCutoffs);
1333+
if (!SkipHotCutoffsStr.empty())
13341334
CmdArgs.push_back(
1335-
Args.MakeArgString("-fno-sanitize-top-hot=" + TopHotCutoffsStr));
1335+
Args.MakeArgString("-fsanitize-skip-hot-cutoff=" + SkipHotCutoffsStr));
13361336

13371337
addSpecialCaseListOpt(Args, CmdArgs,
13381338
"-fsanitize-ignorelist=", UserIgnorelistFiles);
@@ -1533,7 +1533,7 @@ SanitizerMask parseArgValues(const Driver &D, const llvm::opt::Arg *A,
15331533

15341534
void parseArgCutoffs(const Driver &D, const llvm::opt::Arg *A,
15351535
bool DiagnoseErrors, SanitizerMaskCutoffs &Cutoffs) {
1536-
assert(A->getOption().matches(options::OPT_fno_sanitize_top_hot_EQ) &&
1536+
assert(A->getOption().matches(options::OPT_fsanitize_skip_hot_cutoff_EQ) &&
15371537
"Invalid argument in parseArgCutoffs!");
15381538
for (int i = 0, n = A->getNumValues(); i != n; ++i) {
15391539
const char *Value = A->getValue(i);

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,9 +1809,9 @@ void CompilerInvocationBase::GenerateCodeGenArgs(const CodeGenOptions &Opts,
18091809
GenerateArg(Consumer, OPT_fsanitize_merge_handlers_EQ, Sanitizer);
18101810

18111811
SmallVector<std::string, 4> Values;
1812-
serializeSanitizerMaskCutoffs(Opts.NoSanitizeTopHotCutoffs, Values);
1812+
serializeSanitizerMaskCutoffs(Opts.SanitizeSkipHotCutoffs, Values);
18131813
for (std::string Sanitizer : Values)
1814-
GenerateArg(Consumer, OPT_fno_sanitize_top_hot_EQ, Sanitizer);
1814+
GenerateArg(Consumer, OPT_fsanitize_skip_hot_cutoff_EQ, Sanitizer);
18151815

18161816
if (!Opts.EmitVersionIdentMetadata)
18171817
GenerateArg(Consumer, OPT_Qn);
@@ -2294,10 +2294,10 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
22942294
Args.getAllArgValues(OPT_fsanitize_merge_handlers_EQ),
22952295
Diags, Opts.SanitizeMergeHandlers);
22962296

2297-
// Parse -fno-sanitize-top-hot= arguments.
2298-
Opts.NoSanitizeTopHotCutoffs = parseSanitizerWeightedKinds(
2299-
"-fno-sanitize-top-hot=",
2300-
Args.getAllArgValues(OPT_fno_sanitize_top_hot_EQ), Diags);
2297+
// Parse -fsanitize-skip-hot-cutoff= arguments.
2298+
Opts.SanitizeSkipHotCutoffs = parseSanitizerWeightedKinds(
2299+
"-fsanitize-skip-hot-cutoff=",
2300+
Args.getAllArgValues(OPT_fsanitize_skip_hot_cutoff_EQ), Diags);
23012301

23022302
Opts.EmitVersionIdentMetadata = Args.hasFlag(OPT_Qy, OPT_Qn, true);
23032303

clang/test/Driver/fsanitize.c

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,54 +1156,54 @@
11561156
// CHECK-REALTIME-UBSAN: error: invalid argument '-fsanitize=realtime' not allowed with '-fsanitize=undefined'
11571157

11581158

1159-
// * Test -fno-sanitize-top-hot *
1159+
// * Test -fsanitize-skip-hot-cutoff *
11601160

1161-
// -fno-sanitize-top-hot=undefined=0.5
1162-
// RUN: %clang -Werror --target=x86_64-linux-gnu -fsanitize=undefined -fno-sanitize-top-hot=undefined=0.5 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TOP-HOT1
1163-
// CHECK-TOP-HOT1: "-fno-sanitize-top-hot={{((signed-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute|function|vptr)=0.5(0*),?){19}"}}
1161+
// -fsanitize-skip-hot-cutoff=undefined=0.5
1162+
// RUN: %clang -Werror --target=x86_64-linux-gnu -fsanitize=undefined -fsanitize-skip-hot-cutoff=undefined=0.5 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SKIP-HOT-CUTOFF1
1163+
// CHECK-SKIP-HOT-CUTOFF1: "-fsanitize-skip-hot-cutoff={{((signed-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute|function|vptr)=0.5(0*),?){19}"}}
11641164

11651165
// No-op: no sanitizers are specified
1166-
// RUN: %clang -Werror --target=x86_64-linux-gnu -fno-sanitize-top-hot=undefined=0.5 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TOP-HOT2
1167-
// CHECK-TOP-HOT2-NOT: "-fsanitize"
1168-
// CHECK-TOP-HOT2-NOT: "-fno-sanitize-top-hot"
1166+
// RUN: %clang -Werror --target=x86_64-linux-gnu -fsanitize-skip-hot-cutoff=undefined=0.5 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SKIP-HOT-CUTOFF2
1167+
// CHECK-SKIP-HOT-CUTOFF2-NOT: "-fsanitize"
1168+
// CHECK-SKIP-HOT-CUTOFF2-NOT: "-fsanitize-skip-hot-cutoff"
11691169

11701170
// Enable undefined, then cancel out integer using a cutoff of 0.0
1171-
// RUN: %clang -Werror --target=x86_64-linux-gnu -fsanitize=undefined -fno-sanitize-top-hot=undefined=0.5,integer=0.0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TOP-HOT3
1172-
// CHECK-TOP-HOT3: "-fno-sanitize-top-hot={{((unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute|function|vptr)=0.5(0*),?){15}"}}
1171+
// RUN: %clang -Werror --target=x86_64-linux-gnu -fsanitize=undefined -fsanitize-skip-hot-cutoff=undefined=0.5,integer=0.0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SKIP-HOT-CUTOFF3
1172+
// CHECK-SKIP-HOT-CUTOFF3: "-fsanitize-skip-hot-cutoff={{((unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute|function|vptr)=0.5(0*),?){15}"}}
11731173

11741174
// Enable undefined, then cancel out integer using a cutoff of 0.0, then re-enable signed-integer-overflow
1175-
// RUN: %clang -Werror --target=x86_64-linux-gnu -fsanitize=undefined -fno-sanitize-top-hot=undefined=0.5,integer=0.0,signed-integer-overflow=0.7 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TOP-HOT4
1176-
// CHECK-TOP-HOT4: "-fno-sanitize-top-hot={{((signed-integer-overflow|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute|function|vptr)=0.[57]0*,?){16}"}}
1175+
// RUN: %clang -Werror --target=x86_64-linux-gnu -fsanitize=undefined -fsanitize-skip-hot-cutoff=undefined=0.5,integer=0.0,signed-integer-overflow=0.7 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SKIP-HOT-CUTOFF4
1176+
// CHECK-SKIP-HOT-CUTOFF4: "-fsanitize-skip-hot-cutoff={{((signed-integer-overflow|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute|function|vptr)=0.[57]0*,?){16}"}}
11771177

1178-
// Check that -fno-sanitize-top-hot=undefined=0.4 does not widen the set of -fsanitize=integer checks.
1179-
// RUN: %clang -Werror --target=x86_64-linux-gnu -fsanitize=integer -fno-sanitize-top-hot=undefined=0.4 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TOP-HOT5
1180-
// CHECK-TOP-HOT5: "-fno-sanitize-top-hot={{((integer-divide-by-zero|shift-base|shift-exponent|signed-integer-overflow)=0.40*,?){4}"}}
1178+
// Check that -fsanitize-skip-hot-cutoff=undefined=0.4 does not widen the set of -fsanitize=integer checks.
1179+
// RUN: %clang -Werror --target=x86_64-linux-gnu -fsanitize=integer -fsanitize-skip-hot-cutoff=undefined=0.4 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SKIP-HOT-CUTOFF5
1180+
// CHECK-SKIP-HOT-CUTOFF5: "-fsanitize-skip-hot-cutoff={{((integer-divide-by-zero|shift-base|shift-exponent|signed-integer-overflow)=0.40*,?){4}"}}
11811181

11821182
// No-op: it's allowed for the user to specify a cutoff of 0.0, though the argument is not passed along by the driver.
1183-
// RUN: %clang -Werror --target=x86_64-linux-gnu -fsanitize=undefined -fno-sanitize-top-hot=undefined=0.0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TOP-HOT6
1184-
// CHECK-TOP-HOT6: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute|function|vptr),?){19}"}}
1185-
// CHECK-TOP-HOT6-NOT: "-fno-sanitize-top-hot"
1183+
// RUN: %clang -Werror --target=x86_64-linux-gnu -fsanitize=undefined -fsanitize-skip-hot-cutoff=undefined=0.0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SKIP-HOT-CUTOFF6
1184+
// CHECK-SKIP-HOT-CUTOFF6: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute|function|vptr),?){19}"}}
1185+
// CHECK-SKIP-HOT-CUTOFF6-NOT: "-fsanitize-skip-hot-cutoff"
11861186

11871187
// Invalid: bad sanitizer
1188-
// RUN: not %clang --target=x86_64-linux-gnu -fno-sanitize-top-hot=pot=0.0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TOP-HOT7
1189-
// CHECK-TOP-HOT7: unsupported argument 'pot=0.0' to option '-fno-sanitize-top-hot='
1188+
// RUN: not %clang --target=x86_64-linux-gnu -fsanitize-skip-hot-cutoff=pot=0.0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SKIP-HOT-CUTOFF7
1189+
// CHECK-SKIP-HOT-CUTOFF7: unsupported argument 'pot=0.0' to option '-fsanitize-skip-hot-cutoff='
11901190

11911191
// Invalid: bad cutoff
1192-
// RUN: not %clang --target=x86_64-linux-gnu -fno-sanitize-top-hot=undefined=xyzzy %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TOP-HOT8
1193-
// CHECK-TOP-HOT8: unsupported argument 'undefined=xyzzy' to option '-fno-sanitize-top-hot='
1192+
// RUN: not %clang --target=x86_64-linux-gnu -fsanitize-skip-hot-cutoff=undefined=xyzzy %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SKIP-HOT-CUTOFF8
1193+
// CHECK-SKIP-HOT-CUTOFF8: unsupported argument 'undefined=xyzzy' to option '-fsanitize-skip-hot-cutoff='
11941194

11951195
// Invalid: -fno-sanitize-top without parameters
1196-
// RUN: not %clang --target=x86_64-linux-gnu -fno-sanitize-top-hot %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TOP-HOT9
1197-
// CHECK-TOP-HOT9: unknown argument: '-fno-sanitize-top-hot'
1196+
// RUN: not %clang --target=x86_64-linux-gnu -fsanitize-skip-hot-cutoff %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SKIP-HOT-CUTOFF9
1197+
// CHECK-SKIP-HOT-CUTOFF9: unknown argument: '-fsanitize-skip-hot-cutoff'
11981198

11991199
// Invalid: -fno-sanitize-top=undefined without cutoff
1200-
// RUN: not %clang --target=x86_64-linux-gnu -fno-sanitize-top-hot=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TOP-HOT10
1201-
// CHECK-TOP-HOT10: unsupported argument 'undefined' to option '-fno-sanitize-top-hot='
1200+
// RUN: not %clang --target=x86_64-linux-gnu -fsanitize-skip-hot-cutoff=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SKIP-HOT-CUTOFF10
1201+
// CHECK-SKIP-HOT-CUTOFF10: unsupported argument 'undefined' to option '-fsanitize-skip-hot-cutoff='
12021202

12031203
// Invalid: -fno-sanitize-top=undefined= without cutoff
1204-
// RUN: not %clang --target=x86_64-linux-gnu -fno-sanitize-top-hot=undefined= %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TOP-HOT11
1205-
// CHECK-TOP-HOT11: unsupported argument 'undefined=' to option '-fno-sanitize-top-hot='
1204+
// RUN: not %clang --target=x86_64-linux-gnu -fsanitize-skip-hot-cutoff=undefined= %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SKIP-HOT-CUTOFF11
1205+
// CHECK-SKIP-HOT-CUTOFF11: unsupported argument 'undefined=' to option '-fsanitize-skip-hot-cutoff='
12061206

12071207
// No-op: -fno-sanitize-top= without parameters is unusual but valid
1208-
// RUN: %clang -Werror --target=x86_64-linux-gnu -fno-sanitize-top-hot= %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TOP-HOT12
1209-
// CHECK-TOP-HOT12-NOT: "-fno-sanitize-top-hot"
1208+
// RUN: %clang -Werror --target=x86_64-linux-gnu -fsanitize-skip-hot-cutoff= %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SKIP-HOT-CUTOFF12
1209+
// CHECK-SKIP-HOT-CUTOFF12-NOT: "-fsanitize-skip-hot-cutoff"

0 commit comments

Comments
 (0)