[IR] Add Instruction::isLifetimeStartOrEnd, NFC

Instruction::isLifetimeStartOrEnd() checks whether an Instruction is an
llvm.lifetime.start or an llvm.lifetime.end intrinsic.

This was suggested as a cleanup in D55967.

Differential Revision: https://reviews.llvm.org/D56019

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349964 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Vedant Kumar
2018-12-21 21:49:40 +00:00
parent 3995aa63f6
commit eeb1971b1c
18 changed files with 41 additions and 69 deletions
+1 -9
View File
@@ -157,14 +157,6 @@ bool StackProtector::ContainsProtectableArray(Type *Ty, bool &IsLarge,
return NeedsProtector;
}
static bool isLifetimeInst(const Instruction *I) {
if (const auto Intrinsic = dyn_cast<IntrinsicInst>(I)) {
const auto Id = Intrinsic->getIntrinsicID();
return Id == Intrinsic::lifetime_start || Id == Intrinsic::lifetime_end;
}
return false;
}
bool StackProtector::HasAddressTaken(const Instruction *AI) {
for (const User *U : AI->users()) {
if (const StoreInst *SI = dyn_cast<StoreInst>(U)) {
@@ -175,7 +167,7 @@ bool StackProtector::HasAddressTaken(const Instruction *AI) {
return true;
} else if (const CallInst *CI = dyn_cast<CallInst>(U)) {
// Ignore intrinsics that are not calls. TODO: Use isLoweredToCall().
if (!isa<DbgInfoIntrinsic>(CI) && !isLifetimeInst(CI))
if (!isa<DbgInfoIntrinsic>(CI) && !CI->isLifetimeStartOrEnd())
return true;
} else if (isa<InvokeInst>(U)) {
return true;