eliminate a temporary vector

llvm-svn: 33695
This commit is contained in:
Chris Lattner 2007-01-31 04:43:46 +00:00
parent 9888e0a048
commit b0a0d4f999
2 changed files with 5 additions and 4 deletions

View File

@ -20,6 +20,7 @@
#include "llvm/SymbolTable.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/Streams.h"
@ -1733,7 +1734,7 @@ ConstExpr: CastOps '(' ConstVal TO Types ')' {
if (!IdxTy)
GEN_ERROR("Index list invalid for constant getelementptr!");
std::vector<Constant*> IdxVec;
SmallVector<Constant*, 8> IdxVec;
for (unsigned i = 0, e = $4->size(); i != e; ++i)
if (Constant *C = dyn_cast<Constant>((*$4)[i]))
IdxVec.push_back(C);
@ -1742,7 +1743,7 @@ ConstExpr: CastOps '(' ConstVal TO Types ')' {
delete $4;
$$ = ConstantExpr::getGetElementPtr($3, IdxVec);
$$ = ConstantExpr::getGetElementPtr($3, &IdxVec[0], IdxVec.size());
CHECK_FOR_ERROR
}
| SELECT '(' ConstVal ',' ConstVal ',' ConstVal ')' {

View File

@ -1171,8 +1171,8 @@ Value *BytecodeReader::ParseConstantPoolValue(unsigned TypeID) {
if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result);
return Result;
} else if (Opcode == Instruction::GetElementPtr) { // GetElementPtr
std::vector<Constant*> IdxList(ArgVec.begin()+1, ArgVec.end());
Constant *Result = ConstantExpr::getGetElementPtr(ArgVec[0], IdxList);
Constant *Result = ConstantExpr::getGetElementPtr(ArgVec[0], &ArgVec[1],
ArgVec.size()-1);
if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result);
return Result;
} else if (Opcode == Instruction::Select) {