diff options
Diffstat (limited to 'llvm/lib/VMCore/Instruction.cpp')
-rw-r--r-- | llvm/lib/VMCore/Instruction.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/llvm/lib/VMCore/Instruction.cpp b/llvm/lib/VMCore/Instruction.cpp index 0de34b5bd54..5ddf2843540 100644 --- a/llvm/lib/VMCore/Instruction.cpp +++ b/llvm/lib/VMCore/Instruction.cpp @@ -17,14 +17,18 @@ #include "Support/LeakDetector.h" using namespace llvm; -Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name, - Instruction *InsertBefore) - : User(ty, Value::InstructionVal, Name) { - Parent = 0; - iType = it; - +void Instruction::init() +{ // Make sure that we get added to a basicblock LeakDetector::addGarbageObject(this); +} + +Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name, + Instruction *InsertBefore) + : User(ty, Value::InstructionVal, Name), + Parent(0), + iType(it) { + init(); // If requested, insert this instruction into a basic block... if (InsertBefore) { @@ -34,6 +38,18 @@ Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name, } } +Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name, + BasicBlock *InsertAtEnd) + : User(ty, Value::InstructionVal, Name), + Parent(0), + iType(it) { + init(); + + // append this instruction into the basic block + assert(InsertAtEnd && "Basic block to append to may not be NULL!"); + InsertAtEnd->getInstList().push_back(this); +} + void Instruction::setParent(BasicBlock *P) { if (getParent()) { if (!P) LeakDetector::addGarbageObject(this); |