eliminate temporary vectors

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33713 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2007-01-31 20:07:32 +00:00
parent 699d144a4b
commit 20066f936c

View File

@@ -303,12 +303,12 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
for (unsigned i = 0, e = inputs.size(); i != e; ++i) { for (unsigned i = 0, e = inputs.size(); i != e; ++i) {
Value *RewriteVal; Value *RewriteVal;
if (AggregateArgs) { if (AggregateArgs) {
std::vector<Value*> Indices; Value *Idx0 = Constant::getNullValue(Type::Int32Ty);
Indices.push_back(Constant::getNullValue(Type::Int32Ty)); Value *Idx1 = ConstantInt::get(Type::Int32Ty, i);
Indices.push_back(ConstantInt::get(Type::Int32Ty, i));
std::string GEPname = "gep_" + inputs[i]->getName(); std::string GEPname = "gep_" + inputs[i]->getName();
TerminatorInst *TI = newFunction->begin()->getTerminator(); TerminatorInst *TI = newFunction->begin()->getTerminator();
GetElementPtrInst *GEP = new GetElementPtrInst(AI, Indices, GEPname, TI); GetElementPtrInst *GEP = new GetElementPtrInst(AI, Idx0, Idx1,
GEPname, TI);
RewriteVal = new LoadInst(GEP, "load" + GEPname, TI); RewriteVal = new LoadInst(GEP, "load" + GEPname, TI);
} else } else
RewriteVal = AI++; RewriteVal = AI++;
@@ -390,11 +390,10 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
params.push_back(Struct); params.push_back(Struct);
for (unsigned i = 0, e = inputs.size(); i != e; ++i) { for (unsigned i = 0, e = inputs.size(); i != e; ++i) {
std::vector<Value*> Indices; Value *Idx0 = Constant::getNullValue(Type::Int32Ty);
Indices.push_back(Constant::getNullValue(Type::Int32Ty)); Value *Idx1 = ConstantInt::get(Type::Int32Ty, i);
Indices.push_back(ConstantInt::get(Type::Int32Ty, i));
GetElementPtrInst *GEP = GetElementPtrInst *GEP =
new GetElementPtrInst(Struct, Indices, new GetElementPtrInst(Struct, Idx0, Idx1,
"gep_" + StructValues[i]->getName()); "gep_" + StructValues[i]->getName());
codeReplacer->getInstList().push_back(GEP); codeReplacer->getInstList().push_back(GEP);
StoreInst *SI = new StoreInst(StructValues[i], GEP); StoreInst *SI = new StoreInst(StructValues[i], GEP);
@@ -416,11 +415,10 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
for (unsigned i = 0, e = outputs.size(); i != e; ++i) { for (unsigned i = 0, e = outputs.size(); i != e; ++i) {
Value *Output = 0; Value *Output = 0;
if (AggregateArgs) { if (AggregateArgs) {
std::vector<Value*> Indices; Value *Idx0 = Constant::getNullValue(Type::Int32Ty);
Indices.push_back(Constant::getNullValue(Type::Int32Ty)); Value *Idx1 = ConstantInt::get(Type::Int32Ty, FirstOut + i);
Indices.push_back(ConstantInt::get(Type::Int32Ty, FirstOut + i));
GetElementPtrInst *GEP GetElementPtrInst *GEP
= new GetElementPtrInst(Struct, Indices, = new GetElementPtrInst(Struct, Idx0, Idx1,
"gep_reload_" + outputs[i]->getName()); "gep_reload_" + outputs[i]->getName());
codeReplacer->getInstList().push_back(GEP); codeReplacer->getInstList().push_back(GEP);
Output = GEP; Output = GEP;
@@ -517,11 +515,10 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
if (DominatesDef) { if (DominatesDef) {
if (AggregateArgs) { if (AggregateArgs) {
std::vector<Value*> Indices; Value *Idx0 = Constant::getNullValue(Type::Int32Ty);
Indices.push_back(Constant::getNullValue(Type::Int32Ty)); Value *Idx1 = ConstantInt::get(Type::Int32Ty,FirstOut+out);
Indices.push_back(ConstantInt::get(Type::Int32Ty,FirstOut+out));
GetElementPtrInst *GEP = GetElementPtrInst *GEP =
new GetElementPtrInst(OAI, Indices, new GetElementPtrInst(OAI, Idx0, Idx1,
"gep_" + outputs[out]->getName(), "gep_" + outputs[out]->getName(),
NTRet); NTRet);
new StoreInst(outputs[out], GEP, NTRet); new StoreInst(outputs[out], GEP, NTRet);