Load & StoreInst no longer derive from MemAccessInst, so we don't have
authorChris Lattner <sabre@nondot.org>
Thu, 22 Aug 2002 22:49:05 +0000 (22:49 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 22 Aug 2002 22:49:05 +0000 (22:49 +0000)
to handle indexing anymore

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3485 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/DataStructure/Local.cpp
lib/Bytecode/Reader/InstructionReader.cpp
lib/ExecutionEngine/Interpreter/Execution.cpp
lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp
lib/Transforms/Scalar/GCSE.cpp
lib/Transforms/Scalar/LICM.cpp
lib/VMCore/Verifier.cpp

index 1abc199a9c6173e405c316d1859a6fd70d9d66b9..d5c488f05c31aa61d8b2b7c1a9f5b9c96dfd8eda 100644 (file)
@@ -263,13 +263,13 @@ void GraphBuilder::visitGetElementPtrInst(GetElementPtrInst &GEP) {
 }
 
 void GraphBuilder::visitLoadInst(LoadInst &LI) {
-  DSNode *Ptr = getSubscriptedNode(LI, getValueNode(*LI.getOperand(0)));
-  if (!isa<PointerType>(LI.getType())) return; // Only pointer PHIs
+  DSNode *Ptr = getValueNode(*LI.getOperand(0));
+  if (!isa<PointerType>(LI.getType())) return;   // only loads OF pointers
   getValueNode(LI)->addEdgeTo(getLink(Ptr, 0));
 }
 
 void GraphBuilder::visitStoreInst(StoreInst &SI) {
-  DSNode *DestPtr = getSubscriptedNode(SI, getValueNode(*SI.getOperand(1)));
+  DSNode *DestPtr = getValueNode(*SI.getOperand(1));
   if (!isa<PointerType>(SI.getOperand(0)->getType())) return;
   DSNode *Value   = getValueNode(*SI.getOperand(0));
   DestPtr->addEdgeTo(getLink(Value, 0));
index 1f1485e2f2e56c082627a668b496f9cfc67f2baa..123a94c9dc5752af086b28bfbe8a1c92ee312ae1 100644 (file)
@@ -444,7 +444,7 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
       cerr << "WARNING: Bytecode contains load instruction with indices.  "
            << "Replacing with getelementptr/load pair\n";
 
-      const Type *ElType = StoreInst::getIndexedType(Raw.Ty, Idx);
+      const Type *ElType = GetElementPtrInst::getIndexedType(Raw.Ty, Idx);
       if (ElType == 0) return true;
 
       Ptr = new GetElementPtrInst(Ptr, Idx);
index 7bf276a7606318d624c93783248373f23fe5795b..7b5a63ead07329e8791ad455501c000bb3be2fb1 100644 (file)
@@ -765,9 +765,9 @@ static void executeFreeInst(FreeInst &I, ExecutionContext &SF) {
 }
 
 
-// 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()) &&
@@ -832,11 +832,7 @@ static void executeGEPInst(GetElementPtrInst &I, ExecutionContext &SF) {
 
 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()) {
@@ -861,10 +857,7 @@ static void executeLoadInst(LoadInst &I, ExecutionContext &SF) {
 
 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()) {
index 7bfa329b57ca8637caa4314610c079511d2d3b5c..4e6cbcf5f4f17d28dedd20f07a44be46486080ec 100644 (file)
@@ -49,7 +49,7 @@ DecomposePass::runOnBasicBlock(BasicBlock &BB)
   for (BasicBlock::iterator II = BB.begin(); II != BB.end(); ) {
     if (MemAccessInst *MAI = dyn_cast<MemAccessInst>(&*II))
       if (MAI->getNumIndices() >= 2) {
-        Changed = decomposeArrayRef(II) || Changed; // always modifies II
+        Changed |= decomposeArrayRef(II); // always modifies II
         continue;
       }
     ++II;
@@ -88,19 +88,7 @@ IsZero(Value* idx)
 bool
 DecomposePass::decomposeArrayRef(BasicBlock::iterator &BBI)
 {
-  // FIXME: If condition below
   MemAccessInst &MAI = cast<MemAccessInst>(*BBI);
-  // FIXME: If condition below
-
-  // If this instr has no indexes, then the decomposed version is identical to
-  // the instruction itself.  FIXME: this should go away once GEP is the only
-  // MAI
-  //
-  if (MAI.getNumIndices() == 0) {
-    ++BBI;
-    return false;
-  }
-
   BasicBlock *BB = MAI.getParent();
   Value *LastPtr = MAI.getPointerOperand();
 
@@ -141,12 +129,6 @@ DecomposePass::decomposeArrayRef(BasicBlock::iterator &BBI)
 
   Instruction *NewI = 0;
   switch(MAI.getOpcode()) {
-  case Instruction::Load:
-    NewI = new LoadInst(LastPtr, Indices, MAI.getName());
-    break;
-  case Instruction::Store:
-    NewI = new StoreInst(MAI.getOperand(0), LastPtr, Indices);
-    break;
   case Instruction::GetElementPtr:
     NewI = new GetElementPtrInst(LastPtr, Indices, MAI.getName());
     break;
index dc6a345316b90a3107d0f449a44cfaeeb8964893..b4583e009631b597c131a0df2a2e0e274982ed09 100644 (file)
@@ -381,8 +381,6 @@ bool GCSE::TryToRemoveALoad(LoadInst *L1, LoadInst *L2) {
     return false;  // Neither instruction dominates the other one...
 
   BasicBlock *BB1 = L1->getParent(), *BB2 = L2->getParent();
-
-  assert(!L1->hasIndices());
   Value *LoadAddress = L1->getOperand(0);
 
   // L1 now dominates L2.  Check to see if the intervening instructions between
index 3714d7b08f4b4b1a7fdd7ed489cb6b0cdb724657..37333db1115d30023e7259cc9d84d3a54f7cdd08 100644 (file)
@@ -105,7 +105,6 @@ namespace {
     void visitShiftInst(ShiftInst &I) { visitBinaryOperator((Instruction&)I); }
 
     void visitLoadInst(LoadInst &LI) {
-      assert(!LI.hasIndices());
       if (isLoopInvariant(LI.getOperand(0)) &&
           !pointerInvalidatedByLoop(LI.getOperand(0)))
         hoist(LI);
index 4c9f11600ab54588ab194dec365fb077965eb44e..da65b1ce30ae1c19aebec39bac73e717e957ac9c 100644 (file)
@@ -330,18 +330,16 @@ void Verifier::visitGetElementPtrInst(GetElementPtrInst &GEP) {
 }
 
 void Verifier::visitLoadInst(LoadInst &LI) {
-  const Type *ElTy = LoadInst::getIndexedType(LI.getOperand(0)->getType(),
-                                              LI.copyIndices());
-  Assert1(ElTy, "Invalid indices for load pointer type!", &LI);
+  const Type *ElTy =
+    cast<PointerType>(LI.getOperand(0)->getType())->getElementType();
   Assert2(ElTy == LI.getType(),
           "Load is not of right type for indices!", &LI, ElTy);
   visitInstruction(LI);
 }
 
 void Verifier::visitStoreInst(StoreInst &SI) {
-  const Type *ElTy = StoreInst::getIndexedType(SI.getOperand(1)->getType(),
-                                               SI.copyIndices());
-  Assert1(ElTy, "Invalid indices for store pointer type!", &SI);
+  const Type *ElTy =
+    cast<PointerType>(SI.getOperand(1)->getType())->getElementType();
   Assert2(ElTy == SI.getOperand(0)->getType(),
           "Stored value is not of right type for indices!", &SI, ElTy);
   visitInstruction(SI);