Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nfc][BoundsChecking] Rename BoundsCheckingOptions into Options #122359

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds))
PB.registerScalarOptimizerLateEPCallback([this](FunctionPassManager &FPM,
OptimizationLevel Level) {
BoundsCheckingPass::BoundsCheckingOptions Options;
BoundsCheckingPass::Options Options;
Options.Merge =
CodeGenOpts.SanitizeMergeHandlers.has(SanitizerKind::LocalBounds);
if (!CodeGenOpts.SanitizeTrap.has(SanitizerKind::LocalBounds)) {
Expand Down
6 changes: 3 additions & 3 deletions llvm/include/llvm/Transforms/Instrumentation/BoundsChecking.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Function;
class BoundsCheckingPass : public PassInfoMixin<BoundsCheckingPass> {

public:
struct BoundsCheckingOptions {
struct Options {
struct Runtime {
Runtime(bool MinRuntime, bool MayReturn)
: MinRuntime(MinRuntime), MayReturn(MayReturn) {}
Expand All @@ -31,14 +31,14 @@ class BoundsCheckingPass : public PassInfoMixin<BoundsCheckingPass> {
bool Merge = false;
};

BoundsCheckingPass(BoundsCheckingOptions Options) : Options(Options) {}
BoundsCheckingPass(Options Opts) : Opts(Opts) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
void printPipeline(raw_ostream &OS,
function_ref<StringRef(StringRef)> MapClassName2PassName);

private:
BoundsCheckingOptions Options;
Options Opts;
};

} // end namespace llvm
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Passes/PassBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,9 +1284,9 @@ parseRegAllocFastPassOptions(PassBuilder &PB, StringRef Params) {
return Opts;
}

Expected<BoundsCheckingPass::BoundsCheckingOptions>
Expected<BoundsCheckingPass::Options>
parseBoundsCheckingOptions(StringRef Params) {
BoundsCheckingPass::BoundsCheckingOptions Options;
BoundsCheckingPass::Options Options;
while (!Params.empty()) {
StringRef ParamName;
std::tie(ParamName, Params) = Params.split(';');
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Passes/PassRegistry.def
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ FUNCTION_PASS_WITH_PARAMS(
parseWinEHPrepareOptions, "demote-catchswitch-only")
FUNCTION_PASS_WITH_PARAMS(
"bounds-checking", "BoundsCheckingPass",
[](BoundsCheckingPass::BoundsCheckingOptions Options) {
[](BoundsCheckingPass::Options Options) {
return BoundsCheckingPass(Options);
},
parseBoundsCheckingOptions, "trap")
Expand Down
20 changes: 10 additions & 10 deletions llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ static void insertBoundsCheck(Value *Or, BuilderTy &IRB, GetTrapBBT GetTrapBB) {
BranchInst::Create(TrapBB, Cont, Or, OldBB);
}

static std::string getRuntimeCallName(
const BoundsCheckingPass::BoundsCheckingOptions::Runtime &Opts) {
static std::string
getRuntimeCallName(const BoundsCheckingPass::Options::Runtime &Opts) {
std::string Name = "__ubsan_handle_local_out_of_bounds";
if (Opts.MinRuntime)
Name += "_minimal";
Expand All @@ -172,9 +172,9 @@ static std::string getRuntimeCallName(
return Name;
}

static bool
addBoundsChecking(Function &F, TargetLibraryInfo &TLI, ScalarEvolution &SE,
const BoundsCheckingPass::BoundsCheckingOptions &Opts) {
static bool addBoundsChecking(Function &F, TargetLibraryInfo &TLI,
ScalarEvolution &SE,
const BoundsCheckingPass::Options &Opts) {
if (F.hasFnAttribute(Attribute::NoSanitizeBounds))
return false;

Expand Down Expand Up @@ -271,7 +271,7 @@ PreservedAnalyses BoundsCheckingPass::run(Function &F, FunctionAnalysisManager &
auto &TLI = AM.getResult<TargetLibraryAnalysis>(F);
auto &SE = AM.getResult<ScalarEvolutionAnalysis>(F);

if (!addBoundsChecking(F, TLI, SE, Options))
if (!addBoundsChecking(F, TLI, SE, Opts))
return PreservedAnalyses::all();

return PreservedAnalyses::none();
Expand All @@ -282,16 +282,16 @@ void BoundsCheckingPass::printPipeline(
static_cast<PassInfoMixin<BoundsCheckingPass> *>(this)->printPipeline(
OS, MapClassName2PassName);
OS << "<";
if (Options.Rt) {
if (Options.Rt->MinRuntime)
if (Opts.Rt) {
if (Opts.Rt->MinRuntime)
OS << "min-";
OS << "rt";
if (!Options.Rt->MayReturn)
if (!Opts.Rt->MayReturn)
OS << "-abort";
} else {
OS << "trap";
}
if (Options.Merge)
if (Opts.Merge)
OS << ";merge";
OS << ">";
}
Loading