eliminate temporary vectors

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33712 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2007-01-31 19:59:55 +00:00
parent c0dbec7e10
commit 699d144a4b
2 changed files with 8 additions and 12 deletions
+5 -6
View File
@@ -452,11 +452,11 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV) {
&Idxs[0], Idxs.size());
} else {
GetElementPtrInst *GEPI = cast<GetElementPtrInst>(GEP);
std::vector<Value*> Idxs;
SmallVector<Value*, 8> Idxs;
Idxs.push_back(NullInt);
for (unsigned i = 3, e = GEPI->getNumOperands(); i != e; ++i)
Idxs.push_back(GEPI->getOperand(i));
NewPtr = new GetElementPtrInst(NewPtr, Idxs,
NewPtr = new GetElementPtrInst(NewPtr, &Idxs[0], Idxs.size(),
GEPI->getName()+"."+utostr(Val), GEPI);
}
GEP->replaceAllUsesWith(NewPtr);
@@ -684,10 +684,9 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
MallocInst *NewMI =
new MallocInst(NewTy, Constant::getNullValue(Type::Int32Ty),
MI->getAlignment(), MI->getName(), MI);
std::vector<Value*> Indices;
Indices.push_back(Constant::getNullValue(Type::Int32Ty));
Indices.push_back(Indices[0]);
Value *NewGEP = new GetElementPtrInst(NewMI, Indices,
Value* Indices[2];
Indices[0] = Indices[1] = Constant::getNullValue(Type::Int32Ty);
Value *NewGEP = new GetElementPtrInst(NewMI, Indices, 2,
NewMI->getName()+".el0", MI);
MI->replaceAllUsesWith(NewGEP);
MI->eraseFromParent();