diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp index 0d8e637109066..ed4890eb7c994 100644 --- a/llvm/lib/IR/Instruction.cpp +++ b/llvm/lib/IR/Instruction.cpp @@ -734,13 +734,18 @@ bool Instruction::isVolatile() const { } bool Instruction::mayThrow() const { - if (const CallInst *CI = dyn_cast(this)) - return !CI->doesNotThrow(); - if (const auto *CRI = dyn_cast(this)) - return CRI->unwindsToCaller(); - if (const auto *CatchSwitch = dyn_cast(this)) - return CatchSwitch->unwindsToCaller(); - return isa(this); + switch (getOpcode()) { + case Instruction::Call: + return !cast(this)->doesNotThrow(); + case Instruction::CleanupRet: + return cast(this)->unwindsToCaller(); + case Instruction::CatchSwitch: + return cast(this)->unwindsToCaller(); + case Instruction::Resume: + return true; + default: + return false; + } } bool Instruction::mayHaveSideEffects() const {