Skip to content

Reapply "[sanitizer][NFCI] Add Options parameter to LowerAllowCheckPass" (#122833) #122994

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

Merged
merged 3 commits into from
Jan 22, 2025
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
9 changes: 5 additions & 4 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,10 +796,11 @@ static void addSanitizers(const Triple &TargetTriple,

if (LowerAllowCheckPass::IsRequested()) {
// We want to call it after inline, which is about OptimizerEarlyEPCallback.
PB.registerOptimizerEarlyEPCallback([](ModulePassManager &MPM,
OptimizationLevel Level,
ThinOrFullLTOPhase Phase) {
MPM.addPass(createModuleToFunctionPassAdaptor(LowerAllowCheckPass()));
PB.registerOptimizerEarlyEPCallback([&](ModulePassManager &MPM,
OptimizationLevel Level,
ThinOrFullLTOPhase Phase) {
LowerAllowCheckPass::Options Opts;
MPM.addPass(createModuleToFunctionPassAdaptor(LowerAllowCheckPass(Opts)));
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,18 @@ namespace llvm {
// from the hot code.
class LowerAllowCheckPass : public PassInfoMixin<LowerAllowCheckPass> {
public:
struct Options {
std::vector<unsigned int> placeholder; // TODO: cutoffs
};

explicit LowerAllowCheckPass(LowerAllowCheckPass::Options Opts)
: Opts(std::move(Opts)) {};
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool IsRequested();

private:
LowerAllowCheckPass::Options Opts;
};

} // namespace llvm
Expand Down
15 changes: 15 additions & 0 deletions llvm/lib/Passes/PassBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,21 @@ Expected<EmbedBitcodeOptions> parseEmbedBitcodePassOptions(StringRef Params) {
return Result;
}

Expected<LowerAllowCheckPass::Options>
parseLowerAllowCheckPassOptions(StringRef Params) {
LowerAllowCheckPass::Options Result;
while (!Params.empty()) {
StringRef ParamName;
std::tie(ParamName, Params) = Params.split(';');

return make_error<StringError>(
formatv("invalid LowerAllowCheck pass parameter '{0}' ", ParamName)
.str(),
inconvertibleErrorCode());
}
return Result;
}

Expected<MemorySanitizerOptions> parseMSanPassOptions(StringRef Params) {
MemorySanitizerOptions Result;
while (!Params.empty()) {
Expand Down
5 changes: 4 additions & 1 deletion llvm/lib/Passes/PassRegistry.def
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ FUNCTION_PASS("loop-load-elim", LoopLoadEliminationPass())
FUNCTION_PASS("loop-simplify", LoopSimplifyPass())
FUNCTION_PASS("loop-sink", LoopSinkPass())
FUNCTION_PASS("loop-versioning", LoopVersioningPass())
FUNCTION_PASS("lower-allow-check", LowerAllowCheckPass())
FUNCTION_PASS("lower-atomic", LowerAtomicPass())
FUNCTION_PASS("lower-constant-intrinsics", LowerConstantIntrinsicsPass())
FUNCTION_PASS("lower-expect", LowerExpectIntrinsicPass())
Expand Down Expand Up @@ -553,6 +552,10 @@ FUNCTION_PASS_WITH_PARAMS(
parseLoopVectorizeOptions,
"no-interleave-forced-only;interleave-forced-only;no-vectorize-forced-only;"
"vectorize-forced-only")
FUNCTION_PASS_WITH_PARAMS(
"lower-allow-check", "LowerAllowCheckPass",
[](LowerAllowCheckPass::Options Opts) { return LowerAllowCheckPass(Opts); },
parseLowerAllowCheckPassOptions, "")
FUNCTION_PASS_WITH_PARAMS(
"lower-matrix-intrinsics", "LowerMatrixIntrinsicsPass",
[](bool Minimal) { return LowerMatrixIntrinsicsPass(Minimal); },
Expand Down
Loading