https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/84853
>From d98585586148f2084e36d06996d6c9190cec57d7 Mon Sep 17 00:00:00 2001 From: Vitaly Buka <vitalyb...@google.com> Date: Mon, 11 Mar 2024 16:32:06 -0700 Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?= =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 [skip ci] --- clang/lib/CodeGen/BackendUtil.cpp | 12 +-- clang/lib/CodeGen/CGExpr.cpp | 15 +++- clang/test/CodeGen/remote-traps.c | 23 ++++- llvm/docs/LangRef.rst | 50 ++++++++++- llvm/include/llvm/IR/Intrinsics.td | 5 ++ .../SelectionDAG/SelectionDAGBuilder.cpp | 6 ++ .../InstCombine/InstCombineCalls.cpp | 8 ++ .../Instrumentation/RemoveTrapsPass.cpp | 26 +++--- llvm/test/CodeGen/Generic/builtin-hot.ll | 19 ++++ .../Transforms/InstCombine/builtin-hot.ll | 25 ++++++ .../Transforms/RemoveTraps/remove-traps.ll | 89 +++++++++++++------ 11 files changed, 228 insertions(+), 50 deletions(-) create mode 100644 llvm/test/CodeGen/Generic/builtin-hot.ll create mode 100644 llvm/test/Transforms/InstCombine/builtin-hot.ll diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 82b30b8d815629..7eab1c4ed44b89 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -84,7 +84,6 @@ #include "llvm/Transforms/Scalar/EarlyCSE.h" #include "llvm/Transforms/Scalar/GVN.h" #include "llvm/Transforms/Scalar/JumpThreading.h" -#include "llvm/Transforms/Scalar/SimplifyCFG.h" #include "llvm/Transforms/Utils/Debugify.h" #include "llvm/Transforms/Utils/EntryExitInstrumenter.h" #include "llvm/Transforms/Utils/ModuleUtils.h" @@ -100,9 +99,9 @@ using namespace llvm; namespace llvm { extern cl::opt<bool> PrintPipelinePasses; -cl::opt<bool> ClRemoveTraps("clang-remove-traps", cl::Optional, - cl::desc("Insert remove-traps pass."), - cl::init(false)); +static cl::opt<bool> ClRemoveTraps("clang-remove-traps", cl::Optional, + cl::desc("Insert remove-traps pass."), + cl::init(false)); // Experiment to move sanitizers earlier. static cl::opt<bool> ClSanitizeOnOptimizerEarlyEP( @@ -757,11 +756,6 @@ static void addSanitizers(const Triple &TargetTriple, // from `buildInlinerPipeline`, which called after profile matching. PB.registerScalarOptimizerLateEPCallback( [](FunctionPassManager &FPM, OptimizationLevel Level) { - // RemoveTrapsPass expects trap blocks preceded by conditional - // branches, which usually is not the case without SimplifyCFG. - // TODO: Remove `SimplifyCFGPass` after switching to dedicated - // intrinsic. - FPM.addPass(SimplifyCFGPass()); FPM.addPass(RemoveTrapsPass()); }); } diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 59a7fe8925001c..3a27622f165995 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -56,7 +56,14 @@ using namespace CodeGen; // Experiment to make sanitizers easier to debug static llvm::cl::opt<bool> ClSanitizeDebugDeoptimization( "ubsan-unique-traps", llvm::cl::Optional, - llvm::cl::desc("Deoptimize traps for UBSAN so there is 1 trap per check"), + llvm::cl::desc("Deoptimize traps for UBSAN so there is 1 trap per check."), + llvm::cl::init(false)); + +// TODO: Introduce frontend options to enabled per sanitizers, similar to +// `fsanitize-trap`. +static llvm::cl::opt<bool> ClSanitizeExpHot( + "ubsan-exp-hot", llvm::cl::Optional, + llvm::cl::desc("Pass UBSAN checks if `llvm.experimental.hot()` is true."), llvm::cl::init(false)); //===--------------------------------------------------------------------===// @@ -3805,6 +3812,12 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked, SanitizerHandler CheckHandlerID) { llvm::BasicBlock *Cont = createBasicBlock("cont"); + if (ClSanitizeExpHot) { + Checked = + Builder.CreateOr(Checked, Builder.CreateCall(CGM.getIntrinsic( + llvm::Intrinsic::experimental_hot))); + } + // If we're optimizing, collapse all calls to trap down to just one per // check-type per function to save on code size. if ((int)TrapBBs.size() <= CheckHandlerID) diff --git a/clang/test/CodeGen/remote-traps.c b/clang/test/CodeGen/remote-traps.c index 6751afb96d25f2..16e4ebecb5c326 100644 --- a/clang/test/CodeGen/remote-traps.c +++ b/clang/test/CodeGen/remote-traps.c @@ -1,5 +1,7 @@ -// RUN: %clang_cc1 -O1 -emit-llvm -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow %s -o - | FileCheck %s -// RUN: %clang_cc1 -O1 -emit-llvm -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow -mllvm -clang-remove-traps -mllvm -remove-traps-random-rate=1 %s -o - | FileCheck %s --implicit-check-not="call void @llvm.ubsantrap" --check-prefixes=REMOVE +// 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 + +#include <stdbool.h> int test(int x) { return x + 123; @@ -12,4 +14,19 @@ int test(int x) { // CHECK-NEXT: unreachable // REMOVE-LABEL: define {{.*}}i32 @test( -// REMOVE: call { i32, i1 } @llvm.sadd.with.overflow.i32( +// REMOVE: add i32 %x, 123 +// REMOVE-NEXT: ret i32 + + +bool experimental_hot() __asm("llvm.experimental.hot"); + +bool test_asm() { + return experimental_hot(); +} + +// CHECK-LABEL: define {{.*}}i1 @test_asm( +// CHECK: [[R:%.*]] = tail call zeroext i1 @llvm.experimental.hot() +// CHECK: ret i1 [[R]] + +// REMOVE-LABEL: define {{.*}}i1 @test_asm( +// REMOVE: ret i1 true diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index 77ec72f176d6ed..36f4c964ee296c 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -27553,7 +27553,7 @@ in example below: .. code-block:: text %cond = call i1 @llvm.experimental.widenable.condition() - br i1 %cond, label %solution_1, label %solution_2 + br i1 %cond, label %fast_path, label %slow_path label %fast_path: ; Apply memory-consuming but fast solution for a task. @@ -27639,6 +27639,54 @@ constant `true`. However it is always correct to replace it with any other `i1` value. Any pass can freely do it if it can benefit from non-default lowering. +'``llvm.experimental.hot``' Intrinsic +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Syntax: +""""""" + +:: + + declare i1 @llvm.experimental.hot() + +Overview: +""""""""" + +This intrinsic returns true iff it's known that containing basic block is hot in +profile. + +When used with profile based optimization allows to change program behaviour +deppending on the code hotness. + +Arguments: +"""""""""" + +None. + +Semantics: +"""""""""" + +The intrinsic ``@llvm.experimental.hot()`` returns either `true` or `false`, +deppending on profile used. Expresion is evaluated as `true` iff profile and +summary are availible and profile counter for the block reach hotness threshold. +For each evaluation of a call to this intrinsic, the program must be valid and +correct both if it returns `true` and if it returns `false`. + +When used in a branch condition, it allows us to choose between +two alternative correct solutions for the same problem, like +in example below: + +.. code-block:: text + + %cond = call i1 @llvm.experimental.hot() + br i1 %cond, label %fast_path, label %slow_path + + label %fast_path: + ; Omit diagnostics. + + label %slow_path: + ; Additional diagnostics. + '``llvm.load.relative``' Intrinsic ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td index 144298fd7c0162..96e9cdf6627a75 100644 --- a/llvm/include/llvm/IR/Intrinsics.td +++ b/llvm/include/llvm/IR/Intrinsics.td @@ -1722,6 +1722,11 @@ def int_debugtrap : Intrinsic<[]>, def int_ubsantrap : Intrinsic<[], [llvm_i8_ty], [IntrNoReturn, IntrCold, ImmArg<ArgIndex<0>>]>; +// Return true if profile counter for containing block is hot. +def int_experimental_hot : Intrinsic<[llvm_i1_ty], [], + [IntrInaccessibleMemOnly, IntrWriteMem, + IntrWillReturn, NoUndef<RetIndex>]>; + // Support for dynamic deoptimization (or de-specialization) def int_experimental_deoptimize : Intrinsic<[llvm_any_ty], [llvm_vararg_ty], [Throws]>; diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 22e57d0d99e9b1..8e73433ce82ea5 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -7276,6 +7276,12 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, setValue(&I, getValue(I.getArgOperand(0))); return; + case Intrinsic::experimental_hot: + // Default lowering to false. It's intended to be lowered as soon as profile + // is avalible to unblock other optimizations. + setValue(&I, DAG.getConstant(0, sdl, MVT::i1)); + return; + case Intrinsic::ubsantrap: case Intrinsic::debugtrap: case Intrinsic::trap: { diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index f5f3716d390d77..a7f2b0216bfa00 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -2827,6 +2827,14 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) { })) return nullptr; break; + case Intrinsic::experimental_hot: { + // The intrinsic declaration includes sideeffects to avoid it moved. This + // prevents removing even if the intrinsic is unused. We should remove + // unused ones to enabled other optimizations. + if (CI.use_empty()) + return eraseInstFromFunction(CI); + break; + } case Intrinsic::assume: { Value *IIOperand = II->getArgOperand(0); SmallVector<OperandBundleDef, 4> OpBundles; diff --git a/llvm/lib/Transforms/Instrumentation/RemoveTrapsPass.cpp b/llvm/lib/Transforms/Instrumentation/RemoveTrapsPass.cpp index d87f7482a21d25..fa4716f2e7a403 100644 --- a/llvm/lib/Transforms/Instrumentation/RemoveTrapsPass.cpp +++ b/llvm/lib/Transforms/Instrumentation/RemoveTrapsPass.cpp @@ -11,6 +11,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/ProfileSummaryInfo.h" +#include "llvm/IR/Constant.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/Intrinsics.h" @@ -37,7 +38,7 @@ STATISTIC(NumChecksRemoved, "Number of removed checks"); static bool removeUbsanTraps(Function &F, const BlockFrequencyInfo &BFI, const ProfileSummaryInfo *PSI) { - SmallVector<IntrinsicInst *, 16> Remove; + SmallVector<std::pair<IntrinsicInst *, Value *>, 16> ReplaceWithValue; std::unique_ptr<RandomNumberGenerator> Rng; auto ShouldRemove = [&](bool IsHot) { @@ -56,15 +57,12 @@ static bool removeUbsanTraps(Function &F, const BlockFrequencyInfo &BFI, continue; auto ID = II->getIntrinsicID(); switch (ID) { - case Intrinsic::ubsantrap: { + case Intrinsic::experimental_hot: { ++NumChecksTotal; bool IsHot = false; if (PSI) { - uint64_t Count = 0; - for (const auto *PR : predecessors(&BB)) - Count += BFI.getBlockProfileCount(PR).value_or(0); - + uint64_t Count = BFI.getBlockProfileCount(&BB).value_or(0); IsHot = HotPercentileCutoff.getNumOccurrences() ? (HotPercentileCutoff > 0 && @@ -72,10 +70,14 @@ static bool removeUbsanTraps(Function &F, const BlockFrequencyInfo &BFI, : PSI->isHotCount(Count); } - if (ShouldRemove(IsHot)) { - Remove.push_back(II); + bool ToRemove = ShouldRemove(IsHot); + ReplaceWithValue.push_back({ + II, + ToRemove ? Constant::getAllOnesValue(II->getType()) + : (Constant::getNullValue(II->getType())), + }); + if (ToRemove) ++NumChecksRemoved; - } break; } default: @@ -84,10 +86,12 @@ static bool removeUbsanTraps(Function &F, const BlockFrequencyInfo &BFI, } } - for (IntrinsicInst *I : Remove) + for (auto [I, V] : ReplaceWithValue) { + I->replaceAllUsesWith(V); I->eraseFromParent(); + } - return !Remove.empty(); + return !ReplaceWithValue.empty(); } PreservedAnalyses RemoveTrapsPass::run(Function &F, diff --git a/llvm/test/CodeGen/Generic/builtin-hot.ll b/llvm/test/CodeGen/Generic/builtin-hot.ll new file mode 100644 index 00000000000000..449f58d3c00675 --- /dev/null +++ b/llvm/test/CodeGen/Generic/builtin-hot.ll @@ -0,0 +1,19 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4 +; RUN: llc -o - %s | FileCheck %s + +; REQUIRES: aarch64-registered-target + +target triple = "aarch64-linux" + +define i1 @test() { +; CHECK-LABEL: test: +; CHECK: // %bb.0: // %entry +; CHECK-NEXT: mov w0, wzr +; CHECK-NEXT: ret +entry: + %hot = call i1 @llvm.experimental.hot() + ret i1 %hot +} + +declare i1 @llvm.expect.hot() nounwind + diff --git a/llvm/test/Transforms/InstCombine/builtin-hot.ll b/llvm/test/Transforms/InstCombine/builtin-hot.ll new file mode 100644 index 00000000000000..8d338875d7adb5 --- /dev/null +++ b/llvm/test/Transforms/InstCombine/builtin-hot.ll @@ -0,0 +1,25 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -passes=instcombine -S | FileCheck %s + +define i1 @test() { +; CHECK-LABEL: @test( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[HOT:%.*]] = call i1 @llvm.experimental.hot() +; CHECK-NEXT: ret i1 [[HOT]] +; +entry: + %hot = call i1 @llvm.experimental.hot() + ret i1 %hot +} + +define void @test_void() { +; CHECK-LABEL: @test_void( +; CHECK-NEXT: entry: +; CHECK-NEXT: ret void +; +entry: + %hot = call i1 @llvm.experimental.hot() + ret void +} + +declare i1 @llvm.expect.hot() nounwind diff --git a/llvm/test/Transforms/RemoveTraps/remove-traps.ll b/llvm/test/Transforms/RemoveTraps/remove-traps.ll index 71549e7d9b4122..80b86e0f7455aa 100644 --- a/llvm/test/Transforms/RemoveTraps/remove-traps.ll +++ b/llvm/test/Transforms/RemoveTraps/remove-traps.ll @@ -12,7 +12,8 @@ define dso_local noundef i32 @simple(ptr noundef readonly %0) { ; NOPROFILE-LABEL: define dso_local noundef i32 @simple( ; NOPROFILE-SAME: ptr noundef readonly [[TMP0:%.*]]) { ; NOPROFILE-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null -; NOPROFILE-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]] +; NOPROFILE-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], false +; NOPROFILE-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]] ; NOPROFILE: 3: ; NOPROFILE-NEXT: tail call void @llvm.ubsantrap(i8 22) ; NOPROFILE-NEXT: unreachable @@ -23,8 +24,10 @@ define dso_local noundef i32 @simple(ptr noundef readonly %0) { ; ALL-LABEL: define dso_local noundef i32 @simple( ; ALL-SAME: ptr noundef readonly [[TMP0:%.*]]) { ; ALL-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null -; ALL-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]] +; ALL-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], true +; ALL-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]] ; ALL: 3: +; ALL-NEXT: tail call void @llvm.ubsantrap(i8 22) ; ALL-NEXT: unreachable ; ALL: 4: ; ALL-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4 @@ -33,7 +36,8 @@ define dso_local noundef i32 @simple(ptr noundef readonly %0) { ; HOT-LABEL: define dso_local noundef i32 @simple( ; HOT-SAME: ptr noundef readonly [[TMP0:%.*]]) { ; HOT-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null -; HOT-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]] +; HOT-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], false +; HOT-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]] ; HOT: 3: ; HOT-NEXT: tail call void @llvm.ubsantrap(i8 22) ; HOT-NEXT: unreachable @@ -44,7 +48,8 @@ define dso_local noundef i32 @simple(ptr noundef readonly %0) { ; HOT70-LABEL: define dso_local noundef i32 @simple( ; HOT70-SAME: ptr noundef readonly [[TMP0:%.*]]) { ; HOT70-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null -; HOT70-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]] +; HOT70-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], false +; HOT70-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]] ; HOT70: 3: ; HOT70-NEXT: tail call void @llvm.ubsantrap(i8 22) ; HOT70-NEXT: unreachable @@ -52,7 +57,9 @@ define dso_local noundef i32 @simple(ptr noundef readonly %0) { ; HOT70-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4 ; HOT70-NEXT: ret i32 [[TMP5]] ; - %2 = icmp eq ptr %0, null + %chk = icmp eq ptr %0, null + %hot = call i1 @llvm.experimental.hot() + %2 = or i1 %chk, %hot br i1 %2, label %3, label %4 3: @@ -69,7 +76,8 @@ define dso_local noundef i32 @hot(ptr noundef readonly %0) !prof !36 { ; NOPROFILE-LABEL: define dso_local noundef i32 @hot( ; NOPROFILE-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF16:![0-9]+]] { ; NOPROFILE-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null -; NOPROFILE-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]] +; NOPROFILE-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], false +; NOPROFILE-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]] ; NOPROFILE: 3: ; NOPROFILE-NEXT: tail call void @llvm.ubsantrap(i8 22) ; NOPROFILE-NEXT: unreachable @@ -80,8 +88,10 @@ define dso_local noundef i32 @hot(ptr noundef readonly %0) !prof !36 { ; ALL-LABEL: define dso_local noundef i32 @hot( ; ALL-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF16:![0-9]+]] { ; ALL-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null -; ALL-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]] +; ALL-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], true +; ALL-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]] ; ALL: 3: +; ALL-NEXT: tail call void @llvm.ubsantrap(i8 22) ; ALL-NEXT: unreachable ; ALL: 4: ; ALL-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4 @@ -90,8 +100,10 @@ define dso_local noundef i32 @hot(ptr noundef readonly %0) !prof !36 { ; HOT-LABEL: define dso_local noundef i32 @hot( ; HOT-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF16:![0-9]+]] { ; HOT-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null -; HOT-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]] +; HOT-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], true +; HOT-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]] ; HOT: 3: +; HOT-NEXT: tail call void @llvm.ubsantrap(i8 22) ; HOT-NEXT: unreachable ; HOT: 4: ; HOT-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4 @@ -100,7 +112,8 @@ define dso_local noundef i32 @hot(ptr noundef readonly %0) !prof !36 { ; HOT70-LABEL: define dso_local noundef i32 @hot( ; HOT70-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF16:![0-9]+]] { ; HOT70-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null -; HOT70-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]] +; HOT70-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], false +; HOT70-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]] ; HOT70: 3: ; HOT70-NEXT: tail call void @llvm.ubsantrap(i8 22) ; HOT70-NEXT: unreachable @@ -108,7 +121,9 @@ define dso_local noundef i32 @hot(ptr noundef readonly %0) !prof !36 { ; HOT70-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4 ; HOT70-NEXT: ret i32 [[TMP5]] ; - %2 = icmp eq ptr %0, null + %chk = icmp eq ptr %0, null + %hot = call i1 @llvm.experimental.hot() + %2 = or i1 %chk, %hot br i1 %2, label %3, label %4 3: @@ -124,7 +139,8 @@ define dso_local noundef i32 @veryHot(ptr noundef readonly %0) !prof !39 { ; NOPROFILE-LABEL: define dso_local noundef i32 @veryHot( ; NOPROFILE-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF17:![0-9]+]] { ; NOPROFILE-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null -; NOPROFILE-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]] +; NOPROFILE-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], false +; NOPROFILE-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]] ; NOPROFILE: 3: ; NOPROFILE-NEXT: tail call void @llvm.ubsantrap(i8 22) ; NOPROFILE-NEXT: unreachable @@ -135,8 +151,10 @@ define dso_local noundef i32 @veryHot(ptr noundef readonly %0) !prof !39 { ; ALL-LABEL: define dso_local noundef i32 @veryHot( ; ALL-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF17:![0-9]+]] { ; ALL-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null -; ALL-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]] +; ALL-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], true +; ALL-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]] ; ALL: 3: +; ALL-NEXT: tail call void @llvm.ubsantrap(i8 22) ; ALL-NEXT: unreachable ; ALL: 4: ; ALL-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4 @@ -145,8 +163,10 @@ define dso_local noundef i32 @veryHot(ptr noundef readonly %0) !prof !39 { ; HOT-LABEL: define dso_local noundef i32 @veryHot( ; HOT-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF17:![0-9]+]] { ; HOT-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null -; HOT-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]] +; HOT-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], true +; HOT-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]] ; HOT: 3: +; HOT-NEXT: tail call void @llvm.ubsantrap(i8 22) ; HOT-NEXT: unreachable ; HOT: 4: ; HOT-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4 @@ -155,14 +175,18 @@ define dso_local noundef i32 @veryHot(ptr noundef readonly %0) !prof !39 { ; HOT70-LABEL: define dso_local noundef i32 @veryHot( ; HOT70-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF17:![0-9]+]] { ; HOT70-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null -; HOT70-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]] +; HOT70-NEXT: [[TMP6:%.*]] = or i1 [[TMP2]], true +; HOT70-NEXT: br i1 [[TMP6]], label [[TMP3:%.*]], label [[TMP4:%.*]] ; HOT70: 3: +; HOT70-NEXT: tail call void @llvm.ubsantrap(i8 22) ; HOT70-NEXT: unreachable ; HOT70: 4: ; HOT70-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4 ; HOT70-NEXT: ret i32 [[TMP5]] ; - %2 = icmp eq ptr %0, null + %chk = icmp eq ptr %0, null + %hot = call i1 @llvm.experimental.hot() + %2 = or i1 %chk, %hot br i1 %2, label %3, label %4 3: @@ -182,7 +206,8 @@ define dso_local noundef i32 @branchColdFnHot(i32 noundef %0, ptr noundef readon ; NOPROFILE-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF18:![0-9]+]] ; NOPROFILE: 4: ; NOPROFILE-NEXT: [[TMP5:%.*]] = icmp eq ptr [[TMP1]], null -; NOPROFILE-NEXT: br i1 [[TMP5]], label [[TMP6:%.*]], label [[TMP7:%.*]] +; NOPROFILE-NEXT: [[TMP11:%.*]] = or i1 [[TMP5]], false +; NOPROFILE-NEXT: br i1 [[TMP11]], label [[TMP6:%.*]], label [[TMP7:%.*]] ; NOPROFILE: 6: ; NOPROFILE-NEXT: tail call void @llvm.ubsantrap(i8 22) ; NOPROFILE-NEXT: unreachable @@ -199,8 +224,10 @@ define dso_local noundef i32 @branchColdFnHot(i32 noundef %0, ptr noundef readon ; ALL-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF18:![0-9]+]] ; ALL: 4: ; ALL-NEXT: [[TMP5:%.*]] = icmp eq ptr [[TMP1]], null -; ALL-NEXT: br i1 [[TMP5]], label [[TMP6:%.*]], label [[TMP7:%.*]] +; ALL-NEXT: [[TMP11:%.*]] = or i1 [[TMP5]], true +; ALL-NEXT: br i1 [[TMP11]], label [[TMP6:%.*]], label [[TMP7:%.*]] ; ALL: 6: +; ALL-NEXT: tail call void @llvm.ubsantrap(i8 22) ; ALL-NEXT: unreachable ; ALL: 7: ; ALL-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP1]], align 4 @@ -215,7 +242,8 @@ define dso_local noundef i32 @branchColdFnHot(i32 noundef %0, ptr noundef readon ; HOT-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF18:![0-9]+]] ; HOT: 4: ; HOT-NEXT: [[TMP5:%.*]] = icmp eq ptr [[TMP1]], null -; HOT-NEXT: br i1 [[TMP5]], label [[TMP6:%.*]], label [[TMP7:%.*]] +; HOT-NEXT: [[TMP11:%.*]] = or i1 [[TMP5]], false +; HOT-NEXT: br i1 [[TMP11]], label [[TMP6:%.*]], label [[TMP7:%.*]] ; HOT: 6: ; HOT-NEXT: tail call void @llvm.ubsantrap(i8 22) ; HOT-NEXT: unreachable @@ -232,7 +260,8 @@ define dso_local noundef i32 @branchColdFnHot(i32 noundef %0, ptr noundef readon ; HOT70-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF18:![0-9]+]] ; HOT70: 4: ; HOT70-NEXT: [[TMP5:%.*]] = icmp eq ptr [[TMP1]], null -; HOT70-NEXT: br i1 [[TMP5]], label [[TMP6:%.*]], label [[TMP7:%.*]] +; HOT70-NEXT: [[TMP11:%.*]] = or i1 [[TMP5]], false +; HOT70-NEXT: br i1 [[TMP11]], label [[TMP6:%.*]], label [[TMP7:%.*]] ; HOT70: 6: ; HOT70-NEXT: tail call void @llvm.ubsantrap(i8 22) ; HOT70-NEXT: unreachable @@ -247,7 +276,9 @@ define dso_local noundef i32 @branchColdFnHot(i32 noundef %0, ptr noundef readon br i1 %3, label %9, label %4, !prof !38 4: - %5 = icmp eq ptr %1, null + %chk = icmp eq ptr %1, null + %hot = call i1 @llvm.experimental.hot() + %5 = or i1 %chk, %hot br i1 %5, label %6, label %7 6: @@ -270,7 +301,8 @@ define dso_local noundef i32 @branchHotFnCold(i32 noundef %0, ptr noundef readon ; NOPROFILE-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF19:![0-9]+]] ; NOPROFILE: 4: ; NOPROFILE-NEXT: [[TMP5:%.*]] = icmp eq ptr [[TMP1]], null -; NOPROFILE-NEXT: br i1 [[TMP5]], label [[TMP6:%.*]], label [[TMP7:%.*]] +; NOPROFILE-NEXT: [[TMP11:%.*]] = or i1 [[TMP5]], false +; NOPROFILE-NEXT: br i1 [[TMP11]], label [[TMP6:%.*]], label [[TMP7:%.*]] ; NOPROFILE: 6: ; NOPROFILE-NEXT: tail call void @llvm.ubsantrap(i8 22) ; NOPROFILE-NEXT: unreachable @@ -287,8 +319,10 @@ define dso_local noundef i32 @branchHotFnCold(i32 noundef %0, ptr noundef readon ; ALL-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF19:![0-9]+]] ; ALL: 4: ; ALL-NEXT: [[TMP5:%.*]] = icmp eq ptr [[TMP1]], null -; ALL-NEXT: br i1 [[TMP5]], label [[TMP6:%.*]], label [[TMP7:%.*]] +; ALL-NEXT: [[TMP11:%.*]] = or i1 [[TMP5]], true +; ALL-NEXT: br i1 [[TMP11]], label [[TMP6:%.*]], label [[TMP7:%.*]] ; ALL: 6: +; ALL-NEXT: tail call void @llvm.ubsantrap(i8 22) ; ALL-NEXT: unreachable ; ALL: 7: ; ALL-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP1]], align 4 @@ -303,8 +337,10 @@ define dso_local noundef i32 @branchHotFnCold(i32 noundef %0, ptr noundef readon ; HOT-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF19:![0-9]+]] ; HOT: 4: ; HOT-NEXT: [[TMP5:%.*]] = icmp eq ptr [[TMP1]], null -; HOT-NEXT: br i1 [[TMP5]], label [[TMP6:%.*]], label [[TMP7:%.*]] +; HOT-NEXT: [[TMP11:%.*]] = or i1 [[TMP5]], true +; HOT-NEXT: br i1 [[TMP11]], label [[TMP6:%.*]], label [[TMP7:%.*]] ; HOT: 6: +; HOT-NEXT: tail call void @llvm.ubsantrap(i8 22) ; HOT-NEXT: unreachable ; HOT: 7: ; HOT-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP1]], align 4 @@ -319,7 +355,8 @@ define dso_local noundef i32 @branchHotFnCold(i32 noundef %0, ptr noundef readon ; HOT70-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF19:![0-9]+]] ; HOT70: 4: ; HOT70-NEXT: [[TMP5:%.*]] = icmp eq ptr [[TMP1]], null -; HOT70-NEXT: br i1 [[TMP5]], label [[TMP6:%.*]], label [[TMP7:%.*]] +; HOT70-NEXT: [[TMP11:%.*]] = or i1 [[TMP5]], false +; HOT70-NEXT: br i1 [[TMP11]], label [[TMP6:%.*]], label [[TMP7:%.*]] ; HOT70: 6: ; HOT70-NEXT: tail call void @llvm.ubsantrap(i8 22) ; HOT70-NEXT: unreachable @@ -334,7 +371,9 @@ define dso_local noundef i32 @branchHotFnCold(i32 noundef %0, ptr noundef readon br i1 %3, label %9, label %4, !prof !37 4: - %5 = icmp eq ptr %1, null + %chk = icmp eq ptr %1, null + %hot = call i1 @llvm.experimental.hot() + %5 = or i1 %chk, %hot br i1 %5, label %6, label %7 6: >From b61127a394afddde67638e6334463b9628002429 Mon Sep 17 00:00:00 2001 From: Vitaly Buka <vitalyb...@google.com> Date: Mon, 11 Mar 2024 17:13:21 -0700 Subject: [PATCH 2/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?= =?UTF-8?q?anges=20introduced=20through=20rebase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 [skip ci] --- clang/test/CodeGen/remote-traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/CodeGen/remote-traps.c b/clang/test/CodeGen/remote-traps.c index 16e4ebecb5c326..934b76fae0d2a5 100644 --- a/clang/test/CodeGen/remote-traps.c +++ b/clang/test/CodeGen/remote-traps.c @@ -1,4 +1,4 @@ -// 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 | 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 #include <stdbool.h> >From b2a1f505cdd88218f7c2197644f7fded6a347dc2 Mon Sep 17 00:00:00 2001 From: Vitaly Buka <vitalyb...@google.com> Date: Thu, 4 Apr 2024 18:07:36 -0700 Subject: [PATCH 3/3] shorten name Created using spr 1.3.4 --- clang/lib/CodeGen/BackendUtil.cpp | 6 +++--- ...erBuiltinAllowCheckPass.h => LowerAllowCheckPass.h} | 9 ++++----- llvm/lib/Passes/PassBuilder.cpp | 2 +- llvm/lib/Passes/PassRegistry.def | 2 +- llvm/lib/Transforms/Instrumentation/CMakeLists.txt | 2 +- ...iltinAllowCheckPass.cpp => LowerAllowCheckPass.cpp} | 10 +++++----- .../llvm/lib/Transforms/Instrumentation/BUILD.gn | 2 +- 7 files changed, 16 insertions(+), 17 deletions(-) rename llvm/include/llvm/Transforms/Instrumentation/{LowerBuiltinAllowCheckPass.h => LowerAllowCheckPass.h} (74%) rename llvm/lib/Transforms/Instrumentation/{LowerBuiltinAllowCheckPass.cpp => LowerAllowCheckPass.cpp} (90%) diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index a7547d149ce045..6cc00b85664f41 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -73,7 +73,7 @@ #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h" #include "llvm/Transforms/Instrumentation/InstrProfiling.h" #include "llvm/Transforms/Instrumentation/KCFI.h" -#include "llvm/Transforms/Instrumentation/LowerBuiltinAllowCheckPass.h" +#include "llvm/Transforms/Instrumentation/LowerAllowCheckPass.h" #include "llvm/Transforms/Instrumentation/MemProfiler.h" #include "llvm/Transforms/Instrumentation/MemorySanitizer.h" #include "llvm/Transforms/Instrumentation/PGOInstrumentation.h" @@ -746,13 +746,13 @@ static void addSanitizers(const Triple &TargetTriple, PB.registerOptimizerLastEPCallback(SanitizersCallback); } - if (LowerBuiltinAllowCheckPass::IsRequested()) { + 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(LowerBuiltinAllowCheckPass()); + FPM.addPass(LowerAllowCheckPass()); }); } } diff --git a/llvm/include/llvm/Transforms/Instrumentation/LowerBuiltinAllowCheckPass.h b/llvm/include/llvm/Transforms/Instrumentation/LowerAllowCheckPass.h similarity index 74% rename from llvm/include/llvm/Transforms/Instrumentation/LowerBuiltinAllowCheckPass.h rename to llvm/include/llvm/Transforms/Instrumentation/LowerAllowCheckPass.h index 151bf5479514b6..af974818fec5f3 100644 --- a/llvm/include/llvm/Transforms/Instrumentation/LowerBuiltinAllowCheckPass.h +++ b/llvm/include/llvm/Transforms/Instrumentation/LowerAllowCheckPass.h @@ -1,4 +1,4 @@ -//===- LowerBuiltinAllowCheckPass.h -----------------------------*- C++ -*-===// +//===- LowerAllowCheckPass.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_LOWERBUILTINALLOWCHECKPASS_H -#define LLVM_TRANSFORMS_INSTRUMENTATION_LOWERBUILTINALLOWCHECKPASS_H +#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_LOWERALLOWCHECKPASS_H +#define LLVM_TRANSFORMS_INSTRUMENTATION_LOWERALLOWCHECKPASS_H #include "llvm/IR/Function.h" #include "llvm/IR/PassManager.h" @@ -22,8 +22,7 @@ namespace llvm { // This pass is responsible for removing optional traps, like llvm.ubsantrap // from the hot code. -class LowerBuiltinAllowCheckPass - : public PassInfoMixin<LowerBuiltinAllowCheckPass> { +class LowerAllowCheckPass : public PassInfoMixin<LowerAllowCheckPass> { public: PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 313de329fde022..832ee352205a04 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -172,7 +172,7 @@ #include "llvm/Transforms/Instrumentation/InstrOrderFile.h" #include "llvm/Transforms/Instrumentation/InstrProfiling.h" #include "llvm/Transforms/Instrumentation/KCFI.h" -#include "llvm/Transforms/Instrumentation/LowerBuiltinAllowCheckPass.h" +#include "llvm/Transforms/Instrumentation/LowerAllowCheckPass.h" #include "llvm/Transforms/Instrumentation/MemProfiler.h" #include "llvm/Transforms/Instrumentation/MemorySanitizer.h" #include "llvm/Transforms/Instrumentation/PGOForceFunctionAttrs.h" diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def index 75aab2ef01472b..d15f58d7adfae4 100644 --- a/llvm/lib/Passes/PassRegistry.def +++ b/llvm/lib/Passes/PassRegistry.def @@ -363,7 +363,7 @@ 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", LowerBuiltinAllowCheckPass()) +FUNCTION_PASS("lower-allow-check", LowerAllowCheckPass()) FUNCTION_PASS("lower-atomic", LowerAtomicPass()) FUNCTION_PASS("lower-constant-intrinsics", LowerConstantIntrinsicsPass()) FUNCTION_PASS("lower-expect", LowerExpectIntrinsicPass()) diff --git a/llvm/lib/Transforms/Instrumentation/CMakeLists.txt b/llvm/lib/Transforms/Instrumentation/CMakeLists.txt index 8ba905f3ef52dd..981405329389f4 100644 --- a/llvm/lib/Transforms/Instrumentation/CMakeLists.txt +++ b/llvm/lib/Transforms/Instrumentation/CMakeLists.txt @@ -13,7 +13,7 @@ add_llvm_component_library(LLVMInstrumentation InstrOrderFile.cpp InstrProfiling.cpp KCFI.cpp - LowerBuiltinAllowCheckPass.cpp + LowerAllowCheckPass.cpp PGOForceFunctionAttrs.cpp PGOInstrumentation.cpp PGOMemOPSizeOpt.cpp diff --git a/llvm/lib/Transforms/Instrumentation/LowerBuiltinAllowCheckPass.cpp b/llvm/lib/Transforms/Instrumentation/LowerAllowCheckPass.cpp similarity index 90% rename from llvm/lib/Transforms/Instrumentation/LowerBuiltinAllowCheckPass.cpp rename to llvm/lib/Transforms/Instrumentation/LowerAllowCheckPass.cpp index b1419838e05e93..54b63278e9dd9f 100644 --- a/llvm/lib/Transforms/Instrumentation/LowerBuiltinAllowCheckPass.cpp +++ b/llvm/lib/Transforms/Instrumentation/LowerAllowCheckPass.cpp @@ -1,4 +1,4 @@ -//===- LowerBuiltinAllowCheckPass.cpp ---------------------------*- C++ -*-===// +//===- LowerAllowCheckPass.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/LowerBuiltinAllowCheckPass.h" +#include "llvm/Transforms/Instrumentation/LowerAllowCheckPass.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" @@ -91,8 +91,8 @@ static bool removeUbsanTraps(Function &F, const BlockFrequencyInfo &BFI, return !ReplaceWithValue.empty(); } -PreservedAnalyses LowerBuiltinAllowCheckPass::run(Function &F, - FunctionAnalysisManager &AM) { +PreservedAnalyses LowerAllowCheckPass::run(Function &F, + FunctionAnalysisManager &AM) { if (F.isDeclaration()) return PreservedAnalyses::all(); auto &MAMProxy = AM.getResult<ModuleAnalysisManagerFunctionProxy>(F); @@ -104,7 +104,7 @@ PreservedAnalyses LowerBuiltinAllowCheckPass::run(Function &F, : PreservedAnalyses::all(); } -bool LowerBuiltinAllowCheckPass::IsRequested() { +bool LowerAllowCheckPass::IsRequested() { return RandomRate.getNumOccurrences() || HotPercentileCutoff.getNumOccurrences(); } diff --git a/llvm/utils/gn/secondary/llvm/lib/Transforms/Instrumentation/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/Transforms/Instrumentation/BUILD.gn index fdc4d95fb24c45..d79b5efe69eb00 100644 --- a/llvm/utils/gn/secondary/llvm/lib/Transforms/Instrumentation/BUILD.gn +++ b/llvm/utils/gn/secondary/llvm/lib/Transforms/Instrumentation/BUILD.gn @@ -23,7 +23,7 @@ static_library("Instrumentation") { "InstrProfiling.cpp", "Instrumentation.cpp", "KCFI.cpp", - "LowerBuiltinAllowCheckPass.cpp", + "LowerAllowCheckPass.cpp", "MemProfiler.cpp", "MemorySanitizer.cpp", "PGOForceFunctionAttrs.cpp", _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits