Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -795,11 +795,12 @@ static void addSanitizers(const Triple &TargetTriple,
}

if (LowerAllowCheckPass::IsRequested()) {
LowerAllowCheckOptions Opts;
// 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([&Opts](ModulePassManager &MPM,
OptimizationLevel Level,
ThinOrFullLTOPhase Phase) {
MPM.addPass(createModuleToFunctionPassAdaptor(LowerAllowCheckPass(Opts)));
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,22 @@

namespace llvm {

struct LowerAllowCheckOptions {
std::vector<double> placeholder; // TODO: cutoffs
};

// This pass is responsible for removing optional traps, like llvm.ubsantrap
// from the hot code.
class LowerAllowCheckPass : public PassInfoMixin<LowerAllowCheckPass> {
public:
explicit LowerAllowCheckPass(LowerAllowCheckOptions Options)
: Options(Options) {};
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool IsRequested();

private:
LowerAllowCheckOptions Options;
};

} // 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<LowerAllowCheckOptions>
parseLowerAllowCheckPassOptions(StringRef Params) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we have parsing, we need

void printPipeline(raw_ostream &OS,
                     function_ref<StringRef(StringRef)> MapClassName2PassName);

in the pass

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, noted. I will add it in a follow-up patch that performs parsing (and unparsing).

LowerAllowCheckOptions 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",
[](LowerAllowCheckOptions Opts) { return LowerAllowCheckPass(Opts); },
parseLowerAllowCheckPassOptions, "")
FUNCTION_PASS_WITH_PARAMS(
"lower-matrix-intrinsics", "LowerMatrixIntrinsicsPass",
[](bool Minimal) { return LowerMatrixIntrinsicsPass(Minimal); },
Expand Down
Loading