// If requested, insert this instruction into a basic block...
if (InsertBefore) {
- assert(InsertBefore->getParent() &&
- "Instruction to insert before is not in a basic block!");
- InsertBefore->getParent()->getInstList().insert(InsertBefore, this);
+ BasicBlock *BB = InsertBefore->getParent();
+ assert(BB && "Instruction to insert before is not in a basic block!");
+ BB->getInstList().insert(InsertBefore, this);
}
}
return getParent()->getModule();
}
+Module *Instruction::getModule() {
+ return getParent()->getModule();
+}
+
+
void Instruction::removeFromParent() {
getParent()->getInstList().remove(this);
}
-void Instruction::eraseFromParent() {
- getParent()->getInstList().erase(this);
+iplist<Instruction>::iterator Instruction::eraseFromParent() {
+ return getParent()->getInstList().erase(this);
}
/// insertBefore - Insert an unlinked instructions into a basic block
case Invoke: return "invoke";
case Resume: return "resume";
case Unreachable: return "unreachable";
+ case CleanupRet: return "cleanupret";
+ case CatchEndPad: return "catchendpad";
+ case CatchRet: return "catchret";
+ case CatchPad: return "catchpad";
+ case TerminatePad: return "terminatepad";
// Standard binary operators...
case Add: return "add";
case ExtractValue: return "extractvalue";
case InsertValue: return "insertvalue";
case LandingPad: return "landingpad";
+ case CleanupPad: return "cleanuppad";
default: return "<Invalid operator> ";
}
case Instruction::Fence: // FIXME: refine definition of mayReadFromMemory
case Instruction::AtomicCmpXchg:
case Instruction::AtomicRMW:
+ case Instruction::CatchRet:
+ case Instruction::TerminatePad:
return true;
case Instruction::Call:
return !cast<CallInst>(this)->doesNotAccessMemory();
case Instruction::VAArg:
case Instruction::AtomicCmpXchg:
case Instruction::AtomicRMW:
+ case Instruction::CatchRet:
+ case Instruction::TerminatePad:
return true;
case Instruction::Call:
return !cast<CallInst>(this)->onlyReadsMemory();
bool Instruction::mayThrow() const {
if (const CallInst *CI = dyn_cast<CallInst>(this))
return !CI->doesNotThrow();
+ if (const auto *CRI = dyn_cast<CleanupReturnInst>(this))
+ return CRI->unwindsToCaller();
+ if (const auto *CEPI = dyn_cast<CatchEndPadInst>(this))
+ return CEPI->unwindsToCaller();
+ if (const auto *TPI = dyn_cast<TerminatePadInst>(this))
+ return TPI->unwindsToCaller();
return isa<ResumeInst>(this);
}
return Opcode == Xor;
}
+Instruction *Instruction::cloneImpl() const {
+ llvm_unreachable("Subclass of Instruction failed to implement cloneImpl");
+}
+
Instruction *Instruction::clone() const {
- Instruction *New = clone_impl();
+ Instruction *New = nullptr;
+ switch (getOpcode()) {
+ default:
+ llvm_unreachable("Unhandled Opcode.");
+#define HANDLE_INST(num, opc, clas) \
+ case Instruction::opc: \
+ New = cast<clas>(this)->cloneImpl(); \
+ break;
+#include "llvm/IR/Instruction.def"
+#undef HANDLE_INST
+ }
+
New->SubclassOptionalData = SubclassOptionalData;
if (!hasMetadata())
return New;