llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-llvm-transforms Author: Vitaly Buka (vitalybuka) <details> <summary>Changes</summary> --- Full diff: https://github.com/llvm/llvm-project/pull/84853.diff 8 Files Affected: - (modified) clang/lib/CodeGen/BackendUtil.cpp (+7-6) - (renamed) clang/test/CodeGen/lower-builtin-hot.c (+1-1) - (renamed) llvm/include/llvm/Transforms/Instrumentation/LowerBuiltinHotPass.h (+4-4) - (modified) llvm/lib/Passes/PassBuilder.cpp (+1-1) - (modified) llvm/lib/Passes/PassRegistry.def (+1-1) - (modified) llvm/lib/Transforms/Instrumentation/CMakeLists.txt (+1-1) - (renamed) llvm/lib/Transforms/Instrumentation/LowerBuiltinHotPass.cpp (+7-7) - (renamed) llvm/test/Transforms/LowerBuiltinHotPass/lower-builtin-hot.ll (+4-4) ``````````diff diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 7eab1c4ed44b89..e36e08e8bf5102 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -73,10 +73,10 @@ #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h" #include "llvm/Transforms/Instrumentation/InstrProfiling.h" #include "llvm/Transforms/Instrumentation/KCFI.h" +#include "llvm/Transforms/Instrumentation/LowerBuiltinHotPass.h" #include "llvm/Transforms/Instrumentation/MemProfiler.h" #include "llvm/Transforms/Instrumentation/MemorySanitizer.h" #include "llvm/Transforms/Instrumentation/PGOInstrumentation.h" -#include "llvm/Transforms/Instrumentation/RemoveTrapsPass.h" #include "llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h" #include "llvm/Transforms/Instrumentation/SanitizerCoverage.h" #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h" @@ -99,9 +99,10 @@ using namespace llvm; namespace llvm { extern cl::opt<bool> PrintPipelinePasses; -static cl::opt<bool> ClRemoveTraps("clang-remove-traps", cl::Optional, - cl::desc("Insert remove-traps pass."), - cl::init(false)); +static cl::opt<bool> + ClLowerBuiltinHot("clang-lower-builtin-hot", cl::Optional, + cl::desc("Insert lower-builtin-hot pass."), + cl::init(false)); // Experiment to move sanitizers earlier. static cl::opt<bool> ClSanitizeOnOptimizerEarlyEP( @@ -750,13 +751,13 @@ static void addSanitizers(const Triple &TargetTriple, PB.registerOptimizerLastEPCallback(SanitizersCallback); } - if (ClRemoveTraps) { + if (ClLowerBuiltinHot) { // 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(RemoveTrapsPass()); + FPM.addPass(LowerBuiltinHotPass()); }); } } diff --git a/clang/test/CodeGen/remote-traps.c b/clang/test/CodeGen/lower-builtin-hot.c similarity index 87% rename from clang/test/CodeGen/remote-traps.c rename to clang/test/CodeGen/lower-builtin-hot.c index 16e4ebecb5c326..adcd0130bc73db 100644 --- a/clang/test/CodeGen/remote-traps.c +++ b/clang/test/CodeGen/lower-builtin-hot.c @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -O1 %s -o - -emit-llvm -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow -mllvm -ubsan-exp-hot | FileCheck %s -// RUN: %clang_cc1 -O1 %s -o - -emit-llvm -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow -mllvm -ubsan-exp-hot -mllvm -clang-remove-traps -mllvm -remove-traps-random-rate=1 %s -o - | FileCheck %s --check-prefixes=REMOVE +// RUN: %clang_cc1 -O1 %s -o - -emit-llvm -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow -mllvm -ubsan-exp-hot -mllvm -clang-lower-builtin-hot -mllvm -lower-builtin-hot-random-rate=1 %s -o - | FileCheck %s --check-prefixes=REMOVE #include <stdbool.h> diff --git a/llvm/include/llvm/Transforms/Instrumentation/RemoveTrapsPass.h b/llvm/include/llvm/Transforms/Instrumentation/LowerBuiltinHotPass.h similarity index 75% rename from llvm/include/llvm/Transforms/Instrumentation/RemoveTrapsPass.h rename to llvm/include/llvm/Transforms/Instrumentation/LowerBuiltinHotPass.h index 58f6bbcec5dc9d..fa7e9455ce58ea 100644 --- a/llvm/include/llvm/Transforms/Instrumentation/RemoveTrapsPass.h +++ b/llvm/include/llvm/Transforms/Instrumentation/LowerBuiltinHotPass.h @@ -1,4 +1,4 @@ -//===- RemoveTrapsPass.h ----------------------------------------*- C++ -*-===// +//===- LowerBuiltinHotPass.h ------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -11,8 +11,8 @@ /// //===----------------------------------------------------------------------===// -#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_UBSANOPTIMIZATIONPASS_H -#define LLVM_TRANSFORMS_INSTRUMENTATION_UBSANOPTIMIZATIONPASS_H +#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_LOWERBUILTINHOTPASS_H +#define LLVM_TRANSFORMS_INSTRUMENTATION_LOWERBUILTINHOTPASS_H #include "llvm/IR/Function.h" #include "llvm/IR/PassManager.h" @@ -22,7 +22,7 @@ namespace llvm { // This pass is responsible for removing optional traps, like llvm.ubsantrap // from the hot code. -class RemoveTrapsPass : public PassInfoMixin<RemoveTrapsPass> { +class LowerBuiltinHotPass : public PassInfoMixin<LowerBuiltinHotPass> { public: PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); }; diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 4d1eb10d2d41c6..15ead71a84580c 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -172,12 +172,12 @@ #include "llvm/Transforms/Instrumentation/InstrOrderFile.h" #include "llvm/Transforms/Instrumentation/InstrProfiling.h" #include "llvm/Transforms/Instrumentation/KCFI.h" +#include "llvm/Transforms/Instrumentation/LowerBuiltinHotPass.h" #include "llvm/Transforms/Instrumentation/MemProfiler.h" #include "llvm/Transforms/Instrumentation/MemorySanitizer.h" #include "llvm/Transforms/Instrumentation/PGOForceFunctionAttrs.h" #include "llvm/Transforms/Instrumentation/PGOInstrumentation.h" #include "llvm/Transforms/Instrumentation/PoisonChecking.h" -#include "llvm/Transforms/Instrumentation/RemoveTrapsPass.h" #include "llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h" #include "llvm/Transforms/Instrumentation/SanitizerCoverage.h" #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h" diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def index 41f16d0915bf23..6fa0fd0f13c19a 100644 --- a/llvm/lib/Passes/PassRegistry.def +++ b/llvm/lib/Passes/PassRegistry.def @@ -422,7 +422,7 @@ FUNCTION_PASS("print<uniformity>", UniformityInfoPrinterPass(dbgs())) FUNCTION_PASS("reassociate", ReassociatePass()) FUNCTION_PASS("redundant-dbg-inst-elim", RedundantDbgInstEliminationPass()) FUNCTION_PASS("reg2mem", RegToMemPass()) -FUNCTION_PASS("remove-traps", RemoveTrapsPass()) +FUNCTION_PASS("lower-builtin-hot", LowerBuiltinHotPass()) FUNCTION_PASS("safe-stack", SafeStackPass(TM)) FUNCTION_PASS("scalarize-masked-mem-intrin", ScalarizeMaskedMemIntrinPass()) FUNCTION_PASS("scalarizer", ScalarizerPass()) diff --git a/llvm/lib/Transforms/Instrumentation/CMakeLists.txt b/llvm/lib/Transforms/Instrumentation/CMakeLists.txt index b23a6ed1f08415..1deb5751bbc590 100644 --- a/llvm/lib/Transforms/Instrumentation/CMakeLists.txt +++ b/llvm/lib/Transforms/Instrumentation/CMakeLists.txt @@ -13,11 +13,11 @@ add_llvm_component_library(LLVMInstrumentation InstrOrderFile.cpp InstrProfiling.cpp KCFI.cpp + LowerBuiltinHotPass.cpp PGOForceFunctionAttrs.cpp PGOInstrumentation.cpp PGOMemOPSizeOpt.cpp PoisonChecking.cpp - RemoveTrapsPass.cpp SanitizerCoverage.cpp SanitizerBinaryMetadata.cpp ValueProfileCollector.cpp diff --git a/llvm/lib/Transforms/Instrumentation/RemoveTrapsPass.cpp b/llvm/lib/Transforms/Instrumentation/LowerBuiltinHotPass.cpp similarity index 88% rename from llvm/lib/Transforms/Instrumentation/RemoveTrapsPass.cpp rename to llvm/lib/Transforms/Instrumentation/LowerBuiltinHotPass.cpp index fa4716f2e7a403..60b000ede3e241 100644 --- a/llvm/lib/Transforms/Instrumentation/RemoveTrapsPass.cpp +++ b/llvm/lib/Transforms/Instrumentation/LowerBuiltinHotPass.cpp @@ -1,4 +1,4 @@ -//===- RemoveTrapsPass.cpp --------------------------------------*- C++ -*-===// +//===- LowerBuiltinHotPass.cpp ----------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Transforms/Instrumentation/RemoveTrapsPass.h" +#include "llvm/Transforms/Instrumentation/LowerBuiltinHotPass.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" @@ -21,15 +21,15 @@ using namespace llvm; -#define DEBUG_TYPE "remove-traps" +#define DEBUG_TYPE "lower-builtin-hot" static cl::opt<int> HotPercentileCutoff( - "remove-traps-percentile-cutoff-hot", cl::init(0), + "lower-builtin-hot-percentile-cutoff", cl::init(0), cl::desc("Alternative hot percentile cuttoff. By default " "`-profile-summary-cutoff-hot` is used.")); static cl::opt<float> - RandomRate("remove-traps-random-rate", cl::init(0.0), + RandomRate("lower-builtin-hot-random-rate", cl::init(0.0), cl::desc("Probability value in the range [0.0, 1.0] of " "unconditional pseudo-random checks removal.")); @@ -94,8 +94,8 @@ static bool removeUbsanTraps(Function &F, const BlockFrequencyInfo &BFI, return !ReplaceWithValue.empty(); } -PreservedAnalyses RemoveTrapsPass::run(Function &F, - FunctionAnalysisManager &AM) { +PreservedAnalyses LowerBuiltinHotPass::run(Function &F, + FunctionAnalysisManager &AM) { if (F.isDeclaration()) return PreservedAnalyses::all(); auto &MAMProxy = AM.getResult<ModuleAnalysisManagerFunctionProxy>(F); diff --git a/llvm/test/Transforms/RemoveTraps/remove-traps.ll b/llvm/test/Transforms/LowerBuiltinHotPass/lower-builtin-hot.ll similarity index 97% rename from llvm/test/Transforms/RemoveTraps/remove-traps.ll rename to llvm/test/Transforms/LowerBuiltinHotPass/lower-builtin-hot.ll index 80b86e0f7455aa..d35bd80b6b8c61 100644 --- a/llvm/test/Transforms/RemoveTraps/remove-traps.ll +++ b/llvm/test/Transforms/LowerBuiltinHotPass/lower-builtin-hot.ll @@ -1,8 +1,8 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 -; RUN: opt < %s -passes='function(remove-traps)' -S | FileCheck %s --check-prefixes=NOPROFILE -; RUN: opt < %s -passes='function(remove-traps)' -remove-traps-random-rate=1 -S | FileCheck %s --check-prefixes=ALL -; RUN: opt < %s -passes='require<profile-summary>,function(remove-traps)' -S | FileCheck %s --check-prefixes=HOT -; RUN: opt < %s -passes='require<profile-summary>,function(remove-traps)' -remove-traps-percentile-cutoff-hot=700000 -S | FileCheck %s --check-prefixes=HOT70 +; RUN: opt < %s -passes='function(lower-builtin-hot)' -S | FileCheck %s --check-prefixes=NOPROFILE +; RUN: opt < %s -passes='function(lower-builtin-hot)' -lower-builtin-hot-random-rate=1 -S | FileCheck %s --check-prefixes=ALL +; RUN: opt < %s -passes='require<profile-summary>,function(lower-builtin-hot)' -S | FileCheck %s --check-prefixes=HOT +; RUN: opt < %s -passes='require<profile-summary>,function(lower-builtin-hot)' -lower-builtin-hot-percentile-cutoff=700000 -S | FileCheck %s --check-prefixes=HOT70 target triple = "x86_64-pc-linux-gnu" `````````` </details> https://github.com/llvm/llvm-project/pull/84853 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits