}
-// getElementOffset - The workhorse for getelementptr, load and store. This
-// function returns the offset that arguments ArgOff+1 -> NumArgs specify for
-// the pointer type specified by argument Arg.
+// getElementOffset - The workhorse for getelementptr. This function returns
+// the offset that arguments ArgOff+1 -> NumArgs specify for the pointer type
+// specified by argument Arg.
//
static PointerTy getElementOffset(MemAccessInst &I, ExecutionContext &SF) {
assert(isa<PointerType>(I.getPointerOperand()->getType()) &&
static void executeLoadInst(LoadInst &I, ExecutionContext &SF) {
GenericValue SRC = getOperandValue(I.getPointerOperand(), SF);
- PointerTy SrcPtr = SRC.PointerVal;
- PointerTy Offset = getElementOffset(I, SF); // Handle any structure indices
- SrcPtr += Offset;
-
- GenericValue *Ptr = (GenericValue*)SrcPtr;
+ GenericValue *Ptr = (GenericValue*)SRC.PointerVal;
GenericValue Result;
switch (I.getType()->getPrimitiveID()) {
static void executeStoreInst(StoreInst &I, ExecutionContext &SF) {
GenericValue SRC = getOperandValue(I.getPointerOperand(), SF);
- PointerTy SrcPtr = SRC.PointerVal;
- SrcPtr += getElementOffset(I, SF); // Handle any structure indices
-
- GenericValue *Ptr = (GenericValue *)SrcPtr;
+ GenericValue *Ptr = (GenericValue *)SRC.PointerVal;
GenericValue Val = getOperandValue(I.getOperand(0), SF);
switch (I.getOperand(0)->getType()->getPrimitiveID()) {