[llvm-commits] CVS: llvm/lib/Transforms/IPO/GlobalOpt.cpp
Chris Lattner
sabre at nondot.org
Tue Jan 30 20:41:12 PST 2007
Changes in directory llvm/lib/Transforms/IPO:
GlobalOpt.cpp updated: 1.91 -> 1.92
---
Log message:
eliminate temporary vectors
---
Diffs of the changes: (+12 -9)
GlobalOpt.cpp | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.91 llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.92
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.91 Tue Jan 30 17:46:24 2007
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp Tue Jan 30 22:40:53 2007
@@ -25,6 +25,7 @@
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Support/Debug.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include <algorithm>
@@ -443,11 +444,12 @@
// Form a shorter GEP if needed.
if (GEP->getNumOperands() > 3)
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(GEP)) {
- std::vector<Constant*> Idxs;
+ SmallVector<Constant*, 8> Idxs;
Idxs.push_back(NullInt);
for (unsigned i = 3, e = CE->getNumOperands(); i != e; ++i)
Idxs.push_back(CE->getOperand(i));
- NewPtr = ConstantExpr::getGetElementPtr(cast<Constant>(NewPtr), Idxs);
+ NewPtr = ConstantExpr::getGetElementPtr(cast<Constant>(NewPtr),
+ &Idxs[0], Idxs.size());
} else {
GetElementPtrInst *GEPI = cast<GetElementPtrInst>(GEP);
std::vector<Value*> Idxs;
@@ -576,16 +578,17 @@
}
} else if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(I)) {
// Should handle GEP here.
- std::vector<Constant*> Indices;
- Indices.reserve(GEPI->getNumOperands()-1);
+ SmallVector<Constant*, 8> Idxs;
+ Idxs.reserve(GEPI->getNumOperands()-1);
for (unsigned i = 1, e = GEPI->getNumOperands(); i != e; ++i)
if (Constant *C = dyn_cast<Constant>(GEPI->getOperand(i)))
- Indices.push_back(C);
+ Idxs.push_back(C);
else
break;
- if (Indices.size() == GEPI->getNumOperands()-1)
+ if (Idxs.size() == GEPI->getNumOperands()-1)
Changed |= OptimizeAwayTrappingUsesOfValue(GEPI,
- ConstantExpr::getGetElementPtr(NewV, Indices));
+ ConstantExpr::getGetElementPtr(NewV, &Idxs[0],
+ Idxs.size()));
if (GEPI->use_empty()) {
Changed = true;
GEPI->eraseFromParent();
@@ -1744,10 +1747,10 @@
getVal(Values, SI->getOperand(2)));
} else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(CurInst)) {
Constant *P = getVal(Values, GEP->getOperand(0));
- std::vector<Constant*> GEPOps;
+ SmallVector<Constant*, 8> GEPOps;
for (unsigned i = 1, e = GEP->getNumOperands(); i != e; ++i)
GEPOps.push_back(getVal(Values, GEP->getOperand(i)));
- InstResult = ConstantExpr::getGetElementPtr(P, GEPOps);
+ InstResult = ConstantExpr::getGetElementPtr(P, &GEPOps[0], GEPOps.size());
} else if (LoadInst *LI = dyn_cast<LoadInst>(CurInst)) {
if (LI->isVolatile()) return false; // no volatile accesses.
InstResult = ComputeLoadResult(getVal(Values, LI->getOperand(0)),
More information about the llvm-commits
mailing list