aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-08-21 22:10:52 +0000
committerChris Lattner <sabre@nondot.org>2002-08-21 22:10:52 +0000
commit3f9b28d075e7c3991ddbf4535122298204093791 (patch)
treecccd9d256aa8e32c37c470a5f604c9e9d84ad409
parent905641bb01606d3ce83d8832b7bb7607a017cf06 (diff)
Do not create load/stores with indexes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3420 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/IPO/MutateStructTypes.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/lib/Transforms/IPO/MutateStructTypes.cpp b/lib/Transforms/IPO/MutateStructTypes.cpp
index f0dc16f3e2..2059f9f2a9 100644
--- a/lib/Transforms/IPO/MutateStructTypes.cpp
+++ b/lib/Transforms/IPO/MutateStructTypes.cpp
@@ -413,26 +413,28 @@ void MutateStructTypes::transformFunction(Function *m) {
break;
case Instruction::Load:
+ assert(cast<MemAccessInst>(I).idx_begin() ==
+ cast<MemAccessInst>(I).idx_end() &&
+ "Indexing loads not supported!");
+ NewI = new LoadInst(ConvertValue(I.getOperand(0)));
+ break;
case Instruction::Store:
+ assert(cast<MemAccessInst>(I).idx_begin() ==
+ cast<MemAccessInst>(I).idx_end() &&
+ "Indexing loads not supported!");
+ NewI = new StoreInst(ConvertValue(I.getOperand(0)),
+ ConvertValue(I.getOperand(1)));
+ break;
case Instruction::GetElementPtr: {
- const MemAccessInst &MAI = cast<MemAccessInst>(I);
- vector<Value*> Indices(MAI.idx_begin(), MAI.idx_end());
- const Value *Ptr = MAI.getPointerOperand();
- Value *NewPtr = ConvertValue(Ptr);
+ const GetElementPtrInst &GEP = cast<GetElementPtrInst>(I);
+ vector<Value*> Indices(GEP.idx_begin(), GEP.idx_end());
if (!Indices.empty()) {
- const Type *PTy = cast<PointerType>(Ptr->getType())->getElementType();
+ const Type *PTy =
+ cast<PointerType>(GEP.getOperand(0)->getType())->getElementType();
AdjustIndices(cast<CompositeType>(PTy), Indices);
}
- if (isa<LoadInst>(I)) {
- NewI = new LoadInst(NewPtr, Indices);
- } else if (isa<StoreInst>(I)) {
- NewI = new StoreInst(ConvertValue(I.getOperand(0)), NewPtr, Indices);
- } else if (isa<GetElementPtrInst>(I)) {
- NewI = new GetElementPtrInst(NewPtr, Indices);
- } else {
- assert(0 && "Unknown memory access inst!!!");
- }
+ NewI = new GetElementPtrInst(ConvertValue(GEP.getOperand(0)), Indices);
break;
}