Move implementation of isAssumeLikeIntrinsic into IntrinsicInst

This is remove dependency on ValueTracking in the future patch.

Differential Revision: https://reviews.llvm.org/D96079
This commit is contained in:
Stanislav Mekhanoshin 2021-02-04 14:21:02 -08:00
parent f47d7c145b
commit 8151c1b442
2 changed files with 25 additions and 21 deletions

View File

@ -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: // Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const CallInst *I) { static bool classof(const CallInst *I) {
if (const Function *CF = I->getCalledFunction()) if (const Function *CF = I->getCalledFunction())

View File

@ -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? // Is this an intrinsic that cannot be speculated but also cannot trap?
bool llvm::isAssumeLikeIntrinsic(const Instruction *I) { bool llvm::isAssumeLikeIntrinsic(const Instruction *I) {
if (const CallInst *CI = dyn_cast<CallInst>(I)) if (const IntrinsicInst *CI = dyn_cast<IntrinsicInst>(I))
if (Function *F = CI->getCalledFunction()) return CI->isAssumeLikeIntrinsic();
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;
}
return false; return false;
} }