From 67a806ed90a25d80989f247aff956bfcd40a0dcc Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 21 Aug 2002 22:10:52 +0000 Subject: Do not create load/stores with indexes llvm-svn: 3420 --- llvm/lib/Transforms/IPO/MutateStructTypes.cpp | 30 ++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/IPO/MutateStructTypes.cpp b/llvm/lib/Transforms/IPO/MutateStructTypes.cpp index f0dc16f3e2b..2059f9f2a90 100644 --- a/llvm/lib/Transforms/IPO/MutateStructTypes.cpp +++ b/llvm/lib/Transforms/IPO/MutateStructTypes.cpp @@ -413,26 +413,28 @@ void MutateStructTypes::transformFunction(Function *m) { break; case Instruction::Load: + assert(cast(I).idx_begin() == + cast(I).idx_end() && + "Indexing loads not supported!"); + NewI = new LoadInst(ConvertValue(I.getOperand(0))); + break; case Instruction::Store: + assert(cast(I).idx_begin() == + cast(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(I); - vector Indices(MAI.idx_begin(), MAI.idx_end()); - const Value *Ptr = MAI.getPointerOperand(); - Value *NewPtr = ConvertValue(Ptr); + const GetElementPtrInst &GEP = cast(I); + vector Indices(GEP.idx_begin(), GEP.idx_end()); if (!Indices.empty()) { - const Type *PTy = cast(Ptr->getType())->getElementType(); + const Type *PTy = + cast(GEP.getOperand(0)->getType())->getElementType(); AdjustIndices(cast(PTy), Indices); } - if (isa(I)) { - NewI = new LoadInst(NewPtr, Indices); - } else if (isa(I)) { - NewI = new StoreInst(ConvertValue(I.getOperand(0)), NewPtr, Indices); - } else if (isa(I)) { - NewI = new GetElementPtrInst(NewPtr, Indices); - } else { - assert(0 && "Unknown memory access inst!!!"); - } + NewI = new GetElementPtrInst(ConvertValue(GEP.getOperand(0)), Indices); break; } -- cgit v1.2.3