summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-02-01 01:23:31 +0000
committerChris Lattner <sabre@nondot.org>2005-02-01 01:23:31 +0000
commitd6a4492f812b2c7348231210b31799dd6d06ae60 (patch)
treec3537a809c942201e59fbb3a49b9888b63620981 /llvm/lib/Transforms/IPO/GlobalOpt.cpp
parentf98a7bffb33449c3f920f3311dc86cd0fbc71642 (diff)
downloadbcm5719-llvm-d6a4492f812b2c7348231210b31799dd6d06ae60.tar.gz
bcm5719-llvm-d6a4492f812b2c7348231210b31799dd6d06ae60.zip
Adjust to changes in APIs
llvm-svn: 19958
Diffstat (limited to 'llvm/lib/Transforms/IPO/GlobalOpt.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/GlobalOpt.cpp20
1 files changed, 7 insertions, 13 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index 1068052f1cb..f2c9647e130 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -361,7 +361,8 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV) {
else
assert(0 && "Unknown aggregate sequential type!");
- if (NumElements > 16 && GV->use_size() > 16) return 0; // It's not worth it.
+ if (NumElements > 16 && GV->getNumUses() > 16)
+ return 0; // It's not worth it.
NewGlobals.reserve(NumElements);
for (unsigned i = 0, e = NumElements; i != e; ++i) {
Constant *In = getAggregateConstantElement(Init,
@@ -614,17 +615,11 @@ static void ConstantPropUsersOf(Value *V) {
if (Constant *NewC = ConstantFoldInstruction(I)) {
I->replaceAllUsesWith(NewC);
- // Back up UI to avoid invalidating it!
- bool AtBegin = false;
- if (UI == V->use_begin())
- AtBegin = true;
- else
- --UI;
- I->eraseFromParent();
- if (AtBegin)
- UI = V->use_begin();
- else
+ // Advance UI to the next non-I use to avoid invalidating it!
+ // Instructions could multiply use V.
+ while (UI != E && *UI == I)
++UI;
+ I->eraseFromParent();
}
}
@@ -683,8 +678,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
while (!GV->use_empty())
if (LoadInst *LI = dyn_cast<LoadInst>(GV->use_back())) {
while (!LI->use_empty()) {
- // FIXME: the iterator should expose a getUse() method.
- Use &LoadUse = *(const iplist<Use>::iterator&)LI->use_begin();
+ Use &LoadUse = LI->use_begin().getUse();
if (!isa<SetCondInst>(LoadUse.getUser()))
LoadUse = RepValue;
else {
OpenPOWER on IntegriCloud