From 927653f27fa3027258a8cec0b066117429e38e60 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 31 Jan 2007 19:59:55 +0000 Subject: eliminate temporary vectors llvm-svn: 33712 --- llvm/lib/Transforms/IPO/GlobalOpt.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'llvm/lib/Transforms/IPO/GlobalOpt.cpp') diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp index f76c152b8ad..342a481af74 100644 --- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp +++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp @@ -452,11 +452,11 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV) { &Idxs[0], Idxs.size()); } else { GetElementPtrInst *GEPI = cast(GEP); - std::vector Idxs; + SmallVector 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 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(); -- cgit v1.2.3