diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index fbb3fb6e5ea42..8cf44592a1747 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -789,13 +789,12 @@ static void addSanitizers(const Triple &TargetTriple, } if (LowerAllowCheckPass::IsRequested()) { - // We can optimize after inliner, and PGO profile matching. The hook below - // is called at the end `buildFunctionSimplificationPipeline`, which called - // from `buildInlinerPipeline`, which called after profile matching. - PB.registerScalarOptimizerLateEPCallback( - [](FunctionPassManager &FPM, OptimizationLevel Level) { - FPM.addPass(LowerAllowCheckPass()); - }); + // We want to call it after inline, which is about OptimizerEarlyEPCallback. + PB.registerOptimizerEarlyEPCallback([](ModulePassManager &MPM, + OptimizationLevel Level, + ThinOrFullLTOPhase Phase) { + MPM.addPass(createModuleToFunctionPassAdaptor(LowerAllowCheckPass())); + }); } } diff --git a/clang/test/CodeGen/allow-ubsan-check-inline.c b/clang/test/CodeGen/allow-ubsan-check-inline.c index cabe76d8034d7..1de24ab90dac0 100644 --- a/clang/test/CodeGen/allow-ubsan-check-inline.c +++ b/clang/test/CodeGen/allow-ubsan-check-inline.c @@ -7,8 +7,8 @@ void set(int x); // We will only make decision in the `overflow` function. // NOINL-COUNT-1: remark: Allowed check: -// FIXME: We will make decision on every inline. -// INLINE-COUNT-1: remark: Allowed check: +// We will make decision on every inline. +// INLINE-COUNT-5: remark: Allowed check: static void overflow() { set(get() + get());