summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/source/Expression/IRInterpreter.cpp138
1 files changed, 13 insertions, 125 deletions
diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp
index aeb0351c860..b2e4be5e40f 100644
--- a/lldb/source/Expression/IRInterpreter.cpp
+++ b/lldb/source/Expression/IRInterpreter.cpp
@@ -800,15 +800,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
}
} break;
case Instruction::Alloca: {
- const AllocaInst *alloca_inst = dyn_cast<AllocaInst>(inst);
-
- if (!alloca_inst) {
- LLDB_LOGF(log, "getOpcode() returns Alloca, but instruction is not an "
- "AllocaInst");
- error.SetErrorToGenericError();
- error.SetErrorString(interpreter_internal_error);
- return false;
- }
+ const AllocaInst *alloca_inst = cast<AllocaInst>(inst);
if (alloca_inst->isArrayAllocation()) {
LLDB_LOGF(log,
@@ -871,16 +863,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
} break;
case Instruction::BitCast:
case Instruction::ZExt: {
- const CastInst *cast_inst = dyn_cast<CastInst>(inst);
-
- if (!cast_inst) {
- LLDB_LOGF(
- log, "getOpcode() returns %s, but instruction is not a BitCastInst",
- cast_inst->getOpcodeName());
- error.SetErrorToGenericError();
- error.SetErrorString(interpreter_internal_error);
- return false;
- }
+ const CastInst *cast_inst = cast<CastInst>(inst);
Value *source = cast_inst->getOperand(0);
@@ -896,16 +879,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
frame.AssignValue(inst, S, module);
} break;
case Instruction::SExt: {
- const CastInst *cast_inst = dyn_cast<CastInst>(inst);
-
- if (!cast_inst) {
- LLDB_LOGF(
- log, "getOpcode() returns %s, but instruction is not a BitCastInst",
- cast_inst->getOpcodeName());
- error.SetErrorToGenericError();
- error.SetErrorString(interpreter_internal_error);
- return false;
- }
+ const CastInst *cast_inst = cast<CastInst>(inst);
Value *source = cast_inst->getOperand(0);
@@ -925,15 +899,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
frame.AssignValue(inst, S_signextend, module);
} break;
case Instruction::Br: {
- const BranchInst *br_inst = dyn_cast<BranchInst>(inst);
-
- if (!br_inst) {
- LLDB_LOGF(
- log, "getOpcode() returns Br, but instruction is not a BranchInst");
- error.SetErrorToGenericError();
- error.SetErrorString(interpreter_internal_error);
- return false;
- }
+ const BranchInst *br_inst = cast<BranchInst>(inst);
if (br_inst->isConditional()) {
Value *condition = br_inst->getCondition();
@@ -967,15 +933,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
}
continue;
case Instruction::PHI: {
- const PHINode *phi_inst = dyn_cast<PHINode>(inst);
-
- if (!phi_inst) {
- LLDB_LOGF(log,
- "getOpcode() returns PHI, but instruction is not a PHINode");
- error.SetErrorToGenericError();
- error.SetErrorString(interpreter_internal_error);
- return false;
- }
+ const PHINode *phi_inst = cast<PHINode>(inst);
if (!frame.m_prev_bb) {
LLDB_LOGF(log,
"Encountered PHI node without having jumped from another "
@@ -1002,15 +960,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
}
} break;
case Instruction::GetElementPtr: {
- const GetElementPtrInst *gep_inst = dyn_cast<GetElementPtrInst>(inst);
-
- if (!gep_inst) {
- LLDB_LOGF(log, "getOpcode() returns GetElementPtr, but instruction is "
- "not a GetElementPtrInst");
- error.SetErrorToGenericError();
- error.SetErrorString(interpreter_internal_error);
- return false;
- }
+ const GetElementPtrInst *gep_inst = cast<GetElementPtrInst>(inst);
const Value *pointer_operand = gep_inst->getPointerOperand();
Type *src_elem_ty = gep_inst->getSourceElementType();
@@ -1072,16 +1022,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
}
} break;
case Instruction::ICmp: {
- const ICmpInst *icmp_inst = dyn_cast<ICmpInst>(inst);
-
- if (!icmp_inst) {
- LLDB_LOGF(
- log,
- "getOpcode() returns ICmp, but instruction is not an ICmpInst");
- error.SetErrorToGenericError();
- error.SetErrorString(interpreter_internal_error);
- return false;
- }
+ const ICmpInst *icmp_inst = cast<ICmpInst>(inst);
CmpInst::Predicate predicate = icmp_inst->getPredicate();
@@ -1168,16 +1109,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
}
} break;
case Instruction::IntToPtr: {
- const IntToPtrInst *int_to_ptr_inst = dyn_cast<IntToPtrInst>(inst);
-
- if (!int_to_ptr_inst) {
- LLDB_LOGF(log,
- "getOpcode() returns IntToPtr, but instruction is not an "
- "IntToPtrInst");
- error.SetErrorToGenericError();
- error.SetErrorString(interpreter_internal_error);
- return false;
- }
+ const IntToPtrInst *int_to_ptr_inst = cast<IntToPtrInst>(inst);
Value *src_operand = int_to_ptr_inst->getOperand(0);
@@ -1199,16 +1131,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
}
} break;
case Instruction::PtrToInt: {
- const PtrToIntInst *ptr_to_int_inst = dyn_cast<PtrToIntInst>(inst);
-
- if (!ptr_to_int_inst) {
- LLDB_LOGF(log,
- "getOpcode() returns PtrToInt, but instruction is not an "
- "PtrToIntInst");
- error.SetErrorToGenericError();
- error.SetErrorString(interpreter_internal_error);
- return false;
- }
+ const PtrToIntInst *ptr_to_int_inst = cast<PtrToIntInst>(inst);
Value *src_operand = ptr_to_int_inst->getOperand(0);
@@ -1230,16 +1153,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
}
} break;
case Instruction::Trunc: {
- const TruncInst *trunc_inst = dyn_cast<TruncInst>(inst);
-
- if (!trunc_inst) {
- LLDB_LOGF(
- log,
- "getOpcode() returns Trunc, but instruction is not a TruncInst");
- error.SetErrorToGenericError();
- error.SetErrorString(interpreter_internal_error);
- return false;
- }
+ const TruncInst *trunc_inst = cast<TruncInst>(inst);
Value *src_operand = trunc_inst->getOperand(0);
@@ -1261,15 +1175,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
}
} break;
case Instruction::Load: {
- const LoadInst *load_inst = dyn_cast<LoadInst>(inst);
-
- if (!load_inst) {
- LLDB_LOGF(
- log, "getOpcode() returns Load, but instruction is not a LoadInst");
- error.SetErrorToGenericError();
- error.SetErrorString(interpreter_internal_error);
- return false;
- }
+ const LoadInst *load_inst = cast<LoadInst>(inst);
// The semantics of Load are:
// Create a region D that will contain the loaded data
@@ -1351,16 +1257,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
return true;
}
case Instruction::Store: {
- const StoreInst *store_inst = dyn_cast<StoreInst>(inst);
-
- if (!store_inst) {
- LLDB_LOGF(
- log,
- "getOpcode() returns Store, but instruction is not a StoreInst");
- error.SetErrorToGenericError();
- error.SetErrorString(interpreter_internal_error);
- return false;
- }
+ const StoreInst *store_inst = cast<StoreInst>(inst);
// The semantics of Store are:
// Resolve the region D containing the data to be stored
@@ -1436,16 +1333,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
}
} break;
case Instruction::Call: {
- const CallInst *call_inst = dyn_cast<CallInst>(inst);
-
- if (!call_inst) {
- LLDB_LOGF(log,
- "getOpcode() returns %s, but instruction is not a CallInst",
- inst->getOpcodeName());
- error.SetErrorToGenericError();
- error.SetErrorString(interpreter_internal_error);
- return false;
- }
+ const CallInst *call_inst = cast<CallInst>(inst);
if (CanIgnoreCall(call_inst))
break;
OpenPOWER on IntegriCloud