From 8151c1b44211d5a7154ca860d28a6aed3a4f2715 Mon Sep 17 00:00:00 2001 From: Stanislav Mekhanoshin Date: Thu, 4 Feb 2021 14:21:02 -0800 Subject: [PATCH] Move implementation of isAssumeLikeIntrinsic into IntrinsicInst This is remove dependency on ValueTracking in the future patch. Differential Revision: https://reviews.llvm.org/D96079 --- llvm/include/llvm/IR/IntrinsicInst.h | 23 +++++++++++++++++++++++ llvm/lib/Analysis/ValueTracking.cpp | 23 ++--------------------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/llvm/include/llvm/IR/IntrinsicInst.h b/llvm/include/llvm/IR/IntrinsicInst.h index df3a1d568756..a7dec8837bf8 100644 --- a/llvm/include/llvm/IR/IntrinsicInst.h +++ b/llvm/include/llvm/IR/IntrinsicInst.h @@ -82,6 +82,29 @@ public: } } + // Checks if the intrinsic is an annotation. + bool isAssumeLikeIntrinsic() const { + switch (getIntrinsicID()) { + default: break; + case Intrinsic::assume: + case Intrinsic::sideeffect: + case Intrinsic::pseudoprobe: + case Intrinsic::dbg_declare: + case Intrinsic::dbg_value: + case Intrinsic::dbg_label: + case Intrinsic::invariant_start: + case Intrinsic::invariant_end: + case Intrinsic::lifetime_start: + case Intrinsic::lifetime_end: + case Intrinsic::experimental_noalias_scope_decl: + case Intrinsic::objectsize: + case Intrinsic::ptr_annotation: + case Intrinsic::var_annotation: + return true; + } + return false; + } + // Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const CallInst *I) { if (const Function *CF = I->getCalledFunction()) diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 567d674ec721..d976d495e446 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -519,27 +519,8 @@ static bool isEphemeralValueOf(const Instruction *I, const Value *E) { // Is this an intrinsic that cannot be speculated but also cannot trap? bool llvm::isAssumeLikeIntrinsic(const Instruction *I) { - if (const CallInst *CI = dyn_cast(I)) - if (Function *F = CI->getCalledFunction()) - switch (F->getIntrinsicID()) { - default: break; - // FIXME: This list is repeated from NoTTI::getIntrinsicCost. - case Intrinsic::assume: - case Intrinsic::sideeffect: - case Intrinsic::pseudoprobe: - case Intrinsic::dbg_declare: - case Intrinsic::dbg_value: - case Intrinsic::dbg_label: - case Intrinsic::invariant_start: - case Intrinsic::invariant_end: - case Intrinsic::lifetime_start: - case Intrinsic::lifetime_end: - case Intrinsic::experimental_noalias_scope_decl: - case Intrinsic::objectsize: - case Intrinsic::ptr_annotation: - case Intrinsic::var_annotation: - return true; - } + if (const IntrinsicInst *CI = dyn_cast(I)) + return CI->isAssumeLikeIntrinsic(); return false; }