From 1ccd185cb49d81465a2901622e58ceae046d1d83 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 12 Feb 2007 22:56:41 +0000 Subject: [PATCH] stop using methods that take vectors. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34205 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/IPO/ArgumentPromotion.cpp | 7 +++++-- lib/Transforms/IPO/GlobalOpt.cpp | 7 ++++--- lib/Transforms/Scalar/InstructionCombining.cpp | 3 ++- lib/Transforms/Scalar/LowerPacked.cpp | 4 ++-- lib/Transforms/Scalar/ScalarReplAggregates.cpp | 16 ++++++++++------ lib/Transforms/Utils/LowerInvoke.cpp | 7 ++++--- 6 files changed, 27 insertions(+), 17 deletions(-) diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index 4c1b2c3f281..86f3f74db32 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -370,7 +370,9 @@ Function *ArgPromotion::DoPromotion(Function *F, // Add a parameter to the function for each element passed in. for (ScalarizeTable::iterator SI = ArgIndices.begin(), E = ArgIndices.end(); SI != E; ++SI) - Params.push_back(GetElementPtrInst::getIndexedType(I->getType(), *SI)); + Params.push_back(GetElementPtrInst::getIndexedType(I->getType(), + &(*SI)[0], + SI->size())); if (ArgIndices.size() == 1 && ArgIndices.begin()->empty()) ++NumArgumentsPromoted; @@ -421,7 +423,8 @@ Function *ArgPromotion::DoPromotion(Function *F, Value *V = *AI; LoadInst *OrigLoad = OriginalLoads[*SI]; if (!SI->empty()) { - V = new GetElementPtrInst(V, *SI, V->getName()+".idx", Call); + V = new GetElementPtrInst(V, &(*SI)[0], SI->size(), + V->getName()+".idx", Call); AA.copyValue(OrigLoad->getOperand(0), V); } Args.push_back(new LoadInst(V, V->getName()+".val", Call)); diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index f5b12712f3a..e2e707c4d83 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -908,11 +908,12 @@ static void RewriteUsesOfLoadForHeapSRoA(LoadInst *Ptr, Value *NewPtr = InsertedLoadsForPtr[FieldNo]; // Create the new GEP idx vector. - std::vector GEPIdx; + SmallVector GEPIdx; GEPIdx.push_back(GEPI->getOperand(1)); - GEPIdx.insert(GEPIdx.end(), GEPI->op_begin()+3, GEPI->op_end()); + GEPIdx.append(GEPI->op_begin()+3, GEPI->op_end()); - Value *NGEPI = new GetElementPtrInst(NewPtr, GEPIdx, GEPI->getName(), GEPI); + Value *NGEPI = new GetElementPtrInst(NewPtr, &GEPIdx[0], GEPIdx.size(), + GEPI->getName(), GEPI); GEPI->replaceAllUsesWith(NGEPI); GEPI->eraseFromParent(); } diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 37f4c75a097..556c054a994 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -7832,7 +7832,8 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { } if (!Indices.empty()) - return new GetElementPtrInst(SrcGEPOperands[0], Indices, GEP.getName()); + return new GetElementPtrInst(SrcGEPOperands[0], &Indices[0], + Indices.size(), GEP.getName()); } else if (GlobalValue *GV = dyn_cast(PtrOp)) { // GEP of global variable. If all of the indices for this GEP are diff --git a/lib/Transforms/Scalar/LowerPacked.cpp b/lib/Transforms/Scalar/LowerPacked.cpp index 116cccad62a..72307a18a40 100644 --- a/lib/Transforms/Scalar/LowerPacked.cpp +++ b/lib/Transforms/Scalar/LowerPacked.cpp @@ -231,7 +231,7 @@ void LowerPacked::visitLoadInst(LoadInst& LI) // Get the pointer Value* val = new GetElementPtrInst(array, - Idx, + &Idx[0], Idx.size(), LI.getName() + ".ge." + utostr(i), &LI); @@ -329,7 +329,7 @@ void LowerPacked::visitStoreInst(StoreInst& SI) // Generate the indices for getelementptr Idx[1] = ConstantInt::get(Type::Int32Ty,i); Value* val = new GetElementPtrInst(array, - Idx, + &Idx[0], Idx.size(), "store.ge." + utostr(i) + ".", &SI); diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index e77eca11ca0..bd0cf7476c8 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -33,6 +33,7 @@ #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/Compiler.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringExtras.h" using namespace llvm; @@ -224,10 +225,11 @@ bool SROA::performScalarRepl(Function &F) { // getelement ptr instruction to finish the indexing. This may be // expanded itself once the worklist is rerun. // - std::vector NewArgs; + SmallVector NewArgs; NewArgs.push_back(Constant::getNullValue(Type::Int32Ty)); - NewArgs.insert(NewArgs.end(), GEPI->op_begin()+3, GEPI->op_end()); - RepValue = new GetElementPtrInst(AllocaToUse, NewArgs, "", GEPI); + NewArgs.append(GEPI->op_begin()+3, GEPI->op_end()); + RepValue = new GetElementPtrInst(AllocaToUse, &NewArgs[0], + NewArgs.size(), "", GEPI); RepValue->takeName(GEPI); } @@ -397,12 +399,14 @@ void SROA::CanonicalizeAllocaUsers(AllocationInst *AI) { Constant::getNullValue(I.getOperand()->getType()), "isone", GEPI); // Insert the new GEP instructions, which are properly indexed. - std::vector Indices(GEPI->op_begin()+1, GEPI->op_end()); + SmallVector Indices(GEPI->op_begin()+1, GEPI->op_end()); Indices[1] = Constant::getNullValue(Type::Int32Ty); - Value *ZeroIdx = new GetElementPtrInst(GEPI->getOperand(0), Indices, + Value *ZeroIdx = new GetElementPtrInst(GEPI->getOperand(0), + &Indices[0], Indices.size(), GEPI->getName()+".0", GEPI); Indices[1] = ConstantInt::get(Type::Int32Ty, 1); - Value *OneIdx = new GetElementPtrInst(GEPI->getOperand(0), Indices, + Value *OneIdx = new GetElementPtrInst(GEPI->getOperand(0), + &Indices[0], Indices.size(), GEPI->getName()+".1", GEPI); // Replace all loads of the variable index GEP with loads from both // indexes and a select. diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp index 0da30e2428a..5a4408f802f 100644 --- a/lib/Transforms/Utils/LowerInvoke.cpp +++ b/lib/Transforms/Utils/LowerInvoke.cpp @@ -441,7 +441,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) { std::vector Idx; Idx.push_back(Constant::getNullValue(Type::Int32Ty)); Idx.push_back(ConstantInt::get(Type::Int32Ty, 1)); - OldJmpBufPtr = new GetElementPtrInst(JmpBuf, Idx, "OldBuf", + OldJmpBufPtr = new GetElementPtrInst(JmpBuf, &Idx[0], 2, "OldBuf", EntryBB->getTerminator()); // Copy the JBListHead to the alloca. @@ -480,7 +480,8 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) { "setjmp.cont"); Idx[1] = ConstantInt::get(Type::Int32Ty, 0); - Value *JmpBufPtr = new GetElementPtrInst(JmpBuf, Idx, "TheJmpBuf", + Value *JmpBufPtr = new GetElementPtrInst(JmpBuf, &Idx[0], Idx.size(), + "TheJmpBuf", EntryBB->getTerminator()); Value *SJRet = new CallInst(SetJmpFn, JmpBufPtr, "sjret", EntryBB->getTerminator()); @@ -530,7 +531,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) { std::vector Idx; Idx.push_back(Constant::getNullValue(Type::Int32Ty)); Idx.push_back(ConstantInt::get(Type::Int32Ty, 0)); - Idx[0] = new GetElementPtrInst(BufPtr, Idx, "JmpBuf", UnwindBlock); + Idx[0] = new GetElementPtrInst(BufPtr, &Idx[0], 2, "JmpBuf", UnwindBlock); Idx[1] = ConstantInt::get(Type::Int32Ty, 1); new CallInst(LongJmpFn, Idx, "", UnwindBlock); new UnreachableInst(UnwindBlock); -- 2.34.1