aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/iMemory.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-07-01 20:23:52 +0000
committerChris Lattner <sabre@nondot.org>2004-07-01 20:23:52 +0000
commit4d13294d473c5c1f2e8f7914a0af8ced70a68639 (patch)
treebd11a78de1486e3cefea0cdde8612a762997894e /lib/VMCore/iMemory.cpp
parentcf3290b04ad18e6329dd3efd67b0fabf0ca939d0 (diff)
Add much better assertion checking for load and store insts.
Contributed by Vladimir Merzliakov! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14546 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/iMemory.cpp')
-rw-r--r--lib/VMCore/iMemory.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/VMCore/iMemory.cpp b/lib/VMCore/iMemory.cpp
index bcba93e253..480c332b29 100644
--- a/lib/VMCore/iMemory.cpp
+++ b/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