[clang] [clang] Add optional pass to remove UBSAN traps using PGO (PR #84214)
Vitaly Buka via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 8 22:03:26 PST 2024
================
@@ -744,6 +750,21 @@ static void addSanitizers(const Triple &TargetTriple,
// LastEP does not need GlobalsAA.
PB.registerOptimizerLastEPCallback(SanitizersCallback);
}
+
+ if (ClRemoveTraps) {
+ // We can optimize after inliner, and PGO profile matching. The hook below
+ // is called from `buildModuleOptimizationPipeline` just after profile use,
+ // and inliner is a part of `buildModuleSimplificationPipeline`, which is
+ // before `buildModuleOptimizationPipeline`.
+ PB.registerOptimizerEarlyEPCallback([&](ModulePassManager &MPM,
----------------
vitalybuka wrote:
It's bisected to SimplifyCFG , the one after ScalarOptimizerLateEPCallback.
Most trap blocks preceded by empty blocks with unconditional branch as terminator. And they are always cold.
Inserting `SimplifyCFGPass` solves the issue and now I see no regression.
https://github.com/llvm/llvm-project/pull/84214
More information about the cfe-commits
mailing list