stop using methods that take vectors.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34205 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2007-02-12 22:56:41 +00:00
parent 48d3c108b6
commit 1ccd185cb4
6 changed files with 27 additions and 17 deletions

View File

@ -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));

View File

@ -908,11 +908,12 @@ static void RewriteUsesOfLoadForHeapSRoA(LoadInst *Ptr,
Value *NewPtr = InsertedLoadsForPtr[FieldNo];
// Create the new GEP idx vector.
std::vector<Value*> GEPIdx;
SmallVector<Value*, 8> 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();
}

View File

@ -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<GlobalValue>(PtrOp)) {
// GEP of global variable. If all of the indices for this GEP are

View File

@ -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);

View File

@ -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<Value*> NewArgs;
SmallVector<Value*, 8> 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<Value*> Indices(GEPI->op_begin()+1, GEPI->op_end());
SmallVector<Value*, 8> 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.

View File

@ -441,7 +441,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
std::vector<Value*> 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<Value*> 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);