diff options
| author | Chris Lattner <sabre@nondot.org> | 2004-07-01 20:23:52 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2004-07-01 20:23:52 +0000 |
| commit | 5b20870830224ccd3037e1924958f39e98bc78a8 (patch) | |
| tree | 9632a5ae8cbf200e7d840d648415aa06866228f6 /llvm/lib/VMCore/iMemory.cpp | |
| parent | 153cd4ed30c661d91fb5a378c8f6183bae978afb (diff) | |
| download | bcm5719-llvm-5b20870830224ccd3037e1924958f39e98bc78a8.tar.gz bcm5719-llvm-5b20870830224ccd3037e1924958f39e98bc78a8.zip | |
Add much better assertion checking for load and store insts.
Contributed by Vladimir Merzliakov!
llvm-svn: 14546
Diffstat (limited to 'llvm/lib/VMCore/iMemory.cpp')
| -rw-r--r-- | llvm/lib/VMCore/iMemory.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/iMemory.cpp b/llvm/lib/VMCore/iMemory.cpp index bcba93e253a..480c332b29f 100644 --- a/llvm/lib/VMCore/iMemory.cpp +++ b/llvm/lib/VMCore/iMemory.cpp @@ -86,6 +86,13 @@ FreeInst::FreeInst(Value *Ptr, BasicBlock *InsertAtEnd) // LoadInst Implementation //===----------------------------------------------------------------------===// +void LoadInst::init(Value *Ptr) { + assert(Ptr && isa<PointerType>(Ptr->getType()) && + "Ptr must have pointer type."); + Operands.reserve(1); + Operands.push_back(Use(Ptr, this)); +} + LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef) : Instruction(cast<PointerType>(Ptr->getType())->getElementType(), Load, Name, InsertBef), Volatile(false) { @@ -112,6 +119,7 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile, init(Ptr); } + //===----------------------------------------------------------------------===// // StoreInst Implementation //===----------------------------------------------------------------------===// @@ -138,6 +146,15 @@ StoreInst::StoreInst(Value *Val, Value *Ptr, bool isVolatile, init(Val, Ptr); } +void StoreInst::init(Value *Val, Value *Ptr) { + assert(isa<PointerType>(Ptr->getType()) && + Val->getType() == cast<PointerType>(Ptr->getType())->getElementType() + && "Ptr must have pointer type."); + + Operands.reserve(2); + Operands.push_back(Use(Val, this)); + Operands.push_back(Use(Ptr, this)); +} //===----------------------------------------------------------------------===// // GetElementPtrInst Implementation |

